feat(frontend): add config types and API client for file-config endpoints
- types/config.ts: TypeScript interfaces for ActionConfig, FilterConfig, JailFileConfig, ConfFileContent, and related request/response shapes - api/config.ts: typed API functions for reading and writing conf files - api/endpoints.ts: add /config/file/* endpoint constants
This commit is contained in:
@@ -242,3 +242,141 @@ export interface ConfFileCreateRequest {
|
||||
name: string;
|
||||
content: string;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Parsed filter config (Task 2.1 / 2.2)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Structured representation of a ``filter.d/*.conf`` file.
|
||||
* Maps 1-to-1 with the backend ``FilterConfig`` Pydantic model.
|
||||
*/
|
||||
export interface FilterConfig {
|
||||
/** Base name without extension, e.g. "sshd". */
|
||||
name: string;
|
||||
/** Actual filename, e.g. "sshd.conf". */
|
||||
filename: string;
|
||||
/** [INCLUDES] before directive, or null. */
|
||||
before: string | null;
|
||||
/** [INCLUDES] after directive, or null. */
|
||||
after: string | null;
|
||||
/** [DEFAULT] section key-value pairs (e.g. _daemon, __prefix). */
|
||||
variables: Record<string, string>;
|
||||
/** prefregex line, or null. */
|
||||
prefregex: string | null;
|
||||
/** failregex patterns (one per entry). */
|
||||
failregex: string[];
|
||||
/** ignoreregex patterns (one per entry). */
|
||||
ignoreregex: string[];
|
||||
/** maxlines, or null. */
|
||||
maxlines: number | null;
|
||||
/** datepattern, or null. */
|
||||
datepattern: string | null;
|
||||
/** journalmatch, or null. */
|
||||
journalmatch: string | null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Partial update payload for a filter config.
|
||||
* All fields are optional; ``null`` means leave unchanged.
|
||||
*/
|
||||
export interface FilterConfigUpdate {
|
||||
before?: string | null;
|
||||
after?: string | null;
|
||||
variables?: Record<string, string> | null;
|
||||
prefregex?: string | null;
|
||||
failregex?: string[] | null;
|
||||
ignoreregex?: string[] | null;
|
||||
maxlines?: number | null;
|
||||
datepattern?: string | null;
|
||||
journalmatch?: string | null;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Parsed action config (Task 3.1 / 3.2)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Structured representation of an ``action.d/*.conf`` file.
|
||||
* Maps 1-to-1 with the backend ``ActionConfig`` Pydantic model.
|
||||
*/
|
||||
export interface ActionConfig {
|
||||
/** Base name without extension, e.g. "iptables". */
|
||||
name: string;
|
||||
/** Actual filename, e.g. "iptables.conf". */
|
||||
filename: string;
|
||||
/** [INCLUDES] before directive, or null. */
|
||||
before: string | null;
|
||||
/** [INCLUDES] after directive, or null. */
|
||||
after: string | null;
|
||||
/** actionstart command, or null. */
|
||||
actionstart: string | null;
|
||||
/** actionstop command, or null. */
|
||||
actionstop: string | null;
|
||||
/** actioncheck command, or null. */
|
||||
actioncheck: string | null;
|
||||
/** actionban command, or null. */
|
||||
actionban: string | null;
|
||||
/** actionunban command, or null. */
|
||||
actionunban: string | null;
|
||||
/** actionflush command, or null. */
|
||||
actionflush: string | null;
|
||||
/** [Definition] key-value pairs that are not lifecycle commands. */
|
||||
definition_vars: Record<string, string>;
|
||||
/** [Init] section key-value pairs. */
|
||||
init_vars: Record<string, string>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Partial update payload for an action config.
|
||||
* All fields are optional; ``null`` means leave unchanged.
|
||||
*/
|
||||
export interface ActionConfigUpdate {
|
||||
before?: string | null;
|
||||
after?: string | null;
|
||||
actionstart?: string | null;
|
||||
actionstop?: string | null;
|
||||
actioncheck?: string | null;
|
||||
actionban?: string | null;
|
||||
actionunban?: string | null;
|
||||
actionflush?: string | null;
|
||||
definition_vars?: Record<string, string> | null;
|
||||
init_vars?: Record<string, string> | null;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Parsed jail file config (Task 6.1 / 6.2)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Settings within a single [jailname] section of a jail.d/*.conf file.
|
||||
* Maps 1-to-1 with the backend ``JailSectionConfig`` Pydantic model.
|
||||
*/
|
||||
export interface JailSectionConfig {
|
||||
enabled: boolean | null;
|
||||
port: string | null;
|
||||
filter: string | null;
|
||||
logpath: string[];
|
||||
maxretry: number | null;
|
||||
findtime: number | null;
|
||||
bantime: number | null;
|
||||
action: string[];
|
||||
backend: string | null;
|
||||
extra: Record<string, string>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Structured representation of a ``jail.d/*.conf`` file.
|
||||
* Maps 1-to-1 with the backend ``JailFileConfig`` Pydantic model.
|
||||
*/
|
||||
export interface JailFileConfig {
|
||||
filename: string;
|
||||
jails: Record<string, JailSectionConfig>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Partial update payload for a jail file config.
|
||||
*/
|
||||
export interface JailFileConfigUpdate {
|
||||
jails?: Record<string, JailSectionConfig> | null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user