From 7eee807d9ec77c0772efd5211c99bc4a61d886bb Mon Sep 17 00:00:00 2001 From: Bobban Rydh Date: Fri, 30 Oct 2026 23:52:29 +0100 Subject: [PATCH] Port presets on their own tab of the Ports page Co-Authored-By: Claude Sonnet 5.5 --- README.md | 2 +- ROLES.md | 2 +- web/src/components/ServerPorts.tsx | 2 +- web/src/pages/Ports.tsx | 453 +++++++++++++++-------------- 4 files changed, 237 insertions(+), 222 deletions(-) diff --git a/README.md b/README.md index 8da6594..2e4fbd4 100644 --- a/README.md +++ b/README.md @@ -1022,7 +1022,7 @@ host (`ss`), which catches services listening on localhost only — a scan from elsewhere can't see those, so they'd otherwise look free. Re-run the agent install one-liner on a host to pick that up. -**Port presets** (Network → Ports). A preset is a named list of ports written once — *Remote access* (SSH, RDP, VNC, WinRM), *Databases* (MySQL, PostgreSQL, Redis, MongoDB …), *Web*, *File sharing*, *Homelab tools* come ready-made, and are ordinary presets you can change or delete. Add your own by typing one port to a line (`3389 RDP`, `53/udp DNS`). A preset does three things: it **names ports** — a port in any preset shows its name (3389 → RDP) on every server's Ports card, in the agent table and in the new-port alert ("a new port is listening — 3389/tcp RDP"), without a label typed for each host, and a name you write yourself always wins; it **checks hosts** — pick any number of servers and see in one table which of the preset's TCP ports are open on each, from a scan from the app (private addresses only, at the server's first known address; what it finds is remembered like any scan); and it **names the open ports on all of them** in one go, keeping names somebody already wrote unless you say to replace them. Note that a port with a name counts as noted, so writing names also quiets the new-port alert for those ports. A scan only looks at TCP; a UDP port in a preset is only given its name. Operators change presets; everyone sees them. +**Port presets** (Network → Ports → the *Presets* tab). A preset is a named list of ports written once — *Remote access* (SSH, RDP, VNC, WinRM), *Databases* (MySQL, PostgreSQL, Redis, MongoDB …), *Web*, *File sharing*, *Homelab tools* come ready-made, and are ordinary presets you can change or delete. Add your own by typing one port to a line (`3389 RDP`, `53/udp DNS`). A preset does three things: it **names ports** — a port in any preset shows its name (3389 → RDP) on every server's Ports card, in the agent table and in the new-port alert ("a new port is listening — 3389/tcp RDP"), without a label typed for each host, and a name you write yourself always wins; it **checks hosts** — pick any number of servers and see in one table which of the preset's TCP ports are open on each, from a scan from the app (private addresses only, at the server's first known address; what it finds is remembered like any scan); and it **names the open ports on all of them** in one go, keeping names somebody already wrote unless you say to replace them. Note that a port with a name counts as noted, so writing names also quiets the new-port alert for those ports. A scan only looks at TCP; a UDP port in a preset is only given its name. Operators change presets; everyone sees them. **Network → Ports** is the cross-server counterpart: one page listing every port every agent currently reports as listening, across all servers at once diff --git a/ROLES.md b/ROLES.md index 94add1a..adaf919 100644 --- a/ROLES.md +++ b/ROLES.md @@ -115,7 +115,7 @@ even further, to admin only: admin-only (applying an existing tag to a server needs operator). - **Ports**: everyone can see both the agent-reported and manual tables; adding, editing, or deleting a manual port opening needs operator. -- **Port presets** (Network → Ports): everyone can see them and the names they give ports; creating, changing and removing one, scanning hosts for one and writing its names onto many hosts' ports need operator. +- **Port presets** (Network → Ports → Presets tab): everyone can see them and the names they give ports; creating, changing and removing one, scanning hosts for one and writing its names onto many hosts' ports need operator. - **Admin Links**: everyone can see and open every server's admin bookmarks, from that server's own page or the summary page; adding, editing, or removing one needs operator, from either place. diff --git a/web/src/components/ServerPorts.tsx b/web/src/components/ServerPorts.tsx index 12a834a..08f6783 100644 --- a/web/src/components/ServerPorts.tsx +++ b/web/src/components/ServerPorts.tsx @@ -491,7 +491,7 @@ export default function ServerPorts({ - {p.label ?? (p.service ? {p.service} : —)} + {p.label ?? (p.service ? {p.service} : —)} {p.agent?.process &&
{p.agent.process}
} {p.comment ?? "—"} diff --git a/web/src/pages/Ports.tsx b/web/src/pages/Ports.tsx index 0f149c7..0963fbe 100644 --- a/web/src/pages/Ports.tsx +++ b/web/src/pages/Ports.tsx @@ -1,7 +1,7 @@ import { removeWithUndo } from "../utils/undoable"; import { useEffect, useState, type FormEvent } from "react"; import TimeAgo from "../components/TimeAgo"; -import { Link } from "react-router-dom"; +import { Link, useSearchParams } from "react-router-dom"; import { api, type AgentPortRow, @@ -18,6 +18,7 @@ import { downloadCsv } from "../utils/csv"; import { formatAgo } from "../utils/duration"; import { ErrorNotice } from "../components/Notice"; import PortPresets from "../components/PortPresets"; +import ViewTabs from "../components/ViewTabs"; import { EmptyRow, LoadingRow } from "../components/EmptyState"; const emptyForm: PortForwardInput = { @@ -33,6 +34,8 @@ const emptyForm: PortForwardInput = { export default function Ports({ user }: { user: CurrentUser }) { const canEdit = user.role === "admin" || user.role === "operator"; + const [params] = useSearchParams(); + const view = params.get("view") === "presets" ? "presets" : "ports"; const [agentPorts, setAgentPorts] = useState(null); const [reportingServers, setReportingServers] = useState(0); @@ -186,251 +189,263 @@ export default function Ports({ user }: { user: CurrentUser }) { <>

Ports

- + + + {view === "presets" && } + + {view === "ports" && ( + <> +
+
+
+
+

Ports reported by agents

+
+ + {reportingServers} of {totalServers} server{totalServers !== 1 ? "s" : ""} reporting + + + +
+
+ +
+ + + + label="Server" sortKeyName="serverName" activeKey={agentSortKey} direction={agentSortDir} onSort={requestAgentSort} /> + label="Protocol" sortKeyName="protocol" activeKey={agentSortKey} direction={agentSortDir} onSort={requestAgentSort} /> + label="Port" sortKeyName="port" activeKey={agentSortKey} direction={agentSortDir} onSort={requestAgentSort} /> + + + + label="Last report" sortKeyName="lastSeenAt" activeKey={agentSortKey} direction={agentSortDir} onSort={requestAgentSort} /> + + + + {(agentPageItems ?? []).map((p) => ( + + + + + + + + + + ))} + {agentPorts === null && } + {agentPorts !== null && agentPorts.length === 0 && ( + + )} + +
ServiceAddressProcess
+ {p.serverName} + {p.serverHostname &&
{p.serverHostname}
} +
{p.protocol}{p.port}{p.service ?? "—"} + {p.addresses.join(", ")} + {p.localOnly && local only} + {p.process ?? "—"}
+
+ +
+
+
+ + {canEdit && showForm && ( +
+
+

{editing ? `Edit "${editing.label}"` : "Add a manual port opening"}

+
+
+
+
+ + setForm({ ...form, label: e.target.value })} + /> +
+
+ + setForm({ ...form, externalPort: Number(e.target.value) })} + /> +
+
+ + +
+
+ + setForm({ ...form, internalPort: e.target.value ? Number(e.target.value) : null })} + /> +
+
+ + +
+
+ + setForm({ ...form, destination: e.target.value })} + /> +
+
+ + setForm({ ...form, source: e.target.value })} + /> +
+
+ + setForm({ ...form, comment: e.target.value })} + /> +
+
+
+ + +
+
+
+ )} -
-
-

Ports reported by agents

+

Manual port openings

+

+ Router port forwards, edge firewall rules, cloud security groups — anything opened further out on the + network that this app can't see on its own. +

- - {reportingServers} of {totalServers} server{totalServers !== 1 ? "s" : ""} reporting - - + )} + -
- +
- label="Server" sortKeyName="serverName" activeKey={agentSortKey} direction={agentSortDir} onSort={requestAgentSort} /> - label="Protocol" sortKeyName="protocol" activeKey={agentSortKey} direction={agentSortDir} onSort={requestAgentSort} /> - label="Port" sortKeyName="port" activeKey={agentSortKey} direction={agentSortDir} onSort={requestAgentSort} /> - - - - label="Last report" sortKeyName="lastSeenAt" activeKey={agentSortKey} direction={agentSortDir} onSort={requestAgentSort} /> + label="Label" sortKeyName="label" activeKey={forwardSortKey} direction={forwardSortDir} onSort={requestForwardSort} /> + + label="External port" + sortKeyName="externalPort" + activeKey={forwardSortKey} + direction={forwardSortDir} + onSort={requestForwardSort} + /> + + label="Source" sortKeyName="source" activeKey={forwardSortKey} direction={forwardSortDir} onSort={requestForwardSort} /> + + {canEdit && } - {(agentPageItems ?? []).map((p) => ( - + {(sortedForwards ?? []).map((f) => ( + + - - - - - + + + {canEdit && ( + + )} ))} - {agentPorts === null && } - {agentPorts !== null && agentPorts.length === 0 && ( - + {forwards === null && } + {forwards !== null && forwards.length === 0 && ( + )}
ServiceAddressProcessDestinationCommentActions
{f.label} - {p.serverName} - {p.serverHostname &&
{p.serverHostname}
} + {f.protocol} + {f.externalPort} + {f.internalPort && f.internalPort !== f.externalPort && ( + → {f.internalPort} + )}
{p.protocol}{p.port}{p.service ?? "—"} - {p.addresses.join(", ")} - {p.localOnly && local only} + {f.serverId ? {f.serverName} : f.destination || "—"} + {f.serverId && f.destination &&
{f.destination}
}
{p.process ?? "—"}{f.source ?? "—"}{f.comment ?? "—"} +
+ + +
+
-
-
-
- - {canEdit && showForm && ( -
-
-

{editing ? `Edit "${editing.label}"` : "Add a manual port opening"}

-
-
-
-
- - setForm({ ...form, label: e.target.value })} - /> -
-
- - setForm({ ...form, externalPort: Number(e.target.value) })} - /> -
-
- - -
-
- - setForm({ ...form, internalPort: e.target.value ? Number(e.target.value) : null })} - /> -
-
- - -
-
- - setForm({ ...form, destination: e.target.value })} - /> -
-
- - setForm({ ...form, source: e.target.value })} - /> -
-
- - setForm({ ...form, comment: e.target.value })} - /> -
-
-
- - -
-
-
+ )} - -
-
-

Manual port openings

-

- Router port forwards, edge firewall rules, cloud security groups — anything opened further out on the - network that this app can't see on its own. -

-
- {canEdit && !showForm && ( - - )} - -
-
- -
- - - - label="Label" sortKeyName="label" activeKey={forwardSortKey} direction={forwardSortDir} onSort={requestForwardSort} /> - - label="External port" - sortKeyName="externalPort" - activeKey={forwardSortKey} - direction={forwardSortDir} - onSort={requestForwardSort} - /> - - label="Source" sortKeyName="source" activeKey={forwardSortKey} direction={forwardSortDir} onSort={requestForwardSort} /> - - {canEdit && } - - - - {(sortedForwards ?? []).map((f) => ( - - - - - - - {canEdit && ( - - )} - - ))} - {forwards === null && } - {forwards !== null && forwards.length === 0 && ( - - )} - -
DestinationCommentActions
{f.label} - {f.protocol} - {f.externalPort} - {f.internalPort && f.internalPort !== f.externalPort && ( - → {f.internalPort} - )} - - {f.serverId ? {f.serverName} : f.destination || "—"} - {f.serverId && f.destination &&
{f.destination}
} -
{f.source ?? "—"}{f.comment ?? "—"} -
- - -
-
-
-
); }