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

Function InitHTTPAllowList

src/httpserver.cpp:164–189  ·  view source on GitHub ↗

Initialize ACL list for HTTP server */

Source from the content-addressed store, hash-verified

162
163/** Initialize ACL list for HTTP server */
164static bool InitHTTPAllowList()
165{
166 rpc_allow_subnets.clear();
167 CNetAddr localv4;
168 CNetAddr localv6;
169 LookupHost("127.0.0.1", localv4, false);
170 LookupHost("::1", localv6, false);
171 rpc_allow_subnets.push_back(CSubNet(localv4, 8)); // always allow IPv4 local subnet
172 rpc_allow_subnets.push_back(CSubNet(localv6)); // always allow IPv6 localhost
173 for (const std::string& strAllow : gArgs.GetArgs("-rpcallowip")) {
174 CSubNet subnet;
175 LookupSubNet(strAllow.c_str(), subnet);
176 if (!subnet.IsValid()) {
177 uiInterface.ThreadSafeMessageBox(
178 strprintf("Invalid -rpcallowip subnet specification: %s. 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 a network/CIDR (e.g. 1.2.3.4/24).", strAllow),
179 "", CClientUIInterface::MSG_ERROR);
180 return false;
181 }
182 rpc_allow_subnets.push_back(subnet);
183 }
184 std::string strAllowed;
185 for (const CSubNet& subnet : rpc_allow_subnets)
186 strAllowed += subnet.ToString() + " ";
187 LogPrint(BCLog::HTTP, "Allowing HTTP connections from: %s\n", strAllowed);
188 return true;
189}
190
191/** HTTP request method as string - use for logging only */
192static std::string RequestMethodString(HTTPRequest::RequestMethod m)

Callers 1

InitHTTPServerFunction · 0.85

Calls 8

LookupHostFunction · 0.85
LookupSubNetFunction · 0.85
GetArgsMethod · 0.80
CSubNetClass · 0.70
clearMethod · 0.45
push_backMethod · 0.45
IsValidMethod · 0.45
ToStringMethod · 0.45

Tested by

no test coverage detected