feat(Core/Network): Add conf to allow/disallow storing IP address (#7168)

* feat(Core/Network): Add conf to allow/disallow storing the IP address

* cherry-pick commit (68bf7e6d12)

Co-Authored-By: Giacomo Pozzoni <giacomopoz@gmail.com>
This commit is contained in:
Kitzunu
2021-08-19 00:20:07 +02:00
committed by GitHub
parent a43d76ede4
commit 556d91a2ea
6 changed files with 42 additions and 16 deletions

View File

@@ -7,6 +7,7 @@
#include "WorldSocket.h"
#include "AccountMgr.h"
#include "BigNumber.h"
#include "Config.h"
#include "CryptoHash.h"
#include "CryptoRandom.h"
#include "DatabaseEnv.h"
@@ -452,10 +453,12 @@ void WorldSocket::HandleAuthSessionCallback(std::shared_ptr<AuthSession> authSes
AccountInfo account(result->Fetch());
// For hook purposes, we get Remoteaddress at this point.
std::string address = GetRemoteIpAddress().to_string();
std::string address = sConfigMgr->GetOption<bool>("AllowLoggingIPAddressesInDatabase", true, true) ? GetRemoteIpAddress().to_string() : "0.0.0.0";
LoginDatabasePreparedStatement* stmt = nullptr;
// 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 = LoginDatabase.GetPreparedStatement(LOGIN_UPD_LAST_ATTEMPT_IP);
stmt->setString(0, address);
stmt->setString(1, authSession->Account);
LoginDatabase.Execute(stmt);