From 4248e4b2656e9de030a2991df995142ae0a0f681 Mon Sep 17 00:00:00 2001 From: Alex Dadgar Date: Tue, 22 May 2018 14:45:15 -0700 Subject: [PATCH] safety guard --- command/agent/agent.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/command/agent/agent.go b/command/agent/agent.go index a75dd1fe77fb..34453a04d7e9 100644 --- a/command/agent/agent.go +++ b/command/agent/agent.go @@ -321,6 +321,12 @@ func (a *Agent) clientConfig() (*clientconfig.Config, error) { // host and -dev mode. conf.Servers = a.config.Client.Servers if a.server != nil { + if a.config.AdvertiseAddrs == nil || a.config.AdvertiseAddrs.RPC == "" { + return nil, fmt.Errorf("AdvertiseAddrs is nil or empty") + } else if a.config.normalizedAddrs == nil || a.config.normalizedAddrs.RPC == "" { + return nil, fmt.Errorf("normalizedAddrs is nil or empty") + } + conf.Servers = append(conf.Servers, a.config.normalizedAddrs.RPC, a.config.AdvertiseAddrs.RPC)