Port presets: name ports automatically, scan many hosts for a preset, apply names in bulk

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5.5 committed 2026-10-30 22:39:52 +01:00
1 parent 93aaf5476d
commit fca2dc0338
24 files changed
+9764 -40

No files matched your search

+50
View File
@@ -396,6 +396,8 @@ export interface AgentPortRow {
process: string | null;
localOnly: boolean;
lastSeenAt: string | null;
/** What a port preset calls this port (22 → SSH); null when no preset has it. */
service: string | null;
}
export interface AgentPortsResponse {
@@ -2596,6 +2598,46 @@ export interface PortEntry {
state: "open" | "reserved";
/** Began listening after the first report and nobody has noted it: a "new port" alert is on. */
isNew: boolean;
/** What a port preset calls this port (3389 → RDP); null when no preset has it. */
service: string | null;
}
export interface PresetPort {
port: number;
protocol: "tcp" | "udp";
label: string;
}
export interface PortPreset {
id: number;
name: string;
ports: PresetPort[];
updatedAt: string;
}
export interface PresetHostResult {
serverId: number;
name: string;
address: string | null;
state: "scanned" | "no_answer" | "skipped" | "error" | "busy";
message: string | null;
open: number[];
closed: number[];
filtered: number;
}
export interface PresetScanResponse {
preset: { id: number; name: string };
/** The TCP ports looked at, in order. */
ports: number[];
/** Port (as text) → the preset's name for it. */
labels: Record<string, string>;
results: PresetHostResult[];
}
export interface PresetApplyResponse {
preset: { id: number; name: string };
results: { serverId: number; name: string; labelled: PresetPort[]; skipped: { port: number; protocol: "tcp" | "udp"; reason: string }[] }[];
}
export interface PortScanSummary {
@@ -3690,6 +3732,14 @@ export const api = {
testClose: (integrationId: number) => request<{ ok: boolean; problems: string[]; notes: string[] }>("/api/alert-tickets/test-close", { method: "POST", body: JSON.stringify({ integrationId }) }),
run: () => request<{ summary: AlertTicketRunSummary; status: AlertTicketOverview["status"] }>("/api/alert-tickets/run", { method: "POST" }),
},
portPresets: {
list: () => request<{ presets: PortPreset[] }>("/api/port-presets"),
create: (data: { name: string; ports: PresetPort[] }) => request<{ preset: PortPreset }>("/api/port-presets", { method: "POST", body: JSON.stringify(data) }),
update: (id: number, data: { name: string; ports: PresetPort[] }) => request<{ preset: PortPreset }>(`/api/port-presets/${id}`, { method: "PUT", body: JSON.stringify(data) }),
remove: (id: number) => request<void>(`/api/port-presets/${id}`, { method: "DELETE" }),
scan: (id: number, targets: { serverId: number; address?: string }[]) => request<PresetScanResponse>(`/api/port-presets/${id}/scan`, { method: "POST", body: JSON.stringify({ targets }) }),
apply: (id: number, data: { serverIds: number[]; onlyOpen?: boolean; overwrite?: boolean }) => request<PresetApplyResponse>(`/api/port-presets/${id}/apply`, { method: "POST", body: JSON.stringify(data) }),
},
ports: {
agent: () => request<AgentPortsResponse>("/api/ports/agent"),
forwards: {