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

@ -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;