Initialize ACL list for HTTP server */
| 227 | |
| 228 | /** Initialize ACL list for HTTP server */ |
| 229 | static bool InitHTTPAllowList() { |
| 230 | rpc_allow_subnets.clear(); |
| 231 | // always allow IPv4 local subnet |
| 232 | rpc_allow_subnets.push_back( |
| 233 | CSubNet{LookupHost("127.0.0.1", false).value(), 8}); |
| 234 | // always allow IPv6 localhost |
| 235 | rpc_allow_subnets.push_back(CSubNet{LookupHost("::1", false).value()}); |
| 236 | for (const std::string &strAllow : gArgs.GetArgs("-rpcallowip")) { |
| 237 | CSubNet subnet; |
| 238 | LookupSubNet(strAllow, subnet); |
| 239 | if (!subnet.IsValid()) { |
| 240 | uiInterface.ThreadSafeMessageBox( |
| 241 | strprintf( |
| 242 | Untranslated("Invalid -rpcallowip subnet specification: " |
| 243 | "%s. Valid are a single IP (e.g. 1.2.3.4), a " |
| 244 | "network/netmask (e.g. 1.2.3.4/255.255.255.0) " |
| 245 | "or a network/CIDR (e.g. 1.2.3.4/24)."), |
| 246 | strAllow), |
| 247 | "", CClientUIInterface::MSG_ERROR); |
| 248 | return false; |
| 249 | } |
| 250 | rpc_allow_subnets.push_back(subnet); |
| 251 | } |
| 252 | std::string strAllowed; |
| 253 | for (const CSubNet &subnet : rpc_allow_subnets) { |
| 254 | strAllowed += subnet.ToString() + " "; |
| 255 | } |
| 256 | LogPrint(BCLog::HTTP, "Allowing HTTP connections from: %s\n", strAllowed); |
| 257 | return true; |
| 258 | } |
| 259 | |
| 260 | /** HTTP request method as string - use for logging only */ |
| 261 | std::string RequestMethodString(HTTPRequest::RequestMethod m) { |
no test coverage detected