Skip to content

Commit 9c6e70b

Browse files
committed
Revert LRU cache changes
1 parent d744d03 commit 9c6e70b

File tree

6 files changed

+8
-11
lines changed

6 files changed

+8
-11
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require (
66
github.com/fsnotify/fsnotify v1.6.0
77
github.com/sagernet/go-tun2socks v1.16.12-0.20220818015926-16cb67876a61
88
github.com/sagernet/netlink v0.0.0-20220905062125-8043b4a9aa97
9-
github.com/sagernet/sing v0.2.4-0.20230418025125-f196b4303e31
9+
github.com/sagernet/sing v0.2.4-0.20230419153323-5fae6fa434c1
1010
golang.org/x/net v0.8.0
1111
golang.org/x/sys v0.7.0
1212
gvisor.dev/gvisor v0.0.0-20220901235040-6ca97ef2ce1c

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ github.com/sagernet/go-tun2socks v1.16.12-0.20220818015926-16cb67876a61/go.mod h
77
github.com/sagernet/netlink v0.0.0-20220905062125-8043b4a9aa97 h1:iL5gZI3uFp0X6EslacyapiRz7LLSJyr4RajF/BhMVyE=
88
github.com/sagernet/netlink v0.0.0-20220905062125-8043b4a9aa97/go.mod h1:xLnfdiJbSp8rNqYEdIW/6eDO4mVoogml14Bh2hSiFpM=
99
github.com/sagernet/sing v0.0.0-20220817130738-ce854cda8522/go.mod h1:QVsS5L/ZA2Q5UhQwLrn0Trw+msNd/NPGEhBKR/ioWiY=
10-
github.com/sagernet/sing v0.2.4-0.20230418025125-f196b4303e31 h1:qgq8jeY/rbnY9NwYXByO//AP0ByIxnsKUxQx1tOB3W0=
11-
github.com/sagernet/sing v0.2.4-0.20230418025125-f196b4303e31/go.mod h1:Ta8nHnDLAwqySzKhGoKk4ZIB+vJ3GTKj7UPrWYvM+4w=
10+
github.com/sagernet/sing v0.2.4-0.20230419153323-5fae6fa434c1 h1:CdzNL25lzfVo0NMeghPqsupNsWvkzrbrUt5t8DoDPcQ=
11+
github.com/sagernet/sing v0.2.4-0.20230419153323-5fae6fa434c1/go.mod h1:Ta8nHnDLAwqySzKhGoKk4ZIB+vJ3GTKj7UPrWYvM+4w=
1212
github.com/vishvananda/netns v0.0.0-20211101163701-50045581ed74 h1:gga7acRE695APm9hlsSMoOoE65U4/TcqNj90mc69Rlg=
1313
github.com/vishvananda/netns v0.0.0-20211101163701-50045581ed74/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0=
1414
golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ=

gvisor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func NewGVisor(
6868
logger: options.Logger,
6969
}
7070
if gStack.router != nil {
71-
gStack.routeMapping = NewRouteMapping(options.Context, options.UDPTimeout)
71+
gStack.routeMapping = NewRouteMapping(options.UDPTimeout)
7272
}
7373
return gStack, nil
7474
}

gvisor_udp.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func NewUDPForwarder(ctx context.Context, stack *stack.Stack, handler Handler, u
2929
return &UDPForwarder{
3030
ctx: ctx,
3131
stack: stack,
32-
udpNat: udpnat.New[netip.AddrPort](ctx, udpTimeout, handler),
32+
udpNat: udpnat.New[netip.AddrPort](udpTimeout, handler),
3333
}
3434
}
3535

route_mapping.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package tun
22

33
import (
4-
"context"
5-
64
"github.com/sagernet/sing/common"
75
"github.com/sagernet/sing/common/cache"
86
)
@@ -11,10 +9,9 @@ type RouteMapping struct {
119
status *cache.LruCache[RouteSession, RouteAction]
1210
}
1311

14-
func NewRouteMapping(ctx context.Context, maxAge int64) *RouteMapping {
12+
func NewRouteMapping(maxAge int64) *RouteMapping {
1513
return &RouteMapping{
1614
status: cache.New(
17-
cache.WithContext[RouteSession, RouteAction](ctx),
1815
cache.WithAge[RouteSession, RouteAction](maxAge),
1916
cache.WithUpdateAgeOnGet[RouteSession, RouteAction](),
2017
cache.WithEvict[RouteSession, RouteAction](func(key RouteSession, conn RouteAction) {

system.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func NewSystem(options StackOptions) (Stack, error) {
6565
underPlatform: options.UnderPlatform,
6666
}
6767
if stack.router != nil {
68-
stack.routeMapping = NewRouteMapping(options.Context, options.UDPTimeout)
68+
stack.routeMapping = NewRouteMapping(options.UDPTimeout)
6969
}
7070
if len(options.Inet4Address) > 0 {
7171
if options.Inet4Address[0].Bits() == 32 {
@@ -118,7 +118,7 @@ func (s *System) Start() error {
118118
go s.acceptLoop(tcpListener)
119119
}
120120
s.tcpNat = NewNat(s.ctx, time.Second*time.Duration(s.udpTimeout))
121-
s.udpNat = udpnat.New[netip.AddrPort](s.ctx, s.udpTimeout, s.handler)
121+
s.udpNat = udpnat.New[netip.AddrPort](s.udpTimeout, s.handler)
122122
go s.tunLoop()
123123
return nil
124124
}

0 commit comments

Comments
 (0)