---
- name: "allow"
description: "Let these packets go through"
+- name: "ByName"
+ skip-cpp: true
+ skip-rust: true
+ no-lua-equivalent: true
+ description: "References an already declared action by its name"
+ version_added: 2.2.0
+ parameters:
+ - name: "action_name"
+ type: "String"
+ descripton: "The action name"
- name: "continue"
description: "Execute the specified action and override its return with None, making it possible to continue the processing. Subsequent rules are processed after this action"
skip-cpp: true
return ptr;
}
+std::shared_ptr<DNSActionWrapper> getByNameAction(const ByNameActionConfiguration& config)
+{
+ auto ptr = dnsdist::configuration::yaml::getRegisteredTypeByName<DNSActionWrapper>(config.action_name);
+ if (!ptr) {
+ throw std::runtime_error("Unable to find an action named " + std::string(config.action_name));
+ }
+ return ptr;
+}
+
+std::shared_ptr<DNSResponseActionWrapper> getByNameResponseAction(const ByNameResponseActionConfiguration& config)
+{
+ auto ptr = dnsdist::configuration::yaml::getRegisteredTypeByName<DNSResponseActionWrapper>(config.action_name);
+ if (!ptr) {
+ throw std::runtime_error("Unable to find an action named " + std::string(config.action_name));
+ }
+ return ptr;
+}
+
#include "dnsdist-rust-bridge-actions-generated-body.hh"
#include "dnsdist-rust-bridge-selectors-generated-body.hh"
}
---
- name: "allow"
description: "Let these packets go through."
+- name: "ByName"
+ skip-cpp: true
+ skip-rust: true
+ no-lua-equivalent: true
+ description: "References an already declared action by its name"
+ version_added: 2.2.0
+ parameters:
+ - name: "action_name"
+ type: "String"
+ descripton: "The action name"
- name: "ClearRecordTypes"
description: "Removes given type(s) records from the response. Beware you can accidentally turn the answer into a NODATA response without a SOA record in the additional section in which case you may want to use NegativeAndSOAAction() to generate an answer, see example below. Subsequent rules are processed after this action."
skip-cpp: true
action:
type: "Pool"
pool_name: "tcp-pool"
+ - name: "reply notimp to notimp1"
+ selector:
+ type: "QNameSet"
+ qnames:
+ - "notimp1.yaml.test.powerdns.com."
+ action:
+ name: "reply-with-notimp"
+ type: "RCode"
+ rcode: "NotImp"
+ - name: "reply notimp to notimp2"
+ selector:
+ type: "QNameSet"
+ qnames:
+ - "notimp2.yaml.test.powerdns.com."
+ action:
+ type: "ByName"
+ action_name: "reply-with-notimp"
response_rules:
- name: "inline RD=0 TCP gets cleared"
self.assertEqual(receivedQuery, query)
self.assertEqual(receivedResponse, response)
+ def testActionByName(self):
+ """
+ Yaml: Action by name
+ """
+ for name in ["notimp1.yaml.test.powerdns.com.", "notimp2.yaml.test.powerdns.com."]:
+ query = dns.message.make_query(name, "A", "IN")
+ query.flags &= ~dns.flags.RD
+ response = dns.message.make_response(query)
+ response.set_rcode(dns.rcode.NOTIMP)
+ (_, receivedResponse) = self.sendUDPQuery(query, response=None, useQueue=False)
+ self.assertEqual(receivedResponse, response)
class TestMixingYamlWithLua(DNSDistTest):
_yaml_config_template = """---