rpcserver: add support to connect to onion addresses

In this commit, we now allow connections to onion addresses due to
recently adding support to properly parse them.

Co-Authored-By: Eugene <crypt-iq@users.noreply.github.com>
This commit is contained in:
Wilmer Paulino 2018-04-27 16:59:59 -04:00
parent 3669a40c52
commit d6d0c26252
No known key found for this signature in database
GPG Key ID: 6DF57B9F9514972F

@ -9,8 +9,6 @@ import (
"fmt"
"io"
"math"
"net"
"strconv"
"strings"
"time"
@ -635,25 +633,14 @@ func (r *rpcServer) ConnectPeer(ctx context.Context,
return nil, fmt.Errorf("cannot make connection to self")
}
// If the address doesn't already have a port, we'll assume the current
// default port.
var addr string
_, _, err = net.SplitHostPort(in.Addr.Host)
if err != nil {
addr = net.JoinHostPort(in.Addr.Host, strconv.Itoa(defaultPeerPort))
} else {
addr = in.Addr.Host
}
// We use ResolveTCPAddr here in case we wish to resolve hosts over Tor.
host, err := cfg.net.ResolveTCPAddr("tcp", addr)
addr, err := parseAddr(in.Addr.Host)
if err != nil {
return nil, err
}
peerAddr := &lnwire.NetAddress{
IdentityKey: pubKey,
Address: host,
Address: addr,
ChainNet: activeNetParams.Net,
}