lnd: use the default peer port when launching persistent conn goroutines

This commit fixes a slight bug in the deamon. Previously we would store
the *net.TCPAddr that we observed when we either connected out to the
peer, or the peer connected to us. When making an outgoing connection
the host+port combination would be correct, but when responding to an
incoming connection, the port assigned after the TCP handshake would be
stored in the database. This would cause many goroutines to repeatedly
fail connections within the connmgr. Atm within the connmgr, it isn’t
possible to cancel requests for failed connection even after we’ve
already established a connection.

This commit fixes that issues by using the default peer port when
attempting to establish outbound connections to our channel peers.
This commit is contained in:
Olaoluwa Osuntokun 2017-01-22 14:34:35 -08:00
parent f623729b64
commit 4634db4f80
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2

@ -206,6 +206,7 @@ func newServer(listenAddrs []string, notifier chainntnfs.ChainNotifier,
for _, node := range linkNodes {
// Create a wrapper address which couples the IP and the pubkey
// so the brontide authenticated connection can be established.
node.Addresses[0].Port = defaultPeerPort
lnAddr := &lnwire.NetAddress{
IdentityKey: node.IdentityPub,
Address: node.Addresses[0],
@ -215,8 +216,8 @@ func newServer(listenAddrs []string, notifier chainntnfs.ChainNotifier,
"peer %v", lnAddr)
// Send the persistent connection request to the connection
// manager, saving the request itself so we can
// cancel/restart the process as needed.
// manager, saving the request itself so we can cancel/restart
// the process as needed.
connReq := &connmgr.ConnReq{
Addr: lnAddr,
Permanent: true,