Skip to content

Commit 4550147

Browse files
committed
feat(dnsdist): Add getServerID function
1 parent c4ceb9f commit 4550147

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

pdns/dnsdistdist/dnsdist-console-completion.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,7 @@ static std::vector<dnsdist::console::completion::ConsoleKeyword> s_consoleKeywor
382382
{"chashed", false, "", "Consistent hashed ('sticky') distribution over available servers, also based on the server 'weight' parameter"},
383383
{"wrandom", false, "", "Weighted random over available servers, based on the server 'weight' parameter"},
384384
{"setServerID", true, "name", "Set the internal Server ID to this value"},
385+
{"getServerID", true, "", "Get the internal Server ID as a string"},
385386
};
386387

387388
#if defined(HAVE_LIBEDIT)

pdns/dnsdistdist/dnsdist-lua-bindings.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
*/
2222
#include "bpf-filter.hh"
2323
#include "config.h"
24+
#include "dnsdist-configuration.hh"
2425
#include "dnsdist.hh"
2526
#include "dnsdist-async.hh"
2627
#include "dnsdist-dynblocks.hh"
@@ -1102,6 +1103,10 @@ void setupLuaBindings(LuaContext& luaCtx, bool client, bool configCheck)
11021103
newThread.detach();
11031104
});
11041105

1106+
luaCtx.writeFunction("getServerID", []() -> std::string {
1107+
return dnsdist::configuration::getCurrentRuntimeConfiguration().d_server_id;
1108+
});
1109+
11051110
luaCtx.writeFunction("refreshRuntimeConfiguration", []() {
11061111
dnsdist::configuration::refreshLocalRuntimeConfiguration();
11071112
});

0 commit comments

Comments
 (0)