mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-01 14:12:51 +00:00
* 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
15 lines
478 B
TypeScript
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;
|
|
}
|