Add mass unban: DELETE /api/bans/all clears all active bans

- Send fail2ban's `unban --all` command via new `unban_all_ips()` service
  function; returns the count of unbanned IPs
- Add `UnbanAllResponse` Pydantic model (message + count)
- Add `DELETE /api/bans/all` router endpoint; handles 502 on socket error
- Frontend: `bansAll` endpoint constant, `unbanAllBans()` API call,
  `UnbanAllResponse` type, `unbanAll` action in `useActiveBans` hook
- JailsPage: "Clear All Bans" button (visible when bans > 0) with a
  Fluent UI confirmation Dialog before executing the operation
- 7 new tests (3 service, 4 router); 440 total pass, 82% coverage
This commit is contained in:
2026-03-07 21:16:49 +01:00
parent 207be94c42
commit 4773ae1c7a
11 changed files with 382 additions and 10 deletions

View File

@@ -13,6 +13,7 @@ import type {
JailCommandResponse,
JailDetailResponse,
JailListResponse,
UnbanAllResponse,
} from "../types/jail";
// ---------------------------------------------------------------------------
@@ -197,6 +198,18 @@ export async function fetchActiveBans(): Promise<ActiveBanListResponse> {
return get<ActiveBanListResponse>(ENDPOINTS.bansActive);
}
/**
* Unban every currently banned IP across all jails in a single operation.
*
* Uses fail2ban's global `unban --all` command.
*
* @returns An {@link UnbanAllResponse} with the count of unbanned IPs.
* @throws {ApiError} On non-2xx responses.
*/
export async function unbanAllBans(): Promise<UnbanAllResponse> {
return del<UnbanAllResponse>(ENDPOINTS.bansAll);
}
// ---------------------------------------------------------------------------
// Geo / IP lookup
// ---------------------------------------------------------------------------