mirror of
https://github.com/SagerNet/sing-tun.git
synced 2025-04-03 03:47:39 +03:00
Wait a second before check route update
This commit is contained in:
parent
0ea2fbc278
commit
ce3573838b
1 changed files with 7 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue