Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
[utils] Allow bitcoin-cli's -rpcconnect option to be used with square brackets #10812
Conversation
MeshCollider
commented
Jul 13, 2017
|
utACK 7b77805 |
|
utACK 7b77805 |
jonasschnelli
added the
Scripts and tools
label
Jul 13, 2017
| - std::string host = GetArg("-rpcconnect", DEFAULT_RPCCONNECT); | ||
| + std::string host; | ||
| + int dummy_port; | ||
| + SplitHostPort(GetArg("-rpcconnect", DEFAULT_RPCCONNECT), dummy_port, host); |
laanwj
Jul 13, 2017
•
Owner
If you're going to do this anyway, why not allow overriding the port? (e.g. pass port instead of dummy_port, to make it possible to override the rpcport)
After all, the point of bracketed addresses is to allow [ip]:port specifications unambigiously.
jnewbery
Jul 13, 2017
Member
I chose not to allow overriding the port since we already have the -rpcport option, and this is the minimal functional change.
I'm equally happy to make the one-line change so -rpcconnect can accept <address>:<port>. I have zero preference either way and I'm happy to go along with consensus opinion. @theuni has already expressed slight preference for allowing a port number in -rpcconnect.
laanwj
Jul 13, 2017
Owner
I'd really prefer to be able to override the port in rpcconnect.
FYI we have a similar thing at the server side with bind which can either take a address and port (overriding -port) or just an address (in which case -port is used).
If not I'd rather NACK this. It is just confusing to parse an [ip]:port spec if you're going to ignore the port.
jnewbery
Jul 13, 2017
Member
sure - changed to use the port from -rpcconnect if it's specified.
It was a bit more than a one line change because it was a little fiddly to get the precedence correct:
- -rpcport if there is one; else
- port in -rpcconnect if there is one; else
- default port for the chain
|
utACK, looks good to me now, thanks! |
|
utACK 5c64324 |
| @@ -91,6 +91,25 @@ std::vector<unsigned char> ParseHex(const std::string& str) | ||
| return ParseHex(str.c_str()); | ||
| } | ||
| +void SplitHostPort(std::string in, int &portOut, std::string &hostOut) { |
jnewbery
Jul 15, 2017
Member
It's decoding a string into two parts and calls ParseInt32().
Happy to take suggestions of a better place to put this. It needs to be in libbitcoin_util to make it available to bitcoin-cli. bitcoin-cli doesn't link libbitcoin_common.
|
utACK 5c64324 |
sipa
merged commit 5c64324
into
bitcoin:master
Jul 15, 2017
1 check passed
sipa
added a commit
that referenced
this pull request
Jul 15, 2017
|
|
sipa |
c5904e8
|
jnewbery commentedJul 12, 2017
bitcoin-cli's
-rpcconnectcan accept ipv6 addresses (as long as the libevent version is new enough), but fails to parse ipv6 with square brackets. This PR makesbitcoin-cliparse ipv6 in square brackets correctly.bitcoin-cli -rpcconnect=[::1] <command>should now be equivalent to
bitcoin-cli -rpcconnect=::1 <command>This is useful so the
bitcoin-clioption can now be in the same format as thebitcoindoption.Doesn't include tests. I have a branch that fully tests
bitcoin-cli, but that's queued behind several intermediate PRs.SplitHostPort()from libbitcoin_common into libbitcoin_util