Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rpc: use SOCKS5 proxy if configured #1294

Merged
merged 2 commits into from
Dec 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions chain/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,32 @@ type RPCClient struct {
quitMtx sync.Mutex
}

// NewRPCClient creates a client connection to the server described by the
// NewRPCClient creates a direct client connection to the server described by the
// connect string. If disableTLS is false, the remote RPC certificate must be
// provided in the certs slice. The connection is not established immediately,
// but must be done using the Start method. If the remote server does not
// operate on the same decred network as described by the passed chain
// parameters, the connection will be disconnected.
// Deprecated: use NewRPCClientConfig
func NewRPCClient(chainParams *chaincfg.Params, connect, user, pass string, certs []byte,
disableTLS bool) (*RPCClient, error) {
return NewRPCClientConfig(chainParams, &dcrrpcclient.ConnConfig{
Host: connect,
Endpoint: "ws",
User: user,
Pass: pass,
Certificates: certs,
DisableAutoReconnect: true,
DisableConnectOnNew: true,
DisableTLS: disableTLS,
})
}

// NewRPCClientConfig creates a client connection to the server described by the
// passed chainParams and connConfig
func NewRPCClientConfig(chainParams *chaincfg.Params, connConfig *dcrrpcclient.ConnConfig) (*RPCClient, error) {
client := &RPCClient{
connConfig: &dcrrpcclient.ConnConfig{
Host: connect,
Endpoint: "ws",
User: user,
Pass: pass,
Certificates: certs,
DisableAutoReconnect: true,
DisableConnectOnNew: true,
DisableTLS: disableTLS,
},
connConfig: connConfig,
chainParams: chainParams,
enqueueNotification: make(chan interface{}),
dequeueNotification: make(chan interface{}),
Expand Down
15 changes: 13 additions & 2 deletions dcrwallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (

"github.com/decred/dcrd/addrmgr"
"github.com/decred/dcrd/chaincfg"
dcrrpcclient "github.com/decred/dcrd/rpcclient"
"github.com/decred/dcrwallet/chain"
"github.com/decred/dcrwallet/errors"
"github.com/decred/dcrwallet/internal/prompt"
Expand Down Expand Up @@ -503,8 +504,18 @@ func readCAFile() []byte {
// authentication error. Instead, all requests to the client will simply error.
func startChainRPC(ctx context.Context, certs []byte) (*chain.RPCClient, error) {
log.Infof("Attempting RPC client connection to %v", cfg.RPCConnect)
rpcc, err := chain.NewRPCClient(activeNet.Params, cfg.RPCConnect,
cfg.DcrdUsername, cfg.DcrdPassword, certs, cfg.DisableClientTLS)
rpcc, err := chain.NewRPCClientConfig(activeNet.Params, &dcrrpcclient.ConnConfig{
Host: cfg.RPCConnect,
Endpoint: "ws",
User: cfg.DcrdUsername,
Pass: cfg.DcrdPassword,
Certificates: certs,
DisableAutoReconnect: true,
DisableConnectOnNew: true,
DisableTLS: cfg.DisableClientTLS,
Proxy: cfg.Proxy,
ProxyUser: cfg.ProxyUser,
ProxyPass: cfg.ProxyPass})
if err != nil {
return nil, err
}
Expand Down