From: Remi Gacogne Date: Tue, 14 Nov 2023 14:20:00 +0000 (+0100) Subject: dnsdist: Apply Charles-Henri's suggestions (many thanks!) X-Git-Tag: rec-5.0.0-rc1~31^2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=58fc0ef5335a7d65b24d803bdc2e69f81f47de78;p=thirdparty%2Fpdns.git dnsdist: Apply Charles-Henri's suggestions (many thanks!) --- diff --git a/pdns/dnsdist-console.cc b/pdns/dnsdist-console.cc index 0856ec9b88..ac2d1a1aa8 100644 --- a/pdns/dnsdist-console.cc +++ b/pdns/dnsdist-console.cc @@ -471,7 +471,7 @@ const std::vector g_consoleKeywords{ { "addDNSCryptBind", true, "\"127.0.0.1:8443\", \"provider name\", \"/path/to/resolver.cert\", \"/path/to/resolver.key\", {reusePort=false, tcpFastOpenQueueSize=0, interface=\"\", cpus={}}", "listen to incoming DNSCrypt queries on 127.0.0.1 port 8443, with a provider name of `provider name`, using a resolver certificate and associated key stored respectively in the `resolver.cert` and `resolver.key` files. The fifth optional parameter is a table of parameters" }, { "addDOHLocal", true, "addr, certFile, keyFile [, urls [, vars]]", "listen to incoming DNS over HTTPS queries on the specified address using the specified certificate and key. The last two parameters are tables" }, { "addDOQLocal", true, "addr, certFile, keyFile [, vars]", "listen to incoming DNS over QUIC queries on the specified address using the specified certificate and key. The last parameter is a table" }, - { "addDynamicBlock", true, "address, message[, action [, seconds [clientIPMask [, clientIPPortMask]]]]", "block the set of addresses with message `msg`, for `seconds` seconds (10 by default), applying `action` (default to the one set with `setDynBlocksAction()`)" }, + { "addDynamicBlock", true, "address, message[, action [, seconds [, clientIPMask [, clientIPPortMask]]]]", "block the set of addresses with message `msg`, for `seconds` seconds (10 by default), applying `action` (default to the one set with `setDynBlocksAction()`)" }, { "addDynBlocks", true, "addresses, message[, seconds[, action]]", "block the set of addresses with message `msg`, for `seconds` seconds (10 by default), applying `action` (default to the one set with `setDynBlocksAction()`)" }, { "addDynBlockSMT", true, "names, message[, seconds [, action]]", "block the set of names with message `msg`, for `seconds` seconds (10 by default), applying `action` (default to the one set with `setDynBlocksAction()`)" }, { "addLocal", true, "addr [, {doTCP=true, reusePort=false, tcpFastOpenQueueSize=0, interface=\"\", cpus={}}]", "add `addr` to the list of addresses we listen on" }, @@ -525,7 +525,7 @@ const std::vector g_consoleKeywords{ { "getCacheInsertedResponseRule", true, "selector", "Return the cache-inserted response rule corresponding to the selector, if any" }, { "getCurrentTime", true, "", "returns the current time" }, { "getDynamicBlocks", true, "", "returns a table of the current network-based dynamic blocks" }, - { "getSMTDynamicBlocks", true, "", "returns a table of the current suffix-based dynamic blocks" }, + { "getDynamicBlocksSMT", true, "", "returns a table of the current suffix-based dynamic blocks" }, { "getDNSCryptBind", true, "n", "return the `DNSCryptContext` object corresponding to the bind `n`" }, { "getDNSCryptBindCount", true, "", "returns the number of DNSCrypt listeners" }, { "getDOHFrontend", true, "n", "returns the DOH frontend with index n" }, diff --git a/pdns/dnsdist-dynblocks.hh b/pdns/dnsdist-dynblocks.hh index 65b036e9e6..29577068f0 100644 --- a/pdns/dnsdist-dynblocks.hh +++ b/pdns/dnsdist-dynblocks.hh @@ -282,9 +282,9 @@ public: d_smtVisitorFFI = std::move(visitor); } - void setNewBlockHook(dnsdist_ffi_dynamic_block_inserted_hook& callback) + void setNewBlockHook(const dnsdist_ffi_dynamic_block_inserted_hook& callback) { - d_newBlockHook = std::move(callback); + d_newBlockHook = callback; } void setMasks(uint8_t v4, uint8_t v6, uint8_t port) diff --git a/pdns/dnsdist-lua-inspection.cc b/pdns/dnsdist-lua-inspection.cc index 105d422ea8..8ff1159ec5 100644 --- a/pdns/dnsdist-lua-inspection.cc +++ b/pdns/dnsdist-lua-inspection.cc @@ -860,7 +860,7 @@ void setupLuaInspection(LuaContext& luaCtx) group->setSuffixMatchRuleFFI(seconds, reason, blockDuration, action ? *action : DNSAction::Action::None, std::move(visitor)); } }); - luaCtx.registerFunction::*)(dnsdist_ffi_dynamic_block_inserted_hook)>("setNewBlockInsertedHook", [](std::shared_ptr& group, dnsdist_ffi_dynamic_block_inserted_hook hook) { + luaCtx.registerFunction::*)(const dnsdist_ffi_dynamic_block_inserted_hook&)>("setNewBlockInsertedHook", [](std::shared_ptr& group, const dnsdist_ffi_dynamic_block_inserted_hook& hook) { if (group) { group->setNewBlockHook(hook); } diff --git a/pdns/dnsdist-lua.cc b/pdns/dnsdist-lua.cc index 6ed9b35190..98ed3f09af 100644 --- a/pdns/dnsdist-lua.cc +++ b/pdns/dnsdist-lua.cc @@ -1444,7 +1444,7 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck) return entries; }); - luaCtx.writeFunction("getSMTDynamicBlocks", []() { + luaCtx.writeFunction("getDynamicBlocksSMT", []() { setLuaNoSideEffect(); struct timespec now { diff --git a/pdns/dnsdistdist/docs/reference/config.rst b/pdns/dnsdistdist/docs/reference/config.rst index d264aed929..fbb8063770 100644 --- a/pdns/dnsdistdist/docs/reference/config.rst +++ b/pdns/dnsdistdist/docs/reference/config.rst @@ -1446,7 +1446,7 @@ Dynamic Blocks Return an associative table of active network-based dynamic blocks. The keys are the network IP or range that are blocked, the value are :class:`DynBlock` objects. -.. function:: getSMTDynamicBlocks() +.. function:: getDynamicBlocksSMT() .. versionadded:: 1.9.0