mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-13 11:09:23 +01:00
#4939 Add socks proxy support to lncli
This commit is contained in:
parent
0b20dcc4f5
commit
b1f6bc977e
2 changed files with 31 additions and 4 deletions
|
@ -5,8 +5,10 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -17,6 +19,7 @@ import (
|
||||||
"github.com/lightningnetwork/lnd/lncfg"
|
"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/lightningnetwork/lnd/tor"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
"golang.org/x/term"
|
"golang.org/x/term"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
|
@ -173,10 +176,24 @@ 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
|
// If a socksproxy server is specified we use a tor dialer
|
||||||
// and not just TCP addresses.
|
// to connect to the grpc server.
|
||||||
|
if ctx.GlobalIsSet("socksproxy") {
|
||||||
|
socksProxy := ctx.GlobalString("socksproxy")
|
||||||
|
torDialer := func(_ context.Context, addr string) (net.Conn, error) {
|
||||||
|
return tor.Dial(
|
||||||
|
addr, socksProxy, false, false,
|
||||||
|
tor.DefaultConnTimeout,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
opts = append(opts, grpc.WithContextDialer(torDialer))
|
||||||
|
} else {
|
||||||
|
// We need to use a custom dialer so we can also connect to
|
||||||
|
// unix sockets and not just TCP addresses.
|
||||||
genericDialer := lncfg.ClientAddressDialer(defaultRPCPort)
|
genericDialer := lncfg.ClientAddressDialer(defaultRPCPort)
|
||||||
opts = append(opts, grpc.WithContextDialer(genericDialer))
|
opts = append(opts, grpc.WithContextDialer(genericDialer))
|
||||||
|
}
|
||||||
|
|
||||||
opts = append(opts, grpc.WithDefaultCallOptions(maxMsgRecvSize))
|
opts = append(opts, grpc.WithDefaultCallOptions(maxMsgRecvSize))
|
||||||
|
|
||||||
conn, err := grpc.Dial(profile.RPCServer, opts...)
|
conn, err := grpc.Dial(profile.RPCServer, opts...)
|
||||||
|
@ -276,6 +293,12 @@ func main() {
|
||||||
Usage: "The path to lnd's base directory.",
|
Usage: "The path to lnd's base directory.",
|
||||||
TakesFile: true,
|
TakesFile: true,
|
||||||
},
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "socksproxy",
|
||||||
|
Usage: "The host:port of a SOCKS proxy through " +
|
||||||
|
"which all connections to the LN " +
|
||||||
|
"daemon will be established over.",
|
||||||
|
},
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "tlscertpath",
|
Name: "tlscertpath",
|
||||||
Value: defaultTLSCertPath,
|
Value: defaultTLSCertPath,
|
||||||
|
|
|
@ -41,6 +41,9 @@ then watch it on chain. Taproot script spends are also supported through the
|
||||||
* Add [update node announcement](https://github.com/lightningnetwork/lnd/pull/5587)
|
* Add [update node announcement](https://github.com/lightningnetwork/lnd/pull/5587)
|
||||||
for updating and propagating node information.
|
for updating and propagating node information.
|
||||||
|
|
||||||
|
* Add [--socksproxy](https://github.com/lightningnetwork/lnd/pull/6422)
|
||||||
|
to allow for RPC calls via Tor.
|
||||||
|
|
||||||
## Bug Fixes
|
## Bug Fixes
|
||||||
|
|
||||||
* [Pipelining an UpdateFulfillHTLC message now only happens when the related UpdateAddHTLC is locked-in.](https://github.com/lightningnetwork/lnd/pull/6246)
|
* [Pipelining an UpdateFulfillHTLC message now only happens when the related UpdateAddHTLC is locked-in.](https://github.com/lightningnetwork/lnd/pull/6246)
|
||||||
|
@ -281,6 +284,7 @@ gRPC performance metrics (latency to process `GetInfo`, etc)](https://github.com
|
||||||
* Eugene Siegel
|
* Eugene Siegel
|
||||||
* Hampus Sjöberg
|
* Hampus Sjöberg
|
||||||
* henta
|
* henta
|
||||||
|
* hieblmi
|
||||||
* Joost Jager
|
* Joost Jager
|
||||||
* Jordi Montes
|
* Jordi Montes
|
||||||
* LightningHelper
|
* LightningHelper
|
||||||
|
|
Loading…
Add table
Reference in a new issue