aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Server
diff options
context:
space:
mode:
authorGiacomo Pozzoni <giacomopoz@gmail.com>2021-07-28 11:44:24 +0200
committerShauren <shauren.trinity@gmail.com>2022-03-11 20:50:36 +0100
commit5afa32e9a7e944d5fbee620c31bf6e2939ec7c5d (patch)
tree1d5744ca239c4ed7850bdbfc12c44f6424fc1386 /src/server/game/Server
parent62df5e860fd3ecfcedbcca14a6d90bf5d8a1bbef (diff)
Core/Network: Add option to allow/disallow saving IP addresses to database (#26723)
Add config option AllowLoggingIPAddressesInDatabase to authserver and worldserver to specify if IP addresses can be logged or not to the database (cherry picked from commit 68bf7e6d12e1689d688db32c05066b8832922c67)
Diffstat (limited to 'src/server/game/Server')
-rw-r--r--src/server/game/Server/WorldSocket.cpp30
1 files changed, 19 insertions, 11 deletions
diff --git a/src/server/game/Server/WorldSocket.cpp b/src/server/game/Server/WorldSocket.cpp
index 2e4b44411bf..f8a42b65916 100644
--- a/src/server/game/Server/WorldSocket.cpp
+++ b/src/server/game/Server/WorldSocket.cpp
@@ -740,12 +740,17 @@ void WorldSocket::HandleAuthSessionCallback(std::shared_ptr<WorldPackets::Auth::
// only first 16 bytes of the hmac are used
memcpy(_encryptKey.data(), encryptKeyGen.GetDigest().data(), 16);
- // 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->RealmJoinTicket);
- 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->RealmJoinTicket);
+ LoginDatabase.Execute(stmt);
+ // This also allows to check for possible "hack" attempts on account
+ }
stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_ACCOUNT_INFO_CONTINUED_SESSION);
stmt->setBinary(0, _sessionKey);
@@ -844,13 +849,16 @@ void WorldSocket::HandleAuthSessionCallback(std::shared_ptr<WorldPackets::Auth::
TC_LOG_DEBUG("network", "WorldSocket::HandleAuthSession: Client '%s' authenticated successfully from %s.", authSession->RealmJoinTicket.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->RealmJoinTicket);
+ stmt->setString(0, address);
+ stmt->setString(1, authSession->RealmJoinTicket);
- LoginDatabase.Execute(stmt);
+ LoginDatabase.Execute(stmt);
+ }
// At this point, we can safely hook a successful login
sScriptMgr->OnAccountLogin(account.Game.Id);