Fix platform interface monitor & Fix system tun stack for ios

This commit is contained in:
世界 2023-04-17 19:05:02 +08:00
parent 5e6e7923e4
commit ec8974673b
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
10 changed files with 68 additions and 13 deletions

View file

@ -15,6 +15,7 @@ import (
"github.com/sagernet/sing-box/adapter"
"github.com/sagernet/sing-box/common/dialer"
"github.com/sagernet/sing-box/common/dialer/conntrack"
"github.com/sagernet/sing-box/common/geoip"
"github.com/sagernet/sing-box/common/geosite"
"github.com/sagernet/sing-box/common/mux"
@ -268,9 +269,9 @@ func NewRouter(
router.transportMap = transportMap
router.transportDomainStrategy = transportDomainStrategy
needInterfaceMonitor := platformInterface == nil && (options.AutoDetectInterface || common.Any(inbounds, func(inbound option.Inbound) bool {
needInterfaceMonitor := options.AutoDetectInterface || common.Any(inbounds, func(inbound option.Inbound) bool {
return inbound.HTTPOptions.SetSystemProxy || inbound.MixedOptions.SetSystemProxy || inbound.TunOptions.AutoRoute
}))
})
if needInterfaceMonitor {
networkMonitor, err := tun.NewNetworkUpdateMonitor(router)
@ -1157,5 +1158,9 @@ func (r *Router) notifyNetworkUpdate(int) error {
}
}
}
if conntrack.Enabled {
conntrack.Close()
}
return nil
}