mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-18 19:35:42 +00:00
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:
@@ -503,9 +503,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->GetOption<bool>("AllowLoggingIPAddressesInDatabase", true, true) ? GetRemoteIpAddress().to_string() : "0.0.0.0";
|
||||
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);
|
||||
|
||||
@@ -135,6 +135,23 @@ WrongPass.BanType = 0
|
||||
|
||||
WrongPass.Logging = 0
|
||||
|
||||
#
|
||||
# BanExpiryCheckInterval
|
||||
# Description: Time (in seconds) between checks for expired bans
|
||||
# Default: 60
|
||||
#
|
||||
|
||||
BanExpiryCheckInterval = 60
|
||||
|
||||
#
|
||||
# StrictVersionCheck
|
||||
# Description: Prevent modified clients from connecting
|
||||
# Default: 0 - (Disabled)
|
||||
# 1 - (Enabled)
|
||||
#
|
||||
|
||||
StrictVersionCheck = 0
|
||||
|
||||
#
|
||||
# SourceDirectory
|
||||
# Description: The path to your AzerothCore source directory.
|
||||
@@ -168,21 +185,13 @@ MySQLExecutable = ""
|
||||
IPLocationFile = ""
|
||||
|
||||
#
|
||||
# BanExpiryCheckInterval
|
||||
# Description: Time (in seconds) between checks for expired bans
|
||||
# Default: 60
|
||||
# AllowLoggingIPAddressesInDatabase
|
||||
# Description: Specifies if IP addresses can be logged to the database
|
||||
# Default: 1 - (Enabled)
|
||||
# 0 - (Disabled)
|
||||
#
|
||||
|
||||
BanExpiryCheckInterval = 60
|
||||
|
||||
#
|
||||
# StrictVersionCheck
|
||||
# Description: Prevent modified clients from connecting
|
||||
# Default: 0 - (Disabled)
|
||||
# 1 - (Enabled)
|
||||
#
|
||||
|
||||
StrictVersionCheck = 0
|
||||
AllowLoggingIPAddressesInDatabase = 1
|
||||
|
||||
#
|
||||
###################################################################################################
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -161,6 +161,7 @@ enum WorldBoolConfigs
|
||||
CONFIG_DUNGEON_ACCESS_REQUIREMENTS_LFG_DBC_LEVEL_OVERRIDE,
|
||||
CONFIG_REGEN_HP_CANNOT_REACH_TARGET_IN_RAID,
|
||||
CONFIG_SET_BOP_ITEM_TRADEABLE,
|
||||
CONFIG_ALLOW_LOGGING_IP_ADDRESSES_IN_DATABASE,
|
||||
BOOL_CONFIG_VALUE_COUNT
|
||||
};
|
||||
|
||||
|
||||
@@ -1404,6 +1404,9 @@ void World::LoadConfigSettings(bool reload)
|
||||
|
||||
m_bool_configs[CONFIG_SET_BOP_ITEM_TRADEABLE] = sConfigMgr->GetOption<bool>("Item.SetItemTradeable", true);
|
||||
|
||||
// Specifies if IP addresses can be logged to the database
|
||||
m_bool_configs[CONFIG_ALLOW_LOGGING_IP_ADDRESSES_IN_DATABASE] = sConfigMgr->GetOption<bool>("AllowLoggingIPAddressesInDatabase", true, true);
|
||||
|
||||
// call ScriptMgr if we're reloading the configuration
|
||||
sScriptMgr->OnAfterConfigLoad(reload);
|
||||
}
|
||||
|
||||
@@ -220,6 +220,15 @@ ThreadPool = 2
|
||||
|
||||
IPLocationFile = ""
|
||||
|
||||
#
|
||||
# AllowLoggingIPAddressesInDatabase
|
||||
# Description: Specifies if IP addresses can be logged to the database
|
||||
# Default: 1 - (Enabled)
|
||||
# 0 - (Disabled)
|
||||
#
|
||||
|
||||
AllowLoggingIPAddressesInDatabase = 1
|
||||
|
||||
#
|
||||
###################################################################################################
|
||||
|
||||
|
||||
Reference in New Issue
Block a user