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:
1 parent
3ae8e74a1d
commit
dde6a12ce4
5 files changed
+146
-34
No files matched your search
@@ -25,7 +25,7 @@ A check flips down after `fail_threshold` consecutive failures and up again on t
|
||||
| `true` | `true` | `rejected` | the API runs, **our token is refused**: revoked, rotated on the peer, or the file is still a placeholder. Mint a new token on the peer and replace the file (`auth_ok` is 0 in OTel while `peer.up` is 1 for both checks) |
|
||||
| `true` | `true` | `unknown` | the peer predates `GET /api/v1/ping`; the check fell back to public `/healthz`, so liveness is proven but not our credential |
|
||||
| `true` | `false` | `unknown` | the port answers but the API does not (`tls_error` for a certificate problem, `timeout`, `http_5xx`) |
|
||||
| `false` | `false` | `unknown` | nothing answers on the port: the peer is down or unreachable (also the case when the name resolves to an address the peer does not listen on, see [Address families](#address-families)) |
|
||||
| `false` | `false` | `unknown` | no resolved address answers on the port: the peer is down or unreachable (see [Address families](#address-families)) |
|
||||
|
||||
A peer that rejects our token is reported to *your* callers as a `503` naming the peer, never as a `401`: re-authenticating with this host would not help.
|
||||
|
||||
@@ -56,7 +56,7 @@ enabled = true # false keeps the declaration without contacting
|
||||
|
||||
Scalar keys accept environment overrides (`SKYG_PEERS__ENABLED`, `SKYG_PEERS__API_INTERVAL_SECS`, ...); `[[peers.peer]]` entries are file-only. `slinuxm --print-config` prints `token_file` paths, never their contents. Validation refuses: a timeout that is not below its interval, more than 64 peers, duplicate names, a bad name, a relative `token_file` or `ca_file`, a non-http(s) URL, userinfo/query/fragment in a URL, an IP literal in `deny_cidrs`, and plain `http` to a non-loopback host without `allow_plain_http = true` (which also logs a warning: the bearer token travels in cleartext). `enabled = true` with no peers logs a warning.
|
||||
|
||||
`deny_cidrs` is checked against the **resolved** address at connect time, so a name that resolves into a denied range is refused as `unreachable`. Private LAN ranges are deliberately allowed; the default denies only link-local/metadata and the unspecified range.
|
||||
`deny_cidrs` is checked against every **resolved** address at connect time, so a name where any address lands in a denied range is refused as `unreachable`. Private LAN ranges are deliberately allowed; the default denies only link-local/metadata and the unspecified range.
|
||||
|
||||
## REST and MCP
|
||||
|
||||
@@ -208,7 +208,9 @@ Every **peer** must accept the consolidator's address on its port; the consolida
|
||||
|
||||
### Address families
|
||||
|
||||
A peer is reached at the address its name resolves to at connect time, and the first resolved address wins. A peer that listens on IPv4 only, with a name that also resolves to an IPv6 address (as a NixOS test network does), reads as `unreachable`; declare it by IP address or let it listen on both families (`bind = "::"` accepts IPv4-mapped connections too). DNS rebinding is not a risk here because the target is pinned to the address that was checked against `deny_cidrs`.
|
||||
A peer's name is resolved at connect time and **every** resolved address is used: the health probe tries them in order within its timeout, and the HTTP client pins the whole list so the connection falls through to the next address when the first one refuses or does not answer. A peer that listens on IPv4 only is therefore reached even when its name also resolves to an IPv6 address (as a NixOS test network or a dual-stack LAN does). Both families and a single family work; `bind = "::"` on a peer is dual stack, `bind = "0.0.0.0"` is IPv4 only.
|
||||
|
||||
DNS rebinding is still not a risk: the set is resolved once per request and pinned, and a name where **any** resolved address falls in `deny_cidrs` is refused as `unreachable` rather than dialled at the permitted addresses.
|
||||
|
||||
## Limits and non-goals
|
||||
|
||||
|
||||
Reference in new issue
Block a user