Skip to content

Commit cf3e4b1

Browse files
committed
fix: auto-redirect android rules
1 parent 1457f83 commit cf3e4b1

File tree

5 files changed

+17
-5
lines changed

5 files changed

+17
-5
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ require (
2424
github.com/metacubex/sing-quic v0.0.0-20240518034124-7696d3f7da72
2525
github.com/metacubex/sing-shadowsocks v0.2.6
2626
github.com/metacubex/sing-shadowsocks2 v0.2.0
27-
github.com/metacubex/sing-tun v0.2.7-0.20240617013029-d05cf9df9cfe
27+
github.com/metacubex/sing-tun v0.2.7-0.20240622050320-d74a7240f063
2828
github.com/metacubex/sing-vmess v0.1.9-0.20231207122118-72303677451f
2929
github.com/metacubex/sing-wireguard v0.0.0-20240618022557-a6efaa37127a
3030
github.com/metacubex/tfo-go v0.0.0-20240228025757-be1269474a66

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ github.com/metacubex/sing-shadowsocks v0.2.6 h1:6oEB3QcsFYnNiFeoevcXrCwJ3sAablwV
116116
github.com/metacubex/sing-shadowsocks v0.2.6/go.mod h1:zIkMeSnb8Mbf4hdqhw0pjzkn1d99YJ3JQm/VBg5WMTg=
117117
github.com/metacubex/sing-shadowsocks2 v0.2.0 h1:hqwT/AfI5d5UdPefIzR6onGHJfDXs5zgOM5QSgaM/9A=
118118
github.com/metacubex/sing-shadowsocks2 v0.2.0/go.mod h1:LCKF6j1P94zN8ZS+LXRK1gmYTVGB3squivBSXAFnOg8=
119-
github.com/metacubex/sing-tun v0.2.7-0.20240617013029-d05cf9df9cfe h1:NrWjVEkRmEkdREVSpohMgEBoznS0PrRfJDr6iCV4348=
120-
github.com/metacubex/sing-tun v0.2.7-0.20240617013029-d05cf9df9cfe/go.mod h1:WwJGbCx7bQcBzuQXiDOJvZH27R0kIjKNNlISIWsL6kM=
119+
github.com/metacubex/sing-tun v0.2.7-0.20240622050320-d74a7240f063 h1:l0kqvpBCy1yUAlr79qc0w70nbELJiqs+tWH61b5poiU=
120+
github.com/metacubex/sing-tun v0.2.7-0.20240622050320-d74a7240f063/go.mod h1:WwJGbCx7bQcBzuQXiDOJvZH27R0kIjKNNlISIWsL6kM=
121121
github.com/metacubex/sing-vmess v0.1.9-0.20231207122118-72303677451f h1:QjXrHKbTMBip/C+R79bvbfr42xH1gZl3uFb0RELdZiQ=
122122
github.com/metacubex/sing-vmess v0.1.9-0.20231207122118-72303677451f/go.mod h1:olVkD4FChQ5gKMHG4ZzuD7+fMkJY1G8vwOKpRehjrmY=
123123
github.com/metacubex/sing-wireguard v0.0.0-20240618022557-a6efaa37127a h1:NpSGclHJUYndUwBmyIpFBSoBVg8PoVX7QQKhYg0DjM0=
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package sing_tun
2+
3+
const supportRedirect = true

listener/sing_tun/redirect_stub.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
//go:build !linux
2+
3+
package sing_tun
4+
5+
const supportRedirect = false

listener/sing_tun/server.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ func New(options LC.Tun, tunnel C.Tunnel, additions ...inbound.Addition) (l *Lis
132132
if options.GSOMaxSize == 0 {
133133
options.GSOMaxSize = 65536
134134
}
135-
if runtime.GOOS != "linux" {
135+
if !supportRedirect {
136136
options.AutoRedirect = false
137137
}
138138
tunName := options.Device
@@ -453,12 +453,16 @@ func (l *Listener) ruleUpdateCallback(ruleProvider provider.RuleProvider) {
453453
}
454454
}
455455

456+
type toIpCidr interface {
457+
ToIpCidr() *netipx.IPSet
458+
}
459+
456460
func (l *Listener) updateRule(ruleProvider provider.RuleProvider, exclude bool, update bool) {
457461
l.ruleUpdateMutex.Lock()
458462
defer l.ruleUpdateMutex.Unlock()
459463
name := ruleProvider.Name()
460464
switch rp := ruleProvider.Strategy().(type) {
461-
case interface{ ToIpCidr() *netipx.IPSet }:
465+
case toIpCidr:
462466
if !exclude {
463467
ipCidr := rp.ToIpCidr()
464468
if ipCidr != nil {

0 commit comments

Comments
 (0)