NoSteamManager: finish anti-spoofing
This commit is contained in:
parent
9d5cacc511
commit
6276a6cf88
@ -11,7 +11,6 @@ ConVar g_hCvar_BlockAdmin;
|
||||
ConVar g_hCvar_BlockVoice;
|
||||
|
||||
/* DATABASE */
|
||||
Database g_hDatabaseSB;
|
||||
Database g_hDatabaseAntiSpoofing;
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
@ -22,7 +21,7 @@ public Plugin myinfo =
|
||||
name = "NoSteamManager",
|
||||
author = "zaCade",
|
||||
description = "Manage No-Steam clients, denying admin access, ect.",
|
||||
version = "1.0.0"
|
||||
version = "1.1.0"
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
@ -42,13 +41,6 @@ public void OnPluginStart()
|
||||
AutoExecConfig();
|
||||
|
||||
char sError[256];
|
||||
|
||||
if (SQL_CheckConfig("sourcebans"))
|
||||
g_hDatabaseSB = SQL_Connect("sourcebans", true, sError, sizeof(sError));
|
||||
|
||||
if (g_hDatabaseSB == null)
|
||||
LogError("Could not connect to database: %s", sError);
|
||||
|
||||
if (SQL_CheckConfig("antispoofing"))
|
||||
g_hDatabaseAntiSpoofing = SQL_Connect("antispoofing", true, sError, sizeof(sError));
|
||||
|
||||
@ -158,21 +150,19 @@ public Action OnClientPreAdminCheck(int client)
|
||||
NotifyPostAdminCheck(client);
|
||||
|
||||
char sQuery[512];
|
||||
Format(sQuery, sizeof(sQuery), "SELECT * from sb_admins WHERE authid = '%s'", sSteamID);
|
||||
SQL_TQuery(g_hDatabaseSB, TQueryCB, sQuery, GetClientUserId(client));
|
||||
Format(sQuery, sizeof(sQuery), "SELECT * from authenticated_steam_ids WHERE steam_auth = '%s'", sSteamID);
|
||||
SQL_TQuery(g_hDatabaseAntiSpoofing, TQueryCB, sQuery, GetClientUserId(client));
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
char sIP[32];
|
||||
GetClientIP(client, sIP, sizeof(sIP));
|
||||
|
||||
int iTimestamp = GetTime();
|
||||
|
||||
char sQuery[512];
|
||||
Format(sQuery, sizeof(sQuery), "INSERT INTO authenticated_steam_ids (steam_auth, last_ip, last_connect) VALUES ('%s', '%s', %d) ON DUPLICATE KEY UPDATE last_ip = '%s', last_connect = %d;", sSteamID, sIP, iTimestamp, sIP, iTimestamp);
|
||||
SQL_TQuery(g_hDatabaseAntiSpoofing, TQueryCB2, sQuery, GetClientUserId(client));
|
||||
|
||||
SQL_FastQuery(g_hDatabaseAntiSpoofing, sQuery);
|
||||
|
||||
return Plugin_Continue;
|
||||
}
|
||||
@ -211,15 +201,26 @@ public void TQueryCB(Handle owner, Handle rs, const char[] error, any data)
|
||||
|
||||
if (SQL_GetRowCount(rs) > 0)
|
||||
{
|
||||
LogMessage("%L tried to join with an Admin-SteamID while not being authentiated with steam.", client);
|
||||
KickClient(client, "Trying to join with an Admin-SteamID while not being authentiated with steam.");
|
||||
char sCurrentIP[32];
|
||||
GetClientIP(client, sCurrentIP, sizeof(sCurrentIP));
|
||||
|
||||
char sStoredIP[32];
|
||||
int iField;
|
||||
|
||||
SQL_FetchRow(rs);
|
||||
SQL_FieldNameToNum(rs, "last_ip", iField);
|
||||
SQL_FetchString(rs, iField, sStoredIP, sizeof(sStoredIP));
|
||||
delete rs;
|
||||
|
||||
if (StrEqual(sCurrentIP, sStoredIP))
|
||||
{
|
||||
LogMessage("%L tried to join with a known authenticated SteamID while not being authentiated with steam. Allowing connection because IPs match (%s).", client, sCurrentIP);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
LogMessage("%L tried to join with a known authenticated SteamID while not being authentiated with steam. Refusing connection because IPs do not match (Stored: %s)(Current: %s).", client, sStoredIP, sCurrentIP);
|
||||
KickClient(client, "Trying to join with a known authenticated SteamID while not being authentiated with steam.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void TQueryCB2(Handle owner, Handle rs, const char[] error, any data)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user