MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / InitHTTPAllowList

Function InitHTTPAllowList

src/httpserver.cpp:92–112  ·  view source on GitHub ↗

Initialize ACL list for HTTP server */

Source from the content-addressed store, hash-verified

90
91/** Initialize ACL list for HTTP server */
92static bool InitHTTPAllowList()
93{
94 rpc_allow_subnets.clear();
95 rpc_allow_subnets.emplace_back(LookupHost("127.0.0.1", false).value(), 8); // always allow IPv4 local subnet
96 rpc_allow_subnets.emplace_back(LookupHost("::1", false).value()); // always allow IPv6 localhost
97 for (const std::string& strAllow : gArgs.GetArgs("-rpcallowip")) {
98 const CSubNet subnet{LookupSubNet(strAllow)};
99 if (!subnet.IsValid()) {
100 uiInterface.ThreadSafeMessageBox(
101 Untranslated(strprintf("Invalid -rpcallowip subnet specification: %s. Valid values are a single IP (e.g. 1.2.3.4), a network/netmask (e.g. 1.2.3.4/255.255.255.0), a network/CIDR (e.g. 1.2.3.4/24), all ipv4 (0.0.0.0/0), or all ipv6 (::/0). RFC4193 is allowed only if -cjdnsreachable=0.", strAllow)),
102 CClientUIInterface::MSG_ERROR);
103 return false;
104 }
105 rpc_allow_subnets.push_back(subnet);
106 }
107 std::string strAllowed;
108 for (const CSubNet& subnet : rpc_allow_subnets)
109 strAllowed += subnet.ToString() + " ";
110 LogDebug(BCLog::HTTP, "Allowing HTTP connections from: %s\n", strAllowed);
111 return true;
112}
113
114/** HTTP request method as string - use for logging only */
115std::string_view RequestMethodString(HTTPRequestMethod m)

Callers 1

InitHTTPServerFunction · 0.85

Calls 10

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

Tested by

no test coverage detected