Only advertise local addr to peers when listenting.

Do not advertise the local address to outbound peers when we aren't
listening and therefore able to accept connections.
This commit is contained in:
Dave Collins 2013-08-17 15:26:51 -05:00
parent 627959adff
commit 6acd51f4b4

View file

@ -204,8 +204,9 @@ func (p *peer) handleVersionMsg(msg *btcwire.MsgVersion) {
// Outbound connections. // Outbound connections.
if !p.inbound { if !p.inbound {
// TODO: Only do this if we're listening, not doing the initial // TODO(davec): Only do this if not doing the initial block
// block download, and are routable. // download and the local address is routable.
if !cfg.DisableListen {
// Advertise the local address. // Advertise the local address.
na, err := newNetAddress(p.conn.LocalAddr(), p.services) na, err := newNetAddress(p.conn.LocalAddr(), p.services)
if err != nil { if err != nil {
@ -217,6 +218,7 @@ func (p *peer) handleVersionMsg(msg *btcwire.MsgVersion) {
NetAddressKey(na): na, NetAddressKey(na): na,
} }
p.pushAddrMsg(addresses) p.pushAddrMsg(addresses)
}
// Request known addresses if the server address manager needs // Request known addresses if the server address manager needs
// more and the peer has a protocol version new enough to // more and the peer has a protocol version new enough to