Commit Graph

113 Commits

Author SHA1 Message Date
世界
866731344f dns: use refcounted snapshot to narrow rule lock scope
Exchange and Lookup held rulesAccess.RLock across all DNS network I/O,
blocking rebuildRules from swapping in new rules until every in-flight
query finished. Replace the RWMutex with an atomic pointer to a
refcounted rulesSnapshot so queries only hold a snapshot reference
during execution, allowing concurrent rule rebuilds.
2026-04-01 16:23:39 +08:00
世界
bd222fe9df dns: serialize rebuilds and keep last good rules on failure 2026-04-01 16:23:39 +08:00
世界
805f073ffb Suppress SA1019 lint warnings for intentional deprecated field usage 2026-04-01 16:23:39 +08:00
世界
ccad6d4595 Use typed SVCB hint structs instead of string parsing 2026-04-01 16:23:38 +08:00
世界
f02b50796a option: reject nested rule actions 2026-04-01 16:23:38 +08:00
世界
4df38c3244 dns: make rule strategy legacy-only 2026-04-01 16:23:38 +08:00
世界
036ef04da1 Make DNS match_response fail as a normal condition 2026-04-01 16:23:38 +08:00
世界
876c8eb283 Fix DNS rule-set ref handling 2026-04-01 16:23:37 +08:00
世界
ae2c869310 Fix legacy DNS rule_set accept_empty matching 2026-04-01 16:23:37 +08:00
世界
5dbabe4b37 dns: restore lookup reject semantics 2026-04-01 16:23:37 +08:00
世界
5cc484f34d Fix DNS record parser file inclusion and rule match log index
Remove SetIncludeAllowed(true) from the DNS record zone parser.
The $INCLUDE directive allows opening arbitrary files via os.Open,
which is unnecessary and dangerous when parsing a single record string
from configuration (especially remote profiles).

Fix displayRuleIndex arithmetic in dns/router.go that computed
2*index+1 instead of the correct 0-based index. This was a
reintroduction of a bug previously fixed in be8ee370a. Both
matchDNS and logRuleMatch now use the index directly, matching
the pattern in route/route.go.
2026-04-01 16:23:37 +08:00
世界
a491c9afef Fix DNS record parsing and shutdown race 2026-04-01 16:23:37 +08:00
世界
e09a6d3206 dns: restore init validation and fix rule-set query type 2026-04-01 16:23:37 +08:00
世界
40b9c64a0d dns: make rule path selection rule-set aware 2026-04-01 16:23:37 +08:00
世界
259e67fca3 dns: complete lookup rule execution in new mode 2026-04-01 16:23:36 +08:00
世界
abd420be44 dns: isolate legacy pre-match semantics 2026-04-01 16:23:36 +08:00
世界
a0d9c27b44 dns: preserve legacy address-filter pre-match semantics
Legacy DNS address-filter mode still accepts destination-side IP
predicates with a deprecation warning, but the recent evaluate/
match_response refactor started evaluating those predicates during
pre-response Match(). That broke rules whose transport selection must
be deferred until MatchAddressLimit() can inspect the upstream reply.

Restore the old defer behavior by reintroducing an internal
IgnoreDestinationIPCIDRMatch flag on InboundContext and using it only
for legacy pre-response DNS matching. Default and logical DNS rules now
carry the legacy mode bit, set the ignore flag on metadata copies while
performing pre-response Match(), and explicitly clear it again for
match_response and MatchAddressLimit() so response-phase matching still
checks the returned addresses.

Add regression coverage for direct legacy destination-IP rules,
rule_set-backed CIDR rules, logical wrappers, and the legacy Lookup
router path, including fallback after a rejected response. This keeps
legacy configs working without changing new-mode evaluate semantics.

Tests: go test ./route/rule ./dns
Tests: make
2026-04-01 16:23:36 +08:00
世界
80965071d9 Remove legacy DNS server formats 2026-04-01 16:23:36 +08:00
世界
8b75fbf83e dns: document non-response rule_set address-filter semantics 2026-04-01 16:23:36 +08:00
世界
58334cfd3c Fix DNS pre-match CIDR fail-closed semantics 2026-04-01 16:23:35 +08:00
世界
04dd0961c4 Fix DNS evaluate regressions 2026-04-01 16:23:35 +08:00
世界
23efd0c961 dns: use response-only address matching 2026-04-01 16:23:35 +08:00
世界
75ddbee71a Fix DNS match_response response address handling 2026-04-01 16:23:35 +08:00
世界
2380ae8506 Fix DNS record parsing and matching regressions 2026-04-01 16:23:35 +08:00
世界
27b60052fe Fix DNS evaluate routing regressions 2026-04-01 16:23:34 +08:00
世界
034727c3b6 Add evaluate DNS rule action and related rule items 2026-04-01 16:23:34 +08:00
世界
72bc4c1f87 Fix DNS transport returning error for empty AAAA response
Closes #3925
2026-03-23 19:21:55 +08:00
世界
0889ddd001 Fix connector canceled dial cleanup 2026-03-15 17:56:37 +08:00
世界
4d6fb1d38d Fix legacy DNS client_subnet options not working 2026-03-09 20:18:47 +08:00
世界
aa495fce38 Fix local DNS transport CNAME chain broken with systemd-resolved
Replace D-Bus ResolveRecord API with direct raw DNS queries to upstream
servers obtained from systemd-resolved's per-interface link properties.
2026-03-09 20:06:34 +08:00
世界
e343cec4d5 Fix legacy DNS defaults on final transport 2026-03-09 20:06:34 +08:00
世界
27c5b0b1af Fix DNS exchange failure and recursion deadlock in connector
Co-authored-by: everyx <lunt.luo@gmail.com>
2026-03-06 15:31:22 +08:00
世界
e62dc7bfa2 Fix rule_set_ip_cidr_accept_empty not working 2026-03-04 11:48:22 +08:00
世界
ab76062a41 Fix fake-ip address allocation 2026-03-03 21:37:24 +08:00
dyhkwong
4c65fea1ac Fix IPv6 local DNS on Windows 2026-03-01 12:30:43 +08:00
世界
8714c157c9 Fix matching multi predefined 2026-02-15 21:09:06 +08:00
世界
aba8346bd6 Fix DNS cache lock goroutine leak
The cache deduplication in Client.Exchange uses a channel-based lock
per DNS question. Waiting goroutines blocked on <-cond without context
awareness, causing them to accumulate indefinitely when the owning
goroutine's transport call stalls. Add select on ctx.Done() so waiters
respect context cancellation and timeouts.
2026-02-06 22:28:35 +08:00
世界
aa8dd6e44f Fix DNS transports 2026-01-17 05:48:41 +08:00
世界
a930356b04 Revert "Stop using DHCP on iOS and tvOS" 2026-01-17 05:47:32 +08:00
世界
5bc0dfa9dd platform: Refactoring libbox to use gRPC-based protocol 2026-01-17 05:47:32 +08:00
世界
fce21607bd Use a more conservative strategy for resolving with systemd-resolved for local DNS server 2026-01-17 05:46:23 +08:00
世界
ed1ee4c3a4 Update quic-go to v0.55.0 2026-01-17 05:46:13 +08:00
世界
107f92381b Add support for kTLS
Reference: https://gitlab.com/go-extension/tls
2026-01-17 05:44:42 +08:00
世界
44fafcef73 Fix resolve using resolved 2026-01-17 05:44:29 +08:00
世界
bba92146b1 Stop using DHCP on iOS and tvOS
We do not have the `com.apple.developer.networking.multicast` entitlement and are unable to obtain it for non-technical reasons.
2026-01-17 05:44:28 +08:00
世界
48f84b31d6 Improve local DNS server on darwin
We mistakenly believed that `libresolv`'s `search` function worked correctly in NetworkExtension, but it seems only `getaddrinfo` does.

This commit changes the behavior of the `local` DNS server in NetworkExtension to prefer DHCP, falling back to `getaddrinfo` if DHCP servers are unavailable.

It's worth noting that `prefer_go` does not disable DHCP since it respects Dial Fields, but `getaddrinfo` does the opposite. The new behavior only applies to NetworkExtension, not to all scenarios (primarily command-line binaries) as it did previously.

In addition, this commit also improves the DHCP DNS server to use the same robust query logic as `local`.
2026-01-17 05:44:28 +08:00
世界
1c846df903 Use resolved in local DNS server if available 2026-01-17 05:44:28 +08:00
neletor
1f03080540 Add support for ech retry configs 2026-01-17 05:44:26 +08:00
Gavin Luo
fffe9fc566 Fix reset buffer in dhcp response loop
Previously, the buffer was not reset within the response loop. If a packet
handle failed or completed, the buffer retained its state. Specifically,
if `ReadPacketFrom` returned `io.ErrShortBuffer`, the error was ignored
via `continue`, but the buffer remained full. This caused the next
read attempt to immediately fail with the same error, creating a tight
busy-wait loop that consumed 100% CPU.

Validates `buffer.Reset()` is called at the start of each iteration to
ensure a clean state for 'ReadPacketFrom'.
2026-01-05 17:46:59 +08:00
世界
1ebff74c21 Fix DNS cache not working when domain strategy is set
The cache lookup was performed before rule matching, using the caller's
strategy (usually AsIS/0) instead of the resolved strategy. This caused
cache misses when ipv4_only was configured globally but the cache lookup
expected both A and AAAA records.

Remove LookupCache and ExchangeCache from Router, as the cache checks
inside client.Lookup and client.Exchange already handle caching correctly
after rule matching with the proper strategy and transport.
2025-12-21 16:59:10 +08:00