From 7e1f2860634a64bc52f52ff691d5c93c65ac5ba3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Sat, 14 Sep 2024 09:26:38 +0800 Subject: [PATCH] monitor: Do not select disconnected interface --- monitor_windows.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/monitor_windows.go b/monitor_windows.go index 8bd0be4..1b9333e 100644 --- a/monitor_windows.go +++ b/monitor_windows.go @@ -78,12 +78,16 @@ func (m *defaultInterfaceMonitor) checkUpdate() error { continue } + if ifrow.Type == winipcfg.IfTypePropVirtual || ifrow.Type == winipcfg.IfTypeSoftwareLoopback { + continue + } + iface, err := row.InterfaceLUID.IPInterface(windows.AF_INET) if err != nil { continue } - if ifrow.Type == winipcfg.IfTypePropVirtual || ifrow.Type == winipcfg.IfTypeSoftwareLoopback { + if !iface.Connected { continue }