Add ignore-self toggle to Jail Detail page
Implements the missing UI control for POST /api/jails/{name}/ignoreself:
- Add jailIgnoreSelf endpoint constant to endpoints.ts
- Add toggleIgnoreSelf(name, on) API function to jails.ts
- Expose toggleIgnoreSelf action from useJailDetail hook
- Replace read-only 'ignore self' badge with a Fluent Switch in
IgnoreListSection to allow enabling/disabling the flag per jail
- Add 5 vitest tests for checked/unchecked state and toggle behaviour
This commit is contained in:
@@ -45,6 +45,7 @@ export const ENDPOINTS = {
|
||||
jailReload: (name: string): string => `/jails/${encodeURIComponent(name)}/reload`,
|
||||
jailsReloadAll: "/jails/reload-all",
|
||||
jailIgnoreIp: (name: string): string => `/jails/${encodeURIComponent(name)}/ignoreip`,
|
||||
jailIgnoreSelf: (name: string): string => `/jails/${encodeURIComponent(name)}/ignoreself`,
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Bans
|
||||
|
||||
@@ -149,6 +149,24 @@ export async function delIgnoreIp(
|
||||
return del<JailCommandResponse>(ENDPOINTS.jailIgnoreIp(name), { ip });
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable or disable the `ignoreself` flag for a jail.
|
||||
*
|
||||
* When enabled, fail2ban automatically adds the server's own IP addresses to
|
||||
* the ignore list so the host can never ban itself.
|
||||
*
|
||||
* @param name - Jail name.
|
||||
* @param on - `true` to enable, `false` to disable.
|
||||
* @returns A {@link JailCommandResponse} confirming the change.
|
||||
* @throws {ApiError} On non-2xx responses.
|
||||
*/
|
||||
export async function toggleIgnoreSelf(
|
||||
name: string,
|
||||
on: boolean,
|
||||
): Promise<JailCommandResponse> {
|
||||
return post<JailCommandResponse>(ENDPOINTS.jailIgnoreSelf(name), on);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Ban / unban
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user