Skip to main content

Module bind

Module bind 

Source
Expand description

Bind-address resolution for trusty-console.

Why: The console needs to be reachable from tailnet clients across restarts without manual --http 0.0.0.0:7788 overrides. This module centralises all bind-address logic — env-var defaults, --tailscale flag handling, and Tailscale-IPv4 detection — behind a clean, mockable boundary so the resolution logic can be unit-tested without a real tailnet. What: Exports resolve_bind_addrs, which returns the ordered list of SocketAddrs the server should bind; and detect_tailscale_ipv4, which shells out to tailscale ip -4 (or accepts an injected command for tests). Test: tests module below; no real tailnet required.

Enums§

BindMode
How the server should bind its listeners.

Functions§

bind_listener
Bind a TCP listener, logging and returning a descriptive error on failure.
detect_tailscale_ipv4
Detect the machine’s Tailscale IPv4 address by running tailscale ip -4.
port_from_addr
Parse the port from an explicit bind address string, falling back to default.
resolve_bind_addrs
Resolve the list of SocketAddrs to bind based on mode and port.