changed flow, now just missing python part
This commit is contained in:
		
							parent
							
								
									3695f56d22
								
							
						
					
					
						commit
						7892a73726
					
				@ -33,6 +33,73 @@ public void OnPluginStart()
 | 
			
		||||
	Database.Connect(SQL_OnDatabaseConnect_sb, "sourcebans");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
public void OnMapStart()
 | 
			
		||||
{
 | 
			
		||||
        CreateTimer(5.0, time_query_nosteam_select, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
public Action time_query_nosteam_select(Handle timer, any data)
 | 
			
		||||
{
 | 
			
		||||
	for (int client = 1; client <= MaxClients; client++)
 | 
			
		||||
		if (IsValidClient(client) && !IsFakeClient(client))
 | 
			
		||||
		{
 | 
			
		||||
			char sAuthID[32];
 | 
			
		||||
			GetClientAuthId(client, AuthId_Steam2, sAuthID, sizeof(sAuthID), false);
 | 
			
		||||
			char sIP[32];
 | 
			
		||||
			GetClientIP(client, sIP, sizeof(sIP));
 | 
			
		||||
			if (!SteamClientAuthenticated(sAuthID))
 | 
			
		||||
			{
 | 
			
		||||
				char sQuery[512];
 | 
			
		||||
				Format(sQuery, sizeof(sQuery), "select * from kicklist cr where cr.steam_id = '%s' and cr.ipv4 = '%s' and cr.kick is TRUE", sAuthID, sIP);
 | 
			
		||||
				g_hDatabase.Query(sql_update_cooldown, sQuery, GetClientSerial(client), DBPrio_High);
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	return Plugin_Continue;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
public void sql_update_cooldown(Database db, DBResultSet results, const char[] error, any data)
 | 
			
		||||
{
 | 
			
		||||
        if(!db || strlen(error))
 | 
			
		||||
        {
 | 
			
		||||
                LogError("Query error: %s", error);
 | 
			
		||||
                return;
 | 
			
		||||
        }
 | 
			
		||||
        int client;
 | 
			
		||||
        if ((client = GetClientFromSerial(data)) == 0)
 | 
			
		||||
                return;
 | 
			
		||||
	if (results.RowCount && results.FetchRow())
 | 
			
		||||
        {
 | 
			
		||||
		char sIP[64];
 | 
			
		||||
		GetClientIP(client, sIP, sizeof(sIP));
 | 
			
		||||
		char sAuthID[512];
 | 
			
		||||
		GetClientAuthId(client, AuthId_Steam2, sAuthID, sizeof(sAuthID), false);
 | 
			
		||||
		char sql_statement[512];
 | 
			
		||||
		Format(sql_statement, sizeof(sql_statement), "delete from kicklist where steam_id = '%s' and ipv4 = '%s' and kick is TRUE", sAuthID, sIP);
 | 
			
		||||
		g_hDatabase.Query(sql_kick_client, sql_statement, GetClientSerial(client), DBPrio_High);
 | 
			
		||||
	}
 | 
			
		||||
	delete results;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
public void sql_kick_client(Database db, DBResultSet results, const char[] error, any data)
 | 
			
		||||
{
 | 
			
		||||
        if(!db || strlen(error))
 | 
			
		||||
        {
 | 
			
		||||
                LogError("Query error: %s", error);
 | 
			
		||||
                return;
 | 
			
		||||
        }
 | 
			
		||||
        int client;
 | 
			
		||||
        if ((client = GetClientFromSerial(data)) == 0)
 | 
			
		||||
                return;
 | 
			
		||||
	char sIP[64];
 | 
			
		||||
	GetClientIP(client, sIP, sizeof(sIP));
 | 
			
		||||
	char sAuthID[512];
 | 
			
		||||
	GetClientAuthId(client, AuthId_Steam2, sAuthID, sizeof(sAuthID), false);
 | 
			
		||||
	LogMessage("%L | %s nosteamer got kicked for dynamic IP ban avoiding(IP: %s).", client, sAuthID, sIP);
 | 
			
		||||
	KickClient(client, "If you believe this is undeserved write a forum post on https://www.unloze.com");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
public void SQL_OnDatabaseConnect(Database db, const char[] error, any data)
 | 
			
		||||
{
 | 
			
		||||
        if(!db || strlen(error))
 | 
			
		||||
@ -72,17 +139,6 @@ public void SQL_OnQueryCompleted(Database db, DBResultSet results, const char[]
 | 
			
		||||
                OnClientPostAdminCheck(i);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
public int OnTransferComplete(Handle hRequest, bool bFailure, bool bSuccessful, EHTTPStatusCode eStatusCode, int iSerial)
 | 
			
		||||
{
 | 
			
		||||
        if (bFailure || !bSuccessful || eStatusCode != k_EHTTPStatusCode200OK)
 | 
			
		||||
        {
 | 
			
		||||
                delete hRequest;
 | 
			
		||||
                LogError("Request-Error: %d", eStatusCode);
 | 
			
		||||
                return;
 | 
			
		||||
        }
 | 
			
		||||
        SteamWorks_GetHTTPResponseBodyCallback(hRequest, OnTransferResponse, iSerial);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
public int OnTransferResponse(char[] sData, int iSerial)
 | 
			
		||||
{
 | 
			
		||||
        int client = GetClientFromSerial(iSerial);
 | 
			
		||||
@ -145,7 +201,6 @@ public void SQL_insert(Database db, DBResultSet results, const char[] error, any
 | 
			
		||||
	char sql_statement_query[1024];
 | 
			
		||||
	Format(sql_statement_query, sizeof(sql_statement_query), "update connect_restriction cr1 inner join (select * from connect_restriction cr3 where cr3.asn = '%s' and cr3.provider = '%s' and cr3.country = '%s' and cr3.ipv4 like '%s.%s.%s' and cr3.cooldown > CURDATE() order by cr3.inserted_on desc limit 1) as cr2 on cr1.asn = cr2.asn and cr1.provider = cr2.provider and cr1.country = cr2.country set cr1.cooldown = cr2.cooldown where cr1.ipv4 like '%s.%s.%s'", g_asn[client], g_provider[client], g_country[client], ip_subblock[0], ip_subblock[1], "%", ip_subblock[0], ip_subblock[1], "%");
 | 
			
		||||
	Format(sql_statement, sizeof(sql_statement), "update connect_restriction cr1 inner join (select * from connect_restriction cr3 where cr3.asn = '%s' and cr3.provider = '%s' and cr3.country = '%s' and cr3.ipv4 like '%s.%s.%s' and cr3.cooldown > CURDATE() order by cr3.inserted_on desc limit 1) as cr2 on cr1.asn = cr2.asn and cr1.provider = cr2.provider and cr1.country = cr2.country set cr1.cooldown = cr2.cooldown, cr1.cooldown_query = %s%s%s where cr1.ipv4 like '%s.%s.%s'", g_asn[client], g_provider[client], g_country[client], ip_subblock[0], ip_subblock[1], "%", "\"", sql_statement_query, "\"", ip_subblock[0], ip_subblock[1], "%");
 | 
			
		||||
	//LogMessage("sql_statement: %s", sql_statement);
 | 
			
		||||
	delete results;
 | 
			
		||||
	g_hDatabase.Query(SQL_update_restriction, sql_statement, GetClientSerial(client), DBPrio_High);
 | 
			
		||||
}
 | 
			
		||||
@ -180,16 +235,9 @@ public void sql_select_cooldown(Database db, DBResultSet results, const char[] e
 | 
			
		||||
        int client; 
 | 
			
		||||
        if ((client = GetClientFromSerial(data)) == 0)
 | 
			
		||||
                return;
 | 
			
		||||
	if (results.RowCount && results.FetchRow())
 | 
			
		||||
        {
 | 
			
		||||
		char sIP[64];
 | 
			
		||||
		GetClientIP(client, sIP, sizeof(sIP));
 | 
			
		||||
		char sAuthID[512];
 | 
			
		||||
                GetClientAuthId(client, AuthId_Steam2, sAuthID, sizeof(sAuthID), false);
 | 
			
		||||
		LogMessage("%L | %s nosteamer got kicked for dynamic IP ban avoiding(IP: %s).", client, sAuthID, sIP);
 | 
			
		||||
		KickClient(client, "If you believe this is undeserved write a forum post on https://www.unloze.com");
 | 
			
		||||
	}
 | 
			
		||||
	else
 | 
			
		||||
	//if client already has a cooldown no further action  needed
 | 
			
		||||
	//if client has no cooldown we update sourcebans copy table
 | 
			
		||||
	if (!results.RowCount || !results.FetchRow())
 | 
			
		||||
        {
 | 
			
		||||
		char sql_statement[512];
 | 
			
		||||
		Format(sql_statement, sizeof(sql_statement), "TRUNCATE table `sb_bans_shortened`");
 | 
			
		||||
@ -289,30 +337,11 @@ public void sql_select_banned(Database db, DBResultSet results, const char[] err
 | 
			
		||||
                char sql_statement_query[512];
 | 
			
		||||
                Format(sql_statement_query, sizeof(sql_statement_query), "update connect_restriction set cooldown = DATE_ADD(now(), INTERVAL 170 DAY) where steam_id = '%s' and ipv4 = '%s'", sAuthID, s_client_ip);
 | 
			
		||||
                Format(sql_statement, sizeof(sql_statement), "update connect_restriction set cooldown = DATE_ADD(now(), INTERVAL 170 DAY), cooldown_query = %s%s%s where steam_id = '%s' and ipv4 = '%s'", "\"", sql_statement_query, "\"", sAuthID, s_client_ip);
 | 
			
		||||
		g_hDatabase.Query(sql_update_cooldown, sql_statement, GetClientSerial(client), DBPrio_High);
 | 
			
		||||
                g_hDatabase.Query(sql_insert_dummy, sql_statement, GetClientSerial(client), DBPrio_High);
 | 
			
		||||
        }
 | 
			
		||||
        delete results;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
public void sql_update_cooldown(Database db, DBResultSet results, const char[] error, any data)
 | 
			
		||||
{
 | 
			
		||||
        if(!db || strlen(error))
 | 
			
		||||
        {
 | 
			
		||||
                LogError("Query error: %s", error);
 | 
			
		||||
                return;
 | 
			
		||||
        }
 | 
			
		||||
        int client;
 | 
			
		||||
        if ((client = GetClientFromSerial(data)) == 0)
 | 
			
		||||
                return;
 | 
			
		||||
	delete results;
 | 
			
		||||
	char sIP[64];
 | 
			
		||||
	GetClientIP(client, sIP, sizeof(sIP));
 | 
			
		||||
	char sAuthID[512];
 | 
			
		||||
	GetClientAuthId(client, AuthId_Steam2, sAuthID, sizeof(sAuthID), false);
 | 
			
		||||
	LogMessage("%L | %s nosteamer got kicked for dynamic IP ban avoiding(IP: %s).", client, sAuthID, sIP);
 | 
			
		||||
	KickClient(client, "If you believe this is undeserved write a forum post on https://www.unloze.com");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
public void sql_select_if_exists(Database db, DBResultSet results, const char[] error, any data)
 | 
			
		||||
{
 | 
			
		||||
        if(!db || strlen(error))
 | 
			
		||||
@ -362,6 +391,18 @@ public void sql_select_if_exists(Database db, DBResultSet results, const char[]
 | 
			
		||||
	delete results;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
public int OnTransferComplete(Handle hRequest, bool bFailure, bool bSuccessful, EHTTPStatusCode eStatusCode, int iSerial)
 | 
			
		||||
{
 | 
			
		||||
        if (bFailure || !bSuccessful || eStatusCode != k_EHTTPStatusCode200OK)
 | 
			
		||||
        {
 | 
			
		||||
                delete hRequest;
 | 
			
		||||
                LogError("Request-Error: %d", eStatusCode);
 | 
			
		||||
                return;
 | 
			
		||||
        }
 | 
			
		||||
        SteamWorks_GetHTTPResponseBodyCallback(hRequest, OnTransferResponse, iSerial);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
public void resetClient(int client)
 | 
			
		||||
{
 | 
			
		||||
	Format(g_asn[client], sizeof(g_asn[]), "");
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user