The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/7269
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) === Closes #7265. Signed-off-by: Free Ekanayaka <free.ekanay...@canonical.com>
From a5a57156823156d018eba9e701c59da1cb46d74e Mon Sep 17 00:00:00 2001 From: Free Ekanayaka <free.ekanay...@canonical.com> Date: Tue, 28 Apr 2020 09:53:57 +0100 Subject: [PATCH] Resolve both core.https_address and cluster.https_address when comparing IPs Signed-off-by: Free Ekanayaka <free.ekanay...@canonical.com> --- lxd/util/net.go | 12 ++++++++++++ lxd/util/net_test.go | 1 + 2 files changed, 13 insertions(+) diff --git a/lxd/util/net.go b/lxd/util/net.go index 8dbbce4e8f..b5a4046523 100644 --- a/lxd/util/net.go +++ b/lxd/util/net.go @@ -167,6 +167,18 @@ func IsAddressCovered(address1, address2 string) bool { return false } + // If address1 contains a host name, let's try to resolve it, in order + // to compare the actual IPs. + if host1 != "" { + ip1 := net.ParseIP(host1) + if ip1 == nil { + ips, err := net.LookupHost(host1) + if err == nil && len(ips) > 0 { + host1 = ips[0] + } + } + } + // If address2 contains a host name, let's try to resolve it, in order // to compare the actual IPs. if host2 != "" { diff --git a/lxd/util/net_test.go b/lxd/util/net_test.go index e79ace9c3b..9702629bc2 100644 --- a/lxd/util/net_test.go +++ b/lxd/util/net_test.go @@ -72,6 +72,7 @@ func TestIsAddressCovered(t *testing.T) { {":8443", "[::]:8443", true}, {"0.0.0.0:8443", "[::]:8443", true}, {"10.30.0.8:8443", "[::]", true}, + {"localhost:8443", "127.0.0.1:8443", true}, } // Test some localhost cases too
_______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel