mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-12-02 08:59:27 +01:00
rpc: allow for omitting the port when handling the Connect RPC
This commit slightly modifies the handling of the Connect RPC to allow users to omit the port when specifying the target node to connect to. If the port isn’t specified, then the default p2p port will be used in place.
This commit is contained in:
13
rpcserver.go
13
rpcserver.go
@@ -9,6 +9,7 @@ import (
|
||||
"io"
|
||||
"math"
|
||||
"net"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -203,7 +204,17 @@ func (r *rpcServer) ConnectPeer(ctx context.Context,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
host, err := net.ResolveTCPAddr("tcp", in.Addr.Host)
|
||||
// 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
|
||||
}
|
||||
|
||||
host, err := net.ResolveTCPAddr("tcp", addr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user