Skip to content

Commit abc8f3f

Browse files
committed
first steps towards --any-to-tcp feature
1 parent c997c3b commit abc8f3f

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

pdns/common_startup.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
/*
22
PowerDNS Versatile Database Driven Nameserver
3-
Copyright (C) 2005 - 2011 PowerDNS.COM BV
3+
Copyright (C) 2005 - 2013 PowerDNS.COM BV
44
55
This program is free software; you can redistribute it and/or modify
66
it under the terms of the GNU General Public License version 2
77
as published by the Free Software Foundation
8-
98
109
This program is distributed in the hope that it will be useful,
1110
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -31,6 +30,8 @@ UDPNameserver *N;
3130
int avg_latency;
3231
TCPNameserver *TN;
3332

33+
bool g_anyToTCP;
34+
3435
ArgvMap &arg()
3536
{
3637
return theArg;
@@ -280,6 +281,8 @@ void *qthread(void *number)
280281
L << Logger::Notice<<"Remote "<< remote <<" wants '" << P->qdomain<<"|"<<P->qtype.getName() <<
281282
"', do = " <<P->d_dnssecOk <<", bufsize = "<< P->getMaxReplyLen()<<": ";
282283
}
284+
285+
283286
if((P->d.opcode != Opcode::Notify) && P->couldBeCached() && PC.get(P, &cached)) { // short circuit - does the PacketCache recognize this question?
284287
if(logDNSQueries)
285288
L<<"packetcache HIT"<<endl;

pdns/dnspacket.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,8 @@ void DNSPacket::wrapup()
274274
pw.getHeader()->qr=d.qr;
275275
pw.getHeader()->id=d.id;
276276
pw.getHeader()->rd=d.rd;
277-
277+
pw.getHeader()->tc=d.tc;
278+
278279
DNSPacketWriter::optvect_t opts;
279280
if(d_wantsnsid) {
280281
opts.push_back(make_pair(3, ::arg()["server-id"]));

pdns/nameserver.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,6 @@ DNSPacket *UDPNameserver::receive(DNSPacket *prefilled)
410410
}
411411
}
412412

413-
414413
DLOG(L<<"Received a packet " << len <<" bytes long from "<< remote.toString()<<endl);
415414

416415
DNSPacket *packet;
@@ -428,7 +427,6 @@ DNSPacket *UDPNameserver::receive(DNSPacket *prefilled)
428427
packet->d_anyLocal = dest;
429428
}
430429

431-
432430
if(packet->parse(mesg, len)<0) {
433431
S.inc("corrupt-packets");
434432
S.ringAccount("remotes-corrupt", packet->getRemote());

pdns/packethandler.cc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1165,7 +1165,7 @@ DNSPacket *PacketHandler::questionOrRecurse(DNSPacket *p, bool *shouldRecurse)
11651165
return r;
11661166
}
11671167

1168-
// L<<Logger::Warning<<"Query for '"<<p->qdomain<<"' "<<p->qtype.getName()<<" from "<<p->getRemote()<<endl;
1168+
L<<Logger::Warning<<"Query for '"<<p->qdomain<<"' "<<p->qtype.getName()<<" from "<<p->getRemote()<<endl;
11691169

11701170
r->d.ra = (p->d.rd && d_doRecursion && DP->recurseFor(p)); // make sure we set ra if rd was set, and we'll do it
11711171

@@ -1185,6 +1185,13 @@ DNSPacket *PacketHandler::questionOrRecurse(DNSPacket *p, bool *shouldRecurse)
11851185
if(doVersionRequest(p,r,target)) // catch version.bind requests
11861186
goto sendit;
11871187

1188+
if(p->qtype.getCode() == QType::ANY) {
1189+
cerr<<"Shunted it to TCP.."<<endl;
1190+
r->d.tc = 1;
1191+
r->commitD();
1192+
return r;
1193+
}
1194+
11881195
if(p->qclass==255) // any class query
11891196
r->setA(false);
11901197
else if(p->qclass != QClass::IN) // we only know about IN, so we don't find anything

0 commit comments

Comments
 (0)