From c1be22cedd41f003d876f668d9ba3d97d2e83c15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Mon, 7 Aug 2023 17:46:51 +0800 Subject: [PATCH] Create monitor by default --- route/router.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/route/router.go b/route/router.go index 0415ce2253..c0320da34e 100644 --- a/route/router.go +++ b/route/router.go @@ -266,16 +266,14 @@ func NewRouter( }) if !usePlatformDefaultInterfaceMonitor { - networkMonitor, err := tun.NewNetworkUpdateMonitor(router.logger) + networkMonitor, err := tun.NewNetworkUpdateMonitor(router) if !((err != nil && !needInterfaceMonitor) || errors.Is(err, os.ErrInvalid)) { if err != nil { return nil, err } router.networkMonitor = networkMonitor - networkMonitor.RegisterCallback(func() { - _ = router.interfaceFinder.update() - }) - interfaceMonitor, err := tun.NewDefaultInterfaceMonitor(router.networkMonitor, router.logger, tun.DefaultInterfaceMonitorOptions{ + networkMonitor.RegisterCallback(router.interfaceFinder.update) + interfaceMonitor, err := tun.NewDefaultInterfaceMonitor(router.networkMonitor, tun.DefaultInterfaceMonitorOptions{ OverrideAndroidVPN: options.OverrideAndroidVPN, UnderNetworkExtension: platformInterface != nil && platformInterface.UnderNetworkExtension(), }) @@ -286,7 +284,7 @@ func NewRouter( router.interfaceMonitor = interfaceMonitor } } else { - interfaceMonitor := platformInterface.CreateDefaultInterfaceMonitor(router.logger) + interfaceMonitor := platformInterface.CreateDefaultInterfaceMonitor(router) interfaceMonitor.RegisterCallback(router.notifyNetworkUpdate) router.interfaceMonitor = interfaceMonitor }