Compare commits

..

108 Commits

Author SHA1 Message Date
renovate[bot]
79bd6c53b1
[dependencies] Update golangci/golangci-lint-action action to v8 2025-06-19 05:06:17 +00:00
世界
16f243b615
documentation: Bump version 2025-06-19 12:17:14 +08:00
世界
89dadbd7d5
Add API to dump AdGuard rules 2025-06-19 12:15:17 +08:00
Sukka
c127a03a61
Improve AdGuard rule-set parser 2025-06-19 12:15:17 +08:00
Restia-Ashbell
b1753b978a
Add ECH support for uTLS 2025-06-19 12:15:17 +08:00
世界
2b88615693
Improve TLS fragments 2025-06-19 12:15:17 +08:00
世界
6ab91ceaac
Add cache support for ssm-api 2025-06-19 12:15:17 +08:00
世界
b01f4f8874
Fix service will not be closed 2025-06-19 12:15:17 +08:00
世界
4376079441
Add loopback address support for tun 2025-06-19 12:15:17 +08:00
世界
c38b73b1b8
release: Update Go to 1.24.4 2025-06-19 12:14:35 +08:00
世界
b92af5b310
Fix tproxy listener 2025-06-19 12:14:35 +08:00
世界
fe7ab6da64
Fix systemd package 2025-06-19 12:14:35 +08:00
世界
996d9bcacf
Fix missing home for derp service 2025-06-19 12:14:34 +08:00
Zero Clover
bd3a0d7c87
documentation: Fix services 2025-06-19 12:14:34 +08:00
世界
9cbacd92cf
Fix dns.client_subnet ignored 2025-06-19 12:14:34 +08:00
世界
aec889fb3a
documentation: Minor fixes 2025-06-19 12:14:34 +08:00
世界
2dc52b695d
Fix tailscale forward 2025-06-19 12:14:34 +08:00
世界
9ca55bdfe0
Minor fixes 2025-06-19 12:14:34 +08:00
世界
62ee191e3b
Add SSM API service 2025-06-19 12:14:33 +08:00
世界
14addc9373
Add resolved service and DNS server 2025-06-19 12:14:33 +08:00
世界
754e525fa2
Add DERP service 2025-06-19 12:14:32 +08:00
世界
49e5bb51b4
Add service component type 2025-06-19 12:14:32 +08:00
世界
2a351d6496
Fix tproxy tcp control 2025-06-19 12:14:32 +08:00
愚者
9e994a87de
release: Fix build tags for android
Signed-off-by: 愚者 <11926619+FansChou@users.noreply.github.com>
2025-06-19 12:14:32 +08:00
世界
196bd238ab
prevent creation of bind and mark controls on unsupported platforms 2025-06-19 12:14:31 +08:00
PuerNya
b0815ab5aa
documentation: Fix description of reject DNS action behavior 2025-06-19 12:14:31 +08:00
Restia-Ashbell
62bf87e6a2
Fix TLS record fragment 2025-06-19 12:14:31 +08:00
世界
5d79da1099
Add missing accept_routes option for Tailscale 2025-06-19 12:14:30 +08:00
世界
5e32528ffc
Add TLS record fragment support 2025-06-19 12:14:30 +08:00
世界
a8b56269db
Fix set edns0 client subnet 2025-06-19 12:14:30 +08:00
世界
fbd90c8131
Update minor dependencies 2025-06-19 12:14:29 +08:00
世界
63639c0a08
Update certmagic and providers 2025-06-19 12:14:29 +08:00
世界
fd68eeffc3
Update protobuf and grpc 2025-06-19 12:14:29 +08:00
世界
3d1eb5fc58
Add control options for listeners 2025-06-19 12:14:29 +08:00
世界
1a2b8c683b
Update quic-go to v0.52.0 2025-06-19 12:14:29 +08:00
世界
4b20c9a9a9
Update utls to v1.7.2 2025-06-19 12:14:29 +08:00
世界
6ea2d0fa7a
Handle EDNS version downgrade 2025-06-19 12:14:28 +08:00
世界
3a2eb2b4a5
documentation: Fix anytls padding scheme description 2025-06-19 12:14:28 +08:00
安容
8728851e0e
Report invalid DNS address early 2025-06-19 12:14:28 +08:00
世界
91f7485fac
Fix wireguard listen_port 2025-06-19 12:14:27 +08:00
世界
b1ec380e68
clash-api: Add more meta api 2025-06-19 12:14:27 +08:00
世界
a38a8278f4
Fix DNS lookup 2025-06-19 12:14:27 +08:00
世界
c819543fd3
Fix fetch ECH configs 2025-06-19 12:14:26 +08:00
reletor
728bf5b5fb
documentation: Minor fixes 2025-06-19 12:14:26 +08:00
caelansar
51df85e22c
Fix callback deletion in UDP transport 2025-06-19 12:14:26 +08:00
世界
ce0029f4dd
documentation: Try to make the play review happy 2025-06-19 12:14:25 +08:00
世界
68f6815f0b
Fix missing handling of legacy domain_strategy options 2025-06-19 12:14:25 +08:00
世界
b3c4ef0ff9
Improve local DNS server 2025-06-19 12:14:24 +08:00
anytls
7f02fc72da
Update anytls
Co-authored-by: anytls <anytls>
2025-06-19 12:14:24 +08:00
世界
a075cca385
Fix DNS dialer 2025-06-19 12:14:24 +08:00
世界
ae4afbcc03
release: Skip override version for iOS 2025-06-19 12:14:23 +08:00
iikira
58c7c0555b
Fix UDP DNS server crash
Signed-off-by: iikira <i2@mail.iikira.com>
2025-06-19 12:14:23 +08:00
ReleTor
5899b04f38
Fix fetch ECH configs 2025-06-19 12:14:23 +08:00
世界
1faf5d422f
Allow direct outbounds without domain_resolver 2025-06-19 12:14:23 +08:00
世界
70bacb9934
Fix Tailscale dialer 2025-06-19 12:14:23 +08:00
dyhkwong
b73be3b29c
Fix DNS over QUIC stream close 2025-06-19 12:14:22 +08:00
anytls
5f41190a15
Update anytls
Co-authored-by: anytls <anytls>
2025-06-19 12:14:22 +08:00
Rambling2076
225bc2a66d
Fix missing with_tailscale in Dockerfile
Signed-off-by: Rambling2076 <Rambling2076@proton.me>
2025-06-19 12:14:21 +08:00
世界
8c73ea38b7
Fail when default DNS server not found 2025-06-19 12:14:21 +08:00
世界
3c572b6352
Update gVisor to 20250319.0 2025-06-19 12:14:21 +08:00
世界
7cbdf206e2
Explicitly reject detour to empty direct outbounds 2025-06-19 12:14:21 +08:00
世界
233952248e
Add netns support 2025-06-19 12:14:21 +08:00
世界
db378108cb
Add wildcard name support for predefined records 2025-06-19 12:14:20 +08:00
世界
a6e19c2da9
Remove map usage in options 2025-06-19 12:14:20 +08:00
世界
9bd4d8b68c
Fix unhandled DNS loop 2025-06-19 12:14:20 +08:00
世界
9eea149a0a
Add wildcard-sni support for shadow-tls inbound 2025-06-19 12:14:20 +08:00
k9982874
3413225a2e
Add ntp protocol sniffing 2025-06-19 12:14:19 +08:00
世界
b9056f75e7
option: Fix marshal legacy DNS options 2025-06-19 12:14:19 +08:00
世界
07f6d8e687
Make domain_resolver optional when only one DNS server is configured 2025-06-19 12:14:19 +08:00
世界
19f8b2d792
Fix DNS lookup context pollution 2025-06-19 12:14:19 +08:00
世界
c6d3ba5ff3
Fix http3 DNS server connecting to wrong address 2025-06-19 12:14:18 +08:00
Restia-Ashbell
21a30285a2
documentation: Fix typo 2025-06-19 12:14:17 +08:00
anytls
42166f8835
Update sing-anytls
Co-authored-by: anytls <anytls>
2025-06-19 12:14:17 +08:00
k9982874
df6080d679
Fix hosts DNS server 2025-06-19 12:14:17 +08:00
世界
642efd2c49
Fix UDP DNS server crash 2025-06-19 12:14:17 +08:00
世界
bde5ff8f50
documentation: Fix missing ip_accept_any DNS rule option 2025-06-19 12:14:16 +08:00
世界
9664a24885
Fix anytls dialer usage 2025-06-19 12:14:16 +08:00
世界
fe90f42c8b
Move predefined DNS server to rule action 2025-06-19 12:14:16 +08:00
世界
61e74411dd
Fix domain resolver on direct outbound 2025-06-19 12:14:16 +08:00
Zephyruso
eb7760e7ba
Fix missing AnyTLS display name 2025-06-19 12:14:15 +08:00
anytls
5ca6fd5f3f
Update sing-anytls
Co-authored-by: anytls <anytls>
2025-06-19 12:14:15 +08:00
Estel
6f689370ee
documentation: Fix typo
Signed-off-by: Estel <callmebedrockdigger@gmail.com>
2025-06-19 12:14:15 +08:00
TargetLocked
2d3e3ad3b0
Fix parsing legacy DNS options 2025-06-19 12:14:14 +08:00
世界
12aa261d50
Fix DNS fallback 2025-06-19 12:14:14 +08:00
世界
6ef834a411
documentation: Fix missing hosts DNS server 2025-06-19 12:14:14 +08:00
anytls
d6860563c0
Add MinIdleSession option to AnyTLS outbound
Co-authored-by: anytls <anytls>
2025-06-19 12:14:14 +08:00
ReleTor
7a0ed4fc4b
documentation: Minor fixes 2025-06-19 12:14:14 +08:00
libtry486
232a5f3888
documentation: Fix typo
fix typo

Signed-off-by: libtry486 <89328481+libtry486@users.noreply.github.com>
2025-06-19 12:14:13 +08:00
Alireza Ahmadi
8703aa5d3e
Fix Outbound deadlock 2025-06-19 12:14:13 +08:00
世界
73d4445791
documentation: Fix AnyTLS doc 2025-06-19 12:14:12 +08:00
anytls
cda2a4397d
Add AnyTLS protocol 2025-06-19 12:14:12 +08:00
世界
8bdbb754ab
Migrate to stdlib ECH support 2025-06-19 12:14:11 +08:00
世界
fd152bac0f
Add fallback local DNS server for iOS 2025-06-19 12:14:11 +08:00
世界
8d4eb01e3b
Get darwin local DNS server from libresolv 2025-06-19 12:14:11 +08:00
世界
c4e5acbb47
Improve resolve action 2025-06-19 12:14:11 +08:00
世界
b0cf71773c
Add back port hopping to hysteria 1 2025-06-19 12:14:10 +08:00
xchacha20-poly1305
47c28fbfd4
Remove single quotes of raw Moziila certs 2025-06-19 12:14:10 +08:00
世界
68303d16ee
Add Tailscale endpoint 2025-06-19 12:14:10 +08:00
世界
10b5a91fdd
Build legacy binaries with latest Go 2025-06-19 12:14:10 +08:00
世界
23b04302f1
documentation: Remove outdated icons 2025-06-19 12:14:10 +08:00
世界
ab6c64f978
documentation: Certificate store 2025-06-19 12:14:09 +08:00
世界
3d3cd7fd92
documentation: TLS fragment 2025-06-19 12:14:09 +08:00
世界
b636fc7d4f
documentation: Outbound domain resolver 2025-06-19 12:14:09 +08:00
世界
894fd841c0
documentation: Refactor DNS 2025-06-19 12:14:09 +08:00
世界
c9c5d6e146
Add certificate store 2025-06-19 12:14:08 +08:00
世界
b13cbfbcb4
Add TLS fragment support 2025-06-19 12:14:08 +08:00
世界
32c26d8055
refactor: Outbound domain resolver 2025-06-19 12:14:08 +08:00
世界
b4b00e7686
refactor: DNS 2025-06-19 12:14:08 +08:00
9 changed files with 50 additions and 61 deletions

View File

@ -46,7 +46,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ^1.24
go-version: ^1.24.4
- name: Check input version
if: github.event_name == 'workflow_dispatch'
run: |-
@ -109,7 +109,7 @@ jobs:
if: ${{ ! matrix.legacy_go }}
uses: actions/setup-go@v5
with:
go-version: ^1.24
go-version: ^1.24.4
- name: Cache Legacy Go
if: matrix.require_legacy_go
id: cache-legacy-go
@ -294,7 +294,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ^1.24
go-version: ^1.24.4
- name: Setup Android NDK
id: setup-ndk
uses: nttld/setup-ndk@v1
@ -374,7 +374,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ^1.24
go-version: ^1.24.4
- name: Setup Android NDK
id: setup-ndk
uses: nttld/setup-ndk@v1
@ -472,7 +472,7 @@ jobs:
if: matrix.if
uses: actions/setup-go@v5
with:
go-version: ^1.24
go-version: ^1.24.4
- name: Setup Xcode stable
if: matrix.if && github.ref == 'refs/heads/main-next'
run: |-

View File

@ -28,7 +28,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ^1.24
go-version: ^1.24.4
- name: golangci-lint
uses: golangci/golangci-lint-action@v8
with:

View File

@ -25,7 +25,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ^1.24
go-version: ^1.24.4
- name: Check input version
if: github.event_name == 'workflow_dispatch'
run: |-
@ -66,7 +66,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ^1.24
go-version: ^1.24.4
- name: Setup Android NDK
if: matrix.os == 'android'
uses: nttld/setup-ndk@v1

View File

@ -40,7 +40,12 @@ parseLine:
if ruleLine == "" {
continue
}
if strings.HasPrefix(ruleLine, "!") || strings.HasPrefix(ruleLine, "#") {
if strings.Contains(ruleLine, "!") {
continue
}
if strings.Contains(ruleLine, "#") {
ignoredLines++
logger.Debug("ignored unsupported cosmetic filter: ", ruleLine)
continue
}
originRuleLine := ruleLine
@ -142,9 +147,12 @@ parseLine:
logger.Debug("ignored unsupported rule with query: ", ruleLine)
continue
}
if strings.Contains(ruleLine, "[") || strings.Contains(ruleLine, "]") ||
strings.Contains(ruleLine, "(") || strings.Contains(ruleLine, ")") ||
strings.Contains(ruleLine, "!") || strings.Contains(ruleLine, "#") {
if strings.Contains(ruleLine, "[") || strings.Contains(ruleLine, "]") {
ignoredLines++
logger.Debug("ignored unsupported cosmetic filter: ", ruleLine)
continue
}
if strings.Contains(ruleLine, "(") || strings.Contains(ruleLine, ")") {
ignoredLines++
logger.Debug("ignored unsupported cosmetic filter: ", ruleLine)
continue
@ -294,9 +302,7 @@ parseLine:
},
}
}
if ignoredLines > 0 {
logger.Info("parsed rules: ", len(ruleLines), "/", len(ruleLines)+ignoredLines)
}
logger.Info("parsed rules: ", len(ruleLines), "/", len(ruleLines)+ignoredLines)
return []option.HeadlessRule{currentRule}, nil
}

2
go.mod
View File

@ -34,7 +34,7 @@ require (
github.com/sagernet/sing-shadowsocks v0.2.8
github.com/sagernet/sing-shadowsocks2 v0.2.1
github.com/sagernet/sing-shadowtls v0.2.1-0.20250503051639-fcd445d33c11
github.com/sagernet/sing-tun v0.6.10-0.20250620051458-5e343c4b66b2
github.com/sagernet/sing-tun v0.6.9-0.20250617062442-df4458520f26
github.com/sagernet/sing-vmess v0.2.4-0.20250605032146-38cc72672c88
github.com/sagernet/smux v1.5.34-mod.2
github.com/sagernet/tailscale v1.80.3-mod.5

4
go.sum
View File

@ -180,8 +180,8 @@ github.com/sagernet/sing-shadowsocks2 v0.2.1 h1:dWV9OXCeFPuYGHb6IRqlSptVnSzOelnq
github.com/sagernet/sing-shadowsocks2 v0.2.1/go.mod h1:RnXS0lExcDAovvDeniJ4IKa2IuChrdipolPYWBv9hWQ=
github.com/sagernet/sing-shadowtls v0.2.1-0.20250503051639-fcd445d33c11 h1:tK+75l64tm9WvEFrYRE1t0YxoFdWQqw/h7Uhzj0vJ+w=
github.com/sagernet/sing-shadowtls v0.2.1-0.20250503051639-fcd445d33c11/go.mod h1:sWqKnGlMipCHaGsw1sTTlimyUpgzP4WP3pjhCsYt9oA=
github.com/sagernet/sing-tun v0.6.10-0.20250620051458-5e343c4b66b2 h1:ykbqGFHDNVvp0jhgLime/XBAtQpcOcFpT8Rs5Hcc5n4=
github.com/sagernet/sing-tun v0.6.10-0.20250620051458-5e343c4b66b2/go.mod h1:fisFCbC4Vfb6HqQNcwPJi2CDK2bf0Xapyz3j3t4cnHE=
github.com/sagernet/sing-tun v0.6.9-0.20250617062442-df4458520f26 h1:N9yAoqtQlawlJzLONjdQvIO3GJLEg9tZBfyKToSi0cM=
github.com/sagernet/sing-tun v0.6.9-0.20250617062442-df4458520f26/go.mod h1:fisFCbC4Vfb6HqQNcwPJi2CDK2bf0Xapyz3j3t4cnHE=
github.com/sagernet/sing-vmess v0.2.4-0.20250605032146-38cc72672c88 h1:0pVm8sPOel+BoiCddW3pV3cKDKEaSioVTYDdTSKjyFI=
github.com/sagernet/sing-vmess v0.2.4-0.20250605032146-38cc72672c88/go.mod h1:IL8Rr+EGwuqijszZkNrEFTQDKhilEpkqFqOlvdpS6/w=
github.com/sagernet/smux v1.5.34-mod.2 h1:gkmBjIjlJ2zQKpLigOkFur5kBKdV6bNRoFu2WkltRQ4=

View File

@ -2,6 +2,7 @@ package route
import (
"context"
"errors"
"net"
"time"
@ -9,7 +10,7 @@ import (
C "github.com/sagernet/sing-box/constant"
"github.com/sagernet/sing-box/dns"
dnsOutbound "github.com/sagernet/sing-box/protocol/dns"
R "github.com/sagernet/sing-box/route/rule"
"github.com/sagernet/sing-tun"
"github.com/sagernet/sing/common/buf"
E "github.com/sagernet/sing/common/exceptions"
"github.com/sagernet/sing/common/logger"
@ -64,7 +65,7 @@ func (r *Router) hijackDNSPacket(ctx context.Context, conn N.PacketConn, packetB
func ExchangeDNSPacket(ctx context.Context, router adapter.DNSRouter, logger logger.ContextLogger, conn N.PacketConn, buffer *buf.Buffer, metadata adapter.InboundContext, destination M.Socksaddr) {
err := exchangeDNSPacket(ctx, router, conn, buffer, metadata, destination)
if err != nil && !R.IsRejected(err) && !E.IsClosedOrCanceled(err) {
if err != nil && !errors.Is(err, tun.ErrDrop) && !E.IsClosedOrCanceled(err) {
logger.ErrorContext(ctx, E.Cause(err, "process DNS packet"))
}
}

View File

@ -15,7 +15,7 @@ import (
"github.com/sagernet/sing-box/common/sniff"
C "github.com/sagernet/sing-box/constant"
"github.com/sagernet/sing-box/option"
R "github.com/sagernet/sing-box/route/rule"
"github.com/sagernet/sing-box/route/rule"
"github.com/sagernet/sing-mux"
"github.com/sagernet/sing-vmess"
"github.com/sagernet/sing/common"
@ -49,7 +49,7 @@ func (r *Router) RouteConnectionEx(ctx context.Context, conn net.Conn, metadata
err := r.routeConnection(ctx, conn, metadata, onClose)
if err != nil {
N.CloseOnHandshakeFailure(conn, onClose, err)
if E.IsClosedOrCanceled(err) || R.IsRejected(err) {
if E.IsClosedOrCanceled(err) {
r.logger.DebugContext(ctx, "connection closed: ", err)
} else {
r.logger.ErrorContext(ctx, err)
@ -99,7 +99,7 @@ func (r *Router) routeConnection(ctx context.Context, conn net.Conn, metadata ad
var selectedOutbound adapter.Outbound
if selectedRule != nil {
switch action := selectedRule.Action().(type) {
case *R.RuleActionRoute:
case *rule.RuleActionRoute:
var loaded bool
selectedOutbound, loaded = r.outbound.Outbound(action.Outbound)
if !loaded {
@ -110,10 +110,10 @@ func (r *Router) routeConnection(ctx context.Context, conn net.Conn, metadata ad
buf.ReleaseMulti(buffers)
return E.New("TCP is not supported by outbound: ", selectedOutbound.Tag())
}
case *R.RuleActionReject:
case *rule.RuleActionReject:
buf.ReleaseMulti(buffers)
return action.Error(ctx)
case *R.RuleActionHijackDNS:
case *rule.RuleActionHijackDNS:
for _, buffer := range buffers {
conn = bufio.NewCachedConn(conn, buffer)
}
@ -151,7 +151,7 @@ func (r *Router) RoutePacketConnection(ctx context.Context, conn N.PacketConn, m
}))
if err != nil {
conn.Close()
if E.IsClosedOrCanceled(err) || R.IsRejected(err) {
if E.IsClosedOrCanceled(err) {
r.logger.DebugContext(ctx, "connection closed: ", err)
} else {
r.logger.ErrorContext(ctx, err)
@ -168,7 +168,7 @@ func (r *Router) RoutePacketConnectionEx(ctx context.Context, conn N.PacketConn,
err := r.routePacketConnection(ctx, conn, metadata, onClose)
if err != nil {
N.CloseOnHandshakeFailure(conn, onClose, err)
if E.IsClosedOrCanceled(err) || R.IsRejected(err) {
if E.IsClosedOrCanceled(err) {
r.logger.DebugContext(ctx, "connection closed: ", err)
} else {
r.logger.ErrorContext(ctx, err)
@ -214,7 +214,7 @@ func (r *Router) routePacketConnection(ctx context.Context, conn N.PacketConn, m
var selectReturn bool
if selectedRule != nil {
switch action := selectedRule.Action().(type) {
case *R.RuleActionRoute:
case *rule.RuleActionRoute:
var loaded bool
selectedOutbound, loaded = r.outbound.Outbound(action.Outbound)
if !loaded {
@ -225,10 +225,10 @@ func (r *Router) routePacketConnection(ctx context.Context, conn N.PacketConn, m
N.ReleaseMultiPacketBuffer(packetBuffers)
return E.New("UDP is not supported by outbound: ", selectedOutbound.Tag())
}
case *R.RuleActionReject:
case *rule.RuleActionReject:
N.ReleaseMultiPacketBuffer(packetBuffers)
return action.Error(ctx)
case *R.RuleActionHijackDNS:
case *rule.RuleActionHijackDNS:
return r.hijackDNSPacket(ctx, conn, packetBuffers, metadata, onClose)
}
}
@ -266,7 +266,7 @@ func (r *Router) PreMatch(metadata adapter.InboundContext) error {
if selectedRule == nil {
return nil
}
rejectAction, isReject := selectedRule.Action().(*R.RuleActionReject)
rejectAction, isReject := selectedRule.Action().(*rule.RuleActionReject)
if !isReject {
return nil
}
@ -342,7 +342,7 @@ func (r *Router) matchRule(
//nolint:staticcheck
if metadata.InboundOptions != common.DefaultValue[option.InboundOptions]() {
if !preMatch && metadata.InboundOptions.SniffEnabled {
newBuffer, newPackerBuffers, newErr := r.actionSniff(ctx, metadata, &R.RuleActionSniff{
newBuffer, newPackerBuffers, newErr := r.actionSniff(ctx, metadata, &rule.RuleActionSniff{
OverrideDestination: metadata.InboundOptions.SniffOverrideDestination,
Timeout: time.Duration(metadata.InboundOptions.SniffTimeout),
}, inputConn, inputPacketConn, nil)
@ -357,7 +357,7 @@ func (r *Router) matchRule(
}
}
if C.DomainStrategy(metadata.InboundOptions.DomainStrategy) != C.DomainStrategyAsIS {
fatalErr = r.actionResolve(ctx, metadata, &R.RuleActionResolve{
fatalErr = r.actionResolve(ctx, metadata, &rule.RuleActionResolve{
Strategy: C.DomainStrategy(metadata.InboundOptions.DomainStrategy),
})
if fatalErr != nil {
@ -394,11 +394,11 @@ match:
}
}
}
var routeOptions *R.RuleActionRouteOptions
var routeOptions *rule.RuleActionRouteOptions
switch action := currentRule.Action().(type) {
case *R.RuleActionRoute:
case *rule.RuleActionRoute:
routeOptions = &action.RuleActionRouteOptions
case *R.RuleActionRouteOptions:
case *rule.RuleActionRouteOptions:
routeOptions = action
}
if routeOptions != nil {
@ -451,7 +451,7 @@ match:
}
}
switch action := currentRule.Action().(type) {
case *R.RuleActionSniff:
case *rule.RuleActionSniff:
if !preMatch {
newBuffer, newPacketBuffers, newErr := r.actionSniff(ctx, metadata, action, inputConn, inputPacketConn, buffers)
if newErr != nil {
@ -468,7 +468,7 @@ match:
selectedRuleIndex = currentRuleIndex
break match
}
case *R.RuleActionResolve:
case *rule.RuleActionResolve:
fatalErr = r.actionResolve(ctx, metadata, action)
if fatalErr != nil {
return
@ -488,7 +488,7 @@ match:
}
func (r *Router) actionSniff(
ctx context.Context, metadata *adapter.InboundContext, action *R.RuleActionSniff,
ctx context.Context, metadata *adapter.InboundContext, action *rule.RuleActionSniff,
inputConn net.Conn, inputPacketConn N.PacketConn, inputBuffers []*buf.Buffer,
) (buffer *buf.Buffer, packetBuffers []*N.PacketBuffer, fatalErr error) {
if sniff.Skip(metadata) {
@ -649,7 +649,7 @@ func (r *Router) actionSniff(
return
}
func (r *Router) actionResolve(ctx context.Context, metadata *adapter.InboundContext, action *R.RuleActionResolve) error {
func (r *Router) actionResolve(ctx context.Context, metadata *adapter.InboundContext, action *rule.RuleActionResolve) error {
if metadata.Destination.IsFqdn() {
var transport adapter.DNSTransport
if action.Server != "" {

View File

@ -2,7 +2,6 @@ package rule
import (
"context"
"errors"
"net/netip"
"strings"
"sync"
@ -285,23 +284,6 @@ func (r *RuleActionDirect) String() string {
return "direct" + r.description
}
type RejectedError struct {
Cause error
}
func (r *RejectedError) Error() string {
return "rejected"
}
func (r *RejectedError) Unwrap() error {
return r.Cause
}
func IsRejected(err error) bool {
var rejected *RejectedError
return errors.As(err, &rejected)
}
type RuleActionReject struct {
Method string
NoDrop bool
@ -325,9 +307,9 @@ func (r *RuleActionReject) Error(ctx context.Context) error {
var returnErr error
switch r.Method {
case C.RuleActionRejectMethodDefault:
returnErr = &RejectedError{syscall.ECONNREFUSED}
returnErr = syscall.ECONNREFUSED
case C.RuleActionRejectMethodDrop:
return &RejectedError{tun.ErrDrop}
return tun.ErrDrop
default:
panic(F.ToString("unknown reject method: ", r.Method))
}
@ -345,7 +327,7 @@ func (r *RuleActionReject) Error(ctx context.Context) error {
if ctx != nil {
r.logger.DebugContext(ctx, "dropped due to flooding")
}
return &RejectedError{tun.ErrDrop}
return tun.ErrDrop
}
return returnErr
}