Skip to main content

Module address

Module address 

Source
Expand description

Where this runtime can be reached: the host:port authorities it advertises and dials back. A server bound to a specific address advertises that address. A server bound to every interface (0.0.0.0) is reachable at each interface’s address and at none called 0.0.0.0, so it advertises its up, non-loopback IPv4 interface addresses — physical ones before container bridges, at most super::protocol::MAX_ENDPOINTS. A server bound to loopback advertises loopback, which only this machine can dial; the mesh doctor says so.

use majordomus_cli::mesh::address::advertised_endpoints;
assert_eq!(advertised_endpoints("127.0.0.1:8742"), vec!["127.0.0.1:8742".to_string()]);
assert!(advertised_endpoints("0.0.0.0:8742").iter().all(|e| !e.starts_with("0.0.0.0")));

Functions§

advertised_endpoints
The endpoints a server bound at bound (host:port) advertises. A bind is what the socket was asked for; an endpoint is what another machine can dial, and the two differ exactly when the bind is unspecified — nobody can reach 0.0.0.0, so that bind is expanded into the interfaces it actually listens on. A bind this cannot parse is passed through unchanged, because a name this process cannot resolve may still be one its peers can.
interfaces
The up, non-loopback IPv4 interfaces of this machine, ranked, with their names. What is left out is what a remote runtime could not dial anyway: an interface that is down, loopback, unspecified, or link-local. The order is the advertising preference — a physical or overlay interface before a container or VM bridge — because only the first MAX_ENDPOINTS survive into an advertisement and a bridge address is the one a peer is least likely to reach.
loopback_only
Whether every endpoint is a loopback address: reachable from this machine alone. A runtime in that state is not broken and is not on the mesh either, which is a distinction the doctor has to be able to draw before it blames the network for a cooperation that was never reachable. One routable endpoint is enough, so this asks of all of them rather than of any.