From: Pieter Lexis Date: Wed, 13 Feb 2019 11:15:44 +0000 (+0100) Subject: Add rec_control setters for dont-throttle-* X-Git-Tag: rec-4.2.0-beta1~7^2~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c4ce5418419ff696d9d5d42a7c88141783777eb3;p=thirdparty%2Fpdns.git Add rec_control setters for dont-throttle-* --- diff --git a/pdns/rec_channel_rec.cc b/pdns/rec_channel_rec.cc index a7fdab2ec7..850cf935ae 100644 --- a/pdns/rec_channel_rec.cc +++ b/pdns/rec_channel_rec.cc @@ -1298,6 +1298,81 @@ string getDontThrottleNetmasks() { return dtn->toString() + "\n"; } +template +string addDontThrottleNames(T begin, T end) { + if (begin == end) { + return "No names specified, keeping existing list\n"; + } + vector toAdd; + while (begin != end) { + try { + auto d = DNSName(*begin); + toAdd.push_back(d); + } + catch(const std::exception &e) { + return "Problem parsing '" + *begin + "': "+ e.what() + ", nothing added\n"; + } + begin++; + } + + string ret = "Added"; + auto dnt = g_dontThrottleNames.getCopy(); + bool first = true; + for (auto const &d : toAdd) { + if (!first) { + ret += ","; + } + first = false; + ret += " " + d.toLogString(); + dnt.add(d); + } + + g_dontThrottleNames.setState(dnt); + + ret += " to the list of nameservers that may not be throttled"; + g_log< +string addDontThrottleNetmasks(T begin, T end) { + if (begin == end) { + return "No netmasks specified, keeping existing list\n"; + } + vector toAdd; + while (begin != end) { + try { + auto n = Netmask(*begin); + toAdd.push_back(n); + } + catch(const std::exception &e) { + return "Problem parsing '" + *begin + "': "+ e.what() + ", nothing added\n"; + } + catch(const PDNSException &e) { + return "Problem parsing '" + *begin + "': "+ e.reason + ", nothing added\n"; + } + begin++; + } + + string ret = "Added"; + auto dnt = g_dontThrottleNetmasks.getCopy(); + bool first = true; + for (auto const &t : toAdd) { + if (!first) { + ret += ","; + } + first = false; + ret += " " + t.toString(); + dnt.addMask(t); + } + + g_dontThrottleNetmasks.setState(dnt); + + ret += " to the list of nameserver netmasks that may not be throttled"; + g_log<