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 {
3232 Close () error
3333 DefaultInterfaceName (destination netip.Addr ) string
3434 DefaultInterfaceIndex (destination netip.Addr ) int
35+ DefaultInterface (destination netip.Addr ) (string , int )
3536 OverrideAndroidVPN () bool
3637 AndroidVPNEnabled () bool
3738 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)
150150 return m .defaultInterfaceIndex
151151}
152152
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+
153167func (m * defaultInterfaceMonitor ) OverrideAndroidVPN () bool {
154168 return m .options .OverrideAndroidVPN
155169}
You can’t perform that action at this time.
0 commit comments