fix: accept tls:// and https:// in [[forwarding]] upstreams #101

Merged
razvandimescu merged 1 commits from fix/forward-tls-upstream into main 2026-04-14 18:09:59 +08:00
razvandimescu commented 2026-04-14 14:23:28 +08:00 (Migrated from github.com)

Summary

  • [[forwarding]] rules now accept tls://IP[:port]#hostname and https://…/dns-query in addition to plain UDP, closing #100
  • Root cause: config.rs reached for parse_upstream_addr (UDP-only primitive) instead of the richer parse_upstream used by [upstream].address and fallback
  • Fix is a type widening: ForwardingRule.upstream: SocketAddr → Upstream. parse_upstream_addr demoted to pub(crate) so the same mistake can't recur from outside the crate
  • numa.toml gains commented DoT and DoH [[forwarding]] examples

Test plan

  • Red-first: added forwarding_upstream_accepts_{dot,doh}_scheme tests — verified they failed with the exact error from #100 before the fix, pass after
  • Existing UDP regression tests kept passing: forwarding_upstream_{with_explicit_port,defaults_to_port_53,invalid_upstream_returns_error}, merge/precedence tests, and end-to-end forwarding_rule_overrides_special_use_domain + pipeline_forwarding_returns_upstream_answer in ctx.rs
  • Added matches!(Upstream::Udp(_)) variant pin on the UDP path so future drift (e.g. parser choosing a different variant for a bare IP) gets caught
  • make all green (fmt, clippy -D warnings, audit, build, 284 tests)
## Summary - `[[forwarding]]` rules now accept `tls://IP[:port]#hostname` and `https://…/dns-query` in addition to plain UDP, closing #100 - Root cause: `config.rs` reached for `parse_upstream_addr` (UDP-only primitive) instead of the richer `parse_upstream` used by `[upstream].address` and `fallback` - Fix is a type widening: `ForwardingRule.upstream: SocketAddr → Upstream`. `parse_upstream_addr` demoted to `pub(crate)` so the same mistake can't recur from outside the crate - `numa.toml` gains commented DoT and DoH `[[forwarding]]` examples ## Test plan - [x] Red-first: added `forwarding_upstream_accepts_{dot,doh}_scheme` tests — verified they failed with the exact error from #100 before the fix, pass after - [x] Existing UDP regression tests kept passing: `forwarding_upstream_{with_explicit_port,defaults_to_port_53,invalid_upstream_returns_error}`, merge/precedence tests, and end-to-end `forwarding_rule_overrides_special_use_domain` + `pipeline_forwarding_returns_upstream_answer` in `ctx.rs` - [x] Added `matches!(Upstream::Udp(_))` variant pin on the UDP path so future drift (e.g. parser choosing a different variant for a bare IP) gets caught - [x] `make all` green (fmt, clippy `-D warnings`, audit, build, 284 tests)
Sign in to join this conversation.