From eb977f41f66fe2bd503877a4c5764f835b55cacf Mon Sep 17 00:00:00 2001 From: Gyu-Ho Lee Date: Wed, 1 Mar 2017 14:36:08 +0000 Subject: [PATCH] embed: use correct host for advertise-client-urls Fix https://github.com/coreos/etcd/issues/7348. https://github.com/coreos/etcd/pull/7027 broke this. It overwriting the advertise-client-urls' host with 'localhost'. Signed-off-by: Gyu-Ho Lee --- embed/config.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/embed/config.go b/embed/config.go index db35e84cbb74..604865e915b6 100644 --- a/embed/config.go +++ b/embed/config.go @@ -381,8 +381,8 @@ func (cfg *Config) UpdateDefaultClusterFromName(defaultInitialCluster string) { // if client-listen-url is 0.0.0.0, just use detected default host // otherwise, rewrite advertise-client-url with localhost if ip != "0.0.0.0" { - _, acPort, _ := net.SplitHostPort(cfg.ACUrls[0].Host) - cfg.ACUrls[0] = url.URL{Scheme: cfg.ACUrls[0].Scheme, Host: fmt.Sprintf("localhost:%s", acPort)} + ahost, acPort, _ := net.SplitHostPort(cfg.ACUrls[0].Host) + cfg.ACUrls[0] = url.URL{Scheme: cfg.ACUrls[0].Scheme, Host: fmt.Sprintf("%s:%s", ahost, acPort)} cfg.InitialCluster = cfg.InitialClusterFromName(cfg.Name) } }