* Query domain
* QPS Limit total
* QPS Limit per IP address or subnet
+ * RegexRule on query name
+ * Packet requests DNSSEC processing
Current actions are:
* Drop
This routes all queries with a DNSSEC OK (DO) or CD bit set to on to the "dnssec" pool.
The final `topRule()` command moves this rule to the top, so it gets evaluated first.
+Regular Expressions
+-------------------
+`RegexRule()` matches a regular expression on the query name, and it works like this:
+
+```
+addAction(RegexRule("[0-9]{5,}"), DelayAction(750)) -- milliseconds
+addAction(RegexRule("[0-9]{4,}\\.cn$"), DropAction())
+```
+
+This delays any query for a domain name with 5 or more consecutive digits in it.
+The second rule drops anything with more than 4 consecutive digits within a .CN domain.
+
+Note that the query name is presented without a trailing dot to the regex.
+The regex is applied case insensitively.
+
Inspecting live traffic
-----------------------
This is still much in flux, but for now, try:
return std::shared_ptr<DNSAction>(new DropAction);
});
+ g_lua.writeFunction("DelayAction", [](int msec) {
+ return std::shared_ptr<DNSAction>(new DelayAction(msec));
+ });
+
+
g_lua.writeFunction("TCAction", []() {
return std::shared_ptr<DNSAction>(new TCAction);
});
});
+ g_lua.writeFunction("RegexRule", [](const std::string& str) {
+ return std::shared_ptr<DNSRule>(new RegexRule(str));
+ });
+
g_lua.writeFunction("addAction", [](luadnsrule_t var, std::shared_ptr<DNSAction> ea)
{
auto rule=makeRule(var);
}
};
+class RegexRule : public DNSRule
+{
+public:
+ RegexRule(const std::string& regex) : d_regex(regex), d_visual(regex)
+ {
+
+ }
+ bool matches(const ComboAddress& remote, const DNSName& qname, uint16_t qtype, dnsheader* dh, int len) const override
+ {
+ return d_regex.match(qname.toStringNoDot());
+ }
+
+ string toString() const override
+ {
+ return "Regex qname: "+d_visual;
+ }
+private:
+ Regex d_regex;
+ string d_visual;
+};
+
class SuffixMatchNodeRule : public DNSRule
{
regfree(&d_preg);
}
/** call this to find out if 'line' matches your expression */
- bool match(const string &line)
+ bool match(const string &line) const
{
return regexec(&d_preg,line.c_str(),0,0,0)==0;
}
- bool match(const DNSName& name)
+ bool match(const DNSName& name) const
{
return match(name.toStringNoDot());
}