feat(Common/IPLocation): replace ip2nation by ip2location (#5653)

This commit is contained in:
Kargatum
2021-06-18 03:02:08 +07:00
committed by GitHub
parent 8ba1ddb033
commit 3da83cc0e6
17 changed files with 306 additions and 167 deletions

View File

@@ -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;
}
}
}

View File

@@ -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;
};