Skip to content

Listen-interface selection, presets, and resolver (pure) #4

Closed

Description

@Khang5687

Parent

Spec: #1 — Exposure as a set of listen interfaces (bind-hosts lane). Governing ADR: 0003.

What to build

The vocabulary every later ticket consumes, as pure code with no callers yet.

In the contracts package (no dependencies):

  • A listenInterfaces selection schema — a set of kinds from loopback | tailnet | lan plus an optional IPv4 address list — normalized so loopback is always present.
  • Exposure preset derivation and its inverse: local-only = {loopback}; tailscale-only = {loopback, tailnet}; lan = {loopback, tailnet, lan}; anything else = custom.
  • Legacy mapping helpers: local-only → {loopback}; network-accessible → the lan preset; the derived legacy mode is local-only iff the selection is exactly {loopback} with no addresses.

In the tailscale package, beside isTailscaleIpv4Address: the resolver — a pure function taking a selection and an injectable network-interface map and returning { addresses, warnings }. No I/O, no tailscale CLI. It is the single home of the fallback policy.

Resolution rules (IPv4 only in v1):

  • loopback → 127.0.0.1
  • tailnet → every non-internal IPv4 in the Tailscale CGNAT range
  • lan → every non-internal IPv4 that is not a tailnet address
  • explicit addresses → included only if present on some interface (or loopback); a missing one is skipped with a warning naming it
  • tailnet selected but absent → warning; continue with whatever else resolved
  • selection had non-loopback kinds or addresses but the result is loopback only → an additional "listening on loopback only" warning
  • deduplicated; ordered loopback → tailnet → lan → explicit

Acceptance criteria

  • Schema rejects unknown kinds and non-IPv4 strings; decoding an input without loopback yields a selection that contains it.
  • Preset derivation and its inverse round-trip for the three named presets; any other selection derives to custom.
  • Legacy mapping helpers behave as specified above.
  • Resolver unit tests with synthetic interface maps cover every rule: multi-NIC lan, CGNAT detection, tailnet-missing warning, explicit-missing warning, loopback-only warning, dedupe and order, IPv6 and internal entries ignored.
  • No production caller yet; typecheck and lint clean.
  • Names use the fork glossary (exposure, listen interface, exposure preset); no "network access" / "bind host" / "mode" in new identifiers.

Blocked by

  • None — can start immediately.

Activity

  1. added
    ready-for-agent
    on Sep 6, 2026
  2. added a commit that references this issue on Sep 6, 2026
  3. Khang5687 commented on Sep 6, 2026

    @Khang5687
    OwnerAuthor

    Merged into fork-main via #11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ready-for-agent

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions