Commit Graph

357 Commits

Author SHA1 Message Date
世界 279f815032 route: Refetch rule-set when cache restore fails 2026-05-19 22:05:25 +08:00
世界 21e27a26a0 Fix lint errors 2026-05-15 07:58:46 +08:00
世界 895bc40641 Fix reset network 2026-05-15 07:43:29 +08:00
macronut ef06e4c2c0 Add more spoof method
Signed-off-by: macronut <4027187+macronut@users.noreply.github.com>
2026-05-15 07:43:29 +08:00
世界 ac900b1742 Allow customizing TUN DNS mode and hijack interface DNS by default 2026-05-15 07:43:29 +08:00
世界 d02a055122 dns: Add preferred_by rule item 2026-05-15 07:43:29 +08:00
世界 d701464377 dns: Add neighbor-based hostname resolution to local server 2026-05-15 07:43:29 +08:00
世界 7b258f2430 dns: Add timeout configuration 2026-05-14 21:56:21 +08:00
世界 770a0c7499 Improve UDP batch support 2026-05-14 21:56:21 +08:00
世界 8224f2e5f9 Reject pure-IP rule-set references without match_response
DNS rules referencing rule-sets that contain only ip_cidr predicates
silently stopped matching when legacy DNS mode was disabled, because the
IP-CIDR branch cannot match against an in-flight DNS query. The existing
validation intentionally let every rule_set through on the premise that
mixed sets still work via their non-IP branches, which is only true when
such a branch exists. Track whether a rule-set carries any non-IP-CIDR
predicate and reject pure-IP references the same way bare ip_cidr fields
are already rejected.
2026-05-14 21:56:20 +08:00
世界 7fe1f47690 Fix legacy rule-set download_detour blocked by empty direct check 2026-05-14 21:56:20 +08:00
世界 195e129000 Refactor: HTTP clients, unified HTTP2/QUIC options, Apple engines 2026-05-14 21:56:20 +08:00
世界 6f23a9652b Add optimistic DNS cache 2026-05-14 21:56:20 +08:00
世界 0a9d8f945e Add package_name_regex route, DNS and headless rule item 2026-05-14 21:56:20 +08:00
世界 825f86af7d Un-deprecate ip_accept_any DNS rule item 2026-05-14 21:56:20 +08:00
nekohasekai 6fa641a277 Add evaluate DNS rule action and related rule items 2026-05-14 21:55:53 +08:00
世界 d0fd6f654b Add macOS support for MAC and hostname rule items 2026-05-14 16:37:10 +08:00
世界 9e548cb3e5 Add Android support for MAC and hostname rule items 2026-05-14 16:37:10 +08:00
世界 443bec777e Add MAC and hostname rule items 2026-05-14 16:36:54 +08:00
世界 5e7fd7ad78 Fix lint errors 2026-05-13 23:39:27 +08:00
世界 6475a5e036 Skip kickWriteHandshake for server first protocols 2026-05-13 16:28:49 +08:00
世界 f102ef1d94 Fix process search skipped for Android again 2026-04-23 05:52:22 +08:00
世界 71f6a2ab4e Fix process search skipped for TUN 2026-04-21 15:45:05 +08:00
世界 e4bc459975 Skip process search for non-local source addresses 2026-04-20 09:49:39 +08:00
世界 3124cdd661 Fix windows bssid matching 2026-04-20 09:49: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
世界 49056b5060 Fix ping domain 2026-01-17 05:46:01 +08:00
世界 e9c46cc359 Improve compatibility for kTLS 2026-01-17 05:46:00 +08:00
世界 107f92381b Add support for kTLS
Reference: https://gitlab.com/go-extension/tls
2026-01-17 05:44:42 +08:00