Initialize ACL list for HTTP server */
| 161 | |
| 162 | /** Initialize ACL list for HTTP server */ |
| 163 | static bool InitHTTPAllowList() |
| 164 | { |
| 165 | rpc_allow_subnets.clear(); |
| 166 | CNetAddr localv4; |
| 167 | CNetAddr localv6; |
| 168 | LookupHost("127.0.0.1", localv4, false); |
| 169 | LookupHost("::1", localv6, false); |
| 170 | rpc_allow_subnets.push_back(CSubNet(localv4, 8)); // always allow IPv4 local subnet |
| 171 | rpc_allow_subnets.push_back(CSubNet(localv6)); // always allow IPv6 localhost |
| 172 | for (const std::string& strAllow : gArgs.GetArgs("-rpcallowip")) { |
| 173 | CSubNet subnet; |
| 174 | LookupSubNet(strAllow, subnet); |
| 175 | if (!subnet.IsValid()) { |
| 176 | uiInterface.ThreadSafeMessageBox( |
| 177 | strprintf(Untranslated("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), |
| 178 | "", CClientUIInterface::MSG_ERROR); |
| 179 | return false; |
| 180 | } |
| 181 | rpc_allow_subnets.push_back(subnet); |
| 182 | } |
| 183 | std::string strAllowed; |
| 184 | for (const CSubNet& subnet : rpc_allow_subnets) |
| 185 | strAllowed += subnet.ToString() + " "; |
| 186 | LogPrint(BCLog::HTTP, "Allowing HTTP connections from: %s\n", strAllowed); |
| 187 | return true; |
| 188 | } |
| 189 | |
| 190 | /** HTTP request method as string - use for logging only */ |
| 191 | std::string RequestMethodString(HTTPRequest::RequestMethod m) |
no test coverage detected