]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
DNSNameSet and QNameSetRule, minor fixes
authorAndrey Domas <andrey.domas@corp.mail.ru>
Mon, 4 Mar 2019 11:23:02 +0000 (14:23 +0300)
committerAndrey Domas <andrey.domas@corp.mail.ru>
Mon, 4 Mar 2019 11:23:02 +0000 (14:23 +0300)
pdns/dnsdist-lua-bindings.cc
pdns/dnsdistdist/dnsdist-rules.hh
pdns/dnsdistdist/docs/reference/dnsnameset.rst
pdns/dnsdistdist/docs/rules-actions.rst
pdns/dnsname.hh

index ee966ab58885cd036c7685800d56b280d235a677..72c3614c8849036a1318dabed21d76b4b9806c26 100644 (file)
@@ -180,7 +180,7 @@ void setupLuaBindings(bool client)
   /* DNSNameSet */
   g_lua.registerFunction<string(DNSNameSet::*)()>("toString", [](const DNSNameSet&dns ) { return dns.toString(); });
   g_lua.registerFunction<void(DNSNameSet::*)(DNSName&)>("add", [](DNSNameSet& dns, DNSName& dn) { dns.insert(dn); });
-  g_lua.registerFunction<bool(DNSNameSet::*)(DNSName&)>("contains", [](DNSNameSet& dns, DNSName& dn) { return dns.find(dn) != dns.end(); });
+  g_lua.registerFunction<bool(DNSNameSet::*)(DNSName&)>("check", [](DNSNameSet& dns, DNSName& dn) { return dns.find(dn) != dns.end(); });
   g_lua.registerFunction("delete",(size_t (DNSNameSet::*)(const DNSName&)) &DNSNameSet::erase);
   g_lua.registerFunction("size",(size_t (DNSNameSet::*)() const) &DNSNameSet::size);
   g_lua.registerFunction("clear",(void (DNSNameSet::*)()) &DNSNameSet::clear);
index c29e48d65cd30bfc5598a2bed127f6077f93956f..166b9282af949449cec60a765cdfa76cf969b22d 100644 (file)
@@ -545,7 +545,7 @@ private:
 
 class QNameSetRule : public DNSRule {
 public:
-    QNameSetRule(const DNSNameSet names) : qname_idx(names) {}
+    QNameSetRule(const DNSNameSet& names) : qname_idx(names) {}
 
     bool matches(const DNSQuestion* dq) const override {
         return qname_idx.find(*dq->qname) != qname_idx.end();
index 49b28602c5908cfa135226604c34546f697440c0..2344dc3a63c496fff8d0cb803d44c27a4fe45213 100644 (file)
@@ -53,7 +53,7 @@ Functions and methods of a ``DNSNameSet``
 
    :param DNSName name The name to remove.
 
-  .. method:: DNSNameSet:contains(name) -> bool
+  .. method:: DNSNameSet:check(name) -> bool
 
     Returns true if the set contains the name.
 
index b6f2d980e408b7d0bccaa11c94705f8ca28b2adf..50b215b0c6d2354741bb93c0f97ada4a591246be 100644 (file)
@@ -611,9 +611,11 @@ These ``DNSRule``\ s be one of the following items:
    :param string qname: Qname to match
 
 .. function:: QNameSetRule(set)
-   Matches if the set contains qname.
+  Matches if the set contains excact qname.
 
-  :param DNSNameSet set: Set with qnames.
+   To match subdomain names, see :func:`SuffixMatchNodeRule`.
+
+   :param DNSNameSet set: Set with qnames.
 
 .. function:: QNameLabelsCountRule(min, max)
 
@@ -718,6 +720,8 @@ These ``DNSRule``\ s be one of the following items:
   Matches based on a group of domain suffixes for rapid testing of membership.
   Pass true as second parameter to prevent listing of all domains matched.
 
+  To match domain names exactly, see :func:`QNameSetRule`.
+
   :param SuffixMatchNode smb: The SuffixMatchNode to match on
   :param bool quiet: Do not return the list of matched domains. Default is false.
 
index 0f64376f6eb81dd11835927196225e3edbcb9c11..a8ea1a92281416210d3b3d84f4e1bb9e416e832b 100644 (file)
@@ -28,6 +28,7 @@
 #include <stdexcept>
 #include <sstream>
 #include <iterator>
+#include <unordered_set>
 
 #include <boost/version.hpp>
 
@@ -379,7 +380,7 @@ bool DNSName::operator==(const DNSName& rhs) const
 
 extern const DNSName g_rootdnsname, g_wildcarddnsname;
 
-struct DNSNameSet: public std::set<DNSName> {
+struct DNSNameSet: public std::unordered_set<DNSName> {
     std::string toString() const {
         std::ostringstream oss;
         std::copy(begin(), end(), std::ostream_iterator<DNSName>(oss, "\n"));