Commit Graph

360 Commits

Author SHA1 Message Date
世界
78348540a9 Replace internal terminology in docs and error messages
Remove all user-facing references to the internal `legacyDNSMode` variable
name. Error messages now reuse the deprecated.Note.MessageWithLink() method
to provide consistent deprecation text with migration URLs. Other internal
jargon ("consume response state", "response_*") is replaced with
user-friendly descriptions.

Add two migration guide entries under 1.14.0: one for strategy → rule items,
one for address filter fields → evaluate with match_response.
2026-04-01 18:27:14 +08:00
世界
99b363c878 test: remove internal-state assertions that test through unexported fields 2026-04-01 16:51:03 +08:00
世界
8916a241ed test: remove low-value DNS WHAT tests 2026-04-01 16:39:12 +08:00
世界
c17a5a3260 Simplify nested action validation and fix FallbackNetworkType bug
- Rename nested_action.go to rule_nested_action.go for naming consistency
- Export error message constants from option package to deduplicate
- Fix RuleActionRouteOptions.Descriptions using wrong field for fallback-network-type
2026-04-01 16:23:42 +08:00
世界
c1ff6a08f0 Format code 2026-04-01 16:23:42 +08:00
世界
faf786ce70 dns: fix variable shadowing in matchDNSHeadlessRuleStatesForMatch 2026-04-01 16:23:41 +08:00
世界
ef99a87de7 dns: reject method reply is not supported for DNS rules
Add config-time validation in NewDNSRule that rejects
RejectMethodReply for both default and logical DNS rules,
matching the existing TCP/UDP validation in route/route.go.
2026-04-01 16:23:40 +08:00
世界
e6377f7ec9 fix: add missing EnvName, document Strategy invariant, improve rcode display
- Add EnvName to four new deprecation constants so users can suppress
  warnings via ENABLE_DEPRECATED_* environment variables
- Add comment explaining why applyDNSRouteOptions skips Strategy
- Use dns.RcodeToString in DNSResponseRCodeItem.String() for readability
- Remove redundant Fqdn(FqdnToDomain(domain)) round-trip
2026-04-01 16:23:40 +08:00
世界
be4e696632 route/rule: remove dead IgnoreDestinationIPCIDRMatch field
The field was never set to true after the legacy pre-match refactor
in 3549c02b8. Remove the declaration, guard check, and redundant
false assignments.
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
世界
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
世界
40b9c64a0d dns: make rule path selection rule-set aware 2026-04-01 16:23:37 +08:00
世界
5604488924 Fix legacy DNS negation expansion 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
世界
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
世界
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
世界
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
世界
859667d650 Add macOS support for MAC and hostname rule items 2026-04-01 16:22:39 +08:00
世界
a91377b67d Add Android support for MAC and hostname rule items 2026-04-01 16:22:39 +08:00
世界
f7ab050e3e Add MAC and hostname rule items 2026-04-01 16:22:39 +08:00
世界
6381de7bab route: Fix query_type never matching in rule_set headless rules 2026-03-26 13:26:18 +08:00
世界
b0c6762bc1 route: merge rule_set branches into outer rules
Treat rule_set items as merged branches instead of standalone boolean
sub-items.

Evaluate each branch inside a referenced rule-set as if it were merged
into the outer rule and keep OR semantics between branches. This lets
outer grouped fields satisfy matching groups inside a branch without
introducing a standalone outer fallback or cross-branch state union.

Keep inherited grouped state outside inverted default and logical
branches. Negated rule-set branches now evaluate !(...) against their
own conditions and only reapply the outer grouped match after negation
succeeds, so configs like outer-group && !inner-condition continue to
work.

Add regression tests for same-group merged matches, cross-group and
extra-AND failures, DNS merged-branch behaviour, and inverted merged
branches. Update the route and DNS rule docs to clarify that rule-set
branches merge into the outer rule while keeping OR semantics between
branches.
2026-03-25 14:00:29 +08:00
世界
d454aa0fdf route: formalize nested rule_set group-state semantics
Before 795d1c289, nested rule-set evaluation reused the parent rule
match cache. In practice, this meant these fields leaked across nested
evaluation:

- SourceAddressMatch
- SourcePortMatch
- DestinationAddressMatch
- DestinationPortMatch
- DidMatch

That leak had two opposite effects.

First, it made included rule-sets partially behave like the docs'
"merged" semantics. For example, if an outer route rule had:

  rule_set = ["geosite-additional-!cn"]
  ip_cidr  = 104.26.10.0/24

and the inline rule-set matched `domain_suffix = speedtest.net`, the
inner match could set `DestinationAddressMatch = true` and the outer
rule would then pass its destination-address group check. This is why
some `rule_set + ip_cidr` combinations used to work.

But the same leak also polluted sibling rules and sibling rule-sets.
A branch could partially match one group, then fail later, and still
leave that group cache set for the next branch. This broke cases such
as gh-3485: with `rule_set = [test1, test2]`, `test1` could touch
destination-address cache before an AdGuard `@@` exclusion made the
whole branch fail, and `test2` would then run against dirty state.

795d1c289 fixed that by cloning metadata for nested rule-set/rule
evaluation and resetting the rule match cache for each branch. That
stopped sibling pollution, but it also removed the only mechanism by
which a successful nested branch could affect the parent rule's grouped
matching state.

As a result, nested rule-sets became pure boolean sub-items against the
outer rule. The previous example stopped working: the inner
`domain_suffix = speedtest.net` still matched, but the outer rule no
longer observed any destination-address-group success, so it fell
through to `final`.

This change makes the semantics explicit instead of relying on cache
side effects:

- `rule_set: ["a", "b"]` is OR
- rules inside one rule-set are OR
- each nested branch is evaluated in isolation
- failed branches contribute no grouped match state
- a successful branch contributes its grouped match state back to the
  parent rule
- grouped state from different rule-sets must not be combined together
  to satisfy one outer rule

In other words, rule-sets now behave as "OR branches whose successful
group matches merge into the outer rule", which matches the documented
intent without reintroducing cross-branch cache leakage.
2026-03-24 15:03:43 +08:00
世界
9ac1e2ff32 Match package_name in process_path rule on Android 2026-03-23 18:57:35 +08:00
世界
0045103d14 Fix package_name shared uid matching 2026-03-23 18:57:35 +08:00
世界
3f05a37f65 Optimize Linux process finder 2026-03-23 18:57:35 +08:00
世界
b8e5a71450 Add process information cache to avoid duplicate lookups
PreMatch and full match phases each created a fresh InboundContext,
causing process search (expensive OS syscalls) to run twice per
connection. Use a freelru ShardedLRU cache with 200ms TTL to serve
the second lookup from cache.
2026-03-23 14:26:45 +08:00
世界
795d1c2892 Fix nested rule-set match cache isolation 2026-03-23 12:26:19 +08:00
世界
d2fa21d07b Deprecate Socksaddr.IsFqdn: do not reject potentially valid domain names 2026-03-16 09:37:59 +08:00
世界
1803471e02 endpoint: Fix UDP resolved destination 2026-03-02 13:55:26 +08:00
世界
8ae93a98e5 Remove overdue deprecated features 2026-03-01 12:30:43 +08:00
世界
cf4791f1ad platform: Improve iOS OOM killer 2026-02-26 14:13:32 +08:00
世界
657fba4ca5 Fix matching rule-set invert 2026-02-15 21:08:33 +08:00
世界
e11dbf3a8e bufio: Refactor copy 2026-02-05 12:03:03 +08:00
世界
0caebd3171 platform: Improve interface 2026-01-17 05:49:12 +08:00
世界
4e94a64dcc platform: Expose process info 2026-01-17 05:48:41 +08:00
世界
494990f914 Update bypass action behavior for auto redirect 2026-01-17 05:48:41 +08:00
世界
78b4eac974 Add pre-match support for auto redirect 2026-01-17 05:48:39 +08:00
世界
ac427b98f4 platform: Add UsePlatformWIFIMonitor to gRPC interface
Align dev-next-grpc with wip2 by adding UsePlatformWIFIMonitor()
to the new PlatformInterface, allowing platform clients to indicate
they handle WIFI monitoring themselves.
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
世界
8d8ca282a1 Add Linux WI-FI state support
Support monitoring WIFI state on Linux through:
- NetworkManager (D-Bus)
- IWD (D-Bus)
- wpa_supplicant (control socket)
- ConnMan (D-Bus)
2026-01-17 05:47:04 +08:00
世界
12b055989b Fix preConnectionCopy 2026-01-17 05:46:01 +08:00