device

package
v0.27.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 25, 2026 License: CC0-1.0 Imports: 7 Imported by: 0

Documentation

Overview

Package device resolves the stable per-machine identity prosa uses for the sessions.device_id column and the future server-side device row. The id is hex(sha256(hostname + machineID))[:16] so it survives hostname renames as long as the machine-id stays put, and survives machine-id changes (rare) as long as the hostname stays put.

macOS: machineID = IOPlatformUUID parsed from `ioreg -rd1 -c IOPlatformExpertDevice`. Linux: machineID = /etc/machine-id (or /var/lib/dbus/machine-id fallback). Other: empty machineID; hostname alone still produces a stable id.

All public funcs return cached values after the first call so repeated importer invocations on the same process pay the cost once.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fingerprint

func Fingerprint(hostname, machineID string) string

Fingerprint computes hex(sha256(hostname + machineID))[:16]. Exposed so tests can reproduce the ID without going through the resolver.

func FriendlyName

func FriendlyName() string

FriendlyName today is just the hostname; INTENT.md §6 promises a `prosa devices rename` flow in a later cut that overrides this.

func Hostname

func Hostname() string

Hostname returns the machine hostname, with macOS' "<host>.local" suffix stripped for friendliness. Cached.

func IDOnce

func IDOnce() string

IDOnce returns the cached fingerprint, computing it on the first call. Errors during machineID resolution are swallowed — the id always falls back to a hash of just the hostname so importers never block on missing platform plumbing.

func MachineID

func MachineID() string

MachineID returns the raw machineID string used in the hash, or "" if the platform reader failed. Surfaced for debugging via `prosa devices`.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL