Fix macos monitor

This commit is contained in:
世界 2023-05-09 12:11:38 +08:00
parent 6999634511
commit 91df97aee2
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
2 changed files with 10 additions and 4 deletions

View file

@ -39,5 +39,6 @@ type DefaultInterfaceMonitor interface {
}
type DefaultInterfaceMonitorOptions struct {
OverrideAndroidVPN bool
OverrideAndroidVPN bool
UnderNetworkExtension bool
}

View file

@ -122,11 +122,16 @@ func (m *defaultInterfaceMonitor) checkUpdate() error {
break
}
if defaultInterface == nil {
defaultInterface, err = getDefaultInterfaceBySocket()
if err != nil {
return err
if m.options.UnderNetworkExtension {
defaultInterface, err = getDefaultInterfaceBySocket()
if err != nil {
return err
}
}
}
if defaultInterface == nil {
return ErrNoRoute
}
oldInterface := m.defaultInterfaceName
oldIndex := m.defaultInterfaceIndex
m.defaultInterfaceIndex = defaultInterface.Index