File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ type DefaultInterfaceMonitor interface {
32
32
Close () error
33
33
DefaultInterfaceName (destination netip.Addr ) string
34
34
DefaultInterfaceIndex (destination netip.Addr ) int
35
+ DefaultInterface (destination netip.Addr ) (string , int )
35
36
OverrideAndroidVPN () bool
36
37
AndroidVPNEnabled () bool
37
38
RegisterCallback (callback DefaultInterfaceUpdateCallback ) * list.Element [DefaultInterfaceUpdateCallback ]
Original file line number Diff line number Diff line change @@ -150,6 +150,20 @@ func (m *defaultInterfaceMonitor) DefaultInterfaceIndex(destination netip.Addr)
150
150
return m .defaultInterfaceIndex
151
151
}
152
152
153
+ func (m * defaultInterfaceMonitor ) DefaultInterface (destination netip.Addr ) (string , int ) {
154
+ for _ , address := range m .networkAddresses {
155
+ for _ , prefix := range address .addresses {
156
+ if prefix .Contains (destination ) {
157
+ return address .interfaceName , address .interfaceIndex
158
+ }
159
+ }
160
+ }
161
+ if m .defaultInterfaceIndex == - 1 {
162
+ m .checkUpdate ()
163
+ }
164
+ return m .defaultInterfaceName , m .defaultInterfaceIndex
165
+ }
166
+
153
167
func (m * defaultInterfaceMonitor ) OverrideAndroidVPN () bool {
154
168
return m .options .OverrideAndroidVPN
155
169
}
You can’t perform that action at this time.
0 commit comments