From cec47783de2f53296dc98ec7b95660df9a24d9b4 Mon Sep 17 00:00:00 2001 From: bert hubert Date: Tue, 2 Feb 2016 20:34:21 +0100 Subject: [PATCH] add qclass to dnsdist (uncompiled) --- pdns/dnsdist-lua.cc | 1 + pdns/dnsdist-tcp.cc | 6 +++--- pdns/dnsdist.cc | 6 +++--- pdns/dnsdist.hh | 3 ++- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/pdns/dnsdist-lua.cc b/pdns/dnsdist-lua.cc index 62562ac29..47801d8f9 100644 --- a/pdns/dnsdist-lua.cc +++ b/pdns/dnsdist-lua.cc @@ -1212,6 +1212,7 @@ vector> setupLua(bool client, const std::string& confi g_lua.registerMember("localaddr", [](const DNSQuestion& dq) -> const ComboAddress { return *dq.local; }, [](DNSQuestion& dq, const ComboAddress newLocal) { (void) newLocal; }); g_lua.registerMember("qname", [](const DNSQuestion& dq) -> const DNSName { return *dq.qname; }, [](DNSQuestion& dq, const DNSName newName) { (void) newName; }); g_lua.registerMember("qtype", [](const DNSQuestion& dq) -> uint16_t { return dq.qtype; }, [](DNSQuestion& dq, uint16_t newType) { (void) newType; }); + g_lua.registerMember("qclass", [](const DNSQuestion& dq) -> uint16_t { return dq.qclass; }); g_lua.registerMember("rcode", [](const DNSQuestion& dq) -> int { return dq.dh->rcode; }, [](DNSQuestion& dq, int newRCode) { dq.dh->rcode = newRCode; }); g_lua.registerMember("remoteaddr", [](const DNSQuestion& dq) -> const ComboAddress { return *dq.remote; }, [](DNSQuestion& dq, const ComboAddress newRemote) { (void) newRemote; }); /* DNSDist DNSQuestion */ diff --git a/pdns/dnsdist-tcp.cc b/pdns/dnsdist-tcp.cc index 60c7cb762..46ed97dde 100644 --- a/pdns/dnsdist-tcp.cc +++ b/pdns/dnsdist-tcp.cc @@ -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; diff --git a/pdns/dnsdist.cc b/pdns/dnsdist.cc index 215a8fa7c..c87b8f118 100644 --- a/pdns/dnsdist.cc +++ b/pdns/dnsdist.cc @@ -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 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); diff --git a/pdns/dnsdist.hh b/pdns/dnsdist.hh index 4da00c8b7..175a5f5bb 100644 --- a/pdns/dnsdist.hh +++ b/pdns/dnsdist.hh @@ -351,10 +351,11 @@ using servers_t =vector>; 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; -- 2.40.0