Skip to content

Commit

Permalink
Create monitor by default
Browse files Browse the repository at this point in the history
  • Loading branch information
nekohasekai authored and hiddify-com committed Aug 21, 2023
1 parent eb8b31a commit c1be22c
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions route/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
})
Expand All @@ -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
}
Expand Down

0 comments on commit c1be22c

Please sign in to comment.