Files
origin_client/go/machineid_linux.go
T
warkanumandClaude Sonnet 5 2590e404f5
CI / rust (push) Successful in 3m6s
CI / go (push) Successful in 33s
CI / js (push) Successful in 34s
feat: initial Go/JS/Rust Origin check-in client SDKs
Standalone clients that resolve a machine unique ID (OS machine ID first,
falling back to a generated UUID persisted to disk), detect hostname/IP/
container/orchestrator, and register+re-ping origin.warky.dev's public
service-checkin endpoint on a daily interval. Ported from icy2's internal
origincheckin package but extended to the full check-in contract and made
dependency-light for external reuse.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-01 15:25:30 +02:00

25 lines
580 B
Go

//go:build linux
package originclient
import (
"os"
"strings"
)
// machineID reads the systemd/dbus machine ID, which is stable across
// reboots and unique per Linux install (but not per container, since it is
// typically inherited from the image unless explicitly reset).
func machineID() (string, error) {
for _, path := range []string{"/etc/machine-id", "/var/lib/dbus/machine-id"} {
data, err := os.ReadFile(path)
if err != nil {
continue
}
if id := strings.TrimSpace(string(data)); id != "" {
return id, nil
}
}
return "", errMachineIDUnavailable
}