From 2feca1f34a8d39ac7eafb970b5a1cc850d191f2d Mon Sep 17 00:00:00 2001 From: Peter van Dijk Date: Fri, 9 Mar 2018 15:45:58 +0100 Subject: [PATCH] add TCP support for ALIAS. Closes #6328 (cherry picked from commit c4e084f20f0cfd995e3f4aa75d534cf3b7ea89fd) --- pdns/dnsproxy.cc | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/pdns/dnsproxy.cc b/pdns/dnsproxy.cc index 8936436fd..275b425a3 100644 --- a/pdns/dnsproxy.cc +++ b/pdns/dnsproxy.cc @@ -32,6 +32,9 @@ #include "logger.hh" #include "statbag.hh" #include "dns_random.hh" +#include "stubresolver.hh" +#include "tcpreceiver.hh" +#include "arguments.hh" extern StatBag S; @@ -81,9 +84,39 @@ void DNSProxy::go() pthread_create(&tid,0,&launchhelper,this); } +extern TCPNameserver *TN; + //! look up qname aname with r->qtype, plonk it in the answer section of 'r' with name target bool DNSProxy::completePacket(DNSPacket *r, const DNSName& target,const DNSName& aname) { + if(r->d_tcp) { + cerr<<"qtype="<qtype.getCode()< ips; + int ret1 = 0, ret2 = 0; + + if(r->qtype == QType::A || r->qtype == QType::ANY) + ret1 = stubDoResolve(target, QType::A, ips); + if(r->qtype == QType::AAAA || r->qtype == QType::ANY) + ret2 = stubDoResolve(target, QType::AAAA, ips); + + if(ret1 != RCode::NoError || ret2 != RCode::NoError) { + L<addRecord(ip); + } + + uint16_t len=htons(r->getString().length()); + string buffer((const char*)&len, 2); + buffer.append(r->getString()); + writen2WithTimeout(r->getSocket(), buffer.c_str(), buffer.length(), ::arg().asNum("tcp-idle-timeout")); + + return true; + } + uint16_t id; { Lock l(&d_lock); -- 2.40.0