server: assume default port if one not present for --externalip

This commit is contained in:
Olaoluwa Osuntokun 2017-04-13 14:41:54 -07:00
parent 54c63f4aa1
commit d93e3e6fbe
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2
2 changed files with 17 additions and 4 deletions

@ -6,6 +6,7 @@ import (
"errors" "errors"
"fmt" "fmt"
"net" "net"
"strconv"
"sync" "sync"
"sync/atomic" "sync/atomic"
"time" "time"
@ -162,11 +163,20 @@ func newServer(listenAddrs []string, notifier chainntnfs.ChainNotifier,
// of this server's addresses. // of this server's addresses.
selfAddrs := make([]net.Addr, 0, len(cfg.ExternalIPs)) selfAddrs := make([]net.Addr, 0, len(cfg.ExternalIPs))
for _, ip := range cfg.ExternalIPs { for _, ip := range cfg.ExternalIPs {
addr, err := net.ResolveTCPAddr("tcp", ip) var addr string
_, _, err = net.SplitHostPort(ip)
if err != nil {
addr = net.JoinHostPort(ip, strconv.Itoa(defaultPeerPort))
} else {
addr = ip
}
lnAddr, err := net.ResolveTCPAddr("tcp", addr)
if err != nil { if err != nil {
return nil, err return nil, err
} }
selfAddrs = append(selfAddrs, addr)
selfAddrs = append(selfAddrs, lnAddr)
} }
chanGraph := chanDB.ChannelGraph() chanGraph := chanDB.ChannelGraph()
@ -617,7 +627,7 @@ func (s *server) inboundPeerConnected(conn net.Conn) {
s.peersMtx.Lock() s.peersMtx.Lock()
defer s.peersMtx.Unlock() defer s.peersMtx.Unlock()
srvrLog.Tracef("New inbound connection from %v", conn.RemoteAddr()) srvrLog.Infof("New inbound connection from %v", conn.RemoteAddr())
nodePub := conn.(*brontide.Conn).RemotePub() nodePub := conn.(*brontide.Conn).RemotePub()
@ -653,7 +663,7 @@ func (s *server) outboundPeerConnected(connReq *connmgr.ConnReq, conn net.Conn)
s.peersMtx.Lock() s.peersMtx.Lock()
defer s.peersMtx.Unlock() defer s.peersMtx.Unlock()
srvrLog.Tracef("Established connection to: %v", conn.RemoteAddr()) srvrLog.Infof("Established connection to: %v", conn.RemoteAddr())
nodePub := conn.(*brontide.Conn).RemotePub() nodePub := conn.(*brontide.Conn).RemotePub()

@ -367,6 +367,9 @@ out:
return return
} }
// TODO(roasbeef): if the BlockChainIO is rescanning
// will give stale data
// A new block has just been connected to the main // A new block has just been connected to the main
// chain which means we might be able to graduate some // chain which means we might be able to graduate some
// outputs out of the kindergarten bucket. Graduation // outputs out of the kindergarten bucket. Graduation