Commit Graph

51 Commits

Author SHA1 Message Date
世界
75f64acd9f route: Fix query_type never matching in rule_set headless rules 2026-03-26 13:26:18 +08:00
世界
fdfd0ffb07 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
世界
3564cdf07e route: formalize nested rule_set group-state semantics
Before 8bf01b7ad, 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.

8bf01b7ad 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
世界
e5053ffcda Match package_name in process_path rule on Android 2026-03-23 18:57:35 +08:00
世界
f3a79dda87 Fix package_name shared uid matching 2026-03-23 18:57:35 +08:00
世界
8bf01b7add Fix nested rule-set match cache isolation 2026-03-23 12:26:19 +08:00
世界
da06212268 Remove overdue deprecated features 2026-03-01 12:30:43 +08:00
世界
f3d3680f74 Fix matching rule-set invert 2026-02-15 21:08:33 +08:00
世界
4caa950da9 Update bypass action behavior for auto redirect 2026-01-17 05:48:41 +08:00
世界
024f7b3072 Add pre-match support for auto redirect 2026-01-17 05:48:39 +08:00
世界
0b6fe45fb9 platform: Refactoring libbox to use gRPC-based protocol 2026-01-17 05:47:32 +08:00
世界
e2ba72e7c1 Add proxy support for ICMP echo request 2026-01-17 05:44:41 +08:00
世界
14bec14972 Fix rule-set format 2026-01-17 05:44:29 +08:00
世界
5c8b07acfe Add preferred_by route rule item 2026-01-17 05:44:27 +08:00
世界
d373f57e57 Add interface address rule items 2026-01-17 05:44:26 +08:00
世界
8df94f091f Fix race codes 2025-09-12 21:58:48 +08:00
世界
1edac3cfff Fix multiple sniff 2025-09-03 20:09:05 +08:00
世界
2efdd4dd7c Deprecate common/atomic 2025-08-25 19:49:12 +08:00
世界
886f7c8253 Add TLS record fragment support 2025-07-08 13:14:38 +08:00
世界
076ed3c69a Add wildcard name support for predefined records 2025-07-08 13:12:27 +08:00
k9982874
6066201331 Add ntp protocol sniffing 2025-07-08 13:12:26 +08:00
世界
6cae3e54d1 Move predefined DNS server to rule action 2025-07-08 13:12:23 +08:00
世界
29d355597f Improve resolve action 2025-07-08 13:12:18 +08:00
世界
a5db391fcf Add certificate store 2025-07-08 13:12:14 +08:00
世界
3d55cef5f2 Add TLS fragment support 2025-07-08 13:12:14 +08:00
世界
2afbe96ea0 refactor: Outbound domain resolver 2025-07-08 13:12:14 +08:00
世界
f75ade1991 refactor: DNS 2025-07-08 13:12:14 +08:00
世界
a6315e5313 Fix log for rejected connections 2025-06-21 12:57:26 +08:00
世界
7208efe294 Fix panic on some stupid input 2025-04-25 16:03:58 +08:00
世界
b56a752547 Fix no_drop not work 2025-04-08 14:16:23 +08:00
世界
b7c20fd165 Improve pause management 2025-04-08 14:16:22 +08:00
世界
eba7eb9e76 Fix override address 2025-02-11 01:32:14 +08:00
世界
8a7e2e46f9 Fix crash on remote rule-set stop 2025-02-05 08:58:10 +08:00
世界
3bc90eef10 Fix rule-set not closed 2025-02-01 19:49:33 +08:00
世界
81f01eddcb Fix local rule-set not updated 2025-02-01 19:42:21 +08:00
世界
8b9d1cc626 Fix domain strategy 2025-01-13 15:14:30 +08:00
世界
00d23d275d Add UDP timeout route option 2025-01-13 15:14:30 +08:00
世界
9dcabfd266 Add override destination to route options 2025-01-13 15:14:30 +08:00
世界
dbffc1982e Refactor multi networks strategy 2025-01-13 15:14:30 +08:00
世界
3eee2a4c04 Add multi network dialing 2025-01-13 15:14:30 +08:00
世界
1a687a6d63 Add network_[type/is_expensive/is_constrained] rule items 2025-01-13 15:14:29 +08:00
世界
fbfefedd1f Merge route options to route actions 2025-01-13 15:14:29 +08:00
世界
25d261df35 refactor: Extract services form router 2025-01-13 15:14:29 +08:00
世界
c493cc521f refactor: Modular network manager 2025-01-13 15:14:29 +08:00
世界
cc924c1a60 refactor: Modular inbound/outbound manager 2025-01-13 15:14:29 +08:00
世界
078de6c0fe Migrate bad options to library 2025-01-13 15:14:29 +08:00
世界
ecb69d41bc Improve rule actions 2025-01-13 15:14:29 +08:00
世界
0c993f6f0c Remove unused reject methods 2025-01-13 15:14:29 +08:00
世界
725080267d Implement dns-hijack 2025-01-13 15:14:29 +08:00
世界
4eeeb9a78a Implement TCP and ICMP rejects 2025-01-13 15:14:29 +08:00