-EXTRA_PROGRAMS=pdns_recursor sdig dnspbench pdns_control qgen dnsscope dnsreplay_mindex dnswasher dnsreplay
+EXTRA_PROGRAMS=pdns_recursor sdig dnspbench pdns_control qgen dnsscope dnsreplay_mindex dnswasher dnsreplay dnsscan
pdns_server_SOURCES=dnspacket.cc nameserver.cc tcpreceiver.hh \
qtype.cc logger.cc arguments.cc packethandler.cc tcpreceiver.cc \
dnsreplay_LDFLAGS= @DYNLINKFLAGS@ @THREADFLAGS@
+dnsscan_SOURCES=dnsscan.cc misc.cc qtype.cc anadns.hh \
+ logger.cc statbag.cc dnspcap.cc dnspcap.hh dnsparser.cc dnsrecords.cc dnsparser.hh \
+ rcpgenerator.cc rcpgenerator.hh base64.cc base64.hh dnswriter.cc dnswriter.hh \
+ unix_utility.cc utility.hh
+
+
dnsreplay_mindex_SOURCES=dnsreplay-mindex.cc misc.cc qtype.cc anadns.hh \
logger.cc statbag.cc dnspcap.cc dnspcap.hh dnsparser.cc dnsrecords.cc dnsparser.hh \
rcpgenerator.cc rcpgenerator.hh base64.cc base64.hh dnswriter.cc dnswriter.hh \
+VERSION=3.0-pre1
+
INCLUDES="iputils.hh arguments.hh base64.hh zoneparser-tng.hh \
rcpgenerator.hh lock.hh dnswriter.hh dnsrecords.hh dnsparser.hh utility.hh \
recursor_cache.hh rec_channel.hh qtype.hh misc.hh dns.hh syncres.hh \
recursor_cache.cc dnsparser.cc dnswriter.cc dnsrecords.cc rcpgenerator.cc \
base64.cc zoneparser-tng.cc rec_channel.cc rec_channel_rec.cc rec_control.cc"
-cat $INCLUDES $CFILES | wc
-rm -rf pdns-recursor
-mkdir pdns-recursor
-cp $INCLUDES $CFILES pdns-recursor
-cp Makefile-recursor pdns-recursor/Makefile
-cp README-recursor pdns-recursor/README
-cp COPYING pdns-recursor/
-cp config-recursor.h pdns-recursor/config.h
-mkdir pdns-recursor/rrd
-cp tools/rrd/{create,update,makegraphs,index.html} pdns-recursor/rrd
-cp ext/nedmalloc/malloc.c pdns-recursor
-tar cf pdns-recursor.tar pdns-recursor
-bzip2 -f pdns-recursor.tar # .. solaris
+DIRNAME=pdns-recursor-$VERSION
+rm -rf $DIRNAME
+mkdir $DIRNAME
+cp $INCLUDES $CFILES $DIRNAME
+cp Makefile-recursor $DIRNAME/Makefile
+cp README-recursor $DIRNAME/README
+cp COPYING $DIRNAME/
+cp config-recursor.h $DIRNAME/config.h
+mkdir $DIRNAME/rrd
+cp tools/rrd/{create,update,makegraphs,index.html} $DIRNAME/rrd
+cp ext/nedmalloc/malloc.c $DIRNAME
+tar cf $DIRNAME.tar $DIRNAME
+bzip2 -f $DIRNAME.tar # .. solaris
--- /dev/null
+#include <bitset>
+#include "statbag.hh"
+#include "dnspcap.hh"
+#include "sstuff.hh"
+#include "anadns.hh"
+
+// this is needed because boost multi_index also uses 'L', as do we (which is sad enough)
+#undef L
+
+#include <arpa/nameser.h>
+#include <set>
+#include <deque>
+
+#include <boost/format.hpp>
+#include <boost/utility.hpp>
+#include <boost/multi_index_container.hpp>
+#include <boost/multi_index/ordered_index.hpp>
+#include <boost/multi_index/key_extractors.hpp>
+#include <cctype>
+
+using namespace boost;
+using namespace ::boost::multi_index;
+using namespace std;
+StatBag S;
+
+int main(int argc, char** argv)
+try
+{
+ PcapPacketReader pr(argv[1]);
+ Socket sock(InterNetwork, Datagram);
+
+ IPEndpoint remote(argc > 2 ? argv[2] : "127.0.0.1",
+ argc > 3 ? atoi(argv[3]) : 5300);
+
+
+ while(pr.getUDPPacket()) {
+ try {
+ MOADNSParser mdp((const char*)pr.d_payload, pr.d_len);
+ for(int i=0; i < mdp.d_qname.length(); ++i)
+ if(!isalnum(mdp.d_qname[i]) && mdp.d_qname[i]!='.' && mdp.d_qname[i]!='-' && mdp.d_qname[i]!='_') {
+ cout<<mdp.d_qname<<"|"<<mdp.d_qtype<<"|"<<mdp.d_qclass<<"\n";
+ sock.sendTo(string(pr.d_payload, pr.d_payload + pr.d_len), remote);
+ break;
+ }
+ if(mdp.d_qtype > 256 || mdp.d_qclass!=1 ) {
+ // sock.sendTo(string(pr.d_payload, pr.d_payload + pr.d_len), remote);
+
+ }
+ for(MOADNSParser::answers_t::const_iterator i=mdp.d_answers.begin(); i!=mdp.d_answers.end(); ++i) {
+
+ }
+
+ }
+ catch(MOADNSException &e) {
+ cerr<<"Error: "<<e.what()<<"\n";
+ sock.sendTo(string(pr.d_payload, pr.d_payload + pr.d_len), remote);
+ }
+ }
+}
+catch(exception& e)
+{
+ cerr<<"Fatal: "<<e.what()<<endl;
+}
+
/** Never throws! */
int LWRes::asyncresolve(uint32_t ip, const char *domain, int type, bool doTCP, struct timeval* now)
{
+ d_ip=ip;
vector<uint8_t> vpacket;
DNSPacketWriter pw(vpacket, domain, type);
d_inaxfr=false;
d_rcode=0;
+
struct sockaddr_in toaddr;
Utility::socklen_t addrlen=sizeof(toaddr);
toaddr.sin_addr.s_addr=htonl(ip);
d_tcbit=mdp.d_header.tc;
d_rcode=mdp.d_header.rcode;
+ if(d_domain != mdp.d_qname) {
+ L<<Logger::Error<<"Packet purporting to come from remote server "<<U32ToIP(d_ip)<<" contained wrong answer: '" << d_domain << "' != '" << mdp.d_qname << "'" << endl;
+ g_stats.spoofedCount++;
+ goto out;
+ }
+
LWRes::res_t ret;
for(MOADNSParser::answers_t::const_iterator i=mdp.d_answers.begin(); i!=mdp.d_answers.end(); ++i) {
// cout<<i->first.d_place<<"\t"<<i->first.d_label<<"\tIN\t"<<DNSRecordContent::NumberToType(i->first.d_type);
catch(...) {
L<<Logger::Error<<"Unknown error parsing packet from remote server"<<endl;
}
+
g_stats.serverParseError++;
+
+ out:
d_rcode=RCode::ServFail;
LWRes::res_t empty;
return empty;
#include <string>
#include <vector>
#include <sys/types.h>
+#include "misc.hh"
#ifndef WIN32
uint64_t tcpClientOverflow;
uint64_t clientParseError;
uint64_t serverParseError;
+ uint64_t spoofedCount;
};
extern RecursorStats g_stats;