diff options
| author | Gooyeth <566327+Gooyeth@users.noreply.github.com> | 2018-06-22 17:32:39 -0600 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2019-01-09 17:35:13 +0100 |
| commit | 163c487be7e60ab0488dade3e3170c9b7b9b5f68 (patch) | |
| tree | c4c299c869d543f9f04d683987ad74a033963285 /src/server/bnetserver | |
| parent | 5620eb9463a8d6cf59851306b92a8c644acd512d (diff) | |
Common: Replace ip2nation by ip2location. (#21957)
Replace ip2nation by ip2location.
Download: https://lite.ip2location.com/database/ip-country
(cherry picked from commit 2fe4ab94c52ad2fa90189ecd9c053da49f06561e)
Diffstat (limited to 'src/server/bnetserver')
| -rw-r--r-- | src/server/bnetserver/Main.cpp | 4 | ||||
| -rw-r--r-- | src/server/bnetserver/Server/Session.cpp | 8 | ||||
| -rw-r--r-- | src/server/bnetserver/bnetserver.conf.dist | 10 |
3 files changed, 18 insertions, 4 deletions
diff --git a/src/server/bnetserver/Main.cpp b/src/server/bnetserver/Main.cpp index c5fac15f19c..f054ff71f66 100644 --- a/src/server/bnetserver/Main.cpp +++ b/src/server/bnetserver/Main.cpp @@ -29,6 +29,7 @@ #include "DatabaseEnv.h" #include "DatabaseLoader.h" #include "GitRevision.h" +#include "IPLocation.h" #include "LoginRESTService.h" #include "MySQLThreading.h" #include "ProcessPriority.h" @@ -151,6 +152,9 @@ int main(int argc, char** argv) if (!StartDB()) return 1; + // Load IP Location Database + sIPLocation->Load(); + std::shared_ptr<void> dbHandle(nullptr, [](void*) { StopDB(); }); std::shared_ptr<Trinity::Asio::IoContext> ioContext = std::make_shared<Trinity::Asio::IoContext>(); 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()); diff --git a/src/server/bnetserver/bnetserver.conf.dist b/src/server/bnetserver/bnetserver.conf.dist index 79691164cac..0e5ccc18a53 100644 --- a/src/server/bnetserver/bnetserver.conf.dist +++ b/src/server/bnetserver/bnetserver.conf.dist @@ -198,6 +198,16 @@ SourceDirectory = "" MySQLExecutable = "" # +# IPLocationFile +# Description: The path to your IP2Location database CSV file. +# Example: "C:/Trinity/IP2Location.csv" +# "/home/trinity/IP2Location.csv" +# Default: "." - (Current core directory) +# "" - (Disabled) + +IPLocationFile = "." + +# ################################################################################################### ################################################################################################### |
