Fix: Fail2ban Restzeit-Fallback bei abgelaufenem DB-Eintrag + Update-Modal 2s Verzögerung vor done-State

main v1.1.423
boban 2026-04-27 04:10:02 +02:00
parent 21015e69a3
commit d84537b343
2 changed files with 24 additions and 12 deletions

View File

@ -154,10 +154,7 @@ class Fail2banBanlist extends Component
escapeshellarg($db), escapeshellarg($q)); escapeshellarg($db), escapeshellarg($q));
$out = trim((string)@shell_exec($cmd)); $out = trim((string)@shell_exec($cmd));
if ($out === '') { if ($out !== '') {
return ['permanent' => $fallbackPermanent, 'remaining' => ''];
}
[$timeofban, $bantime] = array_pad(explode('|', $out), 2, '0'); [$timeofban, $bantime] = array_pad(explode('|', $out), 2, '0');
$timeofban = (int)$timeofban; $timeofban = (int)$timeofban;
$bantime = (int)$bantime; $bantime = (int)$bantime;
@ -166,11 +163,23 @@ class Fail2banBanlist extends Component
return ['permanent' => true, 'remaining' => '']; return ['permanent' => true, 'remaining' => ''];
} }
$remaining = max(0, ($timeofban + $bantime) - time()); $remaining = ($timeofban + $bantime) - time();
return [ if ($remaining > 0) {
'permanent' => false, return ['permanent' => false, 'remaining' => $this->formatRemaining($remaining)];
'remaining' => $this->formatRemaining($remaining), }
]; }
// Fallback: DB-Eintrag ist abgelaufen (fail2ban-Neustart setzt Timer intern neu,
// ohne die DB zu aktualisieren) → konfigurierte Jail-Banzeit als Näherung
$cfgBantime = (int)trim($this->f2b('get ' . escapeshellarg($jail) . ' bantime'));
if ($cfgBantime < 0) {
return ['permanent' => true, 'remaining' => ''];
}
if ($cfgBantime > 0) {
return ['permanent' => false, 'remaining' => '≤ ' . $this->formatRemaining($cfgBantime)];
}
return ['permanent' => $fallbackPermanent, 'remaining' => ''];
} }
private function formatRemaining(int $seconds): string private function formatRemaining(int $seconds): string

View File

@ -369,6 +369,9 @@ _cleanup() {
sudo -u "${APP_USER}" php "${APP_DIR}/artisan" optimize:clear 2>&1 || true sudo -u "${APP_USER}" php "${APP_DIR}/artisan" optimize:clear 2>&1 || true
sudo -u "${APP_USER}" php "${APP_DIR}/artisan" optimize 2>&1 || true sudo -u "${APP_USER}" php "${APP_DIR}/artisan" optimize 2>&1 || true
fi fi
# Kurz warten damit das tee-Pipe den Log vollständig schreibt
# bevor der State auf "done" gesetzt wird
sleep 2
mkdir -p "$STATE_DIR" mkdir -p "$STATE_DIR"
echo "done" > "$STATE_DIR/state" echo "done" > "$STATE_DIR/state"
echo "$rc" > "$STATE_DIR/rc" echo "$rc" > "$STATE_DIR/rc"