Update sing-box core

This commit is contained in:
Sergei Maklagin
2026-04-06 20:54:24 +03:00
162 changed files with 4889 additions and 1067 deletions

View File

@@ -4,6 +4,7 @@ import (
"context"
"os"
"runtime"
"time"
"github.com/sagernet/sing-box/adapter"
"github.com/sagernet/sing-box/common/process"
@@ -12,8 +13,11 @@ import (
"github.com/sagernet/sing-box/log"
"github.com/sagernet/sing-box/option"
R "github.com/sagernet/sing-box/route/rule"
"github.com/sagernet/sing/common"
E "github.com/sagernet/sing/common/exceptions"
"github.com/sagernet/sing/common/task"
"github.com/sagernet/sing/contrab/freelru"
"github.com/sagernet/sing/contrab/maphash"
"github.com/sagernet/sing/service"
"github.com/sagernet/sing/service/pause"
)
@@ -36,6 +40,7 @@ type Router struct {
ruleSets []adapter.RuleSet
ruleSetMap map[string]adapter.RuleSet
processSearcher process.Searcher
processCache freelru.Cache[processCacheKey, processCacheEntry]
pauseManager pause.Manager
trackers []adapter.ConnectionTracker
platformInterface adapter.PlatformInterface
@@ -144,6 +149,11 @@ func (r *Router) Start(stage adapter.StartStage) error {
}
}
}
if r.processSearcher != nil {
processCache := common.Must1(freelru.NewSharded[processCacheKey, processCacheEntry](256, maphash.NewHasher[processCacheKey]().Hash32))
processCache.SetLifetime(200 * time.Millisecond)
r.processCache = processCache
}
case adapter.StartStatePostStart:
for i, rule := range r.rules {
monitor.Start("initialize rule[", i, "]")
@@ -198,6 +208,13 @@ func (r *Router) Close() error {
})
monitor.Finish()
}
if r.processSearcher != nil {
monitor.Start("close process searcher")
err = E.Append(err, r.processSearcher.Close(), func(err error) error {
return E.Cause(err, "close process searcher")
})
monitor.Finish()
}
return err
}