mirror of https://github.com/status-im/consul.git
agent: use bind address as src unless INADDR_ANY
Use the bind address as source address for outgoing RPC connections unless it is INADDR_ANY. The current code uses the advertise address which will not work in certain environments where the advertise address is not routable in the network of the agent, e.g. NAT environment, container... After all, that is the purpose of the advertise address. See #2822
This commit is contained in:
parent
e6c6f8cedd
commit
914a83cae0
|
@ -440,9 +440,10 @@ func (a *Agent) consulConfig() (*consul.Config, error) {
|
|||
}
|
||||
|
||||
// set the src address for outgoing rpc connections
|
||||
// to RPCAdvertise with port 0 so that outgoing
|
||||
// connections use a random port.
|
||||
base.RPCSrcAddr = &net.TCPAddr{IP: base.RPCAdvertise.IP}
|
||||
// Use port 0 so that outgoing connections use a random port.
|
||||
if !isAddrANY(base.RPCAddr.IP) {
|
||||
base.RPCSrcAddr = &net.TCPAddr{IP: base.RPCAddr.IP}
|
||||
}
|
||||
|
||||
// Format the build string
|
||||
revision := a.config.Revision
|
||||
|
|
Loading…
Reference in New Issue