Skip to content

Commit

Permalink
get rid of Router.NormalisePeerAddr
Browse files Browse the repository at this point in the history
There was only one call site left and it always gets invoked with an
ip:port, so normalisation is a no-op.

Also remove mysterious comment.
  • Loading branch information
rade committed Apr 15, 2015
1 parent 290d544 commit 339f85c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 14 deletions.
6 changes: 2 additions & 4 deletions router/local_peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,8 @@ func (peer *LocalPeer) CreateConnection(peerAddr string, acceptNewPeer bool) err
if err := peer.checkConnectionLimit(); err != nil {
return err
}
// We're dialing the remote so that means connections will come from random ports
addrStr := peer.router.NormalisePeerAddr(peerAddr)
tcpAddr, tcpErr := net.ResolveTCPAddr("tcp4", addrStr)
udpAddr, udpErr := net.ResolveUDPAddr("udp4", addrStr)
tcpAddr, tcpErr := net.ResolveTCPAddr("tcp4", peerAddr)
udpAddr, udpErr := net.ResolveUDPAddr("udp4", peerAddr)
if tcpErr != nil || udpErr != nil {
// they really should have the same value, but just in case...
if tcpErr == nil {
Expand Down
10 changes: 0 additions & 10 deletions router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -417,13 +417,3 @@ func (router *Router) applyTopologyUpdate(update []byte) (PeerNameSet, PeerNameS
}
return origUpdate, newUpdate, nil
}

// given an address like '1.2.3.4:567', return the address if it has a port,
// otherwise return the address with the default port number for the router
func (router *Router) NormalisePeerAddr(peerAddr string) string {
_, _, err := net.SplitHostPort(peerAddr)
if err == nil {
return peerAddr
}
return fmt.Sprintf("%s:%d", peerAddr, router.Port)
}

0 comments on commit 339f85c

Please sign in to comment.