| 641 | } |
| 642 | |
| 643 | std::string enableDnsLeaksProtection(const std::string &pars) |
| 644 | { |
| 645 | std::vector<std::wstring> customDnsIp; |
| 646 | deserializePars(pars, customDnsIp); |
| 647 | |
| 648 | // Rather than reject the whole request on bad input, sanitize it: drop any invalid IP entries |
| 649 | // and apply the valid remainder. These IPs are only excluded from the DNS firewall block, so |
| 650 | // dropping a malformed one fails closed (that IP simply stays blocked). |
| 651 | customDnsIp.erase(std::remove_if(customDnsIp.begin(), customDnsIp.end(), |
| 652 | [](const std::wstring &ip) { |
| 653 | if (NetworkValidation::isValidIpAddress(ip)) { |
| 654 | return false; |
| 655 | } |
| 656 | spdlog::error(L"enableDnsLeaksProtection: dropping invalid IP address: \"{}\"", ip); |
| 657 | return true; |
| 658 | }), |
| 659 | customDnsIp.end()); |
| 660 | |
| 661 | spdlog::debug("enableDnsLeaksProtection"); |
| 662 | DnsFirewall::instance().setExcludeIps(customDnsIp); |
| 663 | DnsFirewall::instance().enable(); |
| 664 | return std::string(); |
| 665 | } |
| 666 | |
| 667 | std::string disableDnsLeaksProtection(const std::string &pars) |
| 668 | { |
nothing calls this directly
no test coverage detected