Initialize ACL list for HTTP server */
| 175 | |
| 176 | /** Initialize ACL list for HTTP server */ |
| 177 | static 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 */ |
| 207 | static std::string RequestMethodString(HTTPRequest::RequestMethod m) { |
no test coverage detected