Files
paseo/packages/server/src/server/host-name.ts
T
Mohamed Boudra 087cc71c00 fix(server): use macOS ComputerName for host identity (#5922)
* fix(server): advertise macOS ComputerName

macOS may expose UNKNOWN through its kernel hostname when DHCP or reverse DNS does not provide one. Use the user-configured ComputerName for daemon host identity instead.

* test(server): cover macOS Hub host name
2026-10-02 18:27:51 +01:00

15 lines
478 B
TypeScript

import { execFileSync } from "node:child_process";
import { hostname } from "node:os";
let hostName: string | undefined;
// macOS's kernel hostname comes from DHCP/reverse DNS and can be "UNKNOWN";
// ComputerName is the name the user gave the Mac.
export function getHostName(): string {
hostName ??=
process.platform === "darwin"
? execFileSync("/usr/sbin/scutil", ["--get", "ComputerName"], { encoding: "utf8" }).trim()
: hostname();
return hostName;
}