mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-22 15:04:44 +01:00
Fix nonsensical -norpcbind and -norpcallowip behavior
Treat specifying -norpcbind and -norpcallowip the same as not specifying -rpcbind or -rpcallowip, instead of failing to bind to localhost and failing to show warnings. Also add code comment to clarify what intent of existing code is.
This commit is contained in:
parent
40c4899bc2
commit
e03409c70f
1 changed files with 8 additions and 4 deletions
|
@ -362,16 +362,20 @@ static bool HTTPBindAddresses(struct evhttp* http)
|
||||||
std::vector<std::pair<std::string, uint16_t>> endpoints;
|
std::vector<std::pair<std::string, uint16_t>> endpoints;
|
||||||
|
|
||||||
// Determine what addresses to bind to
|
// Determine what addresses to bind to
|
||||||
if (!(gArgs.IsArgSet("-rpcallowip") && gArgs.IsArgSet("-rpcbind"))) { // Default to loopback if not allowing external IPs
|
// To prevent misconfiguration and accidental exposure of the RPC
|
||||||
|
// interface, require -rpcallowip and -rpcbind to both be specified
|
||||||
|
// together. If either is missing, ignore both values, bind to localhost
|
||||||
|
// instead, and log warnings.
|
||||||
|
if (gArgs.GetArgs("-rpcallowip").empty() || gArgs.GetArgs("-rpcbind").empty()) { // Default to loopback if not allowing external IPs
|
||||||
endpoints.emplace_back("::1", http_port);
|
endpoints.emplace_back("::1", http_port);
|
||||||
endpoints.emplace_back("127.0.0.1", http_port);
|
endpoints.emplace_back("127.0.0.1", http_port);
|
||||||
if (gArgs.IsArgSet("-rpcallowip")) {
|
if (!gArgs.GetArgs("-rpcallowip").empty()) {
|
||||||
LogPrintf("WARNING: option -rpcallowip was specified without -rpcbind; this doesn't usually make sense\n");
|
LogPrintf("WARNING: option -rpcallowip was specified without -rpcbind; this doesn't usually make sense\n");
|
||||||
}
|
}
|
||||||
if (gArgs.IsArgSet("-rpcbind")) {
|
if (!gArgs.GetArgs("-rpcbind").empty()) {
|
||||||
LogPrintf("WARNING: option -rpcbind was ignored because -rpcallowip was not specified, refusing to allow everyone to connect\n");
|
LogPrintf("WARNING: option -rpcbind was ignored because -rpcallowip was not specified, refusing to allow everyone to connect\n");
|
||||||
}
|
}
|
||||||
} else if (gArgs.IsArgSet("-rpcbind")) { // Specific bind address
|
} else { // Specific bind addresses
|
||||||
for (const std::string& strRPCBind : gArgs.GetArgs("-rpcbind")) {
|
for (const std::string& strRPCBind : gArgs.GetArgs("-rpcbind")) {
|
||||||
uint16_t port{http_port};
|
uint16_t port{http_port};
|
||||||
std::string host;
|
std::string host;
|
||||||
|
|
Loading…
Add table
Reference in a new issue