Initialize ACL list for HTTP server */
| 169 | |
| 170 | /** Initialize ACL list for HTTP server */ |
| 171 | static bool InitHTTPAllowList() |
| 172 | { |
| 173 | rpc_allow_subnets.clear(); |
| 174 | rpc_allow_subnets.push_back(CSubNet("127.0.0.0/8")); // always allow IPv4 local subnet |
| 175 | rpc_allow_subnets.push_back(CSubNet("::1")); // always allow IPv6 localhost |
| 176 | if (mapMultiArgs.count("-rpcallowip")) { |
| 177 | const std::vector<std::string>& vAllow = mapMultiArgs["-rpcallowip"]; |
| 178 | BOOST_FOREACH (std::string strAllow, vAllow) { |
| 179 | CSubNet subnet(strAllow); |
| 180 | if (!subnet.IsValid()) { |
| 181 | uiInterface.ThreadSafeMessageBox( |
| 182 | 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), |
| 183 | "", CClientUIInterface::MSG_ERROR); |
| 184 | return false; |
| 185 | } |
| 186 | rpc_allow_subnets.push_back(subnet); |
| 187 | } |
| 188 | } |
| 189 | std::string strAllowed; |
| 190 | BOOST_FOREACH (const CSubNet& subnet, rpc_allow_subnets) |
| 191 | strAllowed += subnet.ToString() + " "; |
| 192 | LogPrint("http", "Allowing HTTP connections from: %s\n", strAllowed); |
| 193 | return true; |
| 194 | } |
| 195 | |
| 196 | /** HTTP request method as string - use for logging only */ |
| 197 | static std::string RequestMethodString(HTTPRequest::RequestMethod m) |