Skip to content

Commit 06c4cce

Browse files
committed
Merge remote-tracking branch 'upstream/main'
# Conflicts: # core.go # go.mod # go.sum # v2ray.go
2 parents e3c518d + a1930df commit 06c4cce

File tree

7 files changed

+52
-22
lines changed

7 files changed

+52
-22
lines changed

.github/workflows/debug.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- name: Install Golang
2323
uses: actions/setup-go@v2
2424
with:
25-
go-version: 1.17.1
25+
go-version: 1.17.2
2626
- name: Build
2727
run: |
2828
./init.sh

core.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package libcore
22

33
import (
44
"github.com/sagernet/libping"
5-
"github.com/sirupsen/logrus"
65
"github.com/xtls/xray-core/common"
76
"os"
87
)
@@ -25,8 +24,6 @@ func closeIgnore(closer ...interface{}) {
2524
_ = ca.Close()
2625
} else if ia, ok := c.(common.Interruptible); ok {
2726
ia.Interrupt()
28-
} else {
29-
logrus.Debug("unable to close ", c)
3027
}
3128
}
3229
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ require (
1818
)
1919

2020
//replace gvisor.dev/gvisor v0.0.0 => ../gvisor
21-
replace gvisor.dev/gvisor v0.0.0 => github.com/sagernet/gvisor v0.0.0-20211014042916-8fb70a9d30b7
21+
replace gvisor.dev/gvisor v0.0.0 => github.com/sagernet/gvisor v0.0.0-20211022025201-1cae8baac6b3
2222

2323
//replace github.com/xtls/xray-core v1.4.5 => ../Xray-core
2424
replace github.com/xtls/xray-core v1.5.0 => github.com/xtls/xray-core v1.5.1-0.20211022054941-db69818f3719

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -587,8 +587,8 @@ github.com/sagernet/clash v1.6.5-0.20210913182617-681dd3780179 h1:sLv055kW5/TfTw
587587
github.com/sagernet/clash v1.6.5-0.20210913182617-681dd3780179/go.mod h1:uqS1RdH2tYclOyhr9HiEIiWRFCeWfmNarJSiVCtrJD8=
588588
github.com/sagernet/gomobile v0.0.0-20210905032500-701a995ff844 h1:o7izBZde2L5foPbQdYisY03y4+6T6UcUXOwR5MyQpUk=
589589
github.com/sagernet/gomobile v0.0.0-20210905032500-701a995ff844/go.mod h1:2Xj8wyq0y6G6B1gCNTzRcKqo+cyVKatMTNWUmxNYfI4=
590-
github.com/sagernet/gvisor v0.0.0-20211014042916-8fb70a9d30b7 h1:AvthsAyQVhhi6q0Ks5J4ZHyted5sIYFOUUnIiSsGEEU=
591-
github.com/sagernet/gvisor v0.0.0-20211014042916-8fb70a9d30b7/go.mod h1:m1RK/gef4nU1CWOFscQWVk7iUgGH2Hz9Ee+lgeCzOBo=
590+
github.com/sagernet/gvisor v0.0.0-20211022025201-1cae8baac6b3 h1:pwo8bcTHpmu6bh7DTyfEZWguvks9o1h7twRRRIA3o5M=
591+
github.com/sagernet/gvisor v0.0.0-20211022025201-1cae8baac6b3/go.mod h1:m1RK/gef4nU1CWOFscQWVk7iUgGH2Hz9Ee+lgeCzOBo=
592592
github.com/sagernet/libping v0.1.1 h1:uNMN/02fQmRbsgJ0EuxuM/Upq8FrVP4Xj2+LlYviIOs=
593593
github.com/sagernet/libping v0.1.1/go.mod h1:FhmyYM8L32JaKI08noqoS5cK+Gw/Q+4VDnI9WvP6Sp8=
594594
github.com/sagernet/sagerconnect v0.1.7 h1:VWNx8NJ2C52b7Mbpty/JMiYERK/nvXyHaUkX5yFRAk4=

gvisor/gvisor.go

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func (t *GVisor) Close() error {
3434

3535
const DefaultNIC tcpip.NICID = 0x01
3636

37-
func New(dev int32, mtu int32, handler tun.Handler, nicId tcpip.NICID, pcap bool, pcapFile *os.File, snapLen uint32) (*GVisor, error) {
37+
func New(dev int32, mtu int32, handler tun.Handler, nicId tcpip.NICID, pcap bool, pcapFile *os.File, snapLen uint32, ipv6Mode int32) (*GVisor, error) {
3838
var endpoint stack.LinkEndpoint
3939
endpoint, _ = newRwEndpoint(dev, mtu)
4040
if pcap {
@@ -44,18 +44,45 @@ func New(dev int32, mtu int32, handler tun.Handler, nicId tcpip.NICID, pcap bool
4444
}
4545
endpoint = pcapEndpoint
4646
}
47-
s := stack.New(stack.Options{
48-
NetworkProtocols: []stack.NetworkProtocolFactory{
49-
ipv4.NewProtocol,
50-
ipv6.NewProtocol,
51-
},
52-
TransportProtocols: []stack.TransportProtocolFactory{
53-
tcp.NewProtocol,
54-
udp.NewProtocol,
55-
icmp.NewProtocol4,
56-
icmp.NewProtocol6,
57-
},
58-
})
47+
var o stack.Options
48+
switch ipv6Mode {
49+
case 0:
50+
o = stack.Options{
51+
NetworkProtocols: []stack.NetworkProtocolFactory{
52+
ipv4.NewProtocol,
53+
},
54+
TransportProtocols: []stack.TransportProtocolFactory{
55+
tcp.NewProtocol,
56+
udp.NewProtocol,
57+
icmp.NewProtocol4,
58+
},
59+
}
60+
case 3:
61+
o = stack.Options{
62+
NetworkProtocols: []stack.NetworkProtocolFactory{
63+
ipv6.NewProtocol,
64+
},
65+
TransportProtocols: []stack.TransportProtocolFactory{
66+
tcp.NewProtocol,
67+
udp.NewProtocol,
68+
icmp.NewProtocol6,
69+
},
70+
}
71+
default:
72+
o = stack.Options{
73+
NetworkProtocols: []stack.NetworkProtocolFactory{
74+
ipv4.NewProtocol,
75+
ipv6.NewProtocol,
76+
},
77+
TransportProtocols: []stack.TransportProtocolFactory{
78+
tcp.NewProtocol,
79+
udp.NewProtocol,
80+
icmp.NewProtocol4,
81+
icmp.NewProtocol6,
82+
},
83+
}
84+
}
85+
s := stack.New(o)
5986
s.SetRouteTable([]tcpip.Route{
6087
{
6188
Destination: header.IPv4EmptySubnet,

tun.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ func NewTun2ray(fd int32, mtu int32, v2ray *V2RayInstance,
102102
}
103103
}
104104

105-
t.dev, err = gvisor.New(fd, mtu, t, gvisor.DefaultNIC, pcap, pcapFile, math.MaxUint32)
105+
t.dev, err = gvisor.New(fd, mtu, t, gvisor.DefaultNIC, pcap, pcapFile, math.MaxUint32, ipv6Mode)
106106
} else {
107107
dev := os.NewFile(uintptr(fd), "")
108108
if dev == nil {
@@ -482,3 +482,9 @@ func (t *natTable) GetOrCreateLock(key string) (*sync.Cond, bool) {
482482
func (t *natTable) Delete(key string) {
483483
t.mapping.Delete(key)
484484
}
485+
486+
var ipv6Mode int32
487+
488+
func SetIPv6Mode(mode int32) {
489+
ipv6Mode = mode
490+
}

v2ray.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
)
2525

2626
func GetV2RayVersion() string {
27-
return core.Version() + "-sn-5"
27+
return core.Version() + "-ax-6"
2828
}
2929

3030
type V2RayInstance struct {

0 commit comments

Comments
 (0)