Add no route event
This commit is contained in:
parent
688d4da4b7
commit
59b86002c4
2 changed files with 9 additions and 3 deletions
|
|
@ -15,8 +15,9 @@ type (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
EventInterfaceUpdate = 1
|
EventInterfaceUpdate = iota
|
||||||
EventAndroidVPNUpdate = 2
|
EventAndroidVPNUpdate
|
||||||
|
EventNoRoute
|
||||||
)
|
)
|
||||||
|
|
||||||
type NetworkUpdateMonitor interface {
|
type NetworkUpdateMonitor interface {
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ package tun
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"net"
|
"net"
|
||||||
"net/netip"
|
"net/netip"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
@ -84,7 +85,11 @@ func (m *defaultInterfaceMonitor) delayCheckUpdate() error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
m.networkMonitor.NewError(context.Background(), E.Cause(err, "update interfaces"))
|
m.networkMonitor.NewError(context.Background(), E.Cause(err, "update interfaces"))
|
||||||
}
|
}
|
||||||
return m.checkUpdate()
|
err = m.checkUpdate()
|
||||||
|
if errors.Is(err, ErrNoRoute) {
|
||||||
|
m.emit(EventNoRoute)
|
||||||
|
}
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *defaultInterfaceMonitor) updateInterfaces() error {
|
func (m *defaultInterfaceMonitor) updateInterfaces() error {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue