From: Pieter Lexis Date: Sat, 13 May 2017 09:34:28 +0000 (+0200) Subject: Merge pull request #5265 from rgacogne/rec-rpz-wildcard-target X-Git-Tag: rec-4.1.0-alpha1~124 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c3cb22ab93f8f95240cb0c9255121a98363367b8;p=thirdparty%2Fpdns.git Merge pull request #5265 from rgacogne/rec-rpz-wildcard-target rec: Add support for RPZ wildcarded target names --- c3cb22ab93f8f95240cb0c9255121a98363367b8 diff --cc pdns/filterpo.cc index 8a5b1e1840,09bc0bec7c..8ef02f4db6 --- a/pdns/filterpo.cc +++ b/pdns/filterpo.cc @@@ -207,8 -237,38 +207,36 @@@ bool DNSFilterEngine::Zone::rmNSTrigger return true; } -bool DNSFilterEngine::rmNSIPTrigger(const Netmask& nm, Policy pol, size_t zone) +bool DNSFilterEngine::Zone::rmNSIPTrigger(const Netmask& nm, Policy pol) { - assureZones(zone); - auto& pols = d_zones[zone].propolNSAddr; - pols.erase(nm); + d_propolNSAddr.erase(nm); return true; } + + DNSRecord DNSFilterEngine::Policy::getCustomRecord(const DNSName& qname) const + { + if (d_kind != PolicyKind::Custom) { + throw std::runtime_error("Asking for a custom record from a filtering policy of a non-custom type"); + } + + DNSRecord result; + result.d_name = qname; + result.d_type = d_custom->getType(); + result.d_ttl = d_ttl; + result.d_class = QClass::IN; + result.d_place = DNSResourceRecord::ANSWER; + result.d_content = d_custom; + + if (result.d_type == QType::CNAME) { + const auto content = std::dynamic_pointer_cast(d_custom); + if (content) { + DNSName target = content->getTarget(); + if (target.isWildcard()) { + target.chopOff(); + result.d_content = std::make_shared(qname + target); + } + } + } + + return result; + }