]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
feat(dnsdist): Add `getServerID` function 16726/head
authorPieter Lexis <pieter.lexis@powerdns.com>
Wed, 14 Jan 2026 11:43:52 +0000 (12:43 +0100)
committerPieter Lexis <pieter.lexis@powerdns.com>
Thu, 15 Jan 2026 16:13:20 +0000 (17:13 +0100)
pdns/dnsdistdist/dnsdist-console-completion.cc
pdns/dnsdistdist/dnsdist-lua-bindings.cc

index 2424808e10d85b7f6015f4c96548dc49328d0ac3..8cd9d4853c335d31a810288c86da68ca585e0610 100644 (file)
@@ -382,6 +382,7 @@ static std::vector<dnsdist::console::completion::ConsoleKeyword> 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)
index 279135f4b52a0c843778b9755fb4e58aa54cb7fc..11dab9752d2373acb79fb7ed2dad9ef823299c0f 100644 (file)
@@ -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();
   });