iter = polmap.find(g_wildcarddnsname+s);
if(iter != polmap.end()) {
pol=iter->second;
+ pol.d_trigger = g_wildcarddnsname+s;
return true;
}
}
const auto& it = polmap.find(qname);
if (it != polmap.end()) {
pol = it->second;
+ pol.d_trigger = qname;
return true;
}
}
if (z->findExactNSPolicy(qname, pol)) {
// cerr<<"Had a hit on the nameserver ("<<qname<<") used to process the query"<<endl;
+ pol.d_trigger = qname;
+ pol.d_trigger.appendRawLabel("rpz-nsdname");
return true;
}
for (const auto& wc : wcNames) {
if (z->findExactNSPolicy(wc, pol)) {
// cerr<<"Had a hit on the nameserver ("<<qname<<") used to process the query"<<endl;
+ pol.d_trigger = wc;
+ pol.d_trigger.appendRawLabel("rpz-nsdname");
return true;
}
}
if(z->findNSIPPolicy(address, pol)) {
// cerr<<"Had a hit on the nameserver ("<<address.toString()<<") used to process the query"<<endl;
+ // XXX should use ns RPZ
+ pol.d_trigger = Zone::maskToRPZ(address);
+ pol.d_trigger.appendRawLabel("rpz-nsip");
return true;
}
}
if (z->findExactQNamePolicy(qname, pol)) {
// cerr<<"Had a hit on the name of the query"<<endl;
+ pol.d_trigger = qname;
return true;
}
for (const auto& wc : wcNames) {
if (z->findExactQNamePolicy(wc, pol)) {
// cerr<<"Had a hit on the name of the query"<<endl;
+ pol.d_trigger = wc;
return true;
}
}
}
if (z->findResponsePolicy(ca, pol)) {
+ pol.d_trigger = Zone::maskToRPZ(ca);
+ pol.d_trigger.appendRawLabel("rpz-ip");
return true;
}
}
std::vector<std::shared_ptr<DNSRecordContent>> d_custom;
std::shared_ptr<PolicyZoneData> d_zoneData{nullptr};
+ DNSName d_trigger;
/* Yup, we are currently using the same TTL for every record for a given name */
int32_t d_ttl;
PolicyKind d_kind;
d_zoneData->d_priority = p;
}
+ static DNSName maskToRPZ(const Netmask& nm);
+
private:
void addNameTrigger(std::unordered_map<DNSName,Policy>& map, const DNSName& n, Policy&& pol, bool ignoreDuplicate, PolicyType ptype);
void addNetmaskTrigger(NetmaskTree<Policy>& nmt, const Netmask& nm, Policy&& pol, bool ignoreDuplicate, PolicyType ptype);
bool rmNameTrigger(std::unordered_map<DNSName,Policy>& map, const DNSName& n, const Policy& pol);
bool rmNetmaskTrigger(NetmaskTree<Policy>& nmt, const Netmask& nm, const Policy& pol);
- static DNSName maskToRPZ(const Netmask& nm);
+ private:
static bool findExactNamedPolicy(const std::unordered_map<DNSName, DNSFilterEngine::Policy>& polmap, const DNSName& qname, DNSFilterEngine::Policy& pol);
static bool findNamedPolicy(const std::unordered_map<DNSName, DNSFilterEngine::Policy>& polmap, const DNSName& qname, DNSFilterEngine::Policy& pol);
static void dumpNamedPolicy(FILE* fp, const DNSName& name, const Policy& pol);
d_lw->registerMember("policyKind", &DNSFilterEngine::Policy::d_kind);
d_lw->registerMember("policyType", &DNSFilterEngine::Policy::d_type);
d_lw->registerMember("policyTTL", &DNSFilterEngine::Policy::d_ttl);
+ d_lw->registerMember("policyTrigger", &DNSFilterEngine::Policy::d_trigger);
d_lw->registerMember<DNSFilterEngine::Policy, std::string>("policyCustom",
[](const DNSFilterEngine::Policy& pol) -> std::string {
std::string result;
{"Custom", (int)DNSFilterEngine::PolicyKind::Custom }
}});
+ d_pd.push_back({"policytypes", in_t {
+ {"None", (int)DNSFilterEngine::PolicyType::None },
+ {"QName", (int)DNSFilterEngine::PolicyType::QName },
+ {"ClientIP", (int)DNSFilterEngine::PolicyType::ClientIP },
+ {"ResponseIP", (int)DNSFilterEngine::PolicyType::ResponseIP },
+ {"NSDName", (int)DNSFilterEngine::PolicyType::NSDName },
+ {"NSIP", (int)DNSFilterEngine::PolicyType::NSIP }
+ }});
+
for(const auto& n : QType::names)
d_pd.push_back({n.first, n.second});
Set by :ref:`policyName <rpz-policyName>` in the :func:`rpzFile` and :func:`rpzMaster` configuration items.
It is advised to overwrite this when modifying the :attr:`DNSQuestion.appliedPolicy.policyKind`
- .. attribute:: DNSQuestion.appliedPolicy.policyAction
-
- The action taken by the engine
+ .. attribute:: DNSQuestion.appliedPolicy.policyType
+
+ The type of match for the policy.
+
+ - ``pdns.policytypes.None`` the empty policy type
+ - ``pdns.policytypes.QName`` a match on qname
+ - ``pdns.policytypes.ClientIP`` a match on client IP
+ - ``pdns.policytypes.ResponseIP`` a match on response IP
+ - ``pdns.policytypes.NSDName`` a match on the name of a nameserver
+ - ``pdns.policytypes.NSIP`` a match on the IP of a nameserver
.. attribute:: DNSQuestion.appliedPolicy.policyCustom