Initialize ACL list for HTTP server */
| 90 | |
| 91 | /** Initialize ACL list for HTTP server */ |
| 92 | static bool InitHTTPAllowList() |
| 93 | { |
| 94 | rpc_allow_subnets.clear(); |
| 95 | rpc_allow_subnets.emplace_back(LookupHost("127.0.0.1", false).value(), 8); // always allow IPv4 local subnet |
| 96 | rpc_allow_subnets.emplace_back(LookupHost("::1", false).value()); // always allow IPv6 localhost |
| 97 | for (const std::string& strAllow : gArgs.GetArgs("-rpcallowip")) { |
| 98 | const CSubNet subnet{LookupSubNet(strAllow)}; |
| 99 | if (!subnet.IsValid()) { |
| 100 | uiInterface.ThreadSafeMessageBox( |
| 101 | Untranslated(strprintf("Invalid -rpcallowip subnet specification: %s. Valid values are a single IP (e.g. 1.2.3.4), a network/netmask (e.g. 1.2.3.4/255.255.255.0), a network/CIDR (e.g. 1.2.3.4/24), all ipv4 (0.0.0.0/0), or all ipv6 (::/0). RFC4193 is allowed only if -cjdnsreachable=0.", strAllow)), |
| 102 | CClientUIInterface::MSG_ERROR); |
| 103 | return false; |
| 104 | } |
| 105 | rpc_allow_subnets.push_back(subnet); |
| 106 | } |
| 107 | std::string strAllowed; |
| 108 | for (const CSubNet& subnet : rpc_allow_subnets) |
| 109 | strAllowed += subnet.ToString() + " "; |
| 110 | LogDebug(BCLog::HTTP, "Allowing HTTP connections from: %s\n", strAllowed); |
| 111 | return true; |
| 112 | } |
| 113 | |
| 114 | /** HTTP request method as string - use for logging only */ |
| 115 | std::string_view RequestMethodString(HTTPRequestMethod m) |
no test coverage detected