Expand description
This computer’s network, as a caller needs it before it acts: whether a host port is free
(port_free) and, when it isn’t, which process holds it (port_holder), and its public
IPv4 address, as the internet sees it (public_ipv4): what a
cloud firewall opens to when it lets this computer alone in. Independent services, run by different
companies, are asked at once (curl, through the Context’s runner), and two must give the
same address: one that is down or blocked fails nothing, and one that answers wrong (a captive
portal’s page, a compromised service) can’t open a firewall to someone else.
Enums§
- Public
IpFailed - Why no public address was agreed on.
Constants§
- HOLDER_
LOOKUP - How long each of the system’s tools
port_holderasks may take. - RESOLVERS
- The services asked by default: each answers a plain-text address over HTTPS.
- RESOLVER_
TIMEOUT - How long one service may take: one that hangs doesn’t hold up the others’ answer for long.
Functions§
- agreed
- The address
answers(one per service ofresolvers, in their order) agree on: at least two gave it, and none another one. - is_
public_ ipv4 - Whether
ipis an address on the internet: not private, loopback, link-local, shared (carrier-grade NAT), documentation, benchmarking, multicast, reserved or broadcast. Anything else can’t be where this computer’s traffic comes from, as a cloud firewall sees it. - port_
free - Whether nothing on this computer holds host
portforprotocolwhere a published port goes (the loopback): a socket bound there and let go at once, nothing kept. A TCP port is also taken when something answers on it: a listener on every address (0.0.0.0) doesn’t stop a loopback bind on every system (macOS lets one through), but it does answer. A free port can still be taken a moment later: this is a check before acting, not a reservation. - port_
holder - The process holding host
portforprotocolon this computer (its program’s name and its pid), when the system’s own tools name one:lsof, thenss(macOS, Linux),netstatthentasklist(Windows), each run through theContext’s runner withinHOLDER_LOOKUP. What a caller says beside a portport_freefound taken, so the user knows what to stop. Best-effort: none when no tool answers or names a process (sswithout root names none). - public_
ipv4 - This computer’s public IPv4 address, as
resolvers(RESOLVERS, unless a caller names its own) agree on it, all asked at once.