Files
mesh-catalog/modules/networkmanager/README.md
T
jochen e539cf6e99 networkmanager: the watcher names no node; the bundle fills in its own
The node-engine gives the watcher's process no MESH_NODE, so the watcher refused to
start and crash-looped on g14. It needs none: a kept change holds its event, its
sequence and its body, and the bundle fills its own node into the subject, the message
id <node>.<event>.<sequence> and the body when it publishes, the same at every publish.

Builds: design 08 sign-in-page §11, §12, §20; lead answer L-3 (hq 09c9a3e3)
2026-11-25 14:32:03 +01:00

7.1 KiB

networkmanager

The machine's network, managed by NetworkManager: this module holds the node seat node-uplink (novox/hq ADR 0241), answering its verbs resolvers and links, writes the machine's resolver file from the mesh's resolvers (ADR 0117, ADR 0223), and reacts when the network asks the person to sign in on its sign-in page (ADR 0687, ADR 0689; design 08 sign-in-page §11 to §27).

Two parts and the folder they share

Behind a sign-in page the private network's tunnel, and with it the bus, is out of reach, and the tool runner starts no bundle before it has reached the bus. So the reaction runs in two parts:

  • the watcher, the process networkmanager-sign-in (uplink-tools watch), started by the machine's service manager at boot as the machine's account and kept running, needing no bus. It hears NetworkManager's rating of the network, opens the sign-in page, tells the person, and keeps the events.
  • the bundle uplink-tools, in the tool runner once it has reached the bus: it answers resolvers and links, serves the tools below, publishes the kept events and calls uplink-names.

They share only the module's own folder, ~/.local/state/mesh/networkmanager (the account's, mode 0700), every file written whole (beside, then renamed over):

file what
watch.sock the watcher's socket: one JSON line asked, one answered; state answers its state, rating-again makes it subscribe again and act on the rating read now
check-address NetworkManager's check address, written by the watcher at its start and at each change
pending/ the kept changes, one <sequence>.json each holding the event, its sequence and its body with no node, written by the watcher and deleted by the bundle once the bus acknowledged it
names.json the bundle's last uplink-names call: the names, its result (ok, no holder or the failure) and when
sequence the next sequence of the watcher's kept changes, never reset while the folder lives

The folder's unknown is module: the node-engine does nothing inside it, and the watcher leaves any other path it finds there as it is and writes it to its journal once per path. When the module leaves, the node-engine keeps the folder while it holds files, and nothing reads it then.

The watcher opens the page on its own machine, without the bus

It hears NetworkManager's PropertiesChanged on the system bus for the rating (Connectivity), the active connection and the check (ConnectivityCheckEnabled, ConnectivityCheckAvailable, ConnectivityCheckUri); nothing runs on a timer, and the check itself stays NetworkManager's. When its system bus connection drops it subscribes again as the bus's socket comes back.

With the check on, it opens the check address in the person's default browser and shows a notification saying why at three moments: when the rating becomes PORTAL on the active connection, at its own start while the rating is PORTAL, and when the person's graphical session starts while it is. It acts once per ask: again only after the rating left PORTAL, a session's start and its own restart excepted. When the rating leaves PORTAL for FULL it says the network is open. An open that failed gives a critical notification naming the reason and the address.

It opens with systemd-run --user --collect --quiet --wait -- xdg-open <address>, the address one argument and never through a shell, after asking xdg-mime query default x-scheme-handler/<scheme> for the program: the browser runs under the person's user manager and outlives the watcher. An open still running after 10 s is said as opening.

How it finds the person's session. Over the system bus it asks logind for its account's sessions: the one of type x11 or wayland, not remote, active or online. Its session bus is <RuntimePath>/bus, and its display is in the user manager's environment (DISPLAY and XAUTHORITY, which the X11 start block imports; WAYLAND_DISPLAY for a Wayland start block). No such session, or no display named there, is no session: then it opens and shows nothing, and still keeps the events. How it hears a session start: logind's SessionNew; for a graphical session of its account it reads the user manager's environment again at each file event in /tmp/.X11-unix (an X server's socket) and in the session's runtime directory (a Wayland socket), for at most 60 s, since the user manager says no change of its Environment; past that it writes that the start was not acted on.

The events: kept by the watcher, published by the bundle

From NetworkManager's own rating the watcher keeps node-uplink's two events, sign-in-asked (node, link, network, the address opened, when) and sign-in-ended (node, link, network, when, and why: signed-in, left or no-longer-asked), at most 256 of them, the oldest dropped past that with a journal line. With the check switched off (not enabled, or not available) it neither opens nor keeps anything. The bundle publishes them in order on the seat's subject mesh.seat.node-uplink.event.<event>.<node>, each under the message id <node>.<event>.<sequence>, the bundle's own node filled into the subject, the id and the body (the watcher names no node), awaiting the stream's acknowledgement, at its start, at each new kept event and when its bus connection comes back; a refused one waits for the next moment. Nothing in the mesh consumes them: they are its record, read with nats.nats_stream_messages filtered to mesh.seat.node-uplink.event.*.<node>, their time in at.

The bundle gives the resolver the check's host name

Where a module holds node-resolver on this node (the assignments say which), the bundle calls its uplink-names with the check address's host name, so NetworkManager's own check resolves through the network it tests: at its start, when check-address changes, when its bus connection comes back and when the node-engine says that holder runs. With no holder it calls nothing, and that is no failure.

Tools

tool what
uplink_sign_in the reaction as it stands: the watcher's state, the events waiting and the publishes refused, the last uplink-names call, the resolver's refusal of the names
uplink_names_again call uplink-names now
uplink_rating_again make the watcher subscribe again and act on the rating now
uplink_publish_again publish the kept events now
uplink_health whether the reaction works: unhealthy while the watcher's socket does not answer, while it is not subscribed, or while the last uplink-names call stands failed; a tool to read, not a health check

The watcher's health is its unit's state (networkmanager-sign-in active), judged on the machine without the bus, so it holds behind a sign-in page. When the system bus comes back and the watcher cannot subscribe on it again, it writes the reason to its journal and exits non-zero, so its unit shows failing and the service manager restarts it. uplink_health is a tool, not a health check; the watcher not subscribed and a failed uplink-names call are also shown by uplink_sign_in and written to the journal.