lncli: add support for unix sockets
This commit is contained in:
parent
c1b1dd96ef
commit
9f0e39f881
@ -14,6 +14,7 @@ import (
|
|||||||
|
|
||||||
macaroon "gopkg.in/macaroon.v2"
|
macaroon "gopkg.in/macaroon.v2"
|
||||||
|
|
||||||
|
"github.com/lightningnetwork/lnd/lncfg"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc"
|
"github.com/lightningnetwork/lnd/lnrpc"
|
||||||
"github.com/lightningnetwork/lnd/macaroons"
|
"github.com/lightningnetwork/lnd/macaroons"
|
||||||
"github.com/roasbeef/btcutil"
|
"github.com/roasbeef/btcutil"
|
||||||
@ -26,6 +27,8 @@ import (
|
|||||||
const (
|
const (
|
||||||
defaultTLSCertFilename = "tls.cert"
|
defaultTLSCertFilename = "tls.cert"
|
||||||
defaultMacaroonFilename = "admin.macaroon"
|
defaultMacaroonFilename = "admin.macaroon"
|
||||||
|
defaultRpcPort = "10009"
|
||||||
|
defaultRpcHostPort = "localhost:" + defaultRpcPort
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -143,6 +146,13 @@ func getClientConn(ctx *cli.Context, skipMacaroons bool) *grpc.ClientConn {
|
|||||||
opts = append(opts, grpc.WithPerRPCCredentials(cred))
|
opts = append(opts, grpc.WithPerRPCCredentials(cred))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We need to use a custom dialer so we can also connect to unix sockets
|
||||||
|
// and not just TCP addresses.
|
||||||
|
opts = append(
|
||||||
|
opts, grpc.WithDialer(
|
||||||
|
lncfg.ClientAddressDialer(defaultRpcPort),
|
||||||
|
),
|
||||||
|
)
|
||||||
conn, err := grpc.Dial(ctx.GlobalString("rpcserver"), opts...)
|
conn, err := grpc.Dial(ctx.GlobalString("rpcserver"), opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fatal(err)
|
fatal(err)
|
||||||
@ -159,7 +169,7 @@ func main() {
|
|||||||
app.Flags = []cli.Flag{
|
app.Flags = []cli.Flag{
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "rpcserver",
|
Name: "rpcserver",
|
||||||
Value: "localhost:10009",
|
Value: defaultRpcHostPort,
|
||||||
Usage: "host:port of ln daemon",
|
Usage: "host:port of ln daemon",
|
||||||
},
|
},
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
|
Loading…
Reference in New Issue
Block a user