Expand description
The admin socket (kernel spec §4.2): <data>/admin.sock, a Unix socket
only the collector’s own user may use, for hennery admin … recovery
commands that work without a browser or a session: print the setup link,
reset the password or public_url, list the hosts, mint a pairing code.
- Who may connect: the socket is 0600, and a peer whose user id is
not the collector’s is dropped without an answer. The client refuses,
in turn, a socket served by another user. Any process of the
collector’s own user is the operator here, agents of the all-in-one
install included (kernel spec §10): it can reset the password or
public_urland mint pairing codes. The CLI’s confirmation on a terminal stops accidents, not a process that speaks this protocol. - The protocol: one JSON
AdminRequeston one line, at mostMAX_REQUEST_BYTES, withinREQUEST_TIMEOUT; one JSONAdminResponseon one line back; then the connection closes. - One collector per data directory: binding refuses a socket that
still answers, replaces one that refuses the connection (a collector
that was killed), and stops at any other error. The socket is removed
when its
AdminSocketis dropped.
Structs§
- Admin
- What the admin commands act on: the router’s own
OperatorandHosts, never a second instance, since the cachedpublic_urland the setup token live in that one. - Admin
Host - One paired host, as
list_hostsshows it. Times are seconds since the Unix epoch. - Admin
Socket - A bound admin socket. Dropping it removes the socket file, however the collector stops.
Enums§
Constants§
- ADMIN_
SOCKET - The socket’s name in the collector’s data directory (kernel spec §1).
- CLIENT_
TIMEOUT - How long the client waits for the whole exchange: connecting, sending
the request and reading the answer. The slowest command is a password
reset, one Argon2 hash on a blocking thread: about 0.1 s, measured in a
debug build (where
argon2is built optimised), run at mostMAX_CONCURRENT_HASHESat a time with the logins’. Only a login flood queued ahead of it (rate limited per address, not in total) could take it past this; the client then says the outcome is unknown. - MAX_
REQUEST_ BYTES - The longest request line read, newline included.
- REQUEST_
TIMEOUT - A connection that has not sent its whole request by then, or not taken its whole answer, is dropped.
Functions§
- bind
- Bind
dir/admin.sock, mode 0600.Ok(None), with a warning, when that path is too long for a Unix socket: the collector then runs without it. Refused when the socket there still answers: another collector serves this data directory. One that refuses the connection is replaced; any other error (not a socket, not ours to connect to) stops the start and is named. - max_
socket_ path_ bytes - The longest path a Unix socket can be bound or reached at, in bytes:
sun_pathless its terminating NUL (103 on macOS, 107 on Linux). - probe
- Check, sending nothing, that a collector of this user’s serves
socket: what a command that prompts does first, so that nothing is typed into a dead end. The connection is closed unused. Bounded bytimeout, likerequest_within. - read_
answer - One
AdminResponseline fromstream, at mostMAX_RESPONSE_BYTES. - request
- The client’s side: send
requestto the collector atsocketand read its answer, withinCLIENT_TIMEOUT. - request_
within request, bounded bytimeout. The answer is read one line, not to the end of the stream: a collector that closes with part of a request unread resets the connection on Linux, after its answer.- serve
- Answer admin commands until
shutdownresolves, then remove the socket (by dropping it). - socket_
path_ too_ long - Whether
pathis too long for a Unix socket: the collector then runs without its admin socket, and the client says so rather than failing to connect (3b-ii’s O7).