Skip to content

Commit

Permalink
dnsdist: Support more types in the YAML configuratio, but it's time t…
Browse files Browse the repository at this point in the history
…o generate all this
  • Loading branch information
rgacogne committed Oct 11, 2024
1 parent c9f26a2 commit 6970994
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pdns/dnsdistdist/dnsdist-configuration-yaml.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@

#include "dnsdist-configuration-yaml.hh"
#include "iputils.hh"
#include "remote_logger.hh"

#if defined(HAVE_YAML_CONFIGURATION)

#include <fstream>

#include "dolog.hh"
#include "dnsdist-rules.hh"
#include "dnsdist-kvs.hh"
#include "rust/cxx.h"
#include "rust/lib.rs.h"
#endif /* HAVE_YAML_CONFIGURATION */
Expand Down Expand Up @@ -74,7 +74,7 @@ bool loadConfigurationFromFile(const std::string fileName)
namespace dnsdist::rust::settings
{

using RegisteredTypes = std::variant<std::shared_ptr<DNSSelector>, std::shared_ptr<NetmaskGroup>>;
using RegisteredTypes = std::variant<std::shared_ptr<DNSSelector>, std::shared_ptr<NetmaskGroup>, std::shared_ptr<KeyValueStore>, std::shared_ptr<KeyValueLookupKey>, std::shared_ptr<RemoteLoggerInterface>>;
static LockGuarded<std::unordered_map<std::string, RegisteredTypes>> s_registeredTypesMap;

template <class T> static void registerType(const std::shared_ptr<T>& entry, std::string& name)
Expand Down
54 changes: 54 additions & 0 deletions pdns/dnsdistdist/dnsdist-rust-lib/rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,57 @@ mod dnsdistsettings {
carbon: Vec<CarbonConfiguration>,
}

#[derive(Default, Deserialize, Serialize, Debug, PartialEq)]
#[serde(deny_unknown_fields)]
struct ProtobufLoggerConfig {
#[serde(default, skip_serializing_if = "crate::is_default")]
address: String,
#[serde(default, skip_serializing_if = "crate::is_default")]
name: String,
#[serde(default, skip_serializing_if = "crate::is_default")]
timeout: u16,
#[serde(
default,
rename = "max-queued-entries",
skip_serializing_if = "crate::is_default"
)]
max_queued_entries: u64,
#[serde(
default,
rename = "reconnect-wait-time",
skip_serializing_if = "crate::is_default"
)]
reconnect_wait_time: u8,
}

#[derive(Default, Deserialize, Serialize, Debug, PartialEq)]
#[serde(deny_unknown_fields)]
struct FrameStreamLoggerConfig {
#[serde(default, skip_serializing_if = "crate::is_default")]
address: String,
#[serde(default, skip_serializing_if = "crate::is_default")]
name: String,
#[serde(default, skip_serializing_if = "crate::is_default")]
protocol: String,
}

#[derive(Default, Deserialize, Serialize, Debug, PartialEq)]
#[serde(deny_unknown_fields)]
struct RemoteLoggingConfiguration {
#[serde(
default,
rename = "protocol-buffer",
skip_serializing_if = "crate::is_default"
)]
protocol_buffer: Vec<ProtobufLoggerConfig>,
#[serde(
default,
rename = "frame-stream",
skip_serializing_if = "crate::is_default"
)]
frame_stream: Vec<FrameStreamLoggerConfig>,
}

#[derive(Default, Deserialize, Serialize, Debug, PartialEq)]
#[serde(deny_unknown_fields)]
struct MaxQPSIPRuleConfig {
Expand Down Expand Up @@ -138,6 +189,7 @@ mod dnsdistsettings {
metrics: MetricsConfiguration,
webserver: WebServerConfiguration,
console: ConsoleConfiguration,
remote_logging: RemoteLoggingConfiguration,
realselectors: Vec<SharedDNSSelector>,
}

Expand Down Expand Up @@ -201,6 +253,8 @@ struct GlobalConfigurationSerde {
#[serde(default, skip_serializing_if = "crate::is_default")]
console: dnsdistsettings::ConsoleConfiguration,
#[serde(default, skip_serializing_if = "crate::is_default")]
remote_logging: dnsdistsettings::RemoteLoggingConfiguration,
#[serde(default, skip_serializing_if = "crate::is_default")]
testselectors: Vec<Selector>,
}

Expand Down

0 comments on commit 6970994

Please sign in to comment.