From: Remi Gacogne Date: Mon, 10 Aug 2020 16:16:17 +0000 (+0200) Subject: dnsdist: Add the 'clearConsoleHistory' command X-Git-Tag: rec-4.4.0-beta1~2^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=87e6359691e1bca47123510eb1da7755178096bc;p=thirdparty%2Fpdns.git dnsdist: Add the 'clearConsoleHistory' command It removes the history items and delta() data from memory. --- diff --git a/pdns/dnsdist-console.cc b/pdns/dnsdist-console.cc index d68eb6b58f..7384cd115c 100644 --- a/pdns/dnsdist-console.cc +++ b/pdns/dnsdist-console.cc @@ -187,7 +187,6 @@ void doClient(ComboAddress server, const std::string& command) } string histfile = historyFile(); - set dupper; { ifstream history(histfile); string line; @@ -230,7 +229,6 @@ void doClient(ComboAddress server, const std::string& command) void doConsole() { string histfile = historyFile(true); - set dupper; { ifstream history(histfile); string line; @@ -362,10 +360,11 @@ const std::vector g_consoleKeywords{ { "AndRule", true, "list of DNS rules", "matches if all sub-rules matches" }, { "benchRule", true, "DNS Rule [, iterations [, suffix]]", "bench the specified DNS rule" }, { "carbonServer", true, "serverIP, [ourname], [interval]", "report statistics to serverIP using our hostname, or 'ourname' if provided, every 'interval' seconds" }, - { "controlSocket", true, "addr", "open a control socket on this address / connect to this address in client mode" }, + { "clearConsoleHistory", true, "", "clear the internal (in-memory) history of console commands" }, { "clearDynBlocks", true, "", "clear all dynamic blocks" }, { "clearQueryCounters", true, "", "clears the query counter buffer" }, { "clearRules", true, "", "remove all current rules" }, + { "controlSocket", true, "addr", "open a control socket on this address / connect to this address in client mode" }, { "ContinueAction", true, "action", "execute the specified action and continue the processing of the remaining rules, regardless of the return of the action" }, { "DelayAction", true, "milliseconds", "delay the response by the specified amount of milliseconds (UDP-only)" }, { "DelayResponseAction", true, "milliseconds", "delay the response by the specified amount of milliseconds (UDP-only)" }, @@ -822,3 +821,9 @@ catch(const std::exception& e) close(fd); errlog("Control connection died: %s", e.what()); } + +void clearConsoleHistory() +{ + clear_history(); + g_confDelta.clear(); +} diff --git a/pdns/dnsdist-console.hh b/pdns/dnsdist-console.hh index 1c3bb6e2f8..70800644a5 100644 --- a/pdns/dnsdist-console.hh +++ b/pdns/dnsdist-console.hh @@ -51,3 +51,4 @@ extern "C" { char** my_completion( const char * text , int start, int end); } void controlThread(int fd, ComboAddress local); +void clearConsoleHistory(); diff --git a/pdns/dnsdist-lua.cc b/pdns/dnsdist-lua.cc index c6477f17f8..f753ba20b6 100644 --- a/pdns/dnsdist-lua.cc +++ b/pdns/dnsdist-lua.cc @@ -1008,6 +1008,10 @@ static void setupLuaConfig(bool client, bool configCheck) g_consoleKey=newkey; }); + g_lua.writeFunction("clearConsoleHistory", []() { + clearConsoleHistory(); + }); + g_lua.writeFunction("testCrypto", [](boost::optional optTestMsg) { setLuaNoSideEffect();