mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-08-10 13:20:33 +02:00
fix: include hostname hints in metadata for API-side fallback
Send all available hostname sources (ComputerName, LocalHostName, HostName, os.Hostname) in the metadata map when provisioning. This allows the API to detect and repair generic hostnames like 'Mac' by picking the best available source server-side. Belt and suspenders: preferredHostname() picks the right one client-side, but metadata gives the API a second chance.
This commit is contained in:
@@ -133,6 +133,15 @@ func FetchResolverUID(ctx context.Context, req *UtilityOrgRequest, version strin
|
||||
ctrld.Log(ctx, logger.Debug(), "Using provided hostname: %s", hostname)
|
||||
}
|
||||
|
||||
// Include all hostname sources in metadata so the API can pick the
|
||||
// best one if the primary looks generic (e.g., "Mac", "Mac.lan").
|
||||
if req.Metadata == nil {
|
||||
req.Metadata = make(map[string]string)
|
||||
}
|
||||
for k, v := range hostnameHints() {
|
||||
req.Metadata["hostname_"+k] = v
|
||||
}
|
||||
|
||||
ctrld.Log(ctx, logger.Debug(), "Sending UID request to ControlD API")
|
||||
body, _ := json.Marshal(req)
|
||||
return postUtilityAPI(ctx, version, cdDev, false, bytes.NewReader(body))
|
||||
|
||||
Reference in New Issue
Block a user