parent
72b0a7f34d
commit
3c5c49bedb
|
@ -794,6 +794,11 @@ func normalizeBind(addr, bind string) (string, error) {
|
|||
//
|
||||
// Loopback is only considered a valid advertise address in dev mode.
|
||||
func normalizeAdvertise(addr string, bind string, defport int) (string, error) {
|
||||
addr, err := parseSingleIPTemplate(addr)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("Error parsing advertise address template: %v", err)
|
||||
}
|
||||
|
||||
if addr != "" {
|
||||
// Default to using manually configured address
|
||||
host, port, err := net.SplitHostPort(addr)
|
||||
|
@ -805,12 +810,7 @@ func normalizeAdvertise(addr string, bind string, defport int) (string, error) {
|
|||
port = strconv.Itoa(defport)
|
||||
}
|
||||
|
||||
ipStr, err := parseSingleIPTemplate(host)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("Error parsing advertise address template: %v", err)
|
||||
}
|
||||
|
||||
return net.JoinHostPort(ipStr, port), nil
|
||||
return net.JoinHostPort(host, port), nil
|
||||
}
|
||||
|
||||
// Fallback to bind address, as it has been resolved before.
|
||||
|
|
|
@ -612,8 +612,10 @@ func TestConfig_normalizeAddrs(t *testing.T) {
|
|||
RPC: 4647,
|
||||
Serf: 4648,
|
||||
},
|
||||
Addresses: &Addresses{},
|
||||
AdvertiseAddrs: &AdvertiseAddrs{},
|
||||
Addresses: &Addresses{},
|
||||
AdvertiseAddrs: &AdvertiseAddrs{
|
||||
RPC: "{{ GetPrivateIP }}:8888",
|
||||
},
|
||||
Server: &ServerConfig{
|
||||
Enabled: true,
|
||||
},
|
||||
|
@ -627,8 +629,8 @@ func TestConfig_normalizeAddrs(t *testing.T) {
|
|||
t.Fatalf("expected HTTP advertise address %s:4646, got %s", c.BindAddr, c.AdvertiseAddrs.HTTP)
|
||||
}
|
||||
|
||||
if c.AdvertiseAddrs.RPC != fmt.Sprintf("%s:4647", c.BindAddr) {
|
||||
t.Fatalf("expected RPC advertise address %s:4647, got %s", c.BindAddr, c.AdvertiseAddrs.RPC)
|
||||
if c.AdvertiseAddrs.RPC != fmt.Sprintf("%s:8888", c.BindAddr) {
|
||||
t.Fatalf("expected RPC advertise address %s:8888, got %s", c.BindAddr, c.AdvertiseAddrs.RPC)
|
||||
}
|
||||
|
||||
if c.AdvertiseAddrs.Serf != fmt.Sprintf("%s:4648", c.BindAddr) {
|
||||
|
|
Loading…
Reference in New Issue