diff --git a/monitor.go b/monitor.go index 0fe6396..910570a 100644 --- a/monitor.go +++ b/monitor.go @@ -39,5 +39,6 @@ type DefaultInterfaceMonitor interface { } type DefaultInterfaceMonitorOptions struct { - OverrideAndroidVPN bool + OverrideAndroidVPN bool + UnderNetworkExtension bool } diff --git a/monitor_darwin.go b/monitor_darwin.go index 296ba54..1df1f21 100644 --- a/monitor_darwin.go +++ b/monitor_darwin.go @@ -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