HID bot detect: 3 temporary lockouts = permanent lockout

USG_1.0
Robert Fisk 7 years ago
parent 1f365434f9
commit 0c7cc00c0a

@ -19,9 +19,9 @@
//Variables common between keyboard and mouse bot detection: //Variables common between keyboard and mouse bot detection:
uint32_t TemporaryLockoutTimeMs;
volatile LockoutStateTypeDef LockoutState = LOCKOUT_STATE_INACTIVE; volatile LockoutStateTypeDef LockoutState = LOCKOUT_STATE_INACTIVE;
uint32_t TemporaryLockoutTimeMs;
uint8_t TemporaryLockoutCount = 0;
//Variables specific to keyboard bot detection: //Variables specific to keyboard bot detection:
@ -201,6 +201,14 @@ static void Upstream_HID_BotDetectKeyboard_DoLockout(void)
return; return;
} }
//Three (temporary) strikes -> you're out!
if (++TemporaryLockoutCount >= 3)
{
LockoutState = LOCKOUT_STATE_PERMANENT_ACTIVE;
LED_SetState(LED_STATUS_FLASH_BOTDETECT);
return;
}
//Otherwise, reset counters and give warning //Otherwise, reset counters and give warning
for (i = 0; i < KEYBOARD_BOTDETECT_FAST_BIN_COUNT; i++) for (i = 0; i < KEYBOARD_BOTDETECT_FAST_BIN_COUNT; i++)
{ {
@ -572,6 +580,14 @@ static void Upstream_HID_BotDetectMouse_DoLockout(void)
return; return;
} }
//Three (temporary) strikes -> you're out!
if (++TemporaryLockoutCount >= 3)
{
LockoutState = LOCKOUT_STATE_PERMANENT_ACTIVE;
LED_SetState(LED_STATUS_FLASH_BOTDETECT);
return;
}
//Otherwise, reset counters and give warning //Otherwise, reset counters and give warning
for (i = 0; i < MOUSE_BOTDETECT_VELOCITY_HISTORY_SIZE; i++) for (i = 0; i < MOUSE_BOTDETECT_VELOCITY_HISTORY_SIZE; i++)
{ {

Loading…
Cancel
Save