Identify alarm-push clients to NetX with hostname labels.

Send client=netxops@host on hub auth so NetX can distinguish multiple DSH subscribers.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
oliver 2026-09-10 16:57:42 +08:00
parent a4993b2407
commit e6f9d062ed
2 changed files with 21 additions and 2 deletions

View file

@ -173,7 +173,18 @@ export function startAlarmPushClient(options: AlarmPushClientOptions): () => voi
socket.addEventListener('open', () => {
setPhase('authenticating', wsUrl, { detail: 'auth' })
socket?.send(JSON.stringify({ type: 'auth', token }))
let clientLabel = 'netxops'
try {
// Node / Bun hosts: include hostname so NetX hub can list multi-DSH links.
const env = typeof process !== 'undefined' ? process.env : undefined
const hostname = env?.HOSTNAME || env?.COMPUTERNAME
if (typeof hostname === 'string' && hostname.trim()) {
clientLabel = `netxops@${hostname.trim()}`
}
} catch {
// browser / restricted runtime — keep generic label
}
socket?.send(JSON.stringify({ type: 'auth', token, client: clientLabel }))
})
socket.addEventListener('message', (event) => {