Wait a second before check route update

This commit is contained in:
世界 2022-08-20 13:40:07 +08:00
parent 0ea2fbc278
commit ce3573838b
No known key found for this signature in database
GPG key ID: CD109927C34A63C4

View file

@ -7,6 +7,7 @@ import (
"sync"
"github.com/sagernet/sing/common/x/list"
"time"
)
func (m *networkUpdateMonitor) RegisterCallback(callback NetworkUpdateCallback) *list.Element[NetworkUpdateCallback] {
@ -57,10 +58,15 @@ func (m *defaultInterfaceMonitor) Start() error {
if err != nil {
return err
}
m.element = m.networkMonitor.RegisterCallback(m.checkUpdate)
m.element = m.networkMonitor.RegisterCallback(m.delayCheckUpdate)
return nil
}
func (m *defaultInterfaceMonitor) delayCheckUpdate() error {
time.Sleep(time.Second)
return m.checkUpdate()
}
func (m *defaultInterfaceMonitor) Close() error {
m.networkMonitor.UnregisterCallback(m.element)
return nil