feat(resolver): tailscale-doh upstream for Tailscale app connectors
Why
A Tailscale app connector (the tag:abs-connector peers serving *.abscproduct.com) learns which IPs to route only from DNS queries it answers on its PeerAPI DoH endpoint (<PeerAPIURL>/dns-query, RFC 8484). Today void reaches it only by forwarding to udp://100.100.100.100:53, and quad-100 honours split-DNS routes only when tailscaled has --accept-dns=true. Void hosts run with accept-dns off (void owns resolv.conf), and the OPNsense gateway has no MagicDNS, so these lookups SERVFAIL. With this change void talks to the connector directly.
What
New upstream scheme, meant for split routes:
dns:
split:
enabled: true
routes:
- id: abs
domains: ['abscproduct.com', '*.abscproduct.com']
upstreams: ['tailscale-doh://tag:abs-connector']Grammar: tailscale-doh://<tag:name | peer-hostname>[?socket=/abs/path]. The default socket is /var/run/tailscale/tailscaled.sock.
- pkg/config:
ParseUpstreamparses the scheme.UpstreamAddrgets two new fields,SelectorandSocket. Parsing of udp/tcp/tcp-tls is unchanged.void validateaccepts the scheme indns.upstreamand in split routes, including under--appliance. - pkg/resolver (
tailscale_doh.go):- Peer discovery: reads LocalAPI
GET /localapi/v0/statusover the unix socket using plain net/http (no tailscale.com dependency). A peer qualifies if it is online, not expired, matches the selector, and reports aPeerAPIURL. The IPv4 URL is preferred. - Peer cache: kept for 30s, and refreshed right away after a failed exchange, because the PeerAPI port changes when the peer's tailscaled restarts.
- Query: sent as RFC 8484 GET with
?dns=and ID 0. Timeouts are 2s per peer and 5s per exchange, which stays under the 6s flight-wait budget for one upstream. Answers are capped at 64 KiB. - Failures: a non-200 status, a wrong content type, a malformed answer or an answer to a different question moves on to the next peer. If no peer gives a usable answer, the pool returns SERVFAIL, as it does for any failed upstream.
- Peer discovery: reads LocalAPI
- OPNsense plugin: the model masks, the PHP validator and the split-route help text accept the scheme. The PHP and model tests are updated.
- Docs: a new "Tailscale app connectors" section in
docs/split-dns.mdcovers the policy grant (tcp/udp 53 to the connector tag) and LocalAPI permissions. README, AGENTS.md, the plugin README and the operator guide are updated too.
Field names were checked against a live tailscaled status. An end-to-end exchange against tag:abs-connector (shadowfax) from a dev host got NOERROR back.
Tests
- New tests use a fake LocalAPI on a temp unix socket and fake DoH servers. They cover:
- selection by tag or hostname
- skipping offline, expired and no-PeerAPI peers
- cache TTL, and refresh after a port change
- the happy path, including ID handling
- non-200, wrong or missing content type, oversized and mismatched answers
- fallback to a second peer
- no matching peer, and LocalAPI errors
- Pool SERVFAIL and the answer path
- Parse and validate cases are added in pkg/config.
golangci-lint run: 0 issues.go vet ./...: clean. The PHP validator tests and the plugin Python unit tests pass.go test -race ./...: green except 3 pkg/server tests (TestACLTwoClientsDistinctOutcomes,TestACLRuntimeSwapAllowlist,TestQueryDecisionEventsEndToEnd). They fail the same way on origin/main on the dev host because of loopback source-address rewriting, so they are not related to this change.
Notes / limitations
- One PeerAPI URL is used per peer: the IPv4 one, or the IPv6 one if the peer has no IPv4 URL. There is no v4-to-v6 fallback within the same peer.
- On FreeBSD/OPNsense, LocalAPI read access for a non-root
run_asuser has not been verified. Root works. - The capabilities API lists inbound transports only, so it does not change.
Jira: ENG-7539