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

Function InitHTTPAllowList

src/httpserver.cpp:171–194  ·  view source on GitHub ↗

Initialize ACL list for HTTP server */

Source from the content-addressed store, hash-verified

169
170/** Initialize ACL list for HTTP server */
171static bool InitHTTPAllowList()
172{
173 rpc_allow_subnets.clear();
174 rpc_allow_subnets.push_back(CSubNet("127.0.0.0/8")); // always allow IPv4 local subnet
175 rpc_allow_subnets.push_back(CSubNet("::1")); // always allow IPv6 localhost
176 if (mapMultiArgs.count("-rpcallowip")) {
177 const std::vector<std::string>& vAllow = mapMultiArgs["-rpcallowip"];
178 BOOST_FOREACH (std::string strAllow, vAllow) {
179 CSubNet subnet(strAllow);
180 if (!subnet.IsValid()) {
181 uiInterface.ThreadSafeMessageBox(
182 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),
183 "", CClientUIInterface::MSG_ERROR);
184 return false;
185 }
186 rpc_allow_subnets.push_back(subnet);
187 }
188 }
189 std::string strAllowed;
190 BOOST_FOREACH (const CSubNet& subnet, rpc_allow_subnets)
191 strAllowed += subnet.ToString() + " ";
192 LogPrint("http", "Allowing HTTP connections from: %s\n", strAllowed);
193 return true;
194}
195
196/** HTTP request method as string - use for logging only */
197static std::string RequestMethodString(HTTPRequest::RequestMethod m)

Callers 1

InitHTTPServerFunction · 0.85

Calls 5

CSubNetClass · 0.85
countMethod · 0.80
clearMethod · 0.45
push_backMethod · 0.45
ToStringMethod · 0.45

Tested by

no test coverage detected