From: Pieter Lexis Date: Wed, 14 Jan 2026 11:43:52 +0000 (+0100) Subject: feat(dnsdist): Add `getServerID` function X-Git-Tag: rec-5.4.0-beta1~41^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F16726%2Fhead;p=thirdparty%2Fpdns.git feat(dnsdist): Add `getServerID` function --- diff --git a/pdns/dnsdistdist/dnsdist-console-completion.cc b/pdns/dnsdistdist/dnsdist-console-completion.cc index 2424808e10..8cd9d4853c 100644 --- a/pdns/dnsdistdist/dnsdist-console-completion.cc +++ b/pdns/dnsdistdist/dnsdist-console-completion.cc @@ -382,6 +382,7 @@ static std::vector s_consoleKeywor {"chashed", false, "", "Consistent hashed ('sticky') distribution over available servers, also based on the server 'weight' parameter"}, {"wrandom", false, "", "Weighted random over available servers, based on the server 'weight' parameter"}, {"setServerID", true, "name", "Set the internal Server ID to this value"}, + {"getServerID", true, "", "Get the internal Server ID as a string"}, }; #if defined(HAVE_LIBEDIT) diff --git a/pdns/dnsdistdist/dnsdist-lua-bindings.cc b/pdns/dnsdistdist/dnsdist-lua-bindings.cc index 279135f4b5..11dab9752d 100644 --- a/pdns/dnsdistdist/dnsdist-lua-bindings.cc +++ b/pdns/dnsdistdist/dnsdist-lua-bindings.cc @@ -21,6 +21,7 @@ */ #include "bpf-filter.hh" #include "config.h" +#include "dnsdist-configuration.hh" #include "dnsdist.hh" #include "dnsdist-async.hh" #include "dnsdist-dynblocks.hh" @@ -1102,6 +1103,10 @@ void setupLuaBindings(LuaContext& luaCtx, bool client, bool configCheck) newThread.detach(); }); + luaCtx.writeFunction("getServerID", []() -> std::string { + return dnsdist::configuration::getCurrentRuntimeConfiguration().d_server_id; + }); + luaCtx.writeFunction("refreshRuntimeConfiguration", []() { dnsdist::configuration::refreshLocalRuntimeConfiguration(); });