mirror of
https://github.com/SagerNet/sing-box.git
synced 2024-11-22 08:31:30 +00:00
platform: reset network on invalid power events
This commit is contained in:
parent
4f5e7b974d
commit
e2d3862e64
|
@ -13,33 +13,28 @@ type servicePauseFields struct {
|
||||||
func (s *BoxService) Pause() {
|
func (s *BoxService) Pause() {
|
||||||
s.pauseAccess.Lock()
|
s.pauseAccess.Lock()
|
||||||
defer s.pauseAccess.Unlock()
|
defer s.pauseAccess.Unlock()
|
||||||
|
|
||||||
if s.pauseTimer != nil {
|
if s.pauseTimer != nil {
|
||||||
s.pauseTimer.Stop()
|
s.pauseTimer.Stop()
|
||||||
}
|
}
|
||||||
|
|
||||||
s.pauseTimer = time.AfterFunc(time.Minute, s.pause)
|
s.pauseTimer = time.AfterFunc(time.Minute, s.pause)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *BoxService) pause() {
|
func (s *BoxService) pause() {
|
||||||
s.pauseAccess.Lock()
|
s.pauseAccess.Lock()
|
||||||
defer s.pauseAccess.Unlock()
|
defer s.pauseAccess.Unlock()
|
||||||
|
|
||||||
s.pauseManager.DevicePause()
|
s.pauseManager.DevicePause()
|
||||||
_ = s.instance.Router().ResetNetwork()
|
_ = s.instance.Router().ResetNetwork()
|
||||||
s.pauseTimer = nil
|
s.pauseTimer = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *BoxService) Wake() {
|
func (s *BoxService) Wake() {
|
||||||
|
_ = s.instance.Router().ResetNetwork()
|
||||||
s.pauseAccess.Lock()
|
s.pauseAccess.Lock()
|
||||||
defer s.pauseAccess.Unlock()
|
defer s.pauseAccess.Unlock()
|
||||||
|
|
||||||
if s.pauseTimer != nil {
|
if s.pauseTimer != nil {
|
||||||
s.pauseTimer.Stop()
|
s.pauseTimer.Stop()
|
||||||
s.pauseTimer = nil
|
s.pauseTimer = nil
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
s.pauseManager.DeviceWake()
|
s.pauseManager.DeviceWake()
|
||||||
_ = s.instance.Router().ResetNetwork()
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue