Stage 7: configuration view — backend service, routers, tests, and frontend

- config_service.py: read/write jail config via asyncio.gather, global
  settings, in-process regex validation, log preview via _read_tail_lines
- server_service.py: read/write server settings, flush logs
- config router: 9 endpoints for jail/global config, regex-test,
  logpath management, log preview
- server router: GET/PUT settings, POST flush-logs
- models/config.py expanded with JailConfig, GlobalConfigUpdate,
  LogPreview* models
- 285 tests pass (68 new), ruff clean, mypy clean (44 files)
- Frontend: types/config.ts, api/config.ts, hooks/useConfig.ts,
  ConfigPage.tsx full implementation (Jails accordion editor,
  Global config, Server settings, Regex Tester with preview)
- Fixed pre-existing frontend lint: JSX.Element → React.JSX.Element
  (10 files), void/promise patterns in useServerStatus + useJails,
  no-misused-spread in client.ts, eslint.config.ts self-excluded
This commit is contained in:
2026-03-01 14:37:55 +01:00
parent ebec5e0f58
commit 7f81f0614b
33 changed files with 4488 additions and 82 deletions

View File

@@ -0,0 +1,130 @@
/**
* TypeScript interfaces for the configuration and server settings API.
*/
// ---------------------------------------------------------------------------
// Jail Configuration
// ---------------------------------------------------------------------------
export interface JailConfig {
name: string;
ban_time: number;
max_retry: number;
find_time: number;
fail_regex: string[];
ignore_regex: string[];
log_paths: string[];
date_pattern: string | null;
log_encoding: string;
backend: string;
actions: string[];
}
export interface JailConfigResponse {
jail: JailConfig;
}
export interface JailConfigListResponse {
jails: JailConfig[];
total: number;
}
export interface JailConfigUpdate {
ban_time?: number | null;
max_retry?: number | null;
find_time?: number | null;
fail_regex?: string[] | null;
ignore_regex?: string[] | null;
date_pattern?: string | null;
dns_mode?: string | null;
enabled?: boolean | null;
}
// ---------------------------------------------------------------------------
// Global Configuration
// ---------------------------------------------------------------------------
export interface GlobalConfig {
log_level: string;
log_target: string;
db_purge_age: number;
db_max_matches: number;
}
export interface GlobalConfigUpdate {
log_level?: string | null;
log_target?: string | null;
db_purge_age?: number | null;
db_max_matches?: number | null;
}
// ---------------------------------------------------------------------------
// Server Settings
// ---------------------------------------------------------------------------
export interface ServerSettings {
log_level: string;
log_target: string;
syslog_socket: string | null;
db_path: string;
db_purge_age: number;
db_max_matches: number;
}
export interface ServerSettingsResponse {
settings: ServerSettings;
}
export interface ServerSettingsUpdate {
log_level?: string | null;
log_target?: string | null;
db_purge_age?: number | null;
db_max_matches?: number | null;
}
// ---------------------------------------------------------------------------
// Regex Tester
// ---------------------------------------------------------------------------
export interface RegexTestRequest {
log_line: string;
fail_regex: string;
}
export interface RegexTestResponse {
matched: boolean;
groups: string[];
error: string | null;
}
// ---------------------------------------------------------------------------
// Log Preview
// ---------------------------------------------------------------------------
export interface LogPreviewRequest {
log_path: string;
fail_regex: string;
num_lines?: number;
}
export interface LogPreviewLine {
line: string;
matched: boolean;
groups: string[];
}
export interface LogPreviewResponse {
lines: LogPreviewLine[];
total_lines: number;
matched_count: number;
regex_error: string | null;
}
// ---------------------------------------------------------------------------
// Add Log Path
// ---------------------------------------------------------------------------
export interface AddLogPathRequest {
log_path: string;
tail?: boolean;
}