Initialize ACL list for HTTP server */
| 165 | |
| 166 | /** Initialize ACL list for HTTP server */ |
| 167 | static 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 */ |
| 193 | static std::string RequestMethodString(HTTPRequest::RequestMethod m) |