Expose ban-time escalation settings in jail detail and config UI
- Backend: Add BantimeEscalation + BantimeEscalationUpdate Pydantic models to app/models/config.py; add bantime_escalation field to Jail in jail.py - Backend: jail_service.get_jail_detail() fetches 7 bantime.* socket commands (increment, factor, formula, multipliers, maxtime, rndtime, overalljails) and populates bantime_escalation on the returned Jail object - Backend: config_service.get_jail_config() fetches same 7 commands; update_jail_config() writes escalation fields when provided - Frontend: Add BantimeEscalation + BantimeEscalationUpdate interfaces to types/config.ts; extend JailConfig + JailConfigUpdate; extend Jail in types/jail.ts - Frontend: JailDetailPage.tsx adds BantimeEscalationSection component that renders only when increment is enabled (shows factor, formula, multipliers, max_time, rnd_time, overall_jails) - Frontend: ConfigPage.tsx JailAccordionPanel adds full escalation edit form (Switch for enable/disable, number inputs for factor/max_time/rnd_time, text inputs for formula/multipliers, Switch for overall_jails); handleSave includes bantime_escalation in the JailConfigUpdate payload - Tests: Update ConfigPageLogPath.test.tsx mock to include bantime_escalation:null - Docs: Mark Task 6 as DONE in Tasks.md
This commit is contained in:
@@ -65,6 +65,7 @@ import {
|
||||
} from "../api/config";
|
||||
import type {
|
||||
AddLogPathRequest,
|
||||
BantimeEscalationUpdate,
|
||||
ConfFileEntry,
|
||||
GlobalConfigUpdate,
|
||||
JailConfig,
|
||||
@@ -260,6 +261,16 @@ function JailAccordionPanel({
|
||||
const [saving, setSaving] = useState(false);
|
||||
const [msg, setMsg] = useState<{ text: string; ok: boolean } | null>(null);
|
||||
|
||||
// Ban-time escalation state (mirrors jail.bantime_escalation or defaults).
|
||||
const esc0 = jail.bantime_escalation;
|
||||
const [escEnabled, setEscEnabled] = useState(esc0?.increment ?? false);
|
||||
const [escFactor, setEscFactor] = useState(esc0?.factor != null ? String(esc0.factor) : "");
|
||||
const [escFormula, setEscFormula] = useState(esc0?.formula ?? "");
|
||||
const [escMultipliers, setEscMultipliers] = useState(esc0?.multipliers ?? "");
|
||||
const [escMaxTime, setEscMaxTime] = useState(esc0?.max_time != null ? String(esc0.max_time) : "");
|
||||
const [escRndTime, setEscRndTime] = useState(esc0?.rnd_time != null ? String(esc0.rnd_time) : "");
|
||||
const [escOverallJails, setEscOverallJails] = useState(esc0?.overall_jails ?? false);
|
||||
|
||||
const handleDeleteLogPath = useCallback(
|
||||
async (path: string) => {
|
||||
setDeletingPath(path);
|
||||
@@ -305,12 +316,22 @@ function JailAccordionPanel({
|
||||
setSaving(true);
|
||||
setMsg(null);
|
||||
try {
|
||||
const escalation: BantimeEscalationUpdate = {
|
||||
increment: escEnabled,
|
||||
factor: escFactor !== "" ? Number(escFactor) : null,
|
||||
formula: escFormula !== "" ? escFormula : null,
|
||||
multipliers: escMultipliers !== "" ? escMultipliers : null,
|
||||
max_time: escMaxTime !== "" ? Number(escMaxTime) : null,
|
||||
rnd_time: escRndTime !== "" ? Number(escRndTime) : null,
|
||||
overall_jails: escOverallJails,
|
||||
};
|
||||
await onSave(jail.name, {
|
||||
ban_time: Number(banTime) || jail.ban_time,
|
||||
find_time: Number(findTime) || jail.find_time,
|
||||
max_retry: Number(maxRetry) || jail.max_retry,
|
||||
fail_regex: failRegex,
|
||||
ignore_regex: ignoreRegex,
|
||||
bantime_escalation: escalation,
|
||||
});
|
||||
setMsg({ text: "Saved.", ok: true });
|
||||
} catch (err: unknown) {
|
||||
@@ -325,6 +346,13 @@ function JailAccordionPanel({
|
||||
maxRetry,
|
||||
failRegex,
|
||||
ignoreRegex,
|
||||
escEnabled,
|
||||
escFactor,
|
||||
escFormula,
|
||||
escMultipliers,
|
||||
escMaxTime,
|
||||
escRndTime,
|
||||
escOverallJails,
|
||||
jail.ban_time,
|
||||
jail.find_time,
|
||||
jail.max_retry,
|
||||
@@ -459,6 +487,77 @@ function JailAccordionPanel({
|
||||
</div>
|
||||
</Field>
|
||||
)}
|
||||
|
||||
{/* Ban-time Escalation */}
|
||||
<div style={{ marginTop: tokens.spacingVerticalM }}>
|
||||
<Text weight="semibold" size={400} block>
|
||||
Ban-time Escalation
|
||||
</Text>
|
||||
<Switch
|
||||
label="Enable incremental banning"
|
||||
checked={escEnabled}
|
||||
onChange={(_e, d) => {
|
||||
setEscEnabled(d.checked);
|
||||
}}
|
||||
/>
|
||||
{escEnabled && (
|
||||
<div>
|
||||
<div className={styles.fieldRowThree}>
|
||||
<Field label="Factor">
|
||||
<Input
|
||||
type="number"
|
||||
value={escFactor}
|
||||
onChange={(_e, d) => {
|
||||
setEscFactor(d.value);
|
||||
}}
|
||||
/>
|
||||
</Field>
|
||||
<Field label="Max Time (s)">
|
||||
<Input
|
||||
type="number"
|
||||
value={escMaxTime}
|
||||
onChange={(_e, d) => {
|
||||
setEscMaxTime(d.value);
|
||||
}}
|
||||
/>
|
||||
</Field>
|
||||
<Field label="Random Jitter (s)">
|
||||
<Input
|
||||
type="number"
|
||||
value={escRndTime}
|
||||
onChange={(_e, d) => {
|
||||
setEscRndTime(d.value);
|
||||
}}
|
||||
/>
|
||||
</Field>
|
||||
</div>
|
||||
<Field label="Formula">
|
||||
<Input
|
||||
value={escFormula}
|
||||
onChange={(_e, d) => {
|
||||
setEscFormula(d.value);
|
||||
}}
|
||||
/>
|
||||
</Field>
|
||||
<Field label="Multipliers (space-separated)">
|
||||
<Input
|
||||
value={escMultipliers}
|
||||
onChange={(_e, d) => {
|
||||
setEscMultipliers(d.value);
|
||||
}}
|
||||
/>
|
||||
</Field>
|
||||
<Switch
|
||||
label="Count repeat offences across all jails"
|
||||
checked={escOverallJails}
|
||||
onChange={(_e, d) => {
|
||||
setEscOverallJails(d.checked);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className={styles.buttonRow}>
|
||||
<Button
|
||||
appearance="primary"
|
||||
|
||||
Reference in New Issue
Block a user