Repository navigation
Pair with IP: join.direct dials a computer name - #58
Merged
Merged
Conversation
…sses in order with one attempt, keep the address reached
…, as a dial leaves it
… dial and once its TLS is up, as before; a name also before it is resolved
…d failure beats a refusal, and a cancel abandons a slow lookup at once A name dials exactly what a typed IP address dials (IPv4 link-local included, IPv6 link-local refused), now pinned by a test. Tests also show each address is dialled once and that a host refusing the code ends the Connect with no other host dialled.
# Conflicts: # Cargo.toml
TheAnimatrix
force-pushed
the
direct-name-dial
branch
from
November 30, 2026 19:15
8eaafe5 to
75904f8
Compare
…s not missed; a paused name is not resolved; out of time ends the answer scan The driver's wait for the flow to leave connecting reads the flow's own state first, so a cancel published before borrow_and_update ends the flow at once. A debug-only pause point lets a test land a cancel in exactly that window. Tests also pin that a repeated answer is dialled once, that IPv4 link-local ends unreachable (dialled), and that a paused name is never resolved.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of the Pair with IP rollout (mousse-agent/mousse#2079), second of three engine steps toward joining by computer name. Follows #52, which made addresses and pending records carry a name.
join.directnow takes a name as well as an IP address. The joiner resolves the name, tries the addresses it gets in order, spends at most one code attempt per Connect, and keeps the address that answered as the owner route.What changed
mousse-net-iocaller/direct.rs,wire.md10.9 "Dialling a name").SystemResolver, or a stub in tests viaCaller::use_resolver.DIRECT_NAME_ADDRESSEScap, so a reachable host listed after many refused addresses is still tried while the time budget lasts.HELLO, moves on to the next address. The first connection whose TLS succeeds becomes the flow's connection, and whatever happens on it ends that Connect. So a name with several addresses never runs more than one code attempt.CONNECT_TIMEOUT_MSandHANDSHAKE_TIMEOUT_MS.wire.mdnow says this explicitly.DirectDialFailure::NotFoundis new: the name did not resolve, or not within the budget. The helper reports it asnot_found("can't find that computer by name"), and the CLI says to try the IP address. A name whose addresses the policy all forbids isForbidden, as for an IP address. In both cases nothing is sent and no attempt is spent. When the dial tried at least one allowed address, it reports what happened there ("not Mousse" over "unreachable"), never "forbidden" for an address it skipped.PAIRED. The I/O layer replacesDirectPaired::addresswith the socket address the verified connection reached (DirectAddress::from_socket, back from Pair with IP: typed addresses and pending records carry a name #52's cut, now with its caller; an IPv4-mapped address is kept as its IPv4 address), before the pin store and thePairedevent see it. So the owner route the helper writes, through its existing fenced write path, is that IP address and port, never the name. For a typed IP address it is the same address as before.typed_addressnow accepts<name>:<port>(lowercased; Pair with IP: typed addresses and pending records carry a name #52's rule still refuses a numeric spelling such as0x7f000001). The policy is still checked at once for a typed IP address; for a name it is checked per resolved address when dialling. CLI help forjoin-directshows the name form.docs/limits.md):MOUSSE_NET_DIRECT_NAME_DIAL_MS: default 20000, range 1000 to 120000. The whole name dial.MOUSSE_NET_DIRECT_NAME_ADDRESSES: default 8, range 1 to 32. Allowed addresses dialled per name dial; refused ones don't count.docs/limits.md). Neither one is security-bound, so neither is clamped.wire.md10.9 (dialling a name; recovery resolves again; the reached address is kept), anddocs/pair-with-ip-design.md§1.4 and thejoin.directerror list (not_found).Tests
io
direct_joiner.rsuses a stub resolver:a_name_tries_its_addresses_in_order_and_spends_one_attempt: the name resolves to a closed port, a port that is not Mousse, the closed port again, the host, then the non-Mousse port again. The flow skips the failures, pairs with the host, keeps the record at the lowercased name, stores the host's socket address as the owner route, debits one attempt, resolves once, and connects to the non-Mousse port only once.a_name_whose_first_host_refuses_the_code_tries_no_other: the first host's code doesn't match. The Connect ends there with one attempt spent, and a second host the name resolves to gets no connection.refused_addresses_do_not_use_up_a_names_tries: more refused addresses than the cap come before the host, and the code still reaches it.a_name_dial_reports_the_failure_of_an_address_it_tried: a closed port followed by a refused address reports "unreachable". A non-Mousse port, a closed port and a refused address report "not Mousse".a_name_dials_what_a_typed_address_dials: 169.254.77.1 is dialled both typed and as a name's answer;fe80::1and 192.0.2.1 are refused both ways.a_cancel_during_a_slow_lookup_frees_the_lookup_at_once: with the lookup never answering, a cancel is confirmed, the flow ends at once, and the same name and code then reach the host.a_cancel_landing_before_the_dial_starts_ends_the_flow_at_once: a debug-only pause point holds the driver after it read "connecting"; a cancel lands there, no lookup starts, and the same name and code then reach the host.a_name_is_not_resolved_while_paused: while paused, the resolver is never asked.a_name_that_resolves_to_nothing_dialable_sends_nothing: only forbidden addresses givesForbidden; no answer givesNotFound. Neither debits an attempt.a_recovery_at_a_name_resolves_again_and_takes_only_the_pinned_key: the code passes andPAIREDis lost. After a restart, the name resolves first to another Mousse host and then to the real one. The recovery resolves again, skips the other host at TLS (it never sees a request), pairs with the real host with no new attempt, and keeps the real host's address.Helper
app_pair_ip::a_typed_name_pairs_and_keeps_the_address_it_reached:join.directwithLocalHost:<port>pairs through the system resolver, and the peer's only owner address is the loopback address that answered.Eight new must-fail controls in
pair-with-ip.joiner-io:direct-name-first-only: only the first resolved address is tried.direct-name-kept-as-route: the typed name is kept as the owner route.direct-name-cap-counts-forbidden: refused addresses count toward the cap.direct-name-forbidden-wins: a refusal replaces the failure of an address tried before it.direct-cancel-waits-for-dial: a cancel waits for the lookup to end.direct-cancel-before-seen: a cancel published before the driver marks "connecting" seen is missed.direct-name-resolved-while-paused: a name is resolved while paused.direct-name-dial-duplicates: a repeated address is dialled again.The existing
direct-dial-uncheckedalso breaks the forbidden-name test.Review fixes (round 1, reviews of 8eaafe5)
MOUSSE_NET_DIRECT_NAME_ADDRESSES, so the cap only limits how many allowed addresses are dialled, and the shared time budget still bounds the whole dial. Testrefused_addresses_do_not_use_up_a_names_tries(more refused answers than the cap, then the host); controldirect-name-cap-counts-forbidden. Both reviewers suggested cutting the cap; it stays as a bound on how many hosts one name dial can touch, with refused answers no longer counting.wire.md10.9 now says so. Testa_name_dials_what_a_typed_address_dialspins it: it fails if names and typed addresses ever get different rules, and the existingdirect-dial-uncheckedcontrol breaks its refused half.a_cancel_during_a_slow_lookup_frees_the_lookup_at_once(the resolver never answers); controldirect-cancel-waits-for-dial.Forbiddenis reported only when no allowed address was tried. Otherwise the failure of an address actually tried is kept, "not Mousse" over "unreachable". Testa_name_dial_reports_the_failure_of_an_address_it_tried; controldirect-name-forbidden-wins.wire.md10.9 now states the exception: a far end showing the joiner's own key ends the Connect as "own device", as for a typed address, rather than moving to the next answer.docs/limits.md: an out-of-range value stops the helper at startup. Neither new limit is security-bound, so neither is clamped.a_name_whose_first_host_refuses_the_code_tries_no_othercovers a code refused on the first host: one attempt spent, the second host gets no connection.direct-contact-checked-oncecontrol still fails its test.Review fixes (round 2, re-checks of 10cb1a3)
Caller::pause_direct_dials, compiled only outside the release profile) lets the new testa_cancel_landing_before_the_dial_starts_ends_the_flow_at_onceland the cancel in exactly that window; it then checks that no lookup was made and that the same name and code reach the host right away. Controldirect-cancel-before-seen.direct-name-dial-duplicates.fe80::1and192.0.2.1"forbidden", for a typed IP and a name alike.a_name_is_not_resolved_while_paused: while paused, a typed name is never looked up. Controldirect-name-resolved-while-paused.Checks run (Windows x64)
Head
5bda28a(onmainatd5b17f0):cargo fmt --all --check,cargo clippy --workspace --all-targets --all-features -- -D warnings: clean.cargo test --workspace --no-fail-fast: all 69 test binaries pass. The known flake Flaky test: a stalled older keys exchange waits 20 s for peer.manifest under load #23 did not fail in this run (it failed in the run on75904f8, and 1 of 3 times run alone there; this PR does not touch it).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.joiner-io: 33 tests, 13 controls, including the eight new ones above.pair-with-ip.sim(the pairing-direct sim drill): pass, 6 controls.pair-with-ip.helper-units: 123 tests, 5 controls.pair-with-ip.helper: 26 tests, 20 controls.pair-with-ip.host-io: 26 tests, 9 controls.