Changeset 1160
- Timestamp:
- 03/16/08 15:58:19 (5 years ago)
- Location:
- trunk/pdns/pdns
- Files:
-
- 6 modified
-
Makefile-recursor (modified) (2 diffs)
-
Makefile.am (modified) (3 diffs)
-
dist-recursor (modified) (2 diffs)
-
lwres.cc (modified) (4 diffs)
-
pdns_recursor.cc (modified) (8 diffs)
-
syncres.cc (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pdns/pdns/Makefile-recursor
r1028 r1160 14 14 arguments.o lwres.o pdns_recursor.o recursor_cache.o dnsparser.o \ 15 15 dnswriter.o dnsrecords.o rcpgenerator.o base64.o zoneparser-tng.o \ 16 rec_channel.o rec_channel_rec.o malloc.o selectmplexer.o sillyrecords.o 16 rec_channel.o rec_channel_rec.o malloc.o selectmplexer.o sillyrecords.o \ 17 dns_random.o aescrypt.o aeskey.o aes_modes.o aestab.o 18 17 19 18 20 REC_CONTROL_OBJECTS=rec_channel.o rec_control.o arguments.o … … 69 71 70 72 dep: 71 $(CXX) $(CXXFLAGS) -MM -MG *.cc *. hh > $@73 $(CXX) $(CXXFLAGS) -MM -MG *.cc *.c *.hh > $@ 72 74 73 75 -include dep -
trunk/pdns/pdns/Makefile.am
r1094 r1160 39 39 base64.cc sillyrecords.cc \ 40 40 base64.hh zoneparser-tng.cc dnsrecords.cc dnswriter.cc \ 41 rcpgenerator.cc dnsparser.cc 41 rcpgenerator.cc dnsparser.cc \ 42 aes/dns_random.cc aes/aescrypt.c aes/aeskey.c aes/aestab.c aes/aes_modes.c 42 43 43 44 # … … 111 112 utility.hh dnsparser.hh sillyrecords.cc 112 113 113 114 115 116 # INCLUDES=-I/usr/include/mysql117 118 114 rec_control_SOURCES=rec_channel.cc rec_channel.hh rec_control.cc arguments.cc arguments.hh 119 115 … … 123 119 dnswriter.cc dnswriter.hh dnsrecords.cc dnsrecords.hh rcpgenerator.cc rcpgenerator.hh \ 124 120 base64.cc base64.hh zoneparser-tng.cc zoneparser-tng.hh rec_channel.cc rec_channel.hh \ 125 rec_channel_rec.cc selectmplexer.cc epollmplexer.cc sillyrecords.cc htimer.cc htimer.hh 121 rec_channel_rec.cc selectmplexer.cc epollmplexer.cc sillyrecords.cc htimer.cc htimer.hh \ 122 aes/dns_random.cc aes/aescrypt.c aes/aeskey.c aes/aestab.c aes/aes_modes.c 126 123 127 124 if NEDMALLOC -
trunk/pdns/pdns/dist-recursor
r1158 r1160 6 6 sstuff.hh mtasker.hh mtasker.cc lwres.hh logger.hh ahuexception.hh \ 7 7 mplexer.hh win32_mtasker.hh win32_utility.cc ntservice.hh singleton.hh \ 8 recursorservice.hh "8 recursorservice.hh dns_random.hh" 9 9 10 10 CFILES="syncres.cc misc.cc unix_utility.cc qtype.cc \ … … 32 32 cp tools/rrd/{create,update,makegraphs,index.html} $DIRNAME/rrd 33 33 cp ext/dlmalloc/malloc.{c,h} $DIRNAME 34 cp aes/*.{c,cc,h} $DIRNAME 34 35 cp pdns-recursor.init.d $DIRNAME 35 36 cp docs/pdns_recursor.1 docs/rec_control.1 $DIRNAME -
trunk/pdns/pdns/lwres.cc
r1130 r1160 1 1 /* 2 2 PowerDNS Versatile Database Driven Nameserver 3 Copyright (C) 2002 - 200 7PowerDNS.COM BV3 Copyright (C) 2002 - 2008 PowerDNS.COM BV 4 4 5 5 This program is free software; you can redistribute it and/or modify … … 37 37 #include "dnsparser.hh" 38 38 #include "logger.hh" 39 #include "dns_random.hh" 39 40 #include <boost/scoped_array.hpp> 41 #include <boost/algorithm/string.hpp> 42 43 string dns0x20(const std::string& in) 44 { 45 string ret(in); 46 string::size_type len=ret.size(); 47 for(string::size_type pos = 0 ; pos < len; ++pos) { 48 if(isalpha(in[pos]) && dns_random(2)) 49 ret[pos]^=0x20; 50 } 51 // cerr<<"'"<<in<<"' -> '"<<ret<<"'\n"; 52 return ret; 53 } 40 54 41 55 //! returns -2 for OS limits error, -1 for permanent error that has to do with remote, 0 for timeout, 1 for success … … 47 61 scoped_array<unsigned char> buf(new unsigned char[bufsize]); 48 62 vector<uint8_t> vpacket; 63 // string mapped0x20=dns0x20(domain); 49 64 DNSPacketWriter pw(vpacket, domain, type); 50 65 51 66 pw.getHeader()->rd=0; 52 pw.getHeader()->id= Utility::random();67 pw.getHeader()->id=dns_random(0xffff); 53 68 54 69 if(doEDNS0 && !doTCP) { … … 141 156 goto out; 142 157 } 143 158 144 159 for(MOADNSParser::answers_t::const_iterator i=mdp.d_answers.begin(); i!=mdp.d_answers.end(); ++i) { 145 160 DNSResourceRecord rr; 146 161 rr.qtype=i->first.d_type; 147 162 rr.qname=i->first.d_label; 163 /* 164 if(i->first.d_label == mapped0x20) 165 rr.qname=domain; 166 else 167 rr.qname=i->first.d_label; 168 */ 148 169 rr.ttl=i->first.d_ttl; 149 170 rr.content=i->first.d_content->getZoneRepresentation(); // this should be the serialised form -
trunk/pdns/pdns/pdns_recursor.cc
r1150 r1160 26 26 27 27 #include "utility.hh" 28 #include "dns_random.hh" 28 29 #include <iostream> 29 30 #include <errno.h> … … 1591 1592 } 1592 1593 1594 void seedRandom(const string& source); 1595 1593 1596 int serviceMain(int argc, char*argv[]) 1594 1597 { … … 1605 1608 } 1606 1609 1607 L<<Logger::Warning<<"PowerDNS recursor "<<VERSION<<" (C) 2001-200 7PowerDNS.COM BV ("<<__DATE__", "__TIME__;1610 L<<Logger::Warning<<"PowerDNS recursor "<<VERSION<<" (C) 2001-2008 PowerDNS.COM BV ("<<__DATE__", "__TIME__; 1608 1611 #ifdef __GNUC__ 1609 1612 L<<", gcc "__VERSION__; … … 1619 1622 1620 1623 L<<Logger::Warning<<"Operating in "<<(sizeof(unsigned long)*8) <<" bits mode"<<endl; 1624 1625 seedRandom(::arg()["entropy-source"]); 1621 1626 1622 1627 if(!::arg()["allow-from-file"].empty()) { … … 1824 1829 #endif 1825 1830 1831 void seedRandom(const string& source) 1832 { 1833 L<<Logger::Warning<<"Reading random entropy from '"<<source<<"'"<<endl; 1834 1835 int fd=open(source.c_str(), O_RDONLY); 1836 if(fd < 0) { 1837 L<<Logger::Error<<"Unable to open source of random '"<<source<<"': "<<stringerror()<<endl; 1838 exit(EXIT_FAILURE); 1839 } 1840 char seed[128]; 1841 int ret; 1842 int pos=0; 1843 while(pos!=sizeof(seed)) { 1844 ret = read(fd, seed+pos, sizeof(seed)-pos); 1845 if(ret < 0) { 1846 L<<Logger::Error<<"Unable to read random seed from "<<source<<": "<<stringerror()<<endl; 1847 close(fd); 1848 exit(EXIT_FAILURE); 1849 } 1850 if(!ret) { 1851 L<<Logger::Error<<"Unable to read random seed from "<<source<<": end of file"<<endl; 1852 close(fd); 1853 exit(EXIT_FAILURE); 1854 } 1855 pos+=ret; 1856 } 1857 close(fd); 1858 dns_random_init(seed); 1859 } 1860 1826 1861 int main(int argc, char **argv) 1827 1862 { … … 1843 1878 1844 1879 try { 1845 Utility::srandom(time(0));1846 1880 ::arg().set("stack-size","stack size per mthread")="200000"; 1847 1881 ::arg().set("soa-minimum-ttl","Don't change")="0"; … … 1884 1918 ::arg().set("allow-from", "If set, only allow these comma separated netmasks to recurse")="127.0.0.0/8, 10.0.0.0/8, 192.168.0.0/16, 172.16.0.0/12, ::1/128, fe80::/10"; 1885 1919 ::arg().set("allow-from-file", "If set, load allowed netmasks from this file")=""; 1920 ::arg().set("entropy-source", "If set, read entropy from this file")="/dev/urandom"; 1886 1921 ::arg().set("dont-query", "If set, do not query these netmasks for DNS data")="127.0.0.0/8, 10.0.0.0/8, 192.168.0.0/16, 172.16.0.0/12, ::1/128, fe80::/10"; 1887 1922 ::arg().set("max-tcp-per-client", "If set, maximum number of TCP sessions per client (IP address)")="0"; … … 1928 1963 } 1929 1964 1965 1930 1966 #ifndef WIN32 1931 1967 serviceMain(argc, argv); -
trunk/pdns/pdns/syncres.cc
r1157 r1160 35 35 #include "recursor_cache.hh" 36 36 #include "dnsparser.hh" 37 #include "dns_random.hh" 37 38 38 39 extern MemRecursorCache RC; … … 277 278 278 279 if(ret.size() > 1) { 279 random_shuffle(ret.begin(), ret.end() );280 random_shuffle(ret.begin(), ret.end(), dns_random); 280 281 281 282 // move 'best' address for this nameserver name up front … … 543 544 speeds[*i]=s_nsSpeeds[*i].get(&d_now); 544 545 } 545 random_shuffle(rnameservers.begin(),rnameservers.end() );546 random_shuffle(rnameservers.begin(),rnameservers.end(), dns_random); 546 547 speedOrder so(speeds); 547 548 stable_sort(rnameservers.begin(),rnameservers.end(), so);