From: Peter van Dijk Date: Fri, 8 Dec 2017 09:32:56 +0000 (+0100) Subject: dnsdist: add inClientStartup() function X-Git-Tag: dnsdist-1.3.0~204^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6f2a4580002ccbf4c32f7383ba2528b4a9cb4e05;p=pdns dnsdist: add inClientStartup() function --- diff --git a/pdns/dnsdist-console.cc b/pdns/dnsdist-console.cc index d70a64674..ae6d449af 100644 --- a/pdns/dnsdist-console.cc +++ b/pdns/dnsdist-console.cc @@ -335,6 +335,7 @@ const std::vector g_consoleKeywords{ { "getResponseRing", true, "", "return the current content of the response ring" }, { "getServer", true, "n", "returns server with index n" }, { "getServers", true, "", "returns a table with all defined servers" }, + { "inClientStartup", true, "", "returns true during console client parsing of configuration" }, { "grepq", true, "Netmask|DNS Name|100ms|{\"::1\", \"powerdns.com\", \"100ms\"} [, n]", "shows the last n queries and responses matching the specified client address or range (Netmask), or the specified DNS Name, or slower than 100ms" }, { "leastOutstanding", false, "", "Send traffic to downstream server with least outstanding queries, with the lowest 'order', and within that the lowest recent latency"}, { "LogAction", true, "[filename], [binary], [append], [buffered]", "Log a line for each query, to the specified file if any, to the console (require verbose) otherwise. When logging to a file, the `binary` optional parameter specifies whether we log in binary form (default) or in textual form, the `append` optional parameter specifies whether we open the file for appending or truncate each time (default), and the `buffered` optional parameter specifies whether writes to the file are buffered (default) or not." }, diff --git a/pdns/dnsdist-lua.cc b/pdns/dnsdist-lua.cc index d6a2b294f..525707e89 100644 --- a/pdns/dnsdist-lua.cc +++ b/pdns/dnsdist-lua.cc @@ -266,6 +266,11 @@ vector> setupLua(bool client, const std::string& confi dd.push_back({n.first, n.second}); g_lua.writeVariable("dnsdist", dd); + g_lua.writeFunction("inClientStartup", [client]() { + return client; + }); + + g_lua.writeFunction("newServer", [client](boost::variant pvars, boost::optional qps) { diff --git a/pdns/dnsdistdist/docs/reference/config.rst b/pdns/dnsdistdist/docs/reference/config.rst index b8f5f08f8..e9d28238e 100644 --- a/pdns/dnsdistdist/docs/reference/config.rst +++ b/pdns/dnsdistdist/docs/reference/config.rst @@ -118,6 +118,10 @@ Control Socket, Console and Webserver :param str address: An IP address with optional port. By default, the port is 5199. +.. function:: inClientStartup() + + Returns true while the console client is parsing the configuration. + .. function:: makeKey() Generate and print an encryption key.