Improve monitor api

This commit is contained in:
世界 2022-08-04 21:06:56 +08:00
parent 2a1554dfd3
commit 7ee0d19103
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
8 changed files with 110 additions and 192 deletions

View file

@ -9,7 +9,7 @@ var ErrNoRoute = E.New("no route to internet")
type (
NetworkUpdateCallback = func() error
DefaultInterfaceUpdateCallback = func()
DefaultInterfaceUpdateCallback = func() error
)
type NetworkUpdateMonitor interface {
@ -17,6 +17,7 @@ type NetworkUpdateMonitor interface {
Close() error
RegisterCallback(callback NetworkUpdateCallback) *list.Element[NetworkUpdateCallback]
UnregisterCallback(element *list.Element[NetworkUpdateCallback])
E.Handler
}
type DefaultInterfaceMonitor interface {
@ -24,4 +25,6 @@ type DefaultInterfaceMonitor interface {
Close() error
DefaultInterfaceName() string
DefaultInterfaceIndex() int
RegisterCallback(callback DefaultInterfaceUpdateCallback) *list.Element[DefaultInterfaceUpdateCallback]
UnregisterCallback(element *list.Element[DefaultInterfaceUpdateCallback])
}