Skip to content

Commit 9c96487

Browse files
committed
ping: Fix mapping initialize
1 parent e8d7fc1 commit 9c96487

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

route_direct.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package tun
33
import (
44
"math"
55
"net/netip"
6+
"runtime"
67
"time"
78

89
"github.com/sagernet/sing/common"
@@ -30,7 +31,7 @@ type DirectRouteMapping struct {
3031
}
3132

3233
func NewDirectRouteMapping(timeout time.Duration) *DirectRouteMapping {
33-
mapping := common.Must1(freelru.NewSharded[DirectRouteSession, DirectRouteDestination](math.MaxUint16, maphash.NewHasher[DirectRouteSession]().Hash32))
34+
mapping := common.Must1(freelru.NewShardedWithSize[DirectRouteSession, DirectRouteDestination](uint32(runtime.GOMAXPROCS(0)*16), math.MaxUint16, math.MaxUint8, maphash.NewHasher[DirectRouteSession]().Hash32))
3435
mapping.SetHealthCheck(func(session DirectRouteSession, action DirectRouteDestination) bool {
3536
if action != nil {
3637
return !action.IsClosed()

0 commit comments

Comments
 (0)