From: Remi Gacogne Date: Fri, 12 Nov 2021 14:57:51 +0000 (+0100) Subject: dnsdist: Only expose KVS helpers when CDB or LMDB is available X-Git-Tag: auth-4.7.0-alpha1~103^2~18 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8d28cbb858809071f483d58309b694536621e2ed;p=thirdparty%2Fpdns.git dnsdist: Only expose KVS helpers when CDB or LMDB is available Idem for DNSCrypt --- diff --git a/pdns/dnsdistdist/dnsdist-lua-bindings-dnscrypt.cc b/pdns/dnsdistdist/dnsdist-lua-bindings-dnscrypt.cc index 8de02805e9..cc482777c5 100644 --- a/pdns/dnsdistdist/dnsdist-lua-bindings-dnscrypt.cc +++ b/pdns/dnsdistdist/dnsdist-lua-bindings-dnscrypt.cc @@ -171,11 +171,9 @@ void setupLuaBindingsDNSCrypt(LuaContext& luaCtx, bool client) g_outputBuffer = "Error: " + string(e.what()) + "\n"; } }); -#endif luaCtx.writeFunction("generateDNSCryptProviderKeys", [client](const std::string& publicKeyFile, const std::string privateKeyFile) { setLuaNoSideEffect(); -#ifdef HAVE_DNSCRYPT if (client) { return; } @@ -203,14 +201,10 @@ void setupLuaBindingsDNSCrypt(LuaContext& luaCtx, bool client) sodium_memzero(privateKey, sizeof(privateKey)); sodium_munlock(privateKey, sizeof(privateKey)); -#else - g_outputBuffer = "Error: DNSCrypt support is not enabled.\n"; -#endif }); luaCtx.writeFunction("printDNSCryptProviderFingerprint", [](const std::string& publicKeyFile) { setLuaNoSideEffect(); -#ifdef HAVE_DNSCRYPT unsigned char publicKey[DNSCRYPT_PROVIDER_PUBLIC_KEY_SIZE]; try { @@ -228,8 +222,6 @@ void setupLuaBindingsDNSCrypt(LuaContext& luaCtx, bool client) errlog(e.what()); g_outputBuffer = "Error: " + string(e.what()) + "\n"; } -#else - g_outputBuffer = "Error: DNSCrypt support is not enabled.\n"; -#endif }); +#endif } diff --git a/pdns/dnsdistdist/dnsdist-lua-bindings-kvs.cc b/pdns/dnsdistdist/dnsdist-lua-bindings-kvs.cc index b1e0c0fc0f..581fec203b 100644 --- a/pdns/dnsdistdist/dnsdist-lua-bindings-kvs.cc +++ b/pdns/dnsdistdist/dnsdist-lua-bindings-kvs.cc @@ -25,20 +25,6 @@ void setupLuaBindingsKVS(LuaContext& luaCtx, bool client) { - /* Key Value Store objects */ - luaCtx.writeFunction("KeyValueLookupKeySourceIP", [](boost::optional v4Mask, boost::optional v6Mask, boost::optional includePort) { - return std::shared_ptr(new KeyValueLookupKeySourceIP(v4Mask.get_value_or(32), v6Mask.get_value_or(128), includePort.get_value_or(false))); - }); - luaCtx.writeFunction("KeyValueLookupKeyQName", [](boost::optional wireFormat) { - return std::shared_ptr(new KeyValueLookupKeyQName(wireFormat ? *wireFormat : true)); - }); - luaCtx.writeFunction("KeyValueLookupKeySuffix", [](boost::optional minLabels, boost::optional wireFormat) { - return std::shared_ptr(new KeyValueLookupKeySuffix(minLabels ? *minLabels : 0, wireFormat ? *wireFormat : true)); - }); - luaCtx.writeFunction("KeyValueLookupKeyTag", [](const std::string& tag) { - return std::shared_ptr(new KeyValueLookupKeyTag(tag)); - }); - #ifdef HAVE_LMDB luaCtx.writeFunction("newLMDBKVStore", [client](const std::string& fname, const std::string& dbName, boost::optional noLock) { if (client) { @@ -57,6 +43,21 @@ void setupLuaBindingsKVS(LuaContext& luaCtx, bool client) }); #endif /* HAVE_CDB */ +#if defined(HAVE_LMDB) || defined(HAVE_CDB) + /* Key Value Store objects */ + luaCtx.writeFunction("KeyValueLookupKeySourceIP", [](boost::optional v4Mask, boost::optional v6Mask, boost::optional includePort) { + return std::shared_ptr(new KeyValueLookupKeySourceIP(v4Mask.get_value_or(32), v6Mask.get_value_or(128), includePort.get_value_or(false))); + }); + luaCtx.writeFunction("KeyValueLookupKeyQName", [](boost::optional wireFormat) { + return std::shared_ptr(new KeyValueLookupKeyQName(wireFormat ? *wireFormat : true)); + }); + luaCtx.writeFunction("KeyValueLookupKeySuffix", [](boost::optional minLabels, boost::optional wireFormat) { + return std::shared_ptr(new KeyValueLookupKeySuffix(minLabels ? *minLabels : 0, wireFormat ? *wireFormat : true)); + }); + luaCtx.writeFunction("KeyValueLookupKeyTag", [](const std::string& tag) { + return std::shared_ptr(new KeyValueLookupKeyTag(tag)); + }); + luaCtx.registerFunction::*)(const boost::variant, boost::optional wireFormat)>("lookup", [](std::shared_ptr& kvs, const boost::variant keyVar, boost::optional wireFormat) { std::string result; if (!kvs) { @@ -112,4 +113,5 @@ void setupLuaBindingsKVS(LuaContext& luaCtx, bool client) return kvs->reload(); }); +#endif /* defined(HAVE_LMDB) || defined(HAVE_CDB) */ }