Skip to content

Pair with IP: the host shows its computer name next to its address - #60

Merged
TheAnimatrix merged 2 commits into
mainfrom
direct-host-name
Nov 30, 2026
Merged

TheAnimatrix merged 2 commits into
mainfrom
direct-host-name

Conversation

@TheAnimatrix

@TheAnimatrix TheAnimatrix commented Nov 30, 2026 •

Copy link
Copy Markdown
Collaborator

Part of the Pair with IP rollout (mousse-agent/mousse#2079), last of three engine steps toward joining by computer name. Follows #58, which dials a typed name. The host now reports its computer name next to the IP address and port it shows, so the person can read out a name instead of an address.

What changed

  • invite.create {kind: "direct"} (app/pairing/direct.rs) returns an optional host_name.
    • It is this computer's name as the operating system reports it, lowercased.
    • It goes with the same port as address.
    • It is left out when that name is not one join.direct reads: it doesn't fit the route grammar's DNS labels, or it is a numeric spelling that Pair with IP: typed addresses and pending records carry a name #52 refuses.
    • It is also left out when it means the joiner's own computer by definition: localhost, localhost.localdomain, or a name under either (RFC 6761 §6.3).
    • It is left out when the name can't be read. The pinned gethostname panics when the Windows call fails; the lookup is caught, so the invitation still reaches the app.
    • Whether the name resolves on the joiner's network is not checked, so the app keeps the IP address and port in view, and the joiner can type either.
  • direct::typable_host_name() holds the rule, and direct::host_name() reads the OS name with gethostname (already used for the computer name). Names are validated with core DirectAddress::parse, the same reader join.direct uses.
  • Docs: docs/pair-with-ip-design.md §4 lists host_name? in the invite.create reply and describes it in "Helper protocol as built".

Tests

  • Helper unit test the_host_name_is_given_only_when_it_names_this_computer_to_a_joiner, with fixed names: Office-PC gives office-pc; studio.example.lan, localhostbox and mylocalhost are given; localhost, LocalHost, box.localhost, localhost.localdomain and a.localhost.localdomain are not; nor are 0x7f000001, 127.1, desk_1, an empty name, localhost. or a 64-byte label.
  • app_pair_ip::pairs_from_the_ops_end_to_end checks the reply's exact host_name (present or absent) for this computer's name. Removing the field, or giving a name a joiner can't type, fails it.
  • New must-fail control direct-host-name-localhost in pair-with-ip.helper-units: a localhost name is given.

Review fixes (reviews of 308ebdc)

  • R1 (both), a localhost host name: localhost, localhost.localdomain and names under either are left out of the reply; the IP address and port stay. Unit test above; control direct-host-name-localhost.
  • R2 (both), the reply test could pass with the field removed or wrong: the rule now has fixed-name unit tests, and the reply test checks the exact value.
  • Astra R3, a failed Windows lookup: caught; host_name is left out and the invitation reply still goes out.
  • Cut (both): the invite --direct NAME line, its field and its doc wording are removed. The app screen only needs invite.create.

Checks run (Windows x64)

Head 8221b98, on #58's head 5bda28a (main at d823b1e has the same tree):

  • cargo fmt --all --check, cargo clippy --workspace --all-targets --all-features -- -D warnings: clean.
  • cargo test --workspace --no-fail-fast: 68 of 69 test binaries pass. The one failure was mousse-relay relay_admission::a_revoked_key_cannot_name_a_successor_before_the_next_read (a close seen without its code), in a crate this PR does not touch; it then passed 5 of 5 runs alone on this head.
  • wasm32 core build and vectors, second implementation (npm run check, npm test): pass.
  • mousse-check, every control failing as required:
    • phase0.core-vectors: 320 tests (wasm32: 291), 3 controls.
    • phase0.second-implementation: pass, 1 control.
    • pair-with-ip.sim (the pairing-direct sim drill): pass, 6 controls.
    • pair-with-ip.helper-units: 124 tests, 6 controls, including the new one.
    • pair-with-ip.helper: 26 tests, 20 controls. In the gate run, direct-no-startup-recovery ended before its tests ran, while the PC was under load from other work. Run again alone on this head, it failed 5 of 26 tests as required.

…s; a failed hostname lookup leaves the name out; the CLI shows no name

localhost, localhost.localdomain and names under either mean the joiner's own computer (RFC 6761 6.3), so invite.create leaves them out. The pinned gethostname panics when the Windows call fails; that now just leaves host_name out. The rule has unit tests with fixed names, and the reply test checks the exact value.
@TheAnimatrix
TheAnimatrix changed the base branch from direct-name-dial to main November 30, 2026 22:16
@TheAnimatrix
TheAnimatrix merged commit 3b5ac07 into main Nov 30, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant