using XSKMap = std::vector<std::shared_ptr<XskSocket>>;
-using RegisteredTypes = std::variant<std::shared_ptr<DNSDistPacketCache>, std::shared_ptr<dnsdist::rust::settings::DNSSelector>, std::shared_ptr<dnsdist::rust::settings::DNSActionWrapper>, std::shared_ptr<dnsdist::rust::settings::DNSResponseActionWrapper>, std::shared_ptr<NetmaskGroup>, std::shared_ptr<KeyValueStore>, std::shared_ptr<KeyValueLookupKey>, std::shared_ptr<RemoteLoggerInterface>, std::shared_ptr<ServerPolicy>, std::shared_ptr<XSKMap>>;
+using RegisteredTypes = std::variant<std::shared_ptr<DNSDistPacketCache>, std::shared_ptr<dnsdist::rust::settings::DNSSelector>, std::shared_ptr<dnsdist::rust::settings::DNSActionWrapper>, std::shared_ptr<dnsdist::rust::settings::DNSResponseActionWrapper>, std::shared_ptr<NetmaskGroup>, std::shared_ptr<KeyValueStore>, std::shared_ptr<KeyValueLookupKey>, std::shared_ptr<RemoteLoggerInterface>, std::shared_ptr<ServerPolicy>, std::shared_ptr<TimedIPSetRule>, std::shared_ptr<XSKMap>>;
static LockGuarded<std::unordered_map<std::string, RegisteredTypes>> s_registeredTypesMap;
static std::atomic<bool> s_inConfigCheckMode;
static std::atomic<bool> s_inClientMode;
void addLuaBindingsForYAMLObjects([[maybe_unused]] LuaContext& luaCtx)
{
#if defined(HAVE_YAML_CONFIGURATION)
- using ReturnValue = boost::optional<boost::variant<std::shared_ptr<DNSDistPacketCache>, std::shared_ptr<DNSRule>, std::shared_ptr<DNSAction>, std::shared_ptr<DNSResponseAction>, std::shared_ptr<NetmaskGroup>, std::shared_ptr<KeyValueStore>, std::shared_ptr<KeyValueLookupKey>, std::shared_ptr<RemoteLoggerInterface>, std::shared_ptr<ServerPolicy>, std::shared_ptr<XSKMap>>>;
+ using ReturnValue = boost::optional<boost::variant<std::shared_ptr<DNSDistPacketCache>, std::shared_ptr<DNSRule>, std::shared_ptr<DNSAction>, std::shared_ptr<DNSResponseAction>, std::shared_ptr<NetmaskGroup>, std::shared_ptr<KeyValueStore>, std::shared_ptr<KeyValueLookupKey>, std::shared_ptr<RemoteLoggerInterface>, std::shared_ptr<ServerPolicy>, std::shared_ptr<TimedIPSetRule>, std::shared_ptr<XSKMap>>>;
luaCtx.writeFunction("getObjectFromYAMLConfiguration", [](const std::string& name) -> ReturnValue {
auto map = s_registeredTypesMap.lock();
if (auto* ptr = std::get_if<std::shared_ptr<ServerPolicy>>(&item->second)) {
return ReturnValue(*ptr);
}
+ if (auto* ptr = std::get_if<std::shared_ptr<TimedIPSetRule>>(&item->second)) {
+ return ReturnValue(*ptr);
+ }
if (auto* ptr = std::get_if<std::shared_ptr<XSKMap>>(&item->second)) {
return ReturnValue(*ptr);
}
#endif
}
+std::shared_ptr<DNSSelector> getTimedIPSetSelector(const TimedIPSetSelectorConfiguration& config)
+{
+ auto obj = dnsdist::configuration::yaml::getRegisteredTypeByName<TimedIPSetRule>(std::string(config.set_name));
+ if (!obj) {
+ throw std::runtime_error("Uanble to find a timed IP set named '" + std::string(config.set_name));
+ }
+ auto selector = std::dynamic_pointer_cast<DNSRule>(obj);
+ return newDNSSelector(std::move(selector), config.name);
+}
+
std::shared_ptr<DNSActionWrapper> getDnstapLogAction([[maybe_unused]] const DnstapLogActionConfiguration& config)
{
#if defined(DISABLE_PROTOBUF) || !defined(HAVE_FSTRM)
}
}
+void registerTimedIPSetObjects(const ::rust::Vec<TimedIpSetConfiguration>& sets)
+{
+ for (const auto& timedIPSet : sets) {
+ auto obj = dnsdist::configuration::yaml::getRegisteredTypeByName<TimedIPSetRule>(std::string(timedIPSet.name));
+ if (!obj) {
+ obj = std::make_shared<TimedIPSetRule>();
+ dnsdist::configuration::yaml::registerType<TimedIPSetRule>(obj, timedIPSet.name);
+ }
+ }
+}
+
std::shared_ptr<DNSSelector> getLuaSelector(const LuaSelectorConfiguration& config)
{
dnsdist::selectors::LuaSelectorFunction function;
struct DnstapLoggerConfiguration;
struct KeyValueStoresConfiguration;
struct NetmaskGroupConfiguration;
+struct TimedIpSetConfiguration;
void registerProtobufLogger(const ProtobufLoggerConfiguration& config);
void registerDnstapLogger(const DnstapLoggerConfiguration& config);
void registerKVSObjects(const KeyValueStoresConfiguration& config);
void registerNMGObjects(const ::rust::Vec<NetmaskGroupConfiguration>& nmgs);
+void registerTimedIPSetObjects(const ::rust::Vec<TimedIpSetConfiguration>& sets);
#include "dnsdist-rust-bridge-actions-generated.hh"
#include "dnsdist-rust-bridge-selectors-generated.hh"
config.ring_buffers = serde.ring_buffers;
config.security_polling = serde.security_polling;
config.snmp = serde.snmp;
+ config.timed_ip_sets = serde.timed_ip_sets;
config.tuning = serde.tuning;
config.webserver = serde.webserver;
config.xsk = serde.xsk;
dnsdistsettings::registerKVSObjects(&config.key_value_stores);
// this needs to be done before the rules so that they can refer to the NMG objects
dnsdistsettings::registerNMGObjects(&config.netmask_groups);
+ // this needs to be done before the rules so that they can refer to the TimeIPSet objects
+ dnsdistsettings::registerTimedIPSetObjects(&config.timed_ip_sets);
// this needs to be done BEFORE the rules so that they can refer to the selectors
// by name
config.selectors = get_selectors_from_serde(&serde.selectors)?;