From 163c487be7e60ab0488dade3e3170c9b7b9b5f68 Mon Sep 17 00:00:00 2001 From: Gooyeth <566327+Gooyeth@users.noreply.github.com> Date: Fri, 22 Jun 2018 17:32:39 -0600 Subject: Common: Replace ip2nation by ip2location. (#21957) Replace ip2nation by ip2location. Download: https://lite.ip2location.com/database/ip-country (cherry picked from commit 2fe4ab94c52ad2fa90189ecd9c053da49f06561e) --- src/server/bnetserver/Server/Session.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/server/bnetserver/Server/Session.cpp') diff --git a/src/server/bnetserver/Server/Session.cpp b/src/server/bnetserver/Server/Session.cpp index bc70b8ba9fb..56c71a3eeb6 100644 --- a/src/server/bnetserver/Server/Session.cpp +++ b/src/server/bnetserver/Server/Session.cpp @@ -20,6 +20,7 @@ #include "ByteConverter.h" #include "DatabaseEnv.h" #include "Errors.h" +#include "IPLocation.h" #include "QueryCallback.h" #include "LoginRESTService.h" #include "ProtobufJSON.h" @@ -92,7 +93,6 @@ void Battlenet::Session::Start() PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_IP_INFO); stmt->setString(0, ip_address); - stmt->setUInt32(1, inet_addr(ip_address.c_str())); _queryProcessor.AddQuery(LoginDatabase.AsyncQuery(stmt).WithPreparedCallback(std::bind(&Battlenet::Session::CheckIpCallback, this, std::placeholders::_1))); } @@ -108,9 +108,6 @@ void Battlenet::Session::CheckIpCallback(PreparedQueryResult result) if (fields[0].GetUInt64() != 0) banned = true; - if (!fields[1].GetString().empty()) - _ipCountry = fields[1].GetString(); - } while (result->NextRow()); if (banned) @@ -339,6 +336,9 @@ uint32 Battlenet::Session::VerifyWebCredentials(std::string const& webCredential } else { + if (IpLocationRecord* location = sIPLocation->GetData(ip_address)) + _ipCountry = location->country_code; + TC_LOG_DEBUG("session", "[Session::HandleVerifyWebCredentials] Account '%s' is not locked to ip", _accountInfo->Login.c_str()); if (_accountInfo->LockCountry.empty() || _accountInfo->LockCountry == "00") TC_LOG_DEBUG("session", "[Session::HandleVerifyWebCredentials] Account '%s' is not locked to country", _accountInfo->Login.c_str()); -- cgit v1.2.3