mirror of
https://github.com/SagerNet/sing-tun.git
synced 2025-04-05 12:57:39 +03:00
Do not submit EventNoRoute repeatedly
This commit is contained in:
parent
1c6d2891ab
commit
4efde6372e
1 changed files with 9 additions and 3 deletions
|
@ -42,6 +42,7 @@ type defaultInterfaceMonitor struct {
|
||||||
defaultInterfaceName string
|
defaultInterfaceName string
|
||||||
defaultInterfaceIndex int
|
defaultInterfaceIndex int
|
||||||
androidVPNEnabled bool
|
androidVPNEnabled bool
|
||||||
|
noRoute bool
|
||||||
networkMonitor NetworkUpdateMonitor
|
networkMonitor NetworkUpdateMonitor
|
||||||
checkUpdateTimer *time.Timer
|
checkUpdateTimer *time.Timer
|
||||||
element *list.Element[NetworkUpdateCallback]
|
element *list.Element[NetworkUpdateCallback]
|
||||||
|
@ -86,11 +87,16 @@ func (m *defaultInterfaceMonitor) postCheckUpdate() {
|
||||||
}
|
}
|
||||||
err = m.checkUpdate()
|
err = m.checkUpdate()
|
||||||
if errors.Is(err, ErrNoRoute) {
|
if errors.Is(err, ErrNoRoute) {
|
||||||
|
if !m.noRoute {
|
||||||
|
m.noRoute = true
|
||||||
m.defaultInterfaceName = ""
|
m.defaultInterfaceName = ""
|
||||||
m.defaultInterfaceIndex = -1
|
m.defaultInterfaceIndex = -1
|
||||||
m.emit(EventNoRoute)
|
m.emit(EventNoRoute)
|
||||||
|
}
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
m.logger.Error("check interface: ", err)
|
m.logger.Error("check interface: ", err)
|
||||||
|
} else {
|
||||||
|
m.noRoute = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue