diff --git a/command/agent/agent.go b/command/agent/agent.go index c57e45b664..4c4b14802d 100644 --- a/command/agent/agent.go +++ b/command/agent/agent.go @@ -313,7 +313,11 @@ func (a *Agent) ForceLeave(node string) (err error) { // LocalMember is used to return the local node func (a *Agent) LocalMember() serf.Member { - return a.server.LocalMember() + if a.server != nil { + return a.server.LocalMember() + } else { + return a.client.LocalMember() + } } // LANMembers is used to retrieve the LAN members diff --git a/consul/client.go b/consul/client.go index 02aa4f658d..9987552405 100644 --- a/consul/client.go +++ b/consul/client.go @@ -31,6 +31,7 @@ const ( type Interface interface { RPC(method string, args interface{}, reply interface{}) error LANMembers() []serf.Member + LocalMember() serf.Member } // Client is Consul client which uses RPC to communicate with the @@ -181,6 +182,11 @@ func (c *Client) JoinLAN(addrs []string) (int, error) { return c.serf.Join(addrs, true) } +// LocalMember is used to return the local node +func (c *Client) LocalMember() serf.Member { + return c.serf.LocalMember() +} + // LANMembers is used to return the members of the LAN cluster func (c *Client) LANMembers() []serf.Member { return c.serf.Members()