From c19b29bb877525a494b3dcab9fe89c8344b372ed Mon Sep 17 00:00:00 2001 From: John Coffey Date: Thu, 19 Nov 2026 10:17:56 -0700 Subject: [PATCH 1/2] Dashboard: listeners a node couldn't open (inbuxa-server#485) Each x:ClusterNode now says which of its listeners it couldn't open. The attention rail shows them as one critical item, "N listeners not open", naming the node, the listener, its address and why, and linking to the cluster page. It shows on a single server too, where the cluster card doesn't. The node fetch no longer names the properties it wants: naming unboundListeners would fail against a server without it, and the cluster card would go with it. Test: unboundOf (inactive leases left out, single server included) and the attention item. --- src/features/dashboard/attention.test.ts | 27 ++++++++++++++ src/features/dashboard/attention.ts | 21 ++++++++++- src/features/dashboard/clusterHealth.test.ts | 15 +++++++- src/features/dashboard/clusterHealth.ts | 37 +++++++++++++++++-- .../dashboard/components/DashboardShell.tsx | 3 +- src/i18n/en.json | 4 +- 6 files changed, 99 insertions(+), 8 deletions(-) diff --git a/src/features/dashboard/attention.test.ts b/src/features/dashboard/attention.test.ts index 90d6ded..0a00456 100644 --- a/src/features/dashboard/attention.test.ts +++ b/src/features/dashboard/attention.test.ts @@ -90,3 +90,30 @@ describe('buildAttention: report warnings (#218)', () => { expect(items[0]).toMatchObject({ id: 'tlsReports', count: 1, title: 'TLS report with warnings' }); }); }); + +describe('buildAttention: listeners not open (inbuxa-server#485)', () => { + it('counts every listener a node could not open and says which', () => { + const items = buildAttention({ + ...quiet, + unbound: [ + { hostname: 'mx1', listeners: ['imaps [::]:993: Failed to bind to [::]:993: Address in use'] }, + { hostname: 'mx2', listeners: ['pop3s [::]:995: x', 'sieve [::]:4190: y'] }, + ], + nodesHref: '/Management/Dashboard/cluster', + }); + expect(items).toHaveLength(1); + expect(items[0]).toMatchObject({ + id: 'listeners', + severity: 'crit', + count: 3, + title: 'listeners not open', + href: '/Management/Dashboard/cluster', + }); + expect(items[0].detail).toContain('mx1: imaps [::]:993'); + expect(items[0].detail).toContain('mx2: pop3s [::]:995: x; sieve [::]:4190: y'); + }); + + it('says nothing when every listener is open', () => { + expect(buildAttention({ ...quiet, unbound: [] })).toEqual([]); + }); +}); diff --git a/src/features/dashboard/attention.ts b/src/features/dashboard/attention.ts index 156091d..5f13cde 100644 --- a/src/features/dashboard/attention.ts +++ b/src/features/dashboard/attention.ts @@ -22,11 +22,12 @@ import { ServerCrash, ShieldAlert, Timer, + Unplug, } from 'lucide-react'; import { LEGACY_PROTOCOLS_VIEW } from '@/features/hardening/LegacyProtocolsBanner'; import type { Metric } from './types/metrics'; import type { ServerFacts } from './serverFacts'; -import type { ClusterHealth } from './clusterHealth'; +import type { ClusterHealth, UnboundNode } from './clusterHealth'; import type { Attention } from './components/AttentionRail'; import { DMARC_WARNINGS, LATENCIES, TLS_WARNINGS, mean, nearQuota, total, zoneOf } from './commandCenter'; @@ -38,6 +39,8 @@ export interface AttentionInput { may: (view: string) => boolean; facts: ServerFacts | null; health: ClusterHealth | null; + /** inbuxa: nodes with listeners they couldn't open (inbuxa-server#485). */ + unbound?: UnboundNode[]; critical: number | null; /** inbuxa: blocklist and reverse-DNS failures on Domains › Deliverability (DL-18). */ deliverability?: number | null; @@ -58,6 +61,7 @@ export function buildAttention({ may, facts, health, + unbound = [], critical, deliverability, deliverabilityHref, @@ -128,6 +132,21 @@ export function buildAttention({ detail: health.silent.map((n) => n.hostname).join(', '), href: nodesHref, }); + const closed = unbound.reduce((s, n) => s + n.listeners.length, 0); + if (closed) + attention.push({ + id: 'listeners', + severity: 'crit', + icon: Unplug, + count: closed, + title: t('cc.a.listeners', { + count: closed, + defaultValue_one: 'listener not open', + defaultValue_other: 'listeners not open', + }), + detail: unbound.map((n) => `${n.hostname}: ${n.listeners.join('; ')}`).join(' · '), + href: nodesHref, + }); if (bounced && may(QUEUE)) attention.push({ id: 'bounced', diff --git a/src/features/dashboard/clusterHealth.test.ts b/src/features/dashboard/clusterHealth.test.ts index 67d0f5d..c08b741 100644 --- a/src/features/dashboard/clusterHealth.test.ts +++ b/src/features/dashboard/clusterHealth.test.ts @@ -5,12 +5,13 @@ */ import { describe, expect, it } from 'vitest'; -import { minutesSilent, summarizeNodes, type ClusterNodeRow } from './clusterHealth'; +import { minutesSilent, summarizeNodes, unboundOf, type ClusterNodeRow } from './clusterHealth'; const node = (hostname: string, status: ClusterNodeRow['status'], lastRenewal = '2026-09-25T10:00:00Z') => ({ hostname, status, lastRenewal, + unboundListeners: [] as string[], }); describe('summarizeNodes', () => { @@ -60,3 +61,15 @@ describe('minutesSilent', () => { expect(minutesSilent('', now)).toBeNull(); }); }); + +describe('unboundOf (inbuxa-server#485)', () => { + it('lists nodes with listeners not open, a single server included, but not old leases', () => { + const nodes = [ + { ...node('mx1', 'active'), unboundListeners: ['imaps [::]:993: in use'] }, + node('mx2', 'active'), + { ...node('old', 'inactive'), unboundListeners: ['smtp [::]:25: gone'] }, + ]; + expect(unboundOf(nodes)).toEqual([{ hostname: 'mx1', listeners: ['imaps [::]:993: in use'] }]); + expect(unboundOf([nodes[0]])).toHaveLength(1); + }); +}); diff --git a/src/features/dashboard/clusterHealth.ts b/src/features/dashboard/clusterHealth.ts index 54f4bf3..01762ff 100644 --- a/src/features/dashboard/clusterHealth.ts +++ b/src/features/dashboard/clusterHealth.ts @@ -14,6 +14,9 @@ * A server counts as a cluster when more than one node holds a lease. On a * single server, or when the viewer can't list nodes, there's nothing here * and the dashboard keeps its Server Memory card. + * + * inbuxa: each node also says which of its listeners it couldn't open + * (inbuxa-server#485), which matters on a single server too. */ import { useCallback, useEffect, useState } from 'react'; import { getAccountId, jmapRequest } from '@/services/jmap/client'; @@ -26,6 +29,21 @@ export interface ClusterNodeRow { status: NodeStatus; /** When the node last renewed its lease. */ lastRenewal: string; + /** Listeners the node couldn't open, as "id address: reason" (#485). */ + unboundListeners: string[]; +} + +/** A node with listeners that aren't open. */ +export interface UnboundNode { + hostname: string; + listeners: string[]; +} + +/** Nodes still in the cluster that couldn't open a listener; old leases are left out. */ +export function unboundOf(nodes: ClusterNodeRow[]): UnboundNode[] { + return nodes + .filter((n) => n.status !== 'inactive' && n.unboundListeners.length > 0) + .map(({ hostname, unboundListeners }) => ({ hostname, listeners: unboundListeners })); } export interface ClusterHealth { @@ -51,6 +69,12 @@ export function minutesSilent(lastRenewal: string, now: number = Date.now()): nu return Number.isNaN(t) ? null : Math.max(0, Math.floor((now - t) / 60_000)); } +/** A registry set: an array, or an index-keyed map. */ +function listOf(value: unknown): string[] { + if (!value || typeof value !== 'object') return []; + return Object.values(value as Record).map(String); +} + async function fetchNodes(): Promise { let accountId: string; try { @@ -64,8 +88,8 @@ async function fetchNodes(): Promise { 'x:ClusterNode/get', { accountId, + // Every property: naming unboundListeners would fail on a server without it '#ids': { resultOf: 'q', name: 'x:ClusterNode/query', path: '/ids' }, - properties: ['hostname', 'nodeId', 'status', 'lastRenewal'], }, 'g', ], @@ -78,6 +102,7 @@ async function fetchNodes(): Promise { nodeId: n.nodeId === undefined || n.nodeId === null ? undefined : String(n.nodeId), status: String(n.status ?? 'active').toLowerCase() as NodeStatus, lastRenewal: String(n.lastRenewal ?? ''), + unboundListeners: listOf(n.unboundListeners), })); } @@ -91,17 +116,21 @@ export interface ClusterState { /** * The cluster's nodes and their health, refreshed every 30 seconds and - * whenever `tick` moves. undefined until the first answer; null when this - * server isn't one node of several, or the viewer can't list nodes. + * whenever `tick` moves. `cluster` is undefined until the first answer, and + * null when this server isn't one node of several or the viewer can't list + * nodes. `unbound` lists nodes, a single server included, with listeners + * they couldn't open. */ export function useClusterState(tick = 0) { const [state, setState] = useState(undefined); + const [unbound, setUnbound] = useState([]); const refresh = useCallback(() => { fetchNodes() .then((nodes) => { const health = nodes ? summarizeNodes(nodes) : null; setState(nodes && health ? { nodes, health } : null); + setUnbound(nodes ? unboundOf(nodes) : []); }) // A failed refresh keeps the last answer rather than flipping the page back. .catch(() => setState((s) => (s === undefined ? null : s))); @@ -117,5 +146,5 @@ export function useClusterState(tick = 0) { }; }, [refresh, tick]); - return state; + return { cluster: state, unbound }; } diff --git a/src/features/dashboard/components/DashboardShell.tsx b/src/features/dashboard/components/DashboardShell.tsx index 6275fde..595bc0a 100644 --- a/src/features/dashboard/components/DashboardShell.tsx +++ b/src/features/dashboard/components/DashboardShell.tsx @@ -61,7 +61,7 @@ export function DashboardShell({ const liveStatus = useLiveMetricsStore((s) => s.status); const liveSnapshot = useLiveMetricsStore((s) => s.snapshot); const facts = useServerFacts(tick).facts; - const cluster = useClusterState(tick); + const { cluster, unbound } = useClusterState(tick); const critical = useCriticalCount(); // inbuxa: DL-18 const deliverability = useDeliverabilityAlarms(tick); @@ -106,6 +106,7 @@ export function DashboardShell({ may: canViewObject, facts, health, + unbound, critical, deliverability, deliverabilityHref: deliverabilitySection ? `/${deliverabilitySection}/CustomComponent/Deliverability` : null, diff --git a/src/i18n/en.json b/src/i18n/en.json index b2311e3..37804b8 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -1823,7 +1823,9 @@ "dmarcReportsDetail": "Received this period, across all your domains.", "tlsReports_one": "TLS report with warnings", "tlsReports_other": "TLS reports with warnings", - "tlsReportsDetail": "Received this period, across all your domains." + "tlsReportsDetail": "Received this period, across all your domains.", + "listeners_one": "listener not open", + "listeners_other": "listeners not open" }, "attention_one": "Needs attention · {{count}}", "attention_other": "Needs attention · {{count}}", -- 2.54.0 From b677d473ce4a06d9c0eedcd62675c4ddaed9e8a6 Mon Sep 17 00:00:00 2001 From: John Coffey Date: Thu, 19 Nov 2026 10:25:01 -0700 Subject: [PATCH 2/2] Dashboard: read a node's unbound listeners as the set the server sends A registry set arrives as {"": true}, so the listener lines are the keys; reading the values showed "true". Found against a live server holding a port; the test uses the string it sent. --- src/features/dashboard/clusterHealth.test.ts | 15 ++++++++++++++- src/features/dashboard/clusterHealth.ts | 11 +++++++---- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/features/dashboard/clusterHealth.test.ts b/src/features/dashboard/clusterHealth.test.ts index c08b741..d9b1db0 100644 --- a/src/features/dashboard/clusterHealth.test.ts +++ b/src/features/dashboard/clusterHealth.test.ts @@ -5,7 +5,7 @@ */ import { describe, expect, it } from 'vitest'; -import { minutesSilent, summarizeNodes, unboundOf, type ClusterNodeRow } from './clusterHealth'; +import { minutesSilent, setOf, summarizeNodes, unboundOf, type ClusterNodeRow } from './clusterHealth'; const node = (hostname: string, status: ClusterNodeRow['status'], lastRenewal = '2026-09-25T10:00:00Z') => ({ hostname, @@ -73,3 +73,16 @@ describe('unboundOf (inbuxa-server#485)', () => { expect(unboundOf([nodes[0]])).toHaveLength(1); }); }); + +describe('setOf', () => { + it('reads a registry set as the server sends it', () => { + // As a live server answered for a listener held by another process + const wire = { 'imaps [::]:12993: Failed to bind to [::]:12993: Address already in use (os error 98); retrying': true }; + expect(setOf(wire)).toEqual([ + 'imaps [::]:12993: Failed to bind to [::]:12993: Address already in use (os error 98); retrying', + ]); + expect(setOf({})).toEqual([]); + expect(setOf(undefined)).toEqual([]); + expect(setOf(['a', 'b'])).toEqual(['a', 'b']); + }); +}); diff --git a/src/features/dashboard/clusterHealth.ts b/src/features/dashboard/clusterHealth.ts index 01762ff..7a9c087 100644 --- a/src/features/dashboard/clusterHealth.ts +++ b/src/features/dashboard/clusterHealth.ts @@ -69,10 +69,13 @@ export function minutesSilent(lastRenewal: string, now: number = Date.now()): nu return Number.isNaN(t) ? null : Math.max(0, Math.floor((now - t) / 60_000)); } -/** A registry set: an array, or an index-keyed map. */ -function listOf(value: unknown): string[] { +/** A registry set, which arrives as `{"": true}`; an array is read as is. */ +export function setOf(value: unknown): string[] { + if (Array.isArray(value)) return value.map(String); if (!value || typeof value !== 'object') return []; - return Object.values(value as Record).map(String); + return Object.entries(value as Record) + .filter(([, on]) => on === true) + .map(([key]) => key); } async function fetchNodes(): Promise { @@ -102,7 +105,7 @@ async function fetchNodes(): Promise { nodeId: n.nodeId === undefined || n.nodeId === null ? undefined : String(n.nodeId), status: String(n.status ?? 'active').toLowerCase() as NodeStatus, lastRenewal: String(n.lastRenewal ?? ''), - unboundListeners: listOf(n.unboundListeners), + unboundListeners: setOf(n.unboundListeners), })); } -- 2.54.0