From: Remi Gacogne Date: Fri, 30 May 2025 09:41:25 +0000 (+0200) Subject: dnsdist: Generate YAML and Lua configuration bindings for SetEDNSOptionResponseAction X-Git-Tag: dnsdist-2.0.0-beta1~47^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ec8c903a54da12e572a4871675ef43e7a027b10a;p=thirdparty%2Fpdns.git dnsdist: Generate YAML and Lua configuration bindings for SetEDNSOptionResponseAction --- diff --git a/pdns/dnsdistdist/dnsdist-lua-response-actions-generated.cc b/pdns/dnsdistdist/dnsdist-lua-response-actions-generated.cc index bef903eea1..bf3938ba19 100644 --- a/pdns/dnsdistdist/dnsdist-lua-response-actions-generated.cc +++ b/pdns/dnsdistdist/dnsdist-lua-response-actions-generated.cc @@ -14,6 +14,9 @@ luaCtx.writeFunction("LogResponseAction", [](boost::optional file_n luaCtx.writeFunction("LuaFFIPerThreadResponseAction", [](std::string code) { return dnsdist::actions::getLuaFFIPerThreadResponseAction(code); }); +luaCtx.writeFunction("SetEDNSOptionResponseAction", [](uint32_t code, std::string data) { + return dnsdist::actions::getSetEDNSOptionResponseAction(code, data); +}); luaCtx.writeFunction("SetExtendedDNSErrorResponseAction", [](uint16_t info_code, boost::optional extra_text) { return dnsdist::actions::getSetExtendedDNSErrorResponseAction(info_code, extra_text ? *extra_text : ""); }); diff --git a/pdns/dnsdistdist/dnsdist-response-actions-definitions.yml b/pdns/dnsdistdist/dnsdist-response-actions-definitions.yml index ae156bd75d..17f20ee2b3 100644 --- a/pdns/dnsdistdist/dnsdist-response-actions-definitions.yml +++ b/pdns/dnsdistdist/dnsdist-response-actions-definitions.yml @@ -174,7 +174,6 @@ The function will be invoked in a per-thread Lua state, without access to the gl description: "A list of ``name``=``key`` pairs, for meta-data to be added to Protocol Buffer message" - name: "SetEDNSOption" description: "Add arbitrary EDNS option and data to the response. Any existing EDNS content with the same option code will be overwritten. Subsequent rules are processed after this action" - skip-rust: true parameters: - name: "code" type: "u32" diff --git a/pdns/dnsdistdist/dnsdist-response-actions-factory-generated.cc b/pdns/dnsdistdist/dnsdist-response-actions-factory-generated.cc index e5f5c8dbee..8883e0375a 100644 --- a/pdns/dnsdistdist/dnsdist-response-actions-factory-generated.cc +++ b/pdns/dnsdistdist/dnsdist-response-actions-factory-generated.cc @@ -19,6 +19,10 @@ std::shared_ptr getLuaFFIPerThreadResponseAction(const std::s { return std::shared_ptr(new LuaFFIPerThreadResponseAction(code)); } +std::shared_ptr getSetEDNSOptionResponseAction(uint32_t code, const std::string& data) +{ + return std::shared_ptr(new SetEDNSOptionResponseAction(code, data)); +} std::shared_ptr getSetExtendedDNSErrorResponseAction(uint16_t info_code, const std::string& extra_text) { return std::shared_ptr(new SetExtendedDNSErrorResponseAction(info_code, extra_text)); diff --git a/pdns/dnsdistdist/dnsdist-response-actions-factory-generated.hh b/pdns/dnsdistdist/dnsdist-response-actions-factory-generated.hh index 7eabf156d2..9fb2f73cda 100644 --- a/pdns/dnsdistdist/dnsdist-response-actions-factory-generated.hh +++ b/pdns/dnsdistdist/dnsdist-response-actions-factory-generated.hh @@ -4,6 +4,7 @@ std::shared_ptr getDelayResponseAction(uint32_t msec); std::shared_ptr getDropResponseAction(); std::shared_ptr getLogResponseAction(const std::string& file_name, bool append, bool buffered, bool verbose_only, bool include_timestamp); std::shared_ptr getLuaFFIPerThreadResponseAction(const std::string& code); +std::shared_ptr getSetEDNSOptionResponseAction(uint32_t code, const std::string& data); std::shared_ptr getSetExtendedDNSErrorResponseAction(uint16_t info_code, const std::string& extra_text); std::shared_ptr getSetReducedTTLResponseAction(uint8_t percentage); std::shared_ptr getSetSkipCacheResponseAction(); diff --git a/pdns/dnsdistdist/dnsdist-rust-bridge-actions-generated.cc b/pdns/dnsdistdist/dnsdist-rust-bridge-actions-generated.cc index c4de7e5bb2..4f0b953095 100644 --- a/pdns/dnsdistdist/dnsdist-rust-bridge-actions-generated.cc +++ b/pdns/dnsdistdist/dnsdist-rust-bridge-actions-generated.cc @@ -179,6 +179,11 @@ std::shared_ptr getLuaFFIPerThreadResponseAction(const auto action = dnsdist::actions::getLuaFFIPerThreadResponseAction(std::string(config.code)); return newDNSResponseActionWrapper(std::move(action), config.name); } +std::shared_ptr getSetEDNSOptionResponseAction(const SetEDNSOptionResponseActionConfiguration& config) +{ + auto action = dnsdist::actions::getSetEDNSOptionResponseAction(config.code, std::string(config.data)); + return newDNSResponseActionWrapper(std::move(action), config.name); +} std::shared_ptr getSetExtendedDNSErrorResponseAction(const SetExtendedDNSErrorResponseActionConfiguration& config) { auto action = dnsdist::actions::getSetExtendedDNSErrorResponseAction(config.info_code, std::string(config.extra_text)); diff --git a/pdns/dnsdistdist/dnsdist-rust-bridge-actions-generated.hh b/pdns/dnsdistdist/dnsdist-rust-bridge-actions-generated.hh index e628aad99d..e3efd22a26 100644 --- a/pdns/dnsdistdist/dnsdist-rust-bridge-actions-generated.hh +++ b/pdns/dnsdistdist/dnsdist-rust-bridge-actions-generated.hh @@ -107,6 +107,8 @@ struct LuaFFIPerThreadResponseActionConfiguration; std::shared_ptr getLuaFFIPerThreadResponseAction(const LuaFFIPerThreadResponseActionConfiguration& config); struct RemoteLogResponseActionConfiguration; std::shared_ptr getRemoteLogResponseAction(const RemoteLogResponseActionConfiguration& config); +struct SetEDNSOptionResponseActionConfiguration; +std::shared_ptr getSetEDNSOptionResponseAction(const SetEDNSOptionResponseActionConfiguration& config); struct SetExtendedDNSErrorResponseActionConfiguration; std::shared_ptr getSetExtendedDNSErrorResponseAction(const SetExtendedDNSErrorResponseActionConfiguration& config); struct SetMaxReturnedTTLResponseActionConfiguration; diff --git a/pdns/dnsdistdist/dnsdist-rust-lib/rust/src/lib.rs b/pdns/dnsdistdist/dnsdist-rust-lib/rust/src/lib.rs index 29131313b7..163f0e334e 100644 --- a/pdns/dnsdistdist/dnsdist-rust-lib/rust/src/lib.rs +++ b/pdns/dnsdistdist/dnsdist-rust-lib/rust/src/lib.rs @@ -647,6 +647,15 @@ mod dnsdistsettings { metas: Vec, } + #[derive(Deserialize, Serialize, Debug, PartialEq)] + #[serde(deny_unknown_fields)] + struct SetEDNSOptionResponseActionConfiguration { + #[serde(default, skip_serializing_if = "crate::is_default")] + name: String, + code: u32, + data: String, + } + #[derive(Deserialize, Serialize, Debug, PartialEq)] #[serde(deny_unknown_fields)] struct SetExtendedDNSErrorResponseActionConfiguration { @@ -2234,6 +2243,7 @@ mod dnsdistsettings { fn getLuaFFIResponseAction(config: &LuaFFIResponseActionConfiguration) -> Result>; fn getLuaFFIPerThreadResponseAction(config: &LuaFFIPerThreadResponseActionConfiguration) -> Result>; fn getRemoteLogResponseAction(config: &RemoteLogResponseActionConfiguration) -> Result>; + fn getSetEDNSOptionResponseAction(config: &SetEDNSOptionResponseActionConfiguration) -> Result>; fn getSetExtendedDNSErrorResponseAction(config: &SetExtendedDNSErrorResponseActionConfiguration) -> Result>; fn getSetMaxReturnedTTLResponseAction(config: &SetMaxReturnedTTLResponseActionConfiguration) -> Result>; fn getSetMaxTTLResponseAction(config: &SetMaxTTLResponseActionConfiguration) -> Result>; @@ -2526,6 +2536,7 @@ enum ResponseAction { LuaFFI(dnsdistsettings::LuaFFIResponseActionConfiguration), LuaFFIPerThread(dnsdistsettings::LuaFFIPerThreadResponseActionConfiguration), RemoteLog(dnsdistsettings::RemoteLogResponseActionConfiguration), + SetEDNSOption(dnsdistsettings::SetEDNSOptionResponseActionConfiguration), SetExtendedDNSError(dnsdistsettings::SetExtendedDNSErrorResponseActionConfiguration), SetMaxReturnedTTL(dnsdistsettings::SetMaxReturnedTTLResponseActionConfiguration), SetMaxTTL(dnsdistsettings::SetMaxTTLResponseActionConfiguration), @@ -4031,6 +4042,11 @@ fn get_one_response_action_from_serde(action: &ResponseAction) -> Result { + return Ok(dnsdistsettings::SharedDNSResponseAction { + action: dnsdistsettings::getSetEDNSOptionResponseAction(&config)?, + }); + } ResponseAction::SetExtendedDNSError(config) => { return Ok(dnsdistsettings::SharedDNSResponseAction { action: dnsdistsettings::getSetExtendedDNSErrorResponseAction(&config)?,