From c73a8f9c97e8261200961316007044d19bc35171 Mon Sep 17 00:00:00 2001 From: zaCade Date: Sun, 24 Feb 2019 14:51:11 +0100 Subject: [PATCH] NoSteamManager: Update include + native. --- .../NoSteamManagerFailSafe_RevEmu.sp | 82 ------------------- .../scripting/NoSteamManager_RevEmu.sp | 40 +-------- includes/RevEmuAPI.inc | 21 +---- 3 files changed, 7 insertions(+), 136 deletions(-) delete mode 100644 NoSteamManager/scripting/NoSteamManagerFailSafe_RevEmu.sp diff --git a/NoSteamManager/scripting/NoSteamManagerFailSafe_RevEmu.sp b/NoSteamManager/scripting/NoSteamManagerFailSafe_RevEmu.sp deleted file mode 100644 index 772f2ce7..00000000 --- a/NoSteamManager/scripting/NoSteamManagerFailSafe_RevEmu.sp +++ /dev/null @@ -1,82 +0,0 @@ -#pragma semicolon 1 - -#include -#include - -#pragma newdecls required - -//---------------------------------------------------------------------------------------------------- -// Purpose: -//---------------------------------------------------------------------------------------------------- -public Plugin myinfo = -{ - name = "NoSteamManagerFailSafe_RevEmu", - author = "Neon", - description = "FailSafe to prevent No-Steam clients from getting admin access.", - version = "1.0.0" -}; - -//---------------------------------------------------------------------------------------------------- -// Purpose: -//---------------------------------------------------------------------------------------------------- -public void OnClientPostAdminCheck(int client) -{ - if(IsFakeClient(client) || IsClientSourceTV(client)) - return; - - if(!CheckCommandAccess(client, "sm_admin", ADMFLAG_GENERIC, true)) - return; - - if(!IsSteam(client)) - { - char sConnectionType[32]; - GetConnectionType(client, sConnectionType, sizeof(sConnectionType)); - - LogMessage("%L got admin access while not being authentiated with steam (type: %s). Attempting to kick.", sConnectionType); - LogAction(client, -1, "\"%L\"got admin access while not being authentiated with steam (type: %s). Attempting to kick.", sConnectionType); - KickClient(client, "Security Validation failed. Please contact an Administrator."); - return; - } -} - -//---------------------------------------------------------------------------------------------------- -// Purpose: -//---------------------------------------------------------------------------------------------------- -public void GetConnectionType(int client, char[] sConnectionType, int iMaxLength) -{ - char sConnectionTypeInternal[32]; - - RevEmu_UserType PlayerType = RevEmu_GetPlayerType(client); - if (PlayerType == Unknown) - sConnectionTypeInternal = "Error"; - else if (PlayerType == SteamLegitUser) - sConnectionTypeInternal = "SteamLegit"; - else if (PlayerType == SteamCrackedUser) - sConnectionTypeInternal = "SteamCracked"; - else if (PlayerType == RevEmuUser) - sConnectionTypeInternal = "RevEmu"; - else if (PlayerType == RevEmuUserOld) - sConnectionTypeInternal = "RevEmuOld"; - else if (PlayerType == SettiSRCScanBot) - sConnectionTypeInternal = "SettiSRCScanBot"; - else if (PlayerType == RevEmuUserV74) - sConnectionTypeInternal = "RevEmuV74"; - else if (PlayerType == RevEmuUserVeryOld) - sConnectionTypeInternal = "RevEmuVeryOld"; - else if (PlayerType == UnknownUser) - sConnectionTypeInternal = "Unknown"; - else if (PlayerType == Steam2Legit) - sConnectionTypeInternal = "Steam2Legit"; - else if (PlayerType == Steam2Cracked) - sConnectionTypeInternal = "Steam2Cracked"; - - strcopy(sConnectionType, iMaxLength, sConnectionTypeInternal); -} - -//---------------------------------------------------------------------------------------------------- -// Purpose: -//---------------------------------------------------------------------------------------------------- -public bool IsSteam(int client) -{ - return (RevEmu_GetPlayerType(client) == SteamLegitUser); -} \ No newline at end of file diff --git a/NoSteamManager/scripting/NoSteamManager_RevEmu.sp b/NoSteamManager/scripting/NoSteamManager_RevEmu.sp index 24c1160c..280e4fc6 100644 --- a/NoSteamManager/scripting/NoSteamManager_RevEmu.sp +++ b/NoSteamManager/scripting/NoSteamManager_RevEmu.sp @@ -104,7 +104,7 @@ public Action Command_DisplaySteamStats(int client, int args) if(IsClientInGame(i) && !IsFakeClient(i) && !RevEmu_IsPlayerSteam(i)) { char sConnectionType[32]; - GetConnectionType(i, sConnectionType, sizeof(sConnectionType)); + RevEmu_GetPlayerType(i, sConnectionType, sizeof(sConnectionType)); Format(aBuf, sizeof(aBuf), "%s%L %s \n", aBuf, i, sConnectionType); } } @@ -173,7 +173,7 @@ public Action OnClientPreAdminCheck(int client) if(!RevEmu_IsPlayerSteam(client)) { char sConnectionType[32]; - GetConnectionType(client, sConnectionType, sizeof(sConnectionType)); + RevEmu_GetPlayerType(client, sConnectionType, sizeof(sConnectionType)); LogMessage("%L was not authenticated with steam (type: %s), denying admin.", client, sConnectionType); NotifyPostAdminCheck(client); @@ -237,7 +237,7 @@ public void TQueryCB(Database db, DBResultSet results, const char[] error, any d GetClientIP(client, sCurrentIP, sizeof(sCurrentIP)); char sCurrentConnectionType[32]; - GetConnectionType(client, sCurrentConnectionType, sizeof(sCurrentConnectionType)); + RevEmu_GetPlayerType(client, sCurrentConnectionType, sizeof(sCurrentConnectionType)); int iTimestamp = GetTime(); @@ -274,40 +274,6 @@ public void TQueryCB(Database db, DBResultSet results, const char[] error, any d g_hDatabaseAntiSpoofing.Query(SQL_DoNothing, sQuery, GetClientUserId(client)); } -//---------------------------------------------------------------------------------------------------- -// Purpose: -//---------------------------------------------------------------------------------------------------- -public void GetConnectionType(int client, char[] sConnectionType, int iMaxLength) -{ - char sConnectionTypeInternal[32]; - - RevEmu_UserType PlayerType = RevEmu_GetPlayerType(client); - if (PlayerType == Invalid) - sConnectionTypeInternal = "Error"; - else if (PlayerType == SteamLegitUser) - sConnectionTypeInternal = "SteamLegit"; - else if (PlayerType == SteamCrackedUser) - sConnectionTypeInternal = "SteamCracked"; - else if (PlayerType == RevEmuUser) - sConnectionTypeInternal = "RevEmu"; - else if (PlayerType == RevEmuUserOld) - sConnectionTypeInternal = "RevEmuOld"; - else if (PlayerType == SettiSRCScanBot) - sConnectionTypeInternal = "SettiSRCScanBot"; - else if (PlayerType == RevEmuUserV74) - sConnectionTypeInternal = "RevEmuV74"; - else if (PlayerType == RevEmuUserVeryOld) - sConnectionTypeInternal = "RevEmuVeryOld"; - else if (PlayerType == UnknownUser) - sConnectionTypeInternal = "Unknown"; - else if (PlayerType == Steam2Legit) - sConnectionTypeInternal = "Steam2Legit"; - else if (PlayerType == Steam2Cracked) - sConnectionTypeInternal = "Steam2Cracked"; - - strcopy(sConnectionType, iMaxLength, sConnectionTypeInternal); -} - //---------------------------------------------------------------------------------------------------- // Purpose: //---------------------------------------------------------------------------------------------------- diff --git a/includes/RevEmuAPI.inc b/includes/RevEmuAPI.inc index a4531525..02595103 100644 --- a/includes/RevEmuAPI.inc +++ b/includes/RevEmuAPI.inc @@ -3,21 +3,6 @@ #endif #define _RevEmuAPI_included -enum RevEmu_UserType -{ - Invalid = -1, - SteamLegitUser = 0, - SteamCrackedUser, - RevEmuUser, - RevEmuUserOld, - SettiSRCScanBot, - RevEmuUserV74, - RevEmuUserVeryOld, - UnknownUser, - Steam2Legit, - Steam2Cracked -}; - /** * Check if clients usertype is legit. * @@ -32,11 +17,13 @@ native bool RevEmu_IsPlayerSteam(int client); * Retrieve clients usertype. * * @param clients The client index. + * @param type The buffer to write to. + * @param maxlength The maximum buffer length. * - * @return The clients usertype. + * @return True on success, false otherwise. * @error Invalid client index, not connected or fake client. */ -native RevEmu_UserType RevEmu_GetPlayerType(int client); +native bool RevEmu_GetPlayerType(int client, char[] type, int maxlength); public Extension __ext_RevEmuAPI =