From 2c287368c3690098079b433fd4d94405b6e73812 Mon Sep 17 00:00:00 2001 From: Ilya Zuyev Date: Wed, 23 Jun 2021 19:09:14 -0700 Subject: [PATCH] improve searching of local network containing the given ip address --- pkg/network/network.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/network/network.go b/pkg/network/network.go index 13e34594f9f9..7fb4cd5587ab 100644 --- a/pkg/network/network.go +++ b/pkg/network/network.go @@ -97,6 +97,8 @@ func inspect(addr string) (*Parameters, error) { if err != nil { return nil, fmt.Errorf("failed listing network interfaces: %w", err) } + +ifLoop: for _, iface := range ifaces { ifAddrs, err := iface.Addrs() if err != nil { @@ -114,7 +116,7 @@ func inspect(addr string) (*Parameters, error) { n.IfaceMAC = iface.HardwareAddr.String() n.Gateway = n.IfaceIPv4 network = lan - break + break ifLoop } } }