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

Function InitHTTPAllowList

src/rpc/core/httpserver.cpp:177–204  ·  view source on GitHub ↗

Initialize ACL list for HTTP server */

Source from the content-addressed store, hash-verified

175
176/** Initialize ACL list for HTTP server */
177static bool InitHTTPAllowList() {
178 rpc_allow_subnets.clear();
179 CNetAddr localv4;
180 CNetAddr localv6;
181 LookupHost("127.0.0.1", localv4, false);
182 LookupHost("::1", localv6, false);
183 rpc_allow_subnets.push_back(CSubNet(localv4, 8)); // always allow IPv4 local subnet
184 rpc_allow_subnets.push_back(CSubNet(localv6)); // always allow IPv6 localhost
185 for (const std::string& strAllow : SysCfg().GetMultiArgs("-rpcallowip")) {
186 CSubNet subnet;
187 LookupSubNet(strAllow.c_str(), subnet);
188 if (!subnet.IsValid()) {
189 LogPrint(BCLog::ERROR,
190 "Invalid -rpcallowip subnet specification: %s. Valid are a single IP "
191 "(e.g. 1.2.3.4), a network/netmask (e.g. 1.2.3.4/255.255.255.0) or a "
192 "network/CIDR (e.g. 1.2.3.4/24).\n",
193 strAllow);
194 return false;
195 }
196 rpc_allow_subnets.push_back(subnet);
197 }
198 std::string strAllowed;
199 for (const CSubNet& subnet : rpc_allow_subnets) {
200 strAllowed += subnet.ToString() + " ";
201 }
202 LogPrint(BCLog::RPC, "Allowing HTTP connections from: %s\n", strAllowed);
203 return true;
204}
205
206/** HTTP request method as string - use for logging only */
207static std::string RequestMethodString(HTTPRequest::RequestMethod m) {

Callers 1

InitHTTPServerFunction · 0.85

Calls 7

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

Tested by

no test coverage detected