MCPcopy Create free account
hub / github.com/Bitcoin-ABC/bitcoin-abc / InitHTTPAllowList

Function InitHTTPAllowList

src/httpserver.cpp:229–258  ·  view source on GitHub ↗

Initialize ACL list for HTTP server */

Source from the content-addressed store, hash-verified

227
228/** Initialize ACL list for HTTP server */
229static bool InitHTTPAllowList() {
230 rpc_allow_subnets.clear();
231 // always allow IPv4 local subnet
232 rpc_allow_subnets.push_back(
233 CSubNet{LookupHost("127.0.0.1", false).value(), 8});
234 // always allow IPv6 localhost
235 rpc_allow_subnets.push_back(CSubNet{LookupHost("::1", false).value()});
236 for (const std::string &strAllow : gArgs.GetArgs("-rpcallowip")) {
237 CSubNet subnet;
238 LookupSubNet(strAllow, subnet);
239 if (!subnet.IsValid()) {
240 uiInterface.ThreadSafeMessageBox(
241 strprintf(
242 Untranslated("Invalid -rpcallowip subnet specification: "
243 "%s. Valid are a single IP (e.g. 1.2.3.4), a "
244 "network/netmask (e.g. 1.2.3.4/255.255.255.0) "
245 "or a network/CIDR (e.g. 1.2.3.4/24)."),
246 strAllow),
247 "", CClientUIInterface::MSG_ERROR);
248 return false;
249 }
250 rpc_allow_subnets.push_back(subnet);
251 }
252 std::string strAllowed;
253 for (const CSubNet &subnet : rpc_allow_subnets) {
254 strAllowed += subnet.ToString() + " ";
255 }
256 LogPrint(BCLog::HTTP, "Allowing HTTP connections from: %s\n", strAllowed);
257 return true;
258}
259
260/** HTTP request method as string - use for logging only */
261std::string RequestMethodString(HTTPRequest::RequestMethod m) {

Callers 1

InitHTTPServerFunction · 0.85

Calls 10

LookupHostFunction · 0.85
LookupSubNetFunction · 0.85
UntranslatedFunction · 0.85
GetArgsMethod · 0.80
ThreadSafeMessageBoxMethod · 0.80
clearMethod · 0.65
push_backMethod · 0.45
valueMethod · 0.45
IsValidMethod · 0.45
ToStringMethod · 0.45

Tested by

no test coverage detected