aboutsummaryrefslogtreecommitdiff
path: root/src/server/authserver
diff options
context:
space:
mode:
authorGooyeth <566327+Gooyeth@users.noreply.github.com>2018-06-22 17:32:39 -0600
committerAokromes <Aokromes@users.noreply.github.com>2018-06-23 01:32:39 +0200
commit2fe4ab94c52ad2fa90189ecd9c053da49f06561e (patch)
treed505bd2176de8a659401c1b87694ca20c96bedb3 /src/server/authserver
parent0dcc318e377138dcbc116b5703d7dc1bffc0cc0f (diff)
Common: Replace ip2nation by ip2location. (#21957)
Replace ip2nation by ip2location. Download: https://lite.ip2location.com/database/ip-country
Diffstat (limited to 'src/server/authserver')
-rw-r--r--src/server/authserver/Main.cpp4
-rw-r--r--src/server/authserver/Server/AuthSession.cpp8
-rw-r--r--src/server/authserver/authserver.conf.dist10
3 files changed, 18 insertions, 4 deletions
diff --git a/src/server/authserver/Main.cpp b/src/server/authserver/Main.cpp
index fa024d324ab..8ed74688372 100644
--- a/src/server/authserver/Main.cpp
+++ b/src/server/authserver/Main.cpp
@@ -31,6 +31,7 @@
#include "DatabaseEnv.h"
#include "DatabaseLoader.h"
#include "IoContext.h"
+#include "IPLocation.h"
#include "GitRevision.h"
#include "MySQLThreading.h"
#include "ProcessPriority.h"
@@ -137,6 +138,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/authserver/Server/AuthSession.cpp b/src/server/authserver/Server/AuthSession.cpp
index 8cfe4c50c1a..648296b620b 100644
--- a/src/server/authserver/Server/AuthSession.cpp
+++ b/src/server/authserver/Server/AuthSession.cpp
@@ -20,6 +20,7 @@
#include "AuthCodes.h"
#include "Config.h"
#include "Errors.h"
+#include "IPLocation.h"
#include "Log.h"
#include "DatabaseEnv.h"
#include "RealmList.h"
@@ -169,7 +170,6 @@ void AuthSession::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(&AuthSession::CheckIpCallback, this, std::placeholders::_1)));
}
@@ -195,9 +195,6 @@ void AuthSession::CheckIpCallback(PreparedQueryResult result)
if (fields[0].GetUInt64() != 0)
banned = true;
- if (!fields[1].GetString().empty())
- _ipCountry = fields[1].GetString();
-
} while (result->NextRow());
if (banned)
@@ -344,6 +341,9 @@ void AuthSession::LogonChallengeCallback(PreparedQueryResult result)
}
else
{
+ if (IpLocationRecord* location = sIPLocation->GetData(ipAddress))
+ _ipCountry = location->country_code;
+
TC_LOG_DEBUG("server.authserver", "[AuthChallenge] Account '%s' is not locked to ip", _accountInfo.Login.c_str());
if (_accountInfo.LockCountry.empty() || _accountInfo.LockCountry == "00")
TC_LOG_DEBUG("server.authserver", "[AuthChallenge] Account '%s' is not locked to country", _accountInfo.Login.c_str());
diff --git a/src/server/authserver/authserver.conf.dist b/src/server/authserver/authserver.conf.dist
index 1d3b48839a8..a6e3d4b8f92 100644
--- a/src/server/authserver/authserver.conf.dist
+++ b/src/server/authserver/authserver.conf.dist
@@ -158,6 +158,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 = "."
+
+#
###################################################################################################
###################################################################################################