fix(darwin): use scutil for provisioning hostname (#485)

macOS Sequoia with Private Wi-Fi Address enabled causes os.Hostname()
to return generic names like "Mac.lan" from DHCP instead of the real
computer name. The /utility provisioning endpoint sends this raw,
resulting in devices named "Mac-lan" in the dashboard.

Fallback chain: ComputerName → LocalHostName → os.Hostname()

LocalHostName can also be affected by DHCP. ComputerName is the
user-set display name from System Settings, fully immune to network state.
This commit is contained in:
Codescribe
2026-04-30 19:19:19 +07:00
committed by Cuong Manh Le
parent 878b3d7920
commit f1e49a7ee6
3 changed files with 37 additions and 2 deletions
+1 -2
View File
@@ -10,7 +10,6 @@ import (
"io"
"net"
"net/http"
"os"
"runtime"
"strings"
"time"
@@ -127,7 +126,7 @@ func FetchResolverUID(ctx context.Context, req *UtilityOrgRequest, version strin
hostname := req.Hostname
if req.Hostname == "" {
hostname, _ = os.Hostname()
hostname, _ = preferredHostname()
ctrld.Log(ctx, logger.Debug(), "Using system hostname: %s", hostname)
req.Hostname = hostname
} else {