mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 09:53:54 +01:00
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"
|
||||
|
||||
"github.com/lightningnetwork/lnd/lncfg"
|
||||
"github.com/lightningnetwork/lnd/lnrpc"
|
||||
"github.com/lightningnetwork/lnd/macaroons"
|
||||
"github.com/roasbeef/btcutil"
|
||||
@ -26,6 +27,8 @@ import (
|
||||
const (
|
||||
defaultTLSCertFilename = "tls.cert"
|
||||
defaultMacaroonFilename = "admin.macaroon"
|
||||
defaultRpcPort = "10009"
|
||||
defaultRpcHostPort = "localhost:" + defaultRpcPort
|
||||
)
|
||||
|
||||
var (
|
||||
@ -143,6 +146,13 @@ func getClientConn(ctx *cli.Context, skipMacaroons bool) *grpc.ClientConn {
|
||||
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...)
|
||||
if err != nil {
|
||||
fatal(err)
|
||||
@ -159,7 +169,7 @@ func main() {
|
||||
app.Flags = []cli.Flag{
|
||||
cli.StringFlag{
|
||||
Name: "rpcserver",
|
||||
Value: "localhost:10009",
|
||||
Value: defaultRpcHostPort,
|
||||
Usage: "host:port of ln daemon",
|
||||
},
|
||||
cli.StringFlag{
|
||||
|
Loading…
Reference in New Issue
Block a user