From cca7b360395e3e7e4ef870005efddc3bd75b86c4 Mon Sep 17 00:00:00 2001 From: henrygd Date: Fri, 3 Oct 2025 13:44:10 -0400 Subject: [PATCH] add SYSTEM_NAME env var (#1184) --- agent/client.go | 1 + internal/common/common-ws.go | 5 +++-- internal/hub/agent_connect.go | 5 ++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/agent/client.go b/agent/client.go index 2f65c758..84bd83d6 100644 --- a/agent/client.go +++ b/agent/client.go @@ -196,6 +196,7 @@ func (client *WebSocketClient) handleAuthChallenge(msg *common.HubRequest[cbor.R } if authRequest.NeedSysInfo { + response.Name, _ = GetEnv("SYSTEM_NAME") response.Hostname = client.agent.systemInfo.Hostname serverAddr := client.agent.connectionManager.serverOptions.Addr _, response.Port, _ = net.SplitHostPort(serverAddr) diff --git a/internal/common/common-ws.go b/internal/common/common-ws.go index b07f3a18..886d42ed 100644 --- a/internal/common/common-ws.go +++ b/internal/common/common-ws.go @@ -38,8 +38,9 @@ type FingerprintRequest struct { type FingerprintResponse struct { Fingerprint string `cbor:"0,keyasint"` // Optional system info for universal token system creation - Hostname string `cbor:"1,keyasint,omitempty,omitzero"` - Port string `cbor:"2,keyasint,omitempty,omitzero"` + Hostname string `cbor:"1,keyasint,omitzero"` + Port string `cbor:"2,keyasint,omitzero"` + Name string `cbor:"3,keyasint,omitzero"` } type DataRequestOptions struct { diff --git a/internal/hub/agent_connect.go b/internal/hub/agent_connect.go index 225d535d..736e2d8d 100644 --- a/internal/hub/agent_connect.go +++ b/internal/hub/agent_connect.go @@ -268,9 +268,12 @@ func (acr *agentConnectRequest) createSystem(agentFingerprint common.Fingerprint if agentFingerprint.Port == "" { agentFingerprint.Port = "45876" } + if agentFingerprint.Name == "" { + agentFingerprint.Name = agentFingerprint.Hostname + } // create new record systemRecord := core.NewRecord(systemsCollection) - systemRecord.Set("name", agentFingerprint.Hostname) + systemRecord.Set("name", agentFingerprint.Name) systemRecord.Set("host", remoteAddr) systemRecord.Set("port", agentFingerprint.Port) systemRecord.Set("users", []string{acr.userId})