mirror of
https://github.com/SagerNet/sing-box.git
synced 2024-11-22 00:21:30 +00:00
Stop passing device sleep events on Android and Apple platforms
This commit is contained in:
parent
e77a8114c5
commit
0ca5909b06
|
@ -16,25 +16,18 @@ func (s *BoxService) Pause() {
|
||||||
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(3*time.Second, s.ResetNetwork)
|
||||||
}
|
|
||||||
|
|
||||||
func (s *BoxService) pause() {
|
|
||||||
s.pauseAccess.Lock()
|
|
||||||
defer s.pauseAccess.Unlock()
|
|
||||||
s.pauseManager.DevicePause()
|
|
||||||
_ = s.instance.Router().ResetNetwork()
|
|
||||||
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
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
s.pauseManager.DeviceWake()
|
s.pauseTimer = time.AfterFunc(3*time.Minute, s.ResetNetwork)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *BoxService) ResetNetwork() {
|
||||||
|
_ = s.instance.Router().ResetNetwork()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue