Fix system nat mapping

This commit is contained in:
世界 2023-04-18 21:21:59 +08:00
parent bf7110b1ab
commit 53f50347e0
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
4 changed files with 60 additions and 23 deletions

View file

@ -1,6 +1,8 @@
package tun
import (
"context"
"github.com/sagernet/sing/common"
"github.com/sagernet/sing/common/cache"
)
@ -9,9 +11,10 @@ type RouteMapping struct {
status *cache.LruCache[RouteSession, RouteAction]
}
func NewRouteMapping(maxAge int64) *RouteMapping {
func NewRouteMapping(ctx context.Context, maxAge int64) *RouteMapping {
return &RouteMapping{
status: cache.New(
cache.WithContext[RouteSession, RouteAction](ctx),
cache.WithAge[RouteSession, RouteAction](maxAge),
cache.WithUpdateAgeOnGet[RouteSession, RouteAction](),
cache.WithEvict[RouteSession, RouteAction](func(key RouteSession, conn RouteAction) {