Add a Network > Ports page: agent-reported ports plus manual openings

Summarizes every server's agent-reported listening ports in one
cross-server table (grouped by protocol+port, addresses merged,
loopback-only flagged) - previously this only existed per-server on
each server's own detail page.

Adds a second table for ports this app has no way to see on its own:
manually-recorded openings on a router, edge firewall, or cloud
security group, each with a label, external port/protocol, an optional
link to a tracked server (with its own internal port when NAT changes
it) or a freeform destination, a free-text source, and a comment.
Viewer-readable; adding/editing/deleting needs operator or admin.

The agent-port grouping logic (dedupe by protocol+port, detect
loopback-only sockets) was shared with the existing per-server Ports
card via a new agentPorts.ts service instead of duplicating it.

Verified with a real HTTP-level test: a genuine Express app with the
actual routers, a scratch SQLite DB, and forged admin/viewer sessions,
covering grouping correctness, the server-name join, input validation,
and role enforcement - the real dev DB was confirmed untouched.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5 committed 2026-09-29 23:48:35 +02:00
1 parent 4e48377348
commit 236b1da0dc
14 files changed
+2486 -39

No files matched your search

+55
View File
@@ -140,6 +140,50 @@ export interface IpamInput {
notes?: string;
}
export interface AgentPortRow {
serverId: number;
serverName: string;
serverHostname: string | null;
protocol: "tcp" | "udp";
port: number;
addresses: string[];
process: string | null;
localOnly: boolean;
lastSeenAt: string | null;
}
export interface AgentPortsResponse {
ports: AgentPortRow[];
reportingServers: number;
totalServers: number;
}
export interface PortForward {
id: number;
label: string;
externalPort: number;
protocol: "tcp" | "udp";
serverId: number | null;
serverName: string | null;
destination: string | null;
internalPort: number | null;
source: string | null;
comment: string | null;
createdAt: string;
updatedAt: string;
}
export interface PortForwardInput {
label: string;
externalPort: number;
protocol: "tcp" | "udp";
serverId?: number | null;
destination?: string | null;
internalPort?: number | null;
source?: string | null;
comment?: string | null;
}
export type DnsProviderType = "cloudflare" | "loopia" | "pihole" | "azure" | "cpanel" | "technitium";
export interface GotifySettings {
@@ -951,6 +995,17 @@ export const api = {
syncProxmox: () => request<IpamSyncResult>("/api/ipam/sync-proxmox", { method: "POST" }),
syncPhpIpam: () => request<IpamSyncResult>("/api/ipam/sync-phpipam", { method: "POST" }),
},
ports: {
agent: () => request<AgentPortsResponse>("/api/ports/agent"),
forwards: {
list: () => request<{ forwards: PortForward[] }>("/api/ports/forwards"),
create: (data: PortForwardInput) =>
request<{ forward: PortForward }>("/api/ports/forwards", { method: "POST", body: JSON.stringify(data) }),
update: (id: number, data: Partial<PortForwardInput>) =>
request<{ forward: PortForward }>(`/api/ports/forwards/${id}`, { method: "PATCH", body: JSON.stringify(data) }),
remove: (id: number) => request<void>(`/api/ports/forwards/${id}`, { method: "DELETE" }),
},
},
dns: {
providerFields: () =>
request<{ fields: Record<DnsProviderType, DnsProviderField[]> }>("/api/dns/provider-fields"),