/*

			   AntiCrash Module
			    BJIADOKC & Co.
	Remove this copyright, if you want to be a superman!
*/





#if defined _ach_included
	#endinput
#endif

#define _ach_included

#define ATTACK_TYPE_DIALOG_RESPONSE 	0
#define ATTACK_TYPE_DIALOG_EXPLOIT	1
#define ATTACK_TYPE_RCON_EXPLOIT	2
#define ATTACK_TYPE_BAD_RCON_ATTEMPT	3
#define ATTACK_TYPE_INVALID_CLIENT	4
#define ATTACK_TYPE_PACKET_MODIFIED	5

forward OnAttackAttempt(attackType, data[]);
forward OnIncomingConnection(ip[]);

public OnAttackAttempt(attackType, data[])
{
	if(data[0] <= '\1')
	{
		printf("AntiCrash Warning: NULL data passed to callback \"OnAttackAttempt\" %d|\"\"", attackType);
	}

	switch(attackType)
	{
		case ATTACK_TYPE_DIALOG_RESPONSE: // DialogResponse match attack
		{
			Kick(strval(data));
		}

		case ATTACK_TYPE_DIALOG_EXPLOIT: // DialogResponse crash exploit
		{
			BanEx(strval(data), "DialogResponse crash exploit");
		}

		case ATTACK_TYPE_RCON_EXPLOIT: // RCON command exploit crash
		{
			BanEx(strval(data), "RCON command crash exploit");
		}

		case ATTACK_TYPE_BAD_RCON_ATTEMPT: // BAD RCON ATTEMPT BY
		{
			new dest[24];
			format(dest, sizeof dest, "banip %s", data);
			SendRconCommand(dest);
		}

		case ATTACK_TYPE_INVALID_CLIENT: // Invalid client connecting
		{
			new dest[24];
			format(dest, sizeof dest, "banip %s", data);
			SendRconCommand(dest);
		}

		case ATTACK_TYPE_PACKET_MODIFIED: // RCON command exploit crash
		{
			BanEx(strval(data), "Client attack (Packet modified)");
		}

		default:
		{
			printf("AntiCrash Warning: Incorrect data passed to callback \"OnAttackAttempt\" %d|\"%s\"", attackType, data);
		}
	}
	return 1;
}

#if defined _ALS_OnAttackAttempt
    #undef OnAttackAttempt
#else
    #define _ALS_OnAttackAttempt
#endif

#define OnAttackAttempt ach_OnAttackAttempt

forward ach_OnAttackAttempt(attackType, data[]);