Rename connect option to rpcconnect.

The connect option is already used by btcd to force a connection to
other full node peers.  Wallet does not talk directly with these
peers, so the connect option is being renamed to something unique for
an RPC client connection.
This commit is contained in:
Josh Rickmar 2014-05-06 13:25:56 -05:00
parent 04a6cb2176
commit 17ebf9461f
3 changed files with 9 additions and 8 deletions

View file

@ -50,7 +50,7 @@ var (
type config struct { type config struct {
ShowVersion bool `short:"V" long:"version" description:"Display version information and exit"` ShowVersion bool `short:"V" long:"version" description:"Display version information and exit"`
CAFile string `long:"cafile" description:"File containing root certificates to authenticate a TLS connections with btcd"` CAFile string `long:"cafile" description:"File containing root certificates to authenticate a TLS connections with btcd"`
Connect string `short:"c" long:"connect" description:"Server and port of btcd instance to connect to (default localhost:18334, mainnet: localhost:8334)"` RPCConnect string `short:"c" long:"rpcconnect" description:"Hostname/IP and port of btcd RPC server to connect to (default localhost:18334, mainnet: localhost:8334)"`
DebugLevel string `short:"d" long:"debuglevel" description:"Logging level {trace, debug, info, warn, error, critical}"` DebugLevel string `short:"d" long:"debuglevel" description:"Logging level {trace, debug, info, warn, error, critical}"`
ConfigFile string `short:"C" long:"configfile" description:"Path to configuration file"` ConfigFile string `short:"C" long:"configfile" description:"Path to configuration file"`
SvrListeners []string `long:"rpclisten" description:"Listen for RPC/websocket connections on this interface/port (default port: 18332, mainnet: 8332)"` SvrListeners []string `long:"rpclisten" description:"Listen for RPC/websocket connections on this interface/port (default port: 18332, mainnet: 8332)"`
@ -218,12 +218,13 @@ func loadConfig() (*config, []string, error) {
return nil, nil, err return nil, nil, err
} }
if cfg.Connect == "" { if cfg.RPCConnect == "" {
cfg.Connect = activeNetParams.connect cfg.RPCConnect = activeNetParams.connect
} }
// Add default port to connect flag if missing. // Add default port to connect flag if missing.
cfg.Connect = normalizeAddress(cfg.Connect, activeNetParams.btcdPort) cfg.RPCConnect = normalizeAddress(cfg.RPCConnect,
activeNetParams.btcdPort)
// If CAFile is unset, choose either the copy or local btcd cert. // If CAFile is unset, choose either the copy or local btcd cert.
if cfg.CAFile == "" { if cfg.CAFile == "" {
@ -232,7 +233,7 @@ func loadConfig() (*config, []string, error) {
// If the CA copy does not exist, check if we're connecting to // If the CA copy does not exist, check if we're connecting to
// a local btcd and switch to its RPC cert if it exists. // a local btcd and switch to its RPC cert if it exists.
if !fileExists(cfg.CAFile) { if !fileExists(cfg.CAFile) {
host, _, err := net.SplitHostPort(cfg.Connect) host, _, err := net.SplitHostPort(cfg.RPCConnect)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }

View file

@ -32,7 +32,7 @@
; proxypass= ; proxypass=
; The server and port used for btcd websocket connections. ; The server and port used for btcd websocket connections.
; connect=localhost:18334 ; rpcconnect=localhost:18334
; File containing root certificates to authenticate a TLS connections with btcd ; File containing root certificates to authenticate a TLS connections with btcd
; cafile=~/.btcwallet/btcd.cert ; cafile=~/.btcwallet/btcd.cert

View file

@ -627,7 +627,7 @@ func (s *server) checkAuth(r *http.Request) error {
// BtcdWS opens a websocket connection to a btcd instance. // BtcdWS opens a websocket connection to a btcd instance.
func BtcdWS(certificates []byte) (*websocket.Conn, error) { func BtcdWS(certificates []byte) (*websocket.Conn, error) {
url := fmt.Sprintf("wss://%s/ws", cfg.Connect) url := fmt.Sprintf("wss://%s/ws", cfg.RPCConnect)
config, err := websocket.NewConfig(url, "https://localhost/") config, err := websocket.NewConfig(url, "https://localhost/")
if err != nil { if err != nil {
return nil, err return nil, err
@ -655,7 +655,7 @@ func BtcdWS(certificates []byte) (*websocket.Conn, error) {
Username: cfg.ProxyUser, Username: cfg.ProxyUser,
Password: cfg.ProxyPass, Password: cfg.ProxyPass,
} }
conn, err := proxy.Dial("tcp", cfg.Connect) conn, err := proxy.Dial("tcp", cfg.RPCConnect)
if err != nil { if err != nil {
return nil, err return nil, err
} }