The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/7232
This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) === Signed-off-by: Stéphane Graber <stgra...@ubuntu.com>
From 02e840161e36153063224390e2ab56366f8e5c2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com> Date: Mon, 20 Apr 2020 19:01:10 -0400 Subject: [PATCH] lxd/util: Tweak NetworkInterfaceAddress to only return global MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber <stgra...@ubuntu.com> --- lxd/util/net.go | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/lxd/util/net.go b/lxd/util/net.go index af99fc98cd..ebf0c1af2b 100644 --- a/lxd/util/net.go +++ b/lxd/util/net.go @@ -114,23 +114,31 @@ func NetworkInterfaceAddress() string { if err != nil { return "" } + for _, iface := range ifaces { - if shared.IsLoopback(&iface) { - continue - } addrs, err := iface.Addrs() if err != nil { continue } + if len(addrs) == 0 { continue } - addr, ok := addrs[0].(*net.IPNet) - if !ok { - continue + + for _, addr := range addrs { + ipNet, ok := addr.(*net.IPNet) + if !ok { + continue + } + + if !ipNet.IP.IsGlobalUnicast() { + continue + } + + return ipNet.IP.String() } - return addr.IP.String() } + return "" }
_______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel