Add DefaultInterface func

This commit is contained in:
世界 2023-10-01 01:00:51 +08:00
parent 56a9b85cf5
commit 1a85bd3ef4
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
2 changed files with 15 additions and 0 deletions

View file

@ -150,6 +150,20 @@ func (m *defaultInterfaceMonitor) DefaultInterfaceIndex(destination netip.Addr)
return m.defaultInterfaceIndex
}
func (m *defaultInterfaceMonitor) DefaultInterface(destination netip.Addr) (string, int) {
for _, address := range m.networkAddresses {
for _, prefix := range address.addresses {
if prefix.Contains(destination) {
return address.interfaceName, address.interfaceIndex
}
}
}
if m.defaultInterfaceIndex == -1 {
m.checkUpdate()
}
return m.defaultInterfaceName, m.defaultInterfaceIndex
}
func (m *defaultInterfaceMonitor) OverrideAndroidVPN() bool {
return m.options.OverrideAndroidVPN
}