mirror of
https://github.com/SagerNet/sing-box.git
synced 2024-11-22 00:21:30 +00:00
Fix enforced power listener on windows
This commit is contained in:
parent
e08c052fc9
commit
51964801ff
|
@ -352,14 +352,6 @@ func NewRouter(
|
||||||
router.interfaceMonitor = interfaceMonitor
|
router.interfaceMonitor = interfaceMonitor
|
||||||
}
|
}
|
||||||
|
|
||||||
if runtime.GOOS == "windows" {
|
|
||||||
powerListener, err := winpowrprof.NewEventListener(router.notifyWindowsPowerEvent)
|
|
||||||
if err != nil {
|
|
||||||
return nil, E.Cause(err, "initialize power listener")
|
|
||||||
}
|
|
||||||
router.powerListener = powerListener
|
|
||||||
}
|
|
||||||
|
|
||||||
if ntpOptions.Enabled {
|
if ntpOptions.Enabled {
|
||||||
ntpDialer, err := dialer.New(router, ntpOptions.DialerOptions)
|
ntpDialer, err := dialer.New(router, ntpOptions.DialerOptions)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -589,6 +581,15 @@ func (r *Router) Start() error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
powerListener, err := winpowrprof.NewEventListener(r.notifyWindowsPowerEvent)
|
||||||
|
if err == nil {
|
||||||
|
r.powerListener = powerListener
|
||||||
|
} else {
|
||||||
|
r.logger.Warn("initialize power listener: ", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if r.powerListener != nil {
|
if r.powerListener != nil {
|
||||||
monitor.Start("start power listener")
|
monitor.Start("start power listener")
|
||||||
err := r.powerListener.Start()
|
err := r.powerListener.Start()
|
||||||
|
|
Loading…
Reference in a new issue