diff --git a/monitor_shared.go b/monitor_shared.go index cede3a3..6980de5 100644 --- a/monitor_shared.go +++ b/monitor_shared.go @@ -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