diff options
author | John Newbery <john@johnnewbery.com> | 2017-07-12 16:59:09 -0400 |
---|---|---|
committer | John Newbery <john@johnnewbery.com> | 2017-07-13 17:15:36 -0400 |
commit | 5c643241e5d98992c0d5487b65e9c7b6d8005d1a (patch) | |
tree | 3f976f056d92f576e87e1d0ad96af871d0982595 /src | |
parent | fe4fabaf12b74782ea99821ed8108f17e582060d (diff) |
[utils] allow square brackets for ipv6 addresses in bitcoin-cli
-rpcconnect can now accept ipv6 addresses with and without square
brackets.
Diffstat (limited to 'src')
-rw-r--r-- | src/bitcoin-cli.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index 885b787b4d..92f6a21ebb 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -10,6 +10,7 @@ #include "chainparamsbase.h" #include "clientversion.h" #include "fs.h" +#include "utilstrencodings.h" #include "rpc/client.h" #include "rpc/protocol.h" #include "util.h" @@ -191,8 +192,14 @@ static void http_error_cb(enum evhttp_request_error err, void *ctx) UniValue CallRPC(const std::string& strMethod, const UniValue& params) { - std::string host = GetArg("-rpcconnect", DEFAULT_RPCCONNECT); - int port = GetArg("-rpcport", BaseParams().RPCPort()); + std::string host; + // In preference order, we choose the following for the port: + // 1. -rpcport + // 2. port in -rpcconnect (ie following : in ipv4 or ]: in ipv6) + // 3. default port for chain + int port = BaseParams().RPCPort(); + SplitHostPort(GetArg("-rpcconnect", DEFAULT_RPCCONNECT), port, host); + port = GetArg("-rpcport", port); // Obtain event base raii_event_base base = obtain_event_base(); |