Changeset View
Changeset View
Standalone View
Standalone View
src/httpserver.cpp
Show First 20 Lines • Show All 174 Lines • ▼ Show 20 Lines | static bool InitHTTPAllowList() { | ||||
CNetAddr localv4; | CNetAddr localv4; | ||||
CNetAddr localv6; | CNetAddr localv6; | ||||
LookupHost("127.0.0.1", localv4, false); | LookupHost("127.0.0.1", localv4, false); | ||||
LookupHost("::1", localv6, false); | LookupHost("::1", localv6, false); | ||||
// always allow IPv4 local subnet. | // always allow IPv4 local subnet. | ||||
rpc_allow_subnets.push_back(CSubNet(localv4, 8)); | rpc_allow_subnets.push_back(CSubNet(localv4, 8)); | ||||
// always allow IPv6 localhost. | // always allow IPv6 localhost. | ||||
rpc_allow_subnets.push_back(CSubNet(localv6)); | rpc_allow_subnets.push_back(CSubNet(localv6)); | ||||
if (mapMultiArgs.count("-rpcallowip")) { | if (gArgs.IsArgSet("-rpcallowip")) { | ||||
const std::vector<std::string> &vAllow = mapMultiArgs.at("-rpcallowip"); | for (const std::string &strAllow : gArgs.GetArgs("-rpcallowip")) { | ||||
for (std::string strAllow : vAllow) { | |||||
CSubNet subnet; | CSubNet subnet; | ||||
LookupSubNet(strAllow.c_str(), subnet); | LookupSubNet(strAllow.c_str(), subnet); | ||||
if (!subnet.IsValid()) { | if (!subnet.IsValid()) { | ||||
uiInterface.ThreadSafeMessageBox( | uiInterface.ThreadSafeMessageBox( | ||||
strprintf("Invalid -rpcallowip subnet specification: %s. " | strprintf("Invalid -rpcallowip subnet specification: %s. " | ||||
"Valid are a single IP (e.g. 1.2.3.4), a " | "Valid are a single IP (e.g. 1.2.3.4), a " | ||||
"network/netmask (e.g. 1.2.3.4/255.255.255.0) or " | "network/netmask (e.g. 1.2.3.4/255.255.255.0) or " | ||||
"a network/CIDR (e.g. 1.2.3.4/24).", | "a network/CIDR (e.g. 1.2.3.4/24).", | ||||
▲ Show 20 Lines • Show All 116 Lines • ▼ Show 20 Lines | if (!IsArgSet("-rpcallowip")) { | ||||
// 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 (IsArgSet("-rpcbind")) { | if (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"); | ||||
} | } | ||||
} else if (mapMultiArgs.count("-rpcbind")) { | } else if (gArgs.IsArgSet("-rpcbind")) { | ||||
// Specific bind address. | // Specific bind address. | ||||
const std::vector<std::string> &vbind = mapMultiArgs.at("-rpcbind"); | for (const std::string &strRPCBind : gArgs.GetArgs("-rpcbind")) { | ||||
for (std::vector<std::string>::const_iterator i = vbind.begin(); | |||||
i != vbind.end(); ++i) { | |||||
int port = defaultPort; | int port = defaultPort; | ||||
std::string host; | std::string host; | ||||
SplitHostPort(*i, port, host); | SplitHostPort(strRPCBind, port, host); | ||||
endpoints.push_back(std::make_pair(host, port)); | endpoints.push_back(std::make_pair(host, port)); | ||||
} | } | ||||
} else { | } else { | ||||
// No specific bind address specified, bind to any. | // No specific bind address specified, bind to any. | ||||
endpoints.push_back(std::make_pair("::", defaultPort)); | endpoints.push_back(std::make_pair("::", defaultPort)); | ||||
endpoints.push_back(std::make_pair("0.0.0.0", defaultPort)); | endpoints.push_back(std::make_pair("0.0.0.0", defaultPort)); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 329 Lines • Show Last 20 Lines |