Commit Graph

2290 Commits

Author SHA1 Message Date
世界
ed57bce5e1 docs: add evaluate action, response matching fields, and deprecation notices 2026-03-29 14:15:47 +08:00
世界
bff6ee1911 Use typed SVCB hint structs instead of string parsing 2026-03-29 14:01:36 +08:00
世界
4cfc1c6fbf option: reject nested rule actions 2026-03-29 12:31:56 +08:00
世界
385cd703d4 dns: make rule strategy legacy-only 2026-03-29 00:44:54 +08:00
世界
6083fe026f Make DNS match_response fail as a normal condition 2026-03-29 00:44:54 +08:00
世界
9941be6b6d Fix DNS rule-set ref handling 2026-03-29 00:44:54 +08:00
世界
44a487b7e9 Fix legacy DNS rule_set accept_empty matching 2026-03-29 00:44:54 +08:00
世界
495ec64da2 dns: restore lookup reject semantics 2026-03-29 00:44:54 +08:00
世界
ce6ec4871c 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-03-27 12:41:20 +08:00
世界
9a4e9c0379 Fix DNS record parsing and shutdown race 2026-03-27 12:41:20 +08:00
世界
5fd49b3752 dns: restore init validation and fix rule-set query type 2026-03-27 12:41:20 +08:00
世界
639bf8f4c3 dns: make rule path selection rule-set aware 2026-03-27 12:41:20 +08:00
世界
ac452580d6 dns: complete lookup rule execution in new mode 2026-03-27 12:41:19 +08:00
世界
40afb6525b Fix legacy DNS negation expansion 2026-03-27 12:41:19 +08:00
世界
20fa9d70c8 dns: isolate legacy pre-match semantics 2026-03-27 12:41:19 +08:00
世界
6c5f351dcf 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-03-27 12:41:19 +08:00
世界
354e2bbff7 Remove legacy DNS server formats 2026-03-27 12:41:19 +08:00
世界
93bc5caea9 dns: document non-response rule_set address-filter semantics 2026-03-27 12:41:19 +08:00
世界
264efce753 Fix DNS pre-match CIDR fail-closed semantics 2026-03-27 12:41:19 +08:00
世界
b74ac6a178 Fix DNS evaluate regressions 2026-03-27 12:41:19 +08:00
世界
2d40044978 dns: use response-only address matching 2026-03-27 12:41:18 +08:00
世界
85fa414474 Fix DNS match_response response address handling 2026-03-27 12:41:18 +08:00
世界
9b3415f7fc Fix DNS record parsing and matching regressions 2026-03-27 12:41:18 +08:00
世界
62247578f4 Fix DNS evaluate routing regressions 2026-03-27 12:41:18 +08:00
世界
30ece8cffc Reorder DNS rule item fields: match_response above address filter and response items, deprecated fields at bottom 2026-03-27 12:41:18 +08:00
世界
2e1fa1951e Add evaluate DNS rule action and related rule items 2026-03-27 12:41:18 +08:00
世界
fd09582c6a platform: Add HTTPResponse.WriteToWithProgress 2026-03-26 16:49:28 +08:00
世界
6c55bbd921 Bump version 2026-03-26 16:44:03 +08:00
nekohasekai
2e15cf82b2 Refactor ACME support to certificate provider 2026-03-26 16:44:03 +08:00
世界
6a7fe70ee8 cronet-go: Update chromium to 145.0.7632.159 2026-03-26 16:44:02 +08:00
世界
a6e4184252 documentation: Update descriptions for neighbor rules 2026-03-26 16:44:02 +08:00
世界
83b19121da Add macOS support for MAC and hostname rule items 2026-03-26 16:44:02 +08:00
世界
ddf24c2154 Add Android support for MAC and hostname rule items 2026-03-26 16:44:02 +08:00
世界
ede12fa117 Add MAC and hostname rule items 2026-03-26 16:44:02 +08:00
世界
e98b4ad449 Fix WireGuard shutdown race crashing
Stop peer goroutines before closing the TUN device to prevent
RoutineSequentialReceiver from calling Write on a nil dispatcher.
2026-03-26 16:33:21 +08:00
世界
d09182614c Bump version v1.13.4 2026-03-26 13:28:33 +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
世界
7425100bac release: Refactor release tracks for Linux packages and Docker
Support 4 release tracks instead of 2:
- sing-box / latest (stable release)
- sing-box-beta / latest-beta (stable pre-release)
- sing-box-testing / latest-testing (testing branch)
- sing-box-oldstable / latest-oldstable (oldstable branch)

Track is detected via git branch --contains and git tag,
replacing the old version-string hyphen check.
2026-03-24 15:03:43 +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
世界
a3623eb41a tun: Fix system stack rewriting TUN subnet destinations to loopback 2026-03-23 19:38:55 +08:00
世界
72bc4c1f87 Fix DNS transport returning error for empty AAAA response
Closes #3925
2026-03-23 19:21:55 +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
世界
d2a933784c Optimize Darwin process finder 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
世界
c13faa8e3c tailscale: Only set ProcessLocalIPs/ProcessSubnets for fake TUN 2026-03-23 14:16:40 +08:00
世界
7623bcd19e Fix DialerForICMPDestination 2026-03-23 13:58:55 +08:00
世界
795d1c2892 Fix nested rule-set match cache isolation 2026-03-23 12:26:19 +08:00