summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/authserver/Server/AuthSocket.cpp36
-rw-r--r--src/scripts/Commands/cs_account.cpp61
-rw-r--r--src/scripts/Commands/cs_misc.cpp12
3 files changed, 103 insertions, 6 deletions
diff --git a/src/authserver/Server/AuthSocket.cpp b/src/authserver/Server/AuthSocket.cpp
index 81a065e461..0df9deb6c9 100644
--- a/src/authserver/Server/AuthSocket.cpp
+++ b/src/authserver/Server/AuthSocket.cpp
@@ -426,7 +426,7 @@ bool AuthSocket::_HandleLogonChallenge()
sLog->outDebug(LOG_FILTER_NETWORKIO, "[AuthChallenge] Player address is '%s'", ip_address.c_str());
#endif
- if (strcmp(fields[3].GetCString(), ip_address.c_str()) != 0)
+ if (strcmp(fields[4].GetCString(), ip_address.c_str()) != 0)
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
sLog->outDebug(LOG_FILTER_NETWORKIO, "[AuthChallenge] Account IP differs");
@@ -440,9 +440,37 @@ bool AuthSocket::_HandleLogonChallenge()
#endif
}
else
+ {
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
sLog->outDebug(LOG_FILTER_NETWORKIO, "[AuthChallenge] Account '%s' is not locked to ip", _login.c_str());
#endif
+ std::string accountCountry = fields[3].GetString();
+ if (accountCountry.empty() || accountCountry == "00")
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "[AuthChallenge] Account '%s' is not locked to country", _login.c_str());
+ else if (!accountCountry.empty())
+ {
+ uint32 ip = inet_addr(ip_address.c_str());
+ EndianConvertReverse(ip);
+
+ stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_LOGON_COUNTRY);
+ stmt->setUInt32(0, ip);
+ if (PreparedQueryResult sessionCountryQuery = LoginDatabase.Query(stmt))
+ {
+ std::string loginCountry = (*sessionCountryQuery)[0].GetString();
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "[AuthChallenge] Account '%s' is locked to country: '%s' Player country is '%s'", _login.c_str(), accountCountry.c_str(), loginCountry.c_str());
+ if (loginCountry != accountCountry)
+ {
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "[AuthChallenge] Account country differs.");
+ pkt << uint8(WOW_FAIL_UNLOCKABLE_LOCK);
+ locked = true;
+ }
+ else
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "[AuthChallenge] Account country matches");
+ }
+ else
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "[AuthChallenge] IP2NATION Table empty");
+ }
+ }
if (!locked)
{
@@ -476,8 +504,8 @@ bool AuthSocket::_HandleLogonChallenge()
std::string rI = fields[0].GetString();
// Don't calculate (v, s) if there are already some in the database
- std::string databaseV = fields[5].GetString();
- std::string databaseS = fields[6].GetString();
+ std::string databaseV = fields[6].GetString();
+ std::string databaseS = fields[7].GetString();
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
sLog->outDebug(LOG_FILTER_NETWORKIO, "database authentication values: v='%s' s='%s'", databaseV.c_str(), databaseS.c_str());
@@ -536,7 +564,7 @@ bool AuthSocket::_HandleLogonChallenge()
if (securityFlags & 0x04) // Security token input
pkt << uint8(1);
- uint8 secLevel = fields[4].GetUInt8();
+ uint8 secLevel = fields[5].GetUInt8();
_accountSecurityLevel = secLevel <= SEC_ADMINISTRATOR ? AccountTypes(secLevel) : SEC_ADMINISTRATOR;
_localizationName.resize(4);
diff --git a/src/scripts/Commands/cs_account.cpp b/src/scripts/Commands/cs_account.cpp
index eb1750d9e1..4b6ba7d79f 100644
--- a/src/scripts/Commands/cs_account.cpp
+++ b/src/scripts/Commands/cs_account.cpp
@@ -30,13 +30,18 @@ public:
{ "gmlevel", SEC_CONSOLE, true, &HandleAccountSetGmLevelCommand, "" },
{ "password", SEC_CONSOLE, true, &HandleAccountSetPasswordCommand, "" }
};
+ static std::vector<ChatCommand> accountLockCommandTable
+ {
+ { "country", SEC_PLAYER, true, &HandleAccountLockCountryCommand, "" },
+ { "ip", SEC_PLAYER, true, &HandleAccountLockIpCommand, "" }
+ };
static std::vector<ChatCommand> accountCommandTable =
{
{ "addon", SEC_MODERATOR, false, &HandleAccountAddonCommand, "" },
{ "create", SEC_CONSOLE, true, &HandleAccountCreateCommand, "" },
{ "delete", SEC_CONSOLE, true, &HandleAccountDeleteCommand, "" },
{ "onlinelist", SEC_CONSOLE, true, &HandleAccountOnlineListCommand, "" },
- { "lock", SEC_PLAYER, false, &HandleAccountLockCommand, "" },
+ { "lock", SEC_PLAYER, false, nullptr, "", accountLockCommandTable },
{ "set", SEC_ADMINISTRATOR, true, nullptr, "", accountSetCommandTable },
{ "password", SEC_PLAYER, false, &HandleAccountPasswordCommand, "" },
{ "", SEC_PLAYER, false, &HandleAccountCommand, "" }
@@ -230,7 +235,59 @@ public:
return true;
}
- static bool HandleAccountLockCommand(ChatHandler* handler, char const* args)
+ static bool HandleAccountLockCountryCommand(ChatHandler* handler, char const* args)
+ {
+ if (!*args)
+ {
+ handler->SendSysMessage(LANG_USE_BOL);
+ handler->SetSentErrorMessage(true);
+ return false;
+ }
+
+ std::string param = (char*)args;
+
+ if (!param.empty())
+ {
+ if (param == "on")
+ {
+ PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_LOGON_COUNTRY);
+ uint32 ip = inet_addr(handler->GetSession()->GetRemoteAddress().c_str());
+ EndianConvertReverse(ip);
+ stmt->setUInt32(0, ip);
+ PreparedQueryResult result = LoginDatabase.Query(stmt);
+ if (result)
+ {
+ Field* fields = result->Fetch();
+ std::string country = fields[0].GetString();
+ stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_ACCOUNT_LOCK_CONTRY);
+ stmt->setString(0, country);
+ stmt->setUInt32(1, handler->GetSession()->GetAccountId());
+ LoginDatabase.Execute(stmt);
+ handler->PSendSysMessage(LANG_COMMAND_ACCLOCKLOCKED);
+ }
+ else
+ {
+ handler->PSendSysMessage("[IP2NATION] Table empty");
+ ;//sLog->outDebug(LOG_FILTER_NETWORKIO, "[IP2NATION] Table empty");
+ }
+ }
+ else if (param == "off")
+ {
+ PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_ACCOUNT_LOCK_CONTRY);
+ stmt->setString(0, "00");
+ stmt->setUInt32(1, handler->GetSession()->GetAccountId());
+ LoginDatabase.Execute(stmt);
+ handler->PSendSysMessage(LANG_COMMAND_ACCLOCKUNLOCKED);
+ }
+ return true;
+ }
+
+ handler->SendSysMessage(LANG_USE_BOL);
+ handler->SetSentErrorMessage(true);
+ return false;
+ }
+
+ static bool HandleAccountLockIpCommand(ChatHandler* handler, char const* args)
{
if (!*args)
{
diff --git a/src/scripts/Commands/cs_misc.cpp b/src/scripts/Commands/cs_misc.cpp
index 3ad187cac5..1af226c38e 100644
--- a/src/scripts/Commands/cs_misc.cpp
+++ b/src/scripts/Commands/cs_misc.cpp
@@ -1887,7 +1887,19 @@ public:
#if TRINITY_ENDIAN == BIGENDIAN
EndianConvertReverse(ip);
#endif
+ PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_IP2NATION_COUNTRY);
+ stmt->setUInt32(0, ip);
+
+ PreparedQueryResult result2 = WorldDatabase.Query(stmt);
+
+ if (result2)
+ {
+ Field* fields2 = result2->Fetch();
+ lastIp.append(" (");
+ lastIp.append(fields2[0].GetString());
+ lastIp.append(")");
+ }
}
else
{