mirror of
https://github.com/nextcloud/server.git
synced 2026-04-15 22:11:17 -04:00
Log bruteforce throttle and blocking
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
a7eefa293e
commit
c6d000f87f
1 changed files with 11 additions and 0 deletions
|
|
@ -354,9 +354,20 @@ class Throttler {
|
|||
public function sleepDelayOrThrowOnMax(string $ip, string $action = ''): int {
|
||||
$delay = $this->getDelay($ip, $action);
|
||||
if (($delay === self::MAX_DELAY_MS) && $this->getAttempts($ip, $action, 0.5) > self::MAX_ATTEMPTS) {
|
||||
$this->logger->info('IP address blocked because it reached the maximum failed attempts in the last 30 minutes [action: {action}, ip: {ip}]', [
|
||||
'action' => $action,
|
||||
'ip' => $ip,
|
||||
]);
|
||||
// If the ip made too many attempts within the last 30 mins we don't execute anymore
|
||||
throw new MaxDelayReached('Reached maximum delay');
|
||||
}
|
||||
if ($delay > 100) {
|
||||
$this->logger->info('IP address throttled because it reached the attempts limit in the last 30 minutes [action: {action}, delay: {delay}, ip: {ip}]', [
|
||||
'action' => $action,
|
||||
'ip' => $ip,
|
||||
'delay' => $delay,
|
||||
]);
|
||||
}
|
||||
usleep($delay * 1000);
|
||||
return $delay;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue