Documentation
¶
Overview ¶
Package endpoint reads and writes the protected local-TCP API discovery document. The TCP listener is opt-in; the default Unix socket never writes this file. The document is written only by a daemon that holds the data directory lock, is atomically replaced, and carries a per-run bearer token plus the pinned self-signed certificate for that run.
Index ¶
Constants ¶
const ( // Version is the only accepted discovery document version. Version = 1 // NetworkTCP is the only accepted transport. NetworkTCP = "tcp" )
Variables ¶
This section is empty.
Functions ¶
func Remove ¶
Remove deletes a stale/current discovery file. A missing file is not an error. It never follows a symlink.
func Supported ¶
func Supported() error
Supported reports whether this platform can protect the endpoint secret with a verifiable owner-only ACL. The TCP transport is explicitly unsupported where that check is unavailable; the default Unix socket stays untouched.
func WriteAtomic ¶
WriteAtomic writes a validated document to the endpoint path, using a same-directory temporary file and an atomic publish. The caller must hold the existing data-directory lock (the daemon does via identity.Open).
writeProtectedFile owns the platform-specific creation policy: on Unix the temporary and final files are 0600; on Windows the temporary file is created with a protected DACL containing only the current user SID, verified through the same handle that is later renamed, and no unprotected byte ever contains the token.
Types ¶
type Document ¶
type Document struct {
Version int `json:"version"`
Network string `json:"network"`
Address string `json:"address"`
Token string `json:"token"`
CertPEM string `json:"cert_pem"`
CertSHA256 string `json:"cert_sha256"`
PID int `json:"pid"`
StartedAtUnixMS int64 `json:"started_at_unix_ms"`
}
Document is the atomic discovery record for one daemon run. Token is a secret; callers must keep it host-side and out of renderer output and logs.
func Read ¶
Read is ReadIfPresent with a stale/missing error suitable for a client that explicitly expects the TCP endpoint.
func ReadIfPresent ¶
ReadIfPresent reads and validates the endpoint when it exists. A missing file is not an error. A stale or malformed file is an error so callers fail closed instead of silently falling back to the Unix socket.
The platform-specific readProtectedFile implementation must validate the object it actually reads. On Windows that means one opened handle used for the type/owner/DACL checks and the bytes, never a path reopen.