Update sing-box core

This commit is contained in:
Sergei Maklagin
2026-03-10 04:50:32 +03:00
439 changed files with 30835 additions and 5833 deletions

View File

@@ -9,7 +9,6 @@ import (
"github.com/sagernet/sing-box/common/process"
"github.com/sagernet/sing-box/common/taskmonitor"
C "github.com/sagernet/sing-box/constant"
"github.com/sagernet/sing-box/experimental/libbox/platform"
"github.com/sagernet/sing-box/log"
"github.com/sagernet/sing-box/option"
R "github.com/sagernet/sing-box/route/rule"
@@ -39,8 +38,7 @@ type Router struct {
processSearcher process.Searcher
pauseManager pause.Manager
trackers []adapter.ConnectionTracker
platformInterface platform.Interface
needWIFIState bool
platformInterface adapter.PlatformInterface
started bool
}
@@ -59,8 +57,7 @@ func NewRouter(ctx context.Context, logFactory log.Factory, options option.Route
ruleSetMap: make(map[string]adapter.RuleSet),
needFindProcess: hasRule(options.Rules, isProcessRule) || hasDNSRule(dnsOptions.Rules, isProcessDNSRule) || options.FindProcess,
pauseManager: service.FromContext[pause.Manager](ctx),
platformInterface: service.FromContext[platform.Interface](ctx),
needWIFIState: hasRule(options.Rules, isWIFIRule) || hasDNSRule(dnsOptions.Rules, isWIFIDNSRule),
platformInterface: service.FromContext[adapter.PlatformInterface](ctx),
}
}
@@ -116,19 +113,21 @@ func (r *Router) Start(stage adapter.StartStage) error {
if cacheContext != nil {
cacheContext.Close()
}
r.network.Initialize(r.ruleSets)
needFindProcess := r.needFindProcess
for _, ruleSet := range r.ruleSets {
metadata := ruleSet.Metadata()
if metadata.ContainsProcessRule {
needFindProcess = true
}
if metadata.ContainsWIFIRule {
r.needWIFIState = true
}
}
if C.IsAndroid && r.platformInterface != nil {
needFindProcess = true
}
r.needFindProcess = needFindProcess
if needFindProcess {
if r.platformInterface != nil {
r.processSearcher = r.platformInterface
if r.platformInterface != nil && r.platformInterface.UsePlatformConnectionOwnerFinder() {
r.processSearcher = newPlatformSearcher(r.platformInterface)
} else {
monitor.Start("initialize process searcher")
searcher, err := process.NewSearcher(process.Config{
@@ -207,10 +206,6 @@ func (r *Router) RuleSet(tag string) (adapter.RuleSet, bool) {
return ruleSet, loaded
}
func (r *Router) NeedWIFIState() bool {
return r.needWIFIState
}
func (r *Router) Rules() []adapter.Rule {
return r.rules
}
@@ -219,6 +214,10 @@ func (r *Router) AppendTracker(tracker adapter.ConnectionTracker) {
r.trackers = append(r.trackers, tracker)
}
func (r *Router) NeedFindProcess() bool {
return r.needFindProcess
}
func (r *Router) ResetNetwork() {
r.network.ResetNetwork()
r.dns.ResetNetwork()