-
Notifications
You must be signed in to change notification settings - Fork 129
/
monitor.go
39 lines (32 loc) · 1.08 KB
/
monitor.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package tun
import (
"github.com/sagernet/sing/common/control"
E "github.com/sagernet/sing/common/exceptions"
"github.com/sagernet/sing/common/x/list"
)
var ErrNoRoute = E.New("no route to internet")
type (
NetworkUpdateCallback = func()
DefaultInterfaceUpdateCallback = func(defaultInterface *control.Interface, flags int)
)
const FlagAndroidVPNUpdate = 1 << iota
type NetworkUpdateMonitor interface {
Start() error
Close() error
RegisterCallback(callback NetworkUpdateCallback) *list.Element[NetworkUpdateCallback]
UnregisterCallback(element *list.Element[NetworkUpdateCallback])
}
type DefaultInterfaceMonitor interface {
Start() error
Close() error
DefaultInterface() *control.Interface
OverrideAndroidVPN() bool
AndroidVPNEnabled() bool
RegisterCallback(callback DefaultInterfaceUpdateCallback) *list.Element[DefaultInterfaceUpdateCallback]
UnregisterCallback(element *list.Element[DefaultInterfaceUpdateCallback])
}
type DefaultInterfaceMonitorOptions struct {
InterfaceFinder control.InterfaceFinder
OverrideAndroidVPN bool
UnderNetworkExtension bool
}