forked from TrueCloudLab/neoneo-go
network: fix PeerAddr() for not-yet-handshaked case
If we have already got Version message, we don't need the rest of handshake to complete before being able to properly answer the PeerAddr() requests. Fixes some duplicate connections between machines.
This commit is contained in:
parent
49bd7aada5
commit
b2c4587dad
1 changed files with 1 additions and 1 deletions
|
@ -333,7 +333,7 @@ func (p *TCPPeer) RemoteAddr() net.Addr {
|
|||
func (p *TCPPeer) PeerAddr() net.Addr {
|
||||
remote := p.conn.RemoteAddr()
|
||||
// The network can be non-tcp in unit tests.
|
||||
if !p.Handshaked() || remote.Network() != "tcp" {
|
||||
if p.version == nil || remote.Network() != "tcp" {
|
||||
return p.RemoteAddr()
|
||||
}
|
||||
host, _, err := net.SplitHostPort(remote.String())
|
||||
|
|
Loading…
Reference in a new issue