From: Christof Chen Date: Fri, 7 Oct 2022 18:32:37 +0000 (+0200) Subject: add getPoolNames() function X-Git-Tag: dnsdist-1.7.4~2^2 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F12621%2Fhead;p=thirdparty%2Fpdns.git add getPoolNames() function (cherry picked from commit 377c12005b8548a3431ccce4be1dcf5e5b01956f) --- diff --git a/pdns/dnsdist-console.cc b/pdns/dnsdist-console.cc index a052779e38..e00cdc7f9a 100644 --- a/pdns/dnsdist-console.cc +++ b/pdns/dnsdist-console.cc @@ -460,6 +460,7 @@ const std::vector g_consoleKeywords{ { "getOutgoingTLSSessionCacheSize", true, "", "returns the number of TLS sessions (for outgoing connections) currently cached" }, { "getPool", true, "name", "return the pool named `name`, or \"\" for the default pool" }, { "getPoolServers", true, "pool", "return servers part of this pool" }, + { "getPoolNames", true, "", "returns a table with all the pool names" }, { "getQueryCounters", true, "[max=10]", "show current buffer of query counters, limited by 'max' if provided" }, { "getResponseRing", true, "", "return the current content of the response ring" }, { "getRespRing", true, "", "return the qname/rcode content of the response ring" }, diff --git a/pdns/dnsdist-lua.cc b/pdns/dnsdist-lua.cc index 641464cd21..653cbd5e53 100644 --- a/pdns/dnsdist-lua.cc +++ b/pdns/dnsdist-lua.cc @@ -1741,6 +1741,18 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck) } }); + luaCtx.writeFunction("getPoolNames", []() { + setLuaNoSideEffect(); + std::vector> ret; + int count = 1; + const auto localPools = g_pools.getCopy(); + for (const auto& entry : localPools) { + const string& name = entry.first; + ret.push_back(make_pair(count++, name)); + } + return ret; + }); + luaCtx.writeFunction("getPool", [client](const string& poolName) { if (client) { return std::make_shared();