From 0c366a8e8183228b86f715d8dd9dbbaf49f7d3e9 Mon Sep 17 00:00:00 2001 From: Pieter Lexis Date: Wed, 13 Feb 2019 11:07:43 +0100 Subject: [PATCH] rec: Add rec_control getters for dont-throttle-* --- pdns/rec_channel.hh | 4 ++++ pdns/rec_channel_rec.cc | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/pdns/rec_channel.hh b/pdns/rec_channel.hh index 0f1dd7973e..8f590340a8 100644 --- a/pdns/rec_channel.hh +++ b/pdns/rec_channel.hh @@ -29,8 +29,12 @@ #include #include "iputils.hh" #include "dnsname.hh" +#include "sholder.hh" #include +extern GlobalStateHolder g_dontThrottleNames; +extern GlobalStateHolder g_dontThrottleNetmasks; + /** this class is used both to send and answer channel commands to the PowerDNS Recursor */ class RecursorControlChannel { diff --git a/pdns/rec_channel_rec.cc b/pdns/rec_channel_rec.cc index 0259c68758..a7fdab2ec7 100644 --- a/pdns/rec_channel_rec.cc +++ b/pdns/rec_channel_rec.cc @@ -1288,6 +1288,16 @@ static string* nopFunction() return new string("pong\n"); } +string getDontThrottleNames() { + auto dtn = g_dontThrottleNames.getLocal(); + return dtn->toString() + "\n"; +} + +string getDontThrottleNetmasks() { + auto dtn = g_dontThrottleNetmasks.getLocal(); + return dtn->toString() + "\n"; +} + string RecursorControlParser::getAnswer(const string& question, RecursorControlParser::func_t** command) { *command=nop; @@ -1315,6 +1325,8 @@ string RecursorControlParser::getAnswer(const string& question, RecursorControlP "dump-throttlemap dump the contents of the throttle to the named file\n" "get [key1] [key2] .. get specific statistics\n" "get-all get all statistics\n" +"get-dont-throttle-names get the list of names that are not allowed to be throttled\n" +"get-dont-throttle-netmasks get the list of netmasks that are not allowed to be throttled\n" "get-ntas get all configured Negative Trust Anchors\n" "get-tas get all configured Trust Anchors\n" "get-parameter [key1] [key2] .. get configuration parameters\n" @@ -1540,5 +1552,13 @@ string RecursorControlParser::getAnswer(const string& question, RecursorControlP if (cmd=="set-dnssec-log-bogus") return doSetDnssecLogBogus(begin, end); + if (cmd == "get-dont-throttle-names") { + return getDontThrottleNames(); + } + + if (cmd == "get-dont-throttle-netmasks") { + return getDontThrottleNetmasks(); + } + return "Unknown command '"+cmd+"', try 'help'\n"; } -- 2.47.2