mirror of
https://github.com/hansjone/netxops.git
synced 2026-10-09 05:10:45 +08:00
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:
parent
a4993b2407
commit
e6f9d062ed
2 changed files with 21 additions and 2 deletions
10
lib/index.js
10
lib/index.js
|
|
@ -222,7 +222,15 @@ function startAlarmPushClient(options) {
|
|||
}
|
||||
socket.addEventListener("open", () => {
|
||||
setPhase("authenticating", wsUrl, { detail: "auth" });
|
||||
socket?.send(JSON.stringify({ type: "auth", token }));
|
||||
let clientLabel = "netxops";
|
||||
try {
|
||||
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 {}
|
||||
socket?.send(JSON.stringify({ type: "auth", token, client: clientLabel }));
|
||||
});
|
||||
socket.addEventListener("message", (event) => {
|
||||
let msg;
|
||||
|
|
|
|||
|
|
@ -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) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue