mirror of
https://github.com/SagerNet/sing-box.git
synced 2024-11-16 00:52:23 +08:00
platform: Export NeedWIFIState
for Android
This commit is contained in:
parent
bca0b86549
commit
5583e01c99
|
@ -33,6 +33,8 @@ type Router interface {
|
|||
|
||||
RuleSet(tag string) (RuleSet, bool)
|
||||
|
||||
NeedWIFIState() bool
|
||||
|
||||
Exchange(ctx context.Context, message *mdns.Msg) (*mdns.Msg, error)
|
||||
Lookup(ctx context.Context, domain string, strategy dns.DomainStrategy) ([]netip.Addr, error)
|
||||
LookupDefault(ctx context.Context, domain string) ([]netip.Addr, error)
|
||||
|
|
|
@ -77,6 +77,10 @@ func (s *BoxService) Close() error {
|
|||
return s.instance.Close()
|
||||
}
|
||||
|
||||
func (s *BoxService) NeedWIFIState() bool {
|
||||
return s.instance.Router().NeedWIFIState()
|
||||
}
|
||||
|
||||
var (
|
||||
_ platform.Interface = (*platformInterfaceWrapper)(nil)
|
||||
_ log.PlatformWriter = (*platformInterfaceWrapper)(nil)
|
||||
|
|
|
@ -560,13 +560,12 @@ func (r *Router) Start() error {
|
|||
}
|
||||
}
|
||||
}
|
||||
if needWIFIStateFromRuleSet || r.needWIFIState {
|
||||
if (needWIFIStateFromRuleSet || r.needWIFIState) && r.platformInterface != nil {
|
||||
monitor.Start("initialize WIFI state")
|
||||
if r.platformInterface != nil && r.interfaceMonitor != nil {
|
||||
r.interfaceMonitor.RegisterCallback(func(_ int) {
|
||||
r.updateWIFIState()
|
||||
})
|
||||
}
|
||||
r.needWIFIState = true
|
||||
r.interfaceMonitor.RegisterCallback(func(_ int) {
|
||||
r.updateWIFIState()
|
||||
})
|
||||
r.updateWIFIState()
|
||||
monitor.Finish()
|
||||
}
|
||||
|
@ -716,6 +715,10 @@ func (r *Router) RuleSet(tag string) (adapter.RuleSet, bool) {
|
|||
return ruleSet, loaded
|
||||
}
|
||||
|
||||
func (r *Router) NeedWIFIState() bool {
|
||||
return r.needWIFIState
|
||||
}
|
||||
|
||||
func (r *Router) RouteConnection(ctx context.Context, conn net.Conn, metadata adapter.InboundContext) error {
|
||||
if r.pauseManager.IsDevicePaused() {
|
||||
return E.New("reject connection to ", metadata.Destination, " while device paused")
|
||||
|
|
Loading…
Reference in New Issue
Block a user