~/Projects/sing-tun
git clone https://code.lsong.org/sing-tun
Commit
- Commit
- 45b089e6bbdc3da55c276cb01fea677a5c7146b8
- Author
- 世界 <[email protected]>
- Date
- 2023-03-23 14:17:48 +0800 +0800
- Diffstat
go.mod | 2 +- go.sum | 4 ++-- gvisor.go | 4 ++++ timeout.go | 14 --------------
Fix gVisor udp conn timeout
diff --git a/go.mod b/go.mod index 1693661c46fa3daf4ccb29904c6114176168d2c4..c4523dfebfcc61c540359529e8b7ca282afa8c93 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/fsnotify/fsnotify v1.6.0 github.com/sagernet/go-tun2socks v1.16.12-0.20220818015926-16cb67876a61 github.com/sagernet/netlink v0.0.0-20220905062125-8043b4a9aa97 - github.com/sagernet/sing v0.2.1-0.20230321172705-3e60222a1a7d + github.com/sagernet/sing v0.2.1-0.20230323071235-f8038854d286 golang.org/x/net v0.7.0 golang.org/x/sys v0.6.0 gvisor.dev/gvisor v0.0.0-20220901235040-6ca97ef2ce1c diff --git a/go.sum b/go.sum index 1cc7040ea633877dc63ff3d3dd959f515a6a2de3..289e60b2cd78ef61a96a0b6b9cb73aaf3b01501e 100644 --- a/go.sum +++ b/go.sum @@ -7,8 +7,8 @@ github.com/sagernet/go-tun2socks v1.16.12-0.20220818015926-16cb67876a61/go.mod h1:QUQ4RRHD6hGGHdFMEtR8T2P6GS6R3D/CXKdaYHKKXms= github.com/sagernet/netlink v0.0.0-20220905062125-8043b4a9aa97 h1:iL5gZI3uFp0X6EslacyapiRz7LLSJyr4RajF/BhMVyE= github.com/sagernet/netlink v0.0.0-20220905062125-8043b4a9aa97/go.mod h1:xLnfdiJbSp8rNqYEdIW/6eDO4mVoogml14Bh2hSiFpM= github.com/sagernet/sing v0.0.0-20220817130738-ce854cda8522/go.mod h1:QVsS5L/ZA2Q5UhQwLrn0Trw+msNd/NPGEhBKR/ioWiY= -github.com/sagernet/sing v0.2.1-0.20230321172705-3e60222a1a7d h1:ktk03rtgPqTDyUd2dWg1uzyr5RnptX8grSMvIzedJlQ= +github.com/sagernet/sing v0.2.1-0.20230323071235-f8038854d286 h1:0Td2b5l1KgrdlOnbRWgFFWsyb0TLoq/tP6j9Lut4JN0= -github.com/sagernet/sing v0.2.1-0.20230321172705-3e60222a1a7d/go.mod h1:9uHswk2hITw8leDbiLS/xn0t9nzBcbePxzm9PJhwdlw= +github.com/sagernet/sing v0.2.1-0.20230323071235-f8038854d286/go.mod h1:9uHswk2hITw8leDbiLS/xn0t9nzBcbePxzm9PJhwdlw= github.com/vishvananda/netns v0.0.0-20211101163701-50045581ed74 h1:gga7acRE695APm9hlsSMoOoE65U4/TcqNj90mc69Rlg= github.com/vishvananda/netns v0.0.0-20211101163701-50045581ed74/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0= golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= diff --git a/gvisor.go b/gvisor.go index b3a081c7163fa7997d3d5f3307ecd9898728ad81..972302af4f15962dd23606346f13f0bb2c423c22 100644 --- a/gvisor.go +++ b/gvisor.go @@ -9,6 +9,7 @@ "syscall" "time" "github.com/sagernet/sing/common/bufio" + "github.com/sagernet/sing/common/canceler" E "github.com/sagernet/sing/common/exceptions" "github.com/sagernet/sing/common/logger" M "github.com/sagernet/sing/common/metadata" @@ -207,8 +208,11 @@ go func() { var metadata M.Metadata metadata.Source = M.SocksaddrFromNet(lAddr) metadata.Destination = M.SocksaddrFromNet(rAddr) + "gvisor.dev/gvisor/pkg/tcpip/network/ipv6" + //go:build with_gvisor + "time" if hErr != nil { endpoint.Abort() } diff --git a/timeout.go b/timeout.go deleted file mode 100644 index 838ca6b530b1b1c9700a501c86dbaf829032293d..0000000000000000000000000000000000000000 --- a/timeout.go +++ /dev/null @@ -1,14 +0,0 @@ -package tun - -import "context" - -type needTimeoutKey struct{} - -func ContextWithNeedTimeout(ctx context.Context, need bool) context.Context { - return context.WithValue(ctx, (*needTimeoutKey)(nil), need) -} - -func NeedTimeoutFromContext(ctx context.Context) bool { - need, _ := ctx.Value((*needTimeoutKey)(nil)).(bool) - return need -}