diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/server/authserver/Server/AuthSession.cpp | 3 | ||||
-rw-r--r-- | src/server/authserver/authserver.conf.dist | 9 | ||||
-rw-r--r-- | src/server/game/Server/WorldSocket.cpp | 30 | ||||
-rw-r--r-- | src/server/game/World/World.cpp | 3 | ||||
-rw-r--r-- | src/server/game/World/World.h | 1 | ||||
-rw-r--r-- | src/server/worldserver/worldserver.conf.dist | 9 |
6 files changed, 43 insertions, 12 deletions
diff --git a/src/server/authserver/Server/AuthSession.cpp b/src/server/authserver/Server/AuthSession.cpp index 0acfa47db1e..dc0bcdd9465 100644 --- a/src/server/authserver/Server/AuthSession.cpp +++ b/src/server/authserver/Server/AuthSession.cpp @@ -507,9 +507,10 @@ bool AuthSession::HandleLogonProof() // Update the sessionkey, last_ip, last login time and reset number of failed logins in the account table for this account // No SQL injection (escaped user name) and IP address as received by socket + std::string address = sConfigMgr->GetBoolDefault("AllowLoggingIPAddressesInDatabase", true, true) ? GetRemoteIpAddress().to_string() : "127.0.0.1"; LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_LOGONPROOF); stmt->setBinary(0, _sessionKey); - stmt->setString(1, GetRemoteIpAddress().to_string()); + stmt->setString(1, address); stmt->setUInt32(2, GetLocaleByName(_localizationName)); stmt->setString(3, _os); stmt->setString(4, _accountInfo.Login); diff --git a/src/server/authserver/authserver.conf.dist b/src/server/authserver/authserver.conf.dist index d7fea17f397..e9dbf52cd41 100644 --- a/src/server/authserver/authserver.conf.dist +++ b/src/server/authserver/authserver.conf.dist @@ -177,6 +177,15 @@ MySQLExecutable = "" IPLocationFile = "" # +# AllowLoggingIPAddressesInDatabase +# Description: Specifies if IP addresses can be logged to the database +# Default: 1 - (Enabled) +# 0 - (Disabled) +# + +AllowLoggingIPAddressesInDatabase = 1 + +# ################################################################################################### ################################################################################################### diff --git a/src/server/game/Server/WorldSocket.cpp b/src/server/game/Server/WorldSocket.cpp index 7430b808370..9dd27515792 100644 --- a/src/server/game/Server/WorldSocket.cpp +++ b/src/server/game/Server/WorldSocket.cpp @@ -459,12 +459,17 @@ void WorldSocket::HandleAuthSessionCallback(std::shared_ptr<AuthSession> authSes // For hook purposes, we get Remoteaddress at this point. std::string address = GetRemoteIpAddress().to_string(); - // As we don't know if attempted login process by ip works, we update last_attempt_ip right away - LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_LAST_ATTEMPT_IP); - stmt->setString(0, address); - stmt->setString(1, authSession->Account); - LoginDatabase.Execute(stmt); - // This also allows to check for possible "hack" attempts on account + LoginDatabasePreparedStatement* stmt = nullptr; + + if (sWorld->getBoolConfig(CONFIG_ALLOW_LOGGING_IP_ADDRESSES_IN_DATABASE)) + { + // As we don't know if attempted login process by ip works, we update last_attempt_ip right away + stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_LAST_ATTEMPT_IP); + stmt->setString(0, address); + stmt->setString(1, authSession->Account); + LoginDatabase.Execute(stmt); + // This also allows to check for possible "hack" attempts on account + } // even if auth credentials are bad, try using the session key we have - client cannot read auth response error without it _authCrypt.Init(account.SessionKey); @@ -580,13 +585,16 @@ void WorldSocket::HandleAuthSessionCallback(std::shared_ptr<AuthSession> authSes TC_LOG_DEBUG("network", "WorldSocket::HandleAuthSession: Client '%s' authenticated successfully from %s.", authSession->Account.c_str(), address.c_str()); - // Update the last_ip in the database as it was successful for login - stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_LAST_IP); + if (sWorld->getBoolConfig(CONFIG_ALLOW_LOGGING_IP_ADDRESSES_IN_DATABASE)) + { + // Update the last_ip in the database as it was successful for login + stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_LAST_IP); - stmt->setString(0, address); - stmt->setString(1, authSession->Account); + stmt->setString(0, address); + stmt->setString(1, authSession->Account); - LoginDatabase.Execute(stmt); + LoginDatabase.Execute(stmt); + } // At this point, we can safely hook a successful login sScriptMgr->OnAccountLogin(account.Id); diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp index e1278d42ab1..24508c8cc31 100644 --- a/src/server/game/World/World.cpp +++ b/src/server/game/World/World.cpp @@ -1540,6 +1540,9 @@ void World::LoadConfigSettings(bool reload) // Anti movement cheat measure. Time each client have to acknowledge a movement change until they are kicked m_int_configs[CONFIG_PENDING_MOVE_CHANGES_TIMEOUT] = sConfigMgr->GetIntDefault("AntiCheat.PendingMoveChangesTimeoutTime", 0); + // Specifies if IP addresses can be logged to the database + m_bool_configs[CONFIG_ALLOW_LOGGING_IP_ADDRESSES_IN_DATABASE] = sConfigMgr->GetBoolDefault("AllowLoggingIPAddressesInDatabase", true, true); + // call ScriptMgr if we're reloading the configuration if (reload) sScriptMgr->OnConfigLoad(reload); diff --git a/src/server/game/World/World.h b/src/server/game/World/World.h index 83ad2db99df..eeda8e69709 100644 --- a/src/server/game/World/World.h +++ b/src/server/game/World/World.h @@ -177,6 +177,7 @@ enum WorldBoolConfigs CONFIG_CHECK_GOBJECT_LOS, CONFIG_RESPAWN_DYNAMIC_ESCORTNPC, CONFIG_REGEN_HP_CANNOT_REACH_TARGET_IN_RAID, + CONFIG_ALLOW_LOGGING_IP_ADDRESSES_IN_DATABASE, BOOL_CONFIG_VALUE_COUNT }; diff --git a/src/server/worldserver/worldserver.conf.dist b/src/server/worldserver/worldserver.conf.dist index d9f145a76ce..b235ee85c98 100644 --- a/src/server/worldserver/worldserver.conf.dist +++ b/src/server/worldserver/worldserver.conf.dist @@ -1305,6 +1305,15 @@ BirthdayTime = 1222964635 CacheDataQueries = 1 # +# AllowLoggingIPAddressesInDatabase +# Description: Specifies if IP addresses can be logged to the database +# Default: 1 - (Enabled) +# 0 - (Disabled) +# + +AllowLoggingIPAddressesInDatabase = 1 + +# ################################################################################################### ################################################################################################### |