lncfg+lncli: replace WithDialer->WitchContextDialer
WithDialer is deprecated, use WitchContextDialer instead.
This commit is contained in:
parent
f0bd4e775b
commit
b3b355659b
@ -136,7 +136,7 @@ func getClientConn(ctx *cli.Context, skipMacaroons bool) *grpc.ClientConn {
|
|||||||
// We need to use a custom dialer so we can also connect to unix sockets
|
// We need to use a custom dialer so we can also connect to unix sockets
|
||||||
// and not just TCP addresses.
|
// and not just TCP addresses.
|
||||||
genericDialer := lncfg.ClientAddressDialer(defaultRPCPort)
|
genericDialer := lncfg.ClientAddressDialer(defaultRPCPort)
|
||||||
opts = append(opts, grpc.WithDialer(genericDialer))
|
opts = append(opts, grpc.WithContextDialer(genericDialer))
|
||||||
opts = append(opts, grpc.WithDefaultCallOptions(maxMsgRecvSize))
|
opts = append(opts, grpc.WithDefaultCallOptions(maxMsgRecvSize))
|
||||||
|
|
||||||
conn, err := grpc.Dial(ctx.GlobalString("rpcserver"), opts...)
|
conn, err := grpc.Dial(ctx.GlobalString("rpcserver"), opts...)
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
package lncfg
|
package lncfg
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/btcsuite/btcd/btcec"
|
"github.com/btcsuite/btcd/btcec"
|
||||||
"github.com/lightningnetwork/lnd/lnwire"
|
"github.com/lightningnetwork/lnd/lnwire"
|
||||||
@ -274,8 +274,10 @@ func verifyPort(address string, defaultPort string) string {
|
|||||||
|
|
||||||
// ClientAddressDialer creates a gRPC dialer that can also dial unix socket
|
// ClientAddressDialer creates a gRPC dialer that can also dial unix socket
|
||||||
// addresses instead of just TCP addresses.
|
// addresses instead of just TCP addresses.
|
||||||
func ClientAddressDialer(defaultPort string) func(string, time.Duration) (net.Conn, error) {
|
func ClientAddressDialer(defaultPort string) func(context.Context,
|
||||||
return func(addr string, timeout time.Duration) (net.Conn, error) {
|
string) (net.Conn, error) {
|
||||||
|
|
||||||
|
return func(ctx context.Context, addr string) (net.Conn, error) {
|
||||||
parsedAddr, err := ParseAddressString(
|
parsedAddr, err := ParseAddressString(
|
||||||
addr, defaultPort, net.ResolveTCPAddr,
|
addr, defaultPort, net.ResolveTCPAddr,
|
||||||
)
|
)
|
||||||
@ -283,8 +285,9 @@ func ClientAddressDialer(defaultPort string) func(string, time.Duration) (net.Co
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return net.DialTimeout(
|
d := net.Dialer{}
|
||||||
parsedAddr.Network(), parsedAddr.String(), timeout,
|
return d.DialContext(
|
||||||
|
ctx, parsedAddr.Network(), parsedAddr.String(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user