Commit Graph

14 Commits

Author SHA1 Message Date
世界
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
世界
da06212268 Remove overdue deprecated features 2026-03-01 12:30:43 +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
世界
f75ade1991 refactor: DNS 2025-07-08 13:12:14 +08:00
世界
7208efe294 Fix panic on some stupid input 2025-04-25 16:03:58 +08:00
世界
dbffc1982e Refactor multi networks strategy 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
世界
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
世界
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
世界
1a91743254 Crazy sekai overturns the small pond 2025-01-13 15:14:29 +08:00