mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-12-01 14:18:36 +00:00
Fix network environment collecting all routes of the default interface
This commit is contained in:
@@ -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())
|
||||
|
||||
Reference in New Issue
Block a user