Name ports after the Docker containers that publish them
The health pass keeps the host ports Dockhand says running containers
publish (new table server_container_ports, migration 0080), matched to a
server by its Docker host's name. They name the port on the server's Ports
card and the network Ports table, ahead of a port preset and behind a
label somebody wrote, and in the new-port alert ("8096/tcp jellyfin
(container)"). Never written onto port notes, so a container's port is
still a new port; an unreadable host keeps its names, a day-old name is
dropped. Dockhand is now read on the health pass even with container
alerts off.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
75f060049f
commit
9ca83994fb
18 files changed
+9026
-29
No files matched your search
@@ -7,6 +7,7 @@ import { requireAuth, requireRole } from "../auth/middleware.js";
|
||||
import { recordAudit } from "../services/audit.js";
|
||||
import { type AgentPort, groupAgentPorts, parseJson, splitPortKey } from "../services/agentPorts.js";
|
||||
import { listPresets, serviceName, serviceNames } from "../services/portPresets.js";
|
||||
import { containerPortName, containerPortNames, type ContainerPortName } from "../services/containerPorts.js";
|
||||
import { asyncHandler } from "../utils/asyncHandler.js";
|
||||
|
||||
export const portsRouter = Router();
|
||||
@@ -26,6 +27,8 @@ export interface AgentPortRow {
|
||||
localOnly: boolean;
|
||||
/** What a port preset calls it ("RDP"), when one does. */
|
||||
service: string | null;
|
||||
/** The container that publishes it, as Dockhand says, when one does. */
|
||||
container: ContainerPortName | null;
|
||||
lastSeenAt: string | null;
|
||||
}
|
||||
|
||||
@@ -35,6 +38,7 @@ portsRouter.get("/agent", asyncHandler(async (_req, res) => {
|
||||
.from(servers);
|
||||
|
||||
const names = serviceNames(await listPresets());
|
||||
const containers = await containerPortNames();
|
||||
const out: AgentPortRow[] = [];
|
||||
for (const s of rows) {
|
||||
const raw = parseJson<AgentPort[] | null>(s.listeningPorts, null);
|
||||
@@ -51,6 +55,7 @@ portsRouter.get("/agent", asyncHandler(async (_req, res) => {
|
||||
process: grouped.process,
|
||||
localOnly: grouped.localOnly,
|
||||
service: serviceName(names, protocol, port),
|
||||
container: containerPortName(containers, s.id, protocol, port),
|
||||
lastSeenAt: s.lastSeenAt,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import { recordAudit } from "../services/audit.js";
|
||||
import { beginScan, endScan, MAX_SCAN_SPAN, resolveScanTarget, scanPorts, toRanges } from "../services/portScan.js";
|
||||
import { type AgentPort, groupAgentPorts, parseJson } from "../services/agentPorts.js";
|
||||
import { listPresets, serviceName, serviceNames } from "../services/portPresets.js";
|
||||
import { containerPortName, containerPortNames, type ContainerPortName } from "../services/containerPorts.js";
|
||||
import { recordPortScan } from "../services/portScanRecord.js";
|
||||
import { newListeningPorts, parseBaseline, portKey } from "../services/newPorts.js";
|
||||
import { getSettings } from "../services/settingsStore.js";
|
||||
@@ -36,6 +37,8 @@ export interface PortEntry {
|
||||
comment: string | null;
|
||||
/** What a port preset calls this port ("RDP"), when one does; shown where there is no label of its own. */
|
||||
service: string | null;
|
||||
/** The container that publishes it, as Dockhand says ("jellyfin"), when one does; shown where there is no label of its own, ahead of the preset's name. */
|
||||
container: ContainerPortName | null;
|
||||
/** The last scan from this app connected to it. */
|
||||
scanOpen: boolean;
|
||||
lastSeenOpenAt: string | null;
|
||||
@@ -60,6 +63,7 @@ async function buildPortList(serverId: number) {
|
||||
const fresh = new Set(alerting ? newListeningPorts(agentRaw, parseBaseline(server.portBaseline), expected).map((p) => portKey(p.protocol, p.port)) : []);
|
||||
|
||||
const names = serviceNames(await listPresets());
|
||||
const containers = await containerPortNames(serverId);
|
||||
const entries = new Map<string, PortEntry>();
|
||||
for (const row of rows) {
|
||||
const key = `${row.protocol}:${row.port}`;
|
||||
@@ -70,6 +74,7 @@ async function buildPortList(serverId: number) {
|
||||
label: row.label,
|
||||
comment: row.comment,
|
||||
service: serviceName(names, row.protocol, row.port),
|
||||
container: containerPortName(containers, serverId, row.protocol, row.port),
|
||||
scanOpen: row.open,
|
||||
lastSeenOpenAt: row.lastSeenOpenAt,
|
||||
agent: agent.get(key) ?? null,
|
||||
@@ -87,6 +92,7 @@ async function buildPortList(serverId: number) {
|
||||
label: null,
|
||||
comment: null,
|
||||
service: serviceName(names, protocol, Number(port)),
|
||||
container: containerPortName(containers, serverId, protocol, Number(port)),
|
||||
scanOpen: false,
|
||||
lastSeenOpenAt: null,
|
||||
agent: info,
|
||||
|
||||
Reference in new issue
Block a user