]> granicus.if.org Git - pdns/commitdiff
add qclass to dnsdist (uncompiled)
authorbert hubert <bert.hubert@netherlabs.nl>
Tue, 2 Feb 2016 19:34:21 +0000 (20:34 +0100)
committerbert hubert <bert.hubert@netherlabs.nl>
Tue, 2 Feb 2016 19:34:21 +0000 (20:34 +0100)
pdns/dnsdist-lua.cc
pdns/dnsdist-tcp.cc
pdns/dnsdist.cc
pdns/dnsdist.hh

index 62562ac290b8ac32ef3b2a9544ae2c0d6e002c94..47801d8f9ab27e78673b4958b1da2876eaa3f1bc 100644 (file)
@@ -1212,6 +1212,7 @@ vector<std::function<void(void)>> setupLua(bool client, const std::string& confi
   g_lua.registerMember<const ComboAddress (DNSQuestion::*)>("localaddr", [](const DNSQuestion& dq) -> const ComboAddress { return *dq.local; }, [](DNSQuestion& dq, const ComboAddress newLocal) { (void) newLocal; });
   g_lua.registerMember<const DNSName (DNSQuestion::*)>("qname", [](const DNSQuestion& dq) -> const DNSName { return *dq.qname; }, [](DNSQuestion& dq, const DNSName newName) { (void) newName; });
   g_lua.registerMember<uint16_t (DNSQuestion::*)>("qtype", [](const DNSQuestion& dq) -> uint16_t { return dq.qtype; }, [](DNSQuestion& dq, uint16_t newType) { (void) newType; });
+  g_lua.registerMember<uint16_t (DNSQuestion::*)>("qclass", [](const DNSQuestion& dq) -> uint16_t { return dq.qclass; });
   g_lua.registerMember<int (DNSQuestion::*)>("rcode", [](const DNSQuestion& dq) -> int { return dq.dh->rcode; }, [](DNSQuestion& dq, int newRCode) { dq.dh->rcode = newRCode; });
   g_lua.registerMember<const ComboAddress (DNSQuestion::*)>("remoteaddr", [](const DNSQuestion& dq) -> const ComboAddress { return *dq.remote; }, [](DNSQuestion& dq, const ComboAddress newRemote) { (void) newRemote; });
   /* DNSDist DNSQuestion */
index 60c7cb762532a38004f21e69b9707cc42b201f3e..46ed97dde0c8458b3eba32629a1186fad18a5d6f 100644 (file)
@@ -223,10 +223,10 @@ void* tcpClientThread(int pipefd)
           goto drop;
         }
 
-       uint16_t qtype;
+       uint16_t qtype, qclass;
        unsigned int consumed = 0;
-       DNSName qname(query, qlen, sizeof(dnsheader), false, &qtype, 0, &consumed);
-       DNSQuestion dq(&qname, qtype, &ci.cs->local, &ci.remote, (dnsheader*)query, querySize, qlen, true);
+       DNSName qname(query, qlen, sizeof(dnsheader), false, &qtype, &qclass, &consumed);
+       DNSQuestion dq(&qname, qtype, qclass, &ci.cs->local, &ci.remote, (dnsheader*)query, querySize, qlen, true);
        string ruleresult;
        const uint16_t * flags = getFlagsFromDNSHeader(dq.dh);
        uint16_t origFlags = *flags;
index 215a8fa7c84a3d6eb21a070882483f26abc859cf..c87b8f1184f2595ff29466a595ce3e0818606ec0 100644 (file)
@@ -520,7 +520,7 @@ try
   remote.sin4.sin_family = cs->local.sin4.sin_family;
   char packet[1500];
   string largerQuery;
-  uint16_t qtype;
+  uint16_t qtype, qclass;
 
   typedef std::function<bool(DNSQuestion*)> blockfilter_t;
   blockfilter_t blockFilter = 0;
@@ -613,9 +613,9 @@ try
       const uint16_t * flags = getFlagsFromDNSHeader(dh);
       const uint16_t origFlags = *flags;
       unsigned int consumed = 0;
-      DNSName qname(query, len, sizeof(dnsheader), false, &qtype, NULL, &consumed);
+      DNSName qname(query, len, sizeof(dnsheader), false, &qtype, &qclass, &consumed);
 
-      DNSQuestion dq(&qname, qtype, &cs->local, &remote, dh, sizeof(packet), len, false);
+      DNSQuestion dq(&qname, qtype, qclass, &cs->local, &remote, dh, sizeof(packet), len, false);
 
       struct timespec now;
       clock_gettime(CLOCK_MONOTONIC, &now);
index 4da00c8b7c15aabac3dec615afeffb1c387c16de..175a5f5bb2b645d70bff33cf999814a626dc917a 100644 (file)
@@ -351,10 +351,11 @@ using servers_t =vector<std::shared_ptr<DownstreamState>>;
 
 struct DNSQuestion
 {
-  DNSQuestion(const DNSName* name, uint16_t type, const ComboAddress* lc, const ComboAddress* rem, struct dnsheader* header, size_t bufferSize, uint16_t queryLen, bool isTcp): qname(name), qtype(type), local(lc), remote(rem), dh(header), size(bufferSize), len(queryLen), tcp(isTcp) {};
+  DNSQuestion(const DNSName* name, uint16_t type, uint16_t class_, const ComboAddress* lc, const ComboAddress* rem, struct dnsheader* header, size_t bufferSize, uint16_t queryLen, bool isTcp): qname(name), qtype(type), qclass(class_), local(lc), remote(rem), dh(header), size(bufferSize), len(queryLen), tcp(isTcp) {};
 
   const DNSName* qname;
   const uint16_t qtype;
+  const uint16_t qclass;
   const ComboAddress* local;
   const ComboAddress* remote;
   struct dnsheader* dh;