mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
adding replace for 0.0.0.0 ip
This commit is contained in:
parent
dcd7c239d6
commit
9a5c090f23
@ -120,15 +120,12 @@ include_directories(
|
||||
|
||||
endif(WIN32)
|
||||
|
||||
|
||||
|
||||
|
||||
target_link_libraries(Gradido_LoginServer ${CONAN_LIBS} ${IROHA_ED25519})
|
||||
if(WIN32)
|
||||
TARGET_LINK_LIBRARIES(Gradido_LoginServer optimized ${MYSQL_LIBRARIES} Shlwapi)
|
||||
TARGET_LINK_LIBRARIES(Gradido_LoginServer debug ${COMPILED_MARIADB_CLIENT_DEBUG} Shlwapi)
|
||||
else(WIN32)
|
||||
target_link_libraries(Gradido_LoginServer mariadb/libmariadb PocoNet PocoUtil PocoJSON PocoFoundation PocoData PocoNetSSL protoc protobuf -pthread)
|
||||
target_link_libraries(Gradido_LoginServer libmariadb PocoNet PocoUtil PocoJSON PocoFoundation PocoData PocoNetSSL protoc protobuf -pthread)
|
||||
endif(WIN32)
|
||||
|
||||
# install
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
#include "Poco/Net/SSLManager.h"
|
||||
#include "Poco/Net/KeyConsoleHandler.h"
|
||||
#include "Poco/Net/RejectCertificateHandler.h"
|
||||
#include "Poco/Net/DNS.h"
|
||||
#include "Poco/SharedPtr.h"
|
||||
|
||||
#include "Poco/Mutex.h"
|
||||
@ -17,6 +18,7 @@
|
||||
#include "Poco/DateTimeFormat.h"
|
||||
#include "Poco/DateTimeFormatter.h"
|
||||
|
||||
|
||||
using Poco::Net::SSLManager;
|
||||
using Poco::Net::Context;
|
||||
using Poco::Net::KeyConsoleHandler;
|
||||
@ -47,6 +49,36 @@ namespace ServerConfig {
|
||||
std::string g_versionString = "";
|
||||
bool g_disableEmail = false;
|
||||
|
||||
bool replaceZeroIPWithLocalhostIP(std::string& url)
|
||||
{
|
||||
auto pos = url.find("0.0.0.0", 0);
|
||||
if (pos != std::string::npos) {
|
||||
std::string ipAddressString = "";
|
||||
auto host = Poco::Net::DNS::thisHost();
|
||||
for (auto it = host.addresses().begin(); it != host.addresses().end(); it++) {
|
||||
auto ipAddress = *it;
|
||||
if (!ipAddress.isIPv4Compatible() && !ipAddress.isIPv4Mapped()) {
|
||||
continue;
|
||||
}
|
||||
if (ipAddress.isLoopback()) {
|
||||
continue;
|
||||
}
|
||||
ipAddressString = ipAddress.toString();
|
||||
//isIPv4Compatible
|
||||
//!isLoopback
|
||||
//printf("ipaddress: %s\n", ipAddressString.data());
|
||||
break;
|
||||
//break;
|
||||
}
|
||||
url.replace(pos, 7, ipAddressString);
|
||||
}
|
||||
|
||||
//printf("ipaddress: %s\n", ipAddress.data());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool loadMnemonicWordLists()
|
||||
{
|
||||
for (int i = 0; i < MNEMONIC_MAX; i++) {
|
||||
@ -104,8 +136,15 @@ namespace ServerConfig {
|
||||
g_SessionTimeout = cfg.getInt("session.timeout", SESSION_TIMEOUT_DEFAULT);
|
||||
g_serverPath = cfg.getString("loginServer.path", "");
|
||||
g_default_locale = LanguageManager::languageFromString(cfg.getString("loginServer.default_locale"));
|
||||
// replace 0.0.0.0 with actual server ip
|
||||
|
||||
g_php_serverPath = cfg.getString("phpServer.url", "");
|
||||
replaceZeroIPWithLocalhostIP(g_php_serverPath);
|
||||
g_php_serverHost = cfg.getString("phpServer.host", "");
|
||||
replaceZeroIPWithLocalhostIP(g_php_serverHost);
|
||||
/*std::string testIp = "http://0.0.0.0/account";
|
||||
replaceZeroIPWithLocalhostIP(testIp);
|
||||
printf("testIp: %s\n", testIp.data());*/
|
||||
//g_FakeLoginSleepTime = cfg.getInt("crypto.fake_login_sleep_time", g_FakeLoginSleepTime);
|
||||
return true;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user