36 lines
939 B
PHP
36 lines
939 B
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use App\Services\BruteforceGuard;
|
|
use Illuminate\Console\Command;
|
|
|
|
class UnbanIp extends Command
|
|
{
|
|
protected $signature = 'clusev:unban {ip? : Zu entsperrende IP-Adresse} {--all : Alle aktiven Bänne entfernen}';
|
|
|
|
protected $description = 'Entfernt App-Level-IP-Bänne des Anmeldeschutzes per Shell (Aussperr-Rettung)';
|
|
|
|
public function handle(BruteforceGuard $guard): int
|
|
{
|
|
if ($this->option('all')) {
|
|
$count = $guard->unbanAll();
|
|
$this->info("{$count} Bann/Bänne entfernt.");
|
|
|
|
return self::SUCCESS;
|
|
}
|
|
|
|
$ip = (string) $this->argument('ip');
|
|
if ($ip === '') {
|
|
$this->error('Bitte eine IP angeben oder --all verwenden.');
|
|
|
|
return self::FAILURE;
|
|
}
|
|
|
|
$guard->unban($ip);
|
|
$this->info("Bann für {$ip} entfernt (falls vorhanden).");
|
|
|
|
return self::SUCCESS;
|
|
}
|
|
}
|