From c8d55a620a7de3644e1a4e1b1506e18c6c588e6c Mon Sep 17 00:00:00 2001 From: wwqgtxx Date: Sun, 30 Oct 2022 12:56:31 +0800 Subject: [PATCH] Avoid choose ZeroTier's tap to defaultInterface --- monitor_windows.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/monitor_windows.go b/monitor_windows.go index a930c53..bf3b24c 100644 --- a/monitor_windows.go +++ b/monitor_windows.go @@ -1,6 +1,7 @@ package tun import ( + "net/netip" "sync" "github.com/sagernet/sing-tun/internal/winipcfg" @@ -10,6 +11,10 @@ import ( "golang.org/x/sys/windows" ) +// zeroTierFakeGatewayIp from +// https://github.com/zerotier/ZeroTierOne/blob/1.8.6/osdep/WindowsEthernetTap.cpp#L994 +var zeroTierFakeGatewayIp = netip.MustParseAddr("25.255.255.254") + type networkUpdateMonitor struct { routeListener *winipcfg.RouteChangeCallback interfaceListener *winipcfg.InterfaceChangeCallback @@ -67,6 +72,10 @@ func (m *defaultInterfaceMonitor) checkUpdate() error { var index int for _, row := range rows { + if row.NextHop.Addr() == zeroTierFakeGatewayIp { + continue + } + ifrow, err := row.InterfaceLUID.Interface() if err != nil || ifrow.OperStatus != winipcfg.IfOperStatusUp { continue