MCPcopy Create free account
hub / github.com/ElementsProject/elements / InitHTTPAllowList

Function InitHTTPAllowList

src/httpserver.cpp:163–188  ·  view source on GitHub ↗

Initialize ACL list for HTTP server */

Source from the content-addressed store, hash-verified

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

Tested by

no test coverage detected