MCPcopy Create free account
hub / github.com/LUX-Core/lux / InitHTTPAllowList

Function InitHTTPAllowList

src/httpserver.cpp:167–190  ·  view source on GitHub ↗

Initialize ACL list for HTTP server */

Source from the content-addressed store, hash-verified

165
166/** Initialize ACL list for HTTP server */
167static bool InitHTTPAllowList()
168{
169 rpc_allow_subnets.clear();
170 rpc_allow_subnets.push_back(CSubNet("127.0.0.0/8")); // always allow IPv4 local subnet
171 rpc_allow_subnets.push_back(CSubNet("::1")); // always allow IPv6 localhost
172 if (mapMultiArgs.count("-rpcallowip")) {
173 const std::vector<std::string>& vAllow = mapMultiArgs["-rpcallowip"];
174 for (std::string strAllow : vAllow) {
175 CSubNet subnet(strAllow);
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 }
185 std::string strAllowed;
186 for (const CSubNet& subnet : rpc_allow_subnets)
187 strAllowed += subnet.ToString() + " ";
188 LogPrint("http", "Allowing HTTP connections from: %s\n", strAllowed);
189 return true;
190}
191
192/** HTTP request method as string - use for logging only */
193static std::string RequestMethodString(HTTPRequest::RequestMethod m)

Callers 1

InitHTTPServerFunction · 0.85

Calls 7

CSubNetClass · 0.85
LogPrintFunction · 0.85
clearMethod · 0.45
push_backMethod · 0.45
countMethod · 0.45
IsValidMethod · 0.45
ToStringMethod · 0.45

Tested by

no test coverage detected