From 43a6cf39f555c86c54444f678784143665821fcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Wed, 25 Nov 2026 20:10:39 +0800 Subject: [PATCH] Fix network environment collecting all routes of the default interface --- route/network_environment_linux.go | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/route/network_environment_linux.go b/route/network_environment_linux.go index 702b3d92..b9c1fe8b 100644 --- a/route/network_environment_linux.go +++ b/route/network_environment_linux.go @@ -9,7 +9,7 @@ import ( ) func systemGateways(interfaceIndex int) []netip.Addr { - routes, err := netlink.RouteListFiltered(netlink.FAMILY_ALL, &netlink.Route{LinkIndex: interfaceIndex}, netlink.RT_FILTER_OIF) + routes, err := netlink.RouteListFiltered(netlink.FAMILY_ALL, &netlink.Route{LinkIndex: interfaceIndex}, netlink.RT_FILTER_OIF|netlink.RT_FILTER_DST) if err != nil { return nil } @@ -18,12 +18,6 @@ func systemGateways(interfaceIndex int) []netip.Addr { if currentRoute.Gw == nil { continue } - if currentRoute.Dst != nil { - ones, _ := currentRoute.Dst.Mask.Size() - if ones != 0 { - continue - } - } gateway, valid := netip.AddrFromSlice(currentRoute.Gw) if valid { gateways = append(gateways, gateway.Unmap())