Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions monitor_windows.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package tun

import (
"net/netip"
"sync"

"github.com/sagernet/sing-tun/internal/winipcfg"
Expand All @@ -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")
Copy link
Member

@nekohasekai nekohasekai Nov 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is better to use a more general check.


type networkUpdateMonitor struct {
routeListener *winipcfg.RouteChangeCallback
interfaceListener *winipcfg.InterfaceChangeCallback
Expand Down Expand Up @@ -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
Expand Down