mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-02-15 16:26:08 +00:00
feat(Common/IPLocation): replace ip2nation by ip2location (#5653)
This commit is contained in:
@@ -12,29 +12,29 @@
|
||||
* authentication server
|
||||
*/
|
||||
|
||||
#include "AppenderDB.h"
|
||||
#include "Banner.h"
|
||||
#include "Common.h"
|
||||
#include "AppenderDB.h"
|
||||
#include "DatabaseEnv.h"
|
||||
#include "Config.h"
|
||||
#include "Log.h"
|
||||
#include "GitRevision.h"
|
||||
#include "Util.h"
|
||||
#include "SignalHandler.h"
|
||||
#include "RealmList.h"
|
||||
#include "RealmAcceptor.h"
|
||||
#include "DatabaseEnv.h"
|
||||
#include "DatabaseLoader.h"
|
||||
#include "GitRevision.h"
|
||||
#include "IPLocation.h"
|
||||
#include "Log.h"
|
||||
#include "RealmAcceptor.h"
|
||||
#include "RealmList.h"
|
||||
#include "SecretMgr.h"
|
||||
#include "SharedDefines.h"
|
||||
#include "SignalHandler.h"
|
||||
#include "Util.h"
|
||||
#include "ProcessPriority.h"
|
||||
#include <ace/Dev_Poll_Reactor.h>
|
||||
#include <ace/TP_Reactor.h>
|
||||
#include <ace/ACE.h>
|
||||
#include <ace/Dev_Poll_Reactor.h>
|
||||
#include <ace/Sig_Handler.h>
|
||||
#include <ace/TP_Reactor.h>
|
||||
#include <boost/version.hpp>
|
||||
#include <openssl/opensslv.h>
|
||||
#include <openssl/crypto.h>
|
||||
#include <openssl/opensslv.h>
|
||||
|
||||
#ifndef _ACORE_REALM_CONFIG
|
||||
#define _ACORE_REALM_CONFIG "authserver.conf"
|
||||
@@ -128,6 +128,9 @@ extern int main(int argc, char** argv)
|
||||
|
||||
sSecretMgr->Initialize();
|
||||
|
||||
// Load IP Location Database
|
||||
sIPLocation->Load();
|
||||
|
||||
// Get the list of realms for the server
|
||||
sRealmList->Initialize(sConfigMgr->GetOption<int32>("RealmsStateUpdateDelay", 20));
|
||||
if (sRealmList->GetRealms().empty())
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "CryptoHash.h"
|
||||
#include "CryptoRandom.h"
|
||||
#include "DatabaseEnv.h"
|
||||
#include "IPLocation.h"
|
||||
#include "Log.h"
|
||||
#include "RealmList.h"
|
||||
#include "SecretMgr.h"
|
||||
@@ -419,31 +420,20 @@ bool AuthSocket::_HandleLogonChallenge()
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_DEBUG("network", "[AuthChallenge] Account '%s' is not locked to ip", _accountInfo.Login.c_str());
|
||||
if (IpLocationRecord const* location = sIPLocation->GetLocationRecord(ipAddress))
|
||||
_ipCountry = location->CountryCode;
|
||||
|
||||
LOG_DEBUG("server.authserver", "[AuthChallenge] Account '%s' is not locked to ip", _accountInfo.Login.c_str());
|
||||
if (_accountInfo.LockCountry.empty() || _accountInfo.LockCountry == "00")
|
||||
LOG_DEBUG("server.authserver", "[AuthChallenge] Account '%s' is not locked to country", _accountInfo.Login.c_str());
|
||||
else if (!_ipCountry.empty())
|
||||
{
|
||||
LOG_DEBUG("network", "[AuthChallenge] Account '%s' is not locked to country", _accountInfo.Login.c_str());
|
||||
}
|
||||
else if (!_accountInfo.LockCountry.empty())
|
||||
{
|
||||
uint32 ip = inet_addr(ipAddress.c_str());
|
||||
EndianConvertReverse(ip);
|
||||
|
||||
stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_LOGON_COUNTRY);
|
||||
stmt->setUInt32(0, ip);
|
||||
|
||||
if (PreparedQueryResult sessionCountryQuery = LoginDatabase.Query(stmt))
|
||||
LOG_DEBUG("server.authserver", "[AuthChallenge] Account '%s' is locked to country: '%s' Player country is '%s'", _accountInfo.Login.c_str(), _accountInfo.LockCountry.c_str(), _ipCountry.c_str());
|
||||
if (_ipCountry != _accountInfo.LockCountry)
|
||||
{
|
||||
std::string loginCountry = (*sessionCountryQuery)[0].GetString();
|
||||
LOG_DEBUG("network", "[AuthChallenge] Account '%s' is locked to country: '%s' Player country is '%s'", _accountInfo.Login.c_str(), _accountInfo.LockCountry.c_str(), loginCountry.c_str());
|
||||
if (loginCountry != _accountInfo.LockCountry)
|
||||
{
|
||||
LOG_DEBUG("network", "[AuthChallenge] Account country differs.");
|
||||
pkt << uint8(WOW_FAIL_UNLOCKABLE_LOCK);
|
||||
SendAuthPacket();
|
||||
return true;
|
||||
}
|
||||
pkt << uint8(WOW_FAIL_UNLOCKABLE_LOCK);
|
||||
SendAuthPacket();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,6 +89,7 @@ private:
|
||||
// between enUS and enGB, which is important for the patch system
|
||||
std::string _localizationName;
|
||||
std::string _os;
|
||||
std::string _ipCountry;
|
||||
uint16 _build;
|
||||
uint8 _expversion;
|
||||
};
|
||||
|
||||
@@ -134,6 +134,15 @@ WrongPass.BanType = 0
|
||||
|
||||
WrongPass.Logging = 0
|
||||
|
||||
#
|
||||
# IPLocationFile
|
||||
# Description: The path to your IP2Location database CSV file.
|
||||
# Example: "C:/acore/IP2LOCATION-LITE-DB1.CSV"
|
||||
# "/home/acore/IP2LOCATION-LITE-DB1.CSV"
|
||||
# Default: "" - (Disabled)
|
||||
|
||||
IPLocationFile = ""
|
||||
|
||||
#
|
||||
###################################################################################################
|
||||
|
||||
|
||||
Reference in New Issue
Block a user