Changeset View
Changeset View
Standalone View
Standalone View
src/httpserver.cpp
Show First 20 Lines • Show All 300 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
/** Bind HTTP server to specified addresses */ | /** Bind HTTP server to specified addresses */ | ||||
static bool HTTPBindAddresses(struct evhttp *http) { | static bool HTTPBindAddresses(struct evhttp *http) { | ||||
int defaultPort = gArgs.GetArg("-rpcport", BaseParams().RPCPort()); | int defaultPort = gArgs.GetArg("-rpcport", BaseParams().RPCPort()); | ||||
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")) { | if (!(gArgs.IsArgSet("-rpcallowip") && gArgs.IsArgSet("-rpcbind")) { | ||||
// Default to loopback if not allowing external IPs. | // Default to loopback if not allowing external IPs. | ||||
endpoints.push_back(std::make_pair("::1", defaultPort)); | endpoints.push_back(std::make_pair("::1", defaultPort)); | ||||
endpoints.push_back(std::make_pair("127.0.0.1", defaultPort)); | endpoints.push_back(std::make_pair("127.0.0.1", defaultPort)); | ||||
if (gArgs.IsArgSet("-rpcbind")) { | if (gArgs.IsArgSet("-rpcbind")) { | ||||
LogPrintf("WARNING: option -rpcbind was ignored because " | LogPrintf("WARNING: option -rpcbind was ignored because " | ||||
"-rpcallowip was not specified, refusing to allow " | "-rpcallowip was not specified, refusing to allow " | ||||
"everyone to connect\n"); | "everyone to connect\n"); | ||||
} | } | ||||
if (gArgs.IsArgSet("-rpcallowip")) { | |||||
LogPrintf("WARNING: option -rpcallowip was specified without" | |||||
"-rpcbind; this doesn't usually make sense\n"); | |||||
} | |||||
} else if (gArgs.IsArgSet("-rpcbind")) { | } else if (gArgs.IsArgSet("-rpcbind")) { | ||||
// Specific bind address. | // Specific bind address. | ||||
for (const std::string &strRPCBind : gArgs.GetArgs("-rpcbind")) { | for (const std::string &strRPCBind : gArgs.GetArgs("-rpcbind")) { | ||||
int port = defaultPort; | int port = defaultPort; | ||||
std::string host; | std::string host; | ||||
SplitHostPort(strRPCBind, port, host); | SplitHostPort(strRPCBind, port, host); | ||||
endpoints.push_back(std::make_pair(host, port)); | endpoints.push_back(std::make_pair(host, port)); | ||||
} | } | ||||
} else { | |||||
// No specific bind address specified, bind to any. | |||||
endpoints.push_back(std::make_pair("::", defaultPort)); | |||||
endpoints.push_back(std::make_pair("0.0.0.0", defaultPort)); | |||||
} | } | ||||
// Bind addresses | // Bind addresses | ||||
for (std::vector<std::pair<std::string, uint16_t>>::iterator i = | for (std::vector<std::pair<std::string, uint16_t>>::iterator i = | ||||
endpoints.begin(); | endpoints.begin(); | ||||
i != endpoints.end(); ++i) { | i != endpoints.end(); ++i) { | ||||
LogPrint(BCLog::HTTP, "Binding RPC on address %s port %i\n", i->first, | LogPrint(BCLog::HTTP, "Binding RPC on address %s port %i\n", i->first, | ||||
i->second); | i->second); | ||||
evhttp_bound_socket *bind_handle = evhttp_bind_socket_with_handle( | evhttp_bound_socket *bind_handle = evhttp_bind_socket_with_handle( | ||||
http, i->first.empty() ? nullptr : i->first.c_str(), i->second); | http, i->first.empty() ? nullptr : i->first.c_str(), i->second); | ||||
if (bind_handle) { | if (bind_handle) { | ||||
CNetAddr addr; | CNetAddr addr; | ||||
if (i->first.empty() || (LookupHost(i->first.c_str(), addr, false) && addr.IsBindAny())) { | if (i->first.empty() || | ||||
LogPrintf("WARNING: the RPC server is not safe to expose to untrusted networks such as the public internet\n"); | (LookupHost(i->first.c_str(), addr, false) && | ||||
deadalnix: This clearly does not match what's in master at the moment, so you probably did something wrong… | |||||
addr.IsBindAny())) { | |||||
LogPrintf("WARNING: the RPC server is not safe to expose to " | |||||
"untrusted networks such as the public internet\n"); | |||||
} | } | ||||
boundSockets.push_back(bind_handle); | boundSockets.push_back(bind_handle); | ||||
} else { | } else { | ||||
LogPrintf("Binding RPC on address %s port %i failed.\n", i->first, | LogPrintf("Binding RPC on address %s port %i failed.\n", i->first, | ||||
i->second); | i->second); | ||||
} | } | ||||
} | } | ||||
return !boundSockets.empty(); | return !boundSockets.empty(); | ||||
▲ Show 20 Lines • Show All 353 Lines • Show Last 20 Lines |
This clearly does not match what's in master at the moment, so you probably did something wrong here.