F: try every resolved peer address instead of the first

A peer whose name resolves to both families but which listens on only one
of them was reported unreachable, which the documented 0.0.0.0 binding
produces on a dual-stack LAN and in the NixOS test network.

resolve_target now returns the whole address set (still refusing the name
if any address is denied), the HTTP client pins it with
resolve_to_addrs so the connector falls through to the next address, and
tcp_check tries each address in order with a per-attempt share of the
remaining deadline. ClientKey keys on the set.

Regression cover: a client test that resolves localhost against a
single-family listener, a tests/peers.rs case declaring the peer as
http://localhost:<port>, and the VM test's TLS peer gamma now binds
0.0.0.0 (IPv4 only) while alpha and beta stay dual stack. Docs and the
contracts section 10 address note describe the new behaviour.
This commit is contained in:
ari committed 2026-10-20 15:04:09 -04:00
1 parent 3ae8e74a1d
commit dde6a12ce4
5 files changed
+146 -34

No files matched your search

+23
View File
@@ -471,6 +471,29 @@ async fn a_plain_peer_serves_its_own_data_through_the_proxy() {
peer.stop().await;
}
/// Declared by name, not by IP literal: `localhost` resolves to both loopback
/// families while the peer listens on IPv4 only, so a transport that pins just
/// the first resolved address reports this peer down.
#[tokio::test]
async fn a_peer_declared_by_name_is_reached_on_the_family_it_listens_on() {
let dir = TempDir::new("localhost");
let peer = Peer::start().await;
let token = peer.token_file(&dir);
let url = format!("http://localhost:{}", peer.port);
let consolidator = Consolidator::start(one_peer("beta", url, None, &token)).await;
let status = consolidator
.wait_status("beta", |s| s.server.up && s.api.up)
.await;
assert_eq!(status.api.auth, AuthState::Ok);
let (code, _, body) = consolidator
.get("/api/v1/peers/beta/systemd/units", None)
.await;
assert_eq!(code, 200, "{body}");
consolidator.stop().await;
peer.stop().await;
}
#[tokio::test]
async fn a_tls_peer_is_trusted_through_its_ca_file() {
let dir = TempDir::new("tls");