Add RemoteAddr and ListenAddr to NodeInfo; Refactor IPRange logic

This commit is contained in:
Jae Kwon
2015-12-05 09:44:03 -08:00
parent c37e25e76b
commit 432a37857d
7 changed files with 50 additions and 241 deletions

View File

@ -224,10 +224,6 @@ func (sw *Switch) AddPeerWithConnection(conn net.Conn, outbound bool) (*Peer, er
return nil, err
}
// The peerNodeInfo is not verified, so overwrite
// the IP, and the port too if we dialed out
// Everything else we just have to trust
peerNodeInfo.Address = sconn.RemoteAddr().String()
peer := newPeer(sconn, peerNodeInfo, outbound, sw.reactorsByCh, sw.chDescs, sw.StopPeerForError)
// Add the peer to .peers
@ -351,12 +347,6 @@ func (sw *Switch) listenerRoutine(l Listener) {
continue
}
// Ignore connections from IP ranges for which we have too many
if sw.peers.HasMaxForIPRange(inConn) {
log.Info("Ignoring inbound connection: already have enough peers for that IP range", "address", inConn.RemoteAddr().String())
continue
}
// New inbound connection!
_, err := sw.AddPeerWithConnection(inConn, false)
if err != nil {