From: Remi Gacogne Date: Thu, 20 Mar 2025 10:56:54 +0000 (+0100) Subject: dnsdist: Fix YAML configuration failure to build without CDB/LMDB X-Git-Tag: dnsdist-2.0.0-alpha2~132^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4a0822fc61bfda874c210eb7a4cf721328f53f53;p=thirdparty%2Fpdns.git dnsdist: Fix YAML configuration failure to build without CDB/LMDB --- diff --git a/pdns/dnsdistdist/dnsdist-configuration-yaml.cc b/pdns/dnsdistdist/dnsdist-configuration-yaml.cc index bb29fda5ea..f4cc0fd13b 100644 --- a/pdns/dnsdistdist/dnsdist-configuration-yaml.cc +++ b/pdns/dnsdistdist/dnsdist-configuration-yaml.cc @@ -1371,8 +1371,9 @@ std::shared_ptr getNetmaskGroupSelector(const NetmaskGroupSelectorC return newDNSSelector(std::move(selector), config.name); } -std::shared_ptr getKeyValueStoreLookupAction(const KeyValueStoreLookupActionConfiguration& config) +std::shared_ptr getKeyValueStoreLookupAction([[maybe_unused]] const KeyValueStoreLookupActionConfiguration& config) { +#if defined(HAVE_LMDB) || defined(HAVE_CDB) auto kvs = dnsdist::configuration::yaml::getRegisteredTypeByName(std::string(config.kvs_name)); if (!kvs && !(dnsdist::configuration::yaml::s_inClientMode || dnsdist::configuration::yaml::s_inConfigCheckMode)) { throw std::runtime_error("Unable to find the key-value store named '" + std::string(config.kvs_name) + "'"); @@ -1383,10 +1384,14 @@ std::shared_ptr getKeyValueStoreLookupAction(const KeyValueSto } auto action = dnsdist::actions::getKeyValueStoreLookupAction(kvs, lookupKey, std::string(config.destination_tag)); return newDNSActionWrapper(std::move(action), config.name); +#else + throw std::runtime_error("Unable to create KVS action: neitherCDB nor LMDB support are enabled"); +#endif } -std::shared_ptr getKeyValueStoreRangeLookupAction(const KeyValueStoreRangeLookupActionConfiguration& config) +std::shared_ptr getKeyValueStoreRangeLookupAction([[maybe_unused]] const KeyValueStoreRangeLookupActionConfiguration& config) { +#if defined(HAVE_LMDB) || defined(HAVE_CDB) auto kvs = dnsdist::configuration::yaml::getRegisteredTypeByName(std::string(config.kvs_name)); if (!kvs && !(dnsdist::configuration::yaml::s_inClientMode || dnsdist::configuration::yaml::s_inConfigCheckMode)) { throw std::runtime_error("Unable to find the key-value store named '" + std::string(config.kvs_name) + "'"); @@ -1397,10 +1402,14 @@ std::shared_ptr getKeyValueStoreRangeLookupAction(const KeyVal } auto action = dnsdist::actions::getKeyValueStoreRangeLookupAction(kvs, lookupKey, std::string(config.destination_tag)); return newDNSActionWrapper(std::move(action), config.name); +#else + throw std::runtime_error("Unable to create KVS action: neitherCDB nor LMDB support are enabled"); +#endif } -std::shared_ptr getKeyValueStoreLookupSelector(const KeyValueStoreLookupSelectorConfiguration& config) +std::shared_ptr getKeyValueStoreLookupSelector([[maybe_unused]] const KeyValueStoreLookupSelectorConfiguration& config) { +#if defined(HAVE_LMDB) || defined(HAVE_CDB) auto kvs = dnsdist::configuration::yaml::getRegisteredTypeByName(std::string(config.kvs_name)); if (!kvs && !(dnsdist::configuration::yaml::s_inClientMode || dnsdist::configuration::yaml::s_inConfigCheckMode)) { throw std::runtime_error("Unable to find the key-value store named '" + std::string(config.kvs_name) + "'"); @@ -1411,10 +1420,14 @@ std::shared_ptr getKeyValueStoreLookupSelector(const KeyValueStoreL } auto selector = dnsdist::selectors::getKeyValueStoreLookupSelector(kvs, lookupKey); return newDNSSelector(std::move(selector), config.name); +#else + throw std::runtime_error("Unable to create KVS action: neitherCDB nor LMDB support are enabled"); +#endif } -std::shared_ptr getKeyValueStoreRangeLookupSelector(const KeyValueStoreRangeLookupSelectorConfiguration& config) +std::shared_ptr getKeyValueStoreRangeLookupSelector([[maybe_unused]] const KeyValueStoreRangeLookupSelectorConfiguration& config) { +#if defined(HAVE_LMDB) || defined(HAVE_CDB) auto kvs = dnsdist::configuration::yaml::getRegisteredTypeByName(std::string(config.kvs_name)); if (!kvs && !(dnsdist::configuration::yaml::s_inClientMode || dnsdist::configuration::yaml::s_inConfigCheckMode)) { throw std::runtime_error("Unable to find the key-value store named '" + std::string(config.kvs_name) + "'"); @@ -1425,6 +1438,9 @@ std::shared_ptr getKeyValueStoreRangeLookupSelector(const KeyValueS } auto selector = dnsdist::selectors::getKeyValueStoreRangeLookupSelector(kvs, lookupKey); return newDNSSelector(std::move(selector), config.name); +#else + throw std::runtime_error("Unable to create KVS action: neitherCDB nor LMDB support are enabled"); +#endif } std::shared_ptr getDnstapLogAction(const DnstapLogActionConfiguration& config) @@ -1604,9 +1620,11 @@ void registerDnstapLogger(const DnstapLoggerConfiguration& config) #endif } -void registerKVSObjects(const KeyValueStoresConfiguration& config) +void registerKVSObjects([[maybe_unused]] const KeyValueStoresConfiguration& config) { +#if defined(HAVE_LMDB) || defined(HAVE_CDB) bool createObjects = !dnsdist::configuration::yaml::s_inClientMode && !dnsdist::configuration::yaml::s_inConfigCheckMode; +#endif /* defined(HAVE_LMDB) || defined(HAVE_CDB) */ #if defined(HAVE_LMDB) for (const auto& lmdb : config.lmdb) { auto store = createObjects ? std::shared_ptr(std::make_shared(std::string(lmdb.file_name), std::string(lmdb.database_name), lmdb.no_lock)) : std::shared_ptr();