From: Remi Gacogne Date: Mon, 22 Aug 2016 14:15:12 +0000 (+0200) Subject: rec: Call `gettag()` for TCP queries X-Git-Tag: dnsdist-1.1.0-beta1~2^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=33dcceba94293f8060944a7edf3912463004a0ba;p=pdns rec: Call `gettag()` for TCP queries The `gettag()` hook used to be called to set a tag for the packet cache and hence it did not make sense to call it for TCP queries, but now it can also be used to policy tags. --- diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index fa2b40c9c..b6c713082 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -1286,23 +1286,48 @@ void handleRunningTCPQuestion(int fd, FDMultiplexer::funcparam_t& var) socklen_t len = dest.getSocklen(); getsockname(conn->getFD(), (sockaddr*)&dest, &len); // if this fails, we're ok with it dc->setLocal(dest); + Netmask ednssubnet; + DNSName qname; + uint16_t qtype=0; + uint16_t qclass=0; + bool needECS = false; #ifdef HAVE_PROTOBUF auto luaconfsLocal = g_luaconfs.getLocal(); + if (luaconfsLocal->protobufServer) { + needECS = true; + } +#endif + + if(needECS || (t_pdl->get() && (*t_pdl)->d_gettag)) { + + try { + getQNameAndSubnet(std::string(conn->data, conn->qlen), &qname, &qtype, &qclass, &ednssubnet); + if(t_pdl->get() && (*t_pdl)->d_gettag) { + try { + dc->d_tag = (*t_pdl)->gettag(conn->d_remote, ednssubnet, dest, qname, qtype, &dc->d_policyTags); + } + catch(std::exception& e) { + if(g_logCommonErrors) + L<protobufServer) { dc->d_uuid = (*t_uuidGenerator)(); try { - DNSName qname; - uint16_t qtype; - uint16_t qclass; - Netmask ednssubnet; const struct dnsheader* dh = (const struct dnsheader*) conn->data; - - getQNameAndSubnet(std::string(conn->data, conn->qlen), &qname, &qtype, &qclass, &ednssubnet); dc->d_ednssubnet = ednssubnet; - protobufLogQuery(luaconfsLocal->protobufServer, luaconfsLocal->protobufMaskV4, luaconfsLocal->protobufMaskV6, dc->d_uuid, dest, conn->d_remote, ednssubnet, true, dh->id, conn->qlen, qname, qtype, qclass, std::vector()); + protobufLogQuery(luaconfsLocal->protobufServer, luaconfsLocal->protobufMaskV4, luaconfsLocal->protobufMaskV6, dc->d_uuid, dest, conn->d_remote, ednssubnet, true, dh->id, conn->qlen, qname, qtype, qclass, dc->d_policyTags); } catch(std::exception& e) { if(g_logCommonErrors)