From: Remi Gacogne Date: Fri, 6 Nov 2015 14:09:18 +0000 (+0100) Subject: Add default values for topResponses() and topQueries() parameters. Fixes #2864. X-Git-Tag: dnsdist-1.0.0-alpha1~224^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a78a3a0e6a97957dd039a552ef56390d136d5ccb;p=pdns Add default values for topResponses() and topQueries() parameters. Fixes #2864. Use 10 as a default 'top' parameter for topQueries() and topResponses(), and 0 as the default 'kind' parameter for topResponses(). --- diff --git a/pdns/dnsdist-lua.cc b/pdns/dnsdist-lua.cc index 3afa7923b..8d10c9fc1 100644 --- a/pdns/dnsdist-lua.cc +++ b/pdns/dnsdist-lua.cc @@ -651,7 +651,7 @@ vector> setupLua(bool client, const std::string& confi }); - g_lua.executeCode(R"(function topQueries(top, labels) for k,v in ipairs(getTopQueries(top,labels)) do show(string.format("%4d %-40s %4d %4.1f%%",k,v[1],v[2], v[3])) end end)"); + g_lua.executeCode(R"(function topQueries(top, labels) top = top or 10; for k,v in ipairs(getTopQueries(top,labels)) do show(string.format("%4d %-40s %4d %4.1f%%",k,v[1],v[2], v[3])) end end)"); @@ -723,7 +723,7 @@ vector> setupLua(bool client, const std::string& confi }); - g_lua.executeCode(R"(function topResponses(top, kind, labels) for k,v in ipairs(getTopResponses(top, kind, labels)) do show(string.format("%4d %-40s %4d %4.1f%%",k,v[1],v[2], v[3])) end end)"); + g_lua.executeCode(R"(function topResponses(top, kind, labels) top = top or 10; kind = kind or 0; for k,v in ipairs(getTopResponses(top, kind, labels)) do show(string.format("%4d %-40s %4d %4.1f%%",k,v[1],v[2],v[3])) end end)"); g_lua.writeFunction("showResponseLatency", []() {