Changeset 1026
- Timestamp:
- 04/12/07 22:50:53 (2 years ago)
- Files:
-
- trunk/pdns/pdns/backends/bind/bindbackend2.cc (modified) (7 diffs)
- trunk/pdns/pdns/backends/bind/bindbackend2.hh (modified) (2 diffs)
- trunk/pdns/pdns/dnsparser.cc (modified) (2 diffs)
- trunk/pdns/pdns/dnswriter.cc (modified) (3 diffs)
- trunk/pdns/pdns/rcpgenerator.cc (modified) (2 diffs)
- trunk/pdns/pdns/resolver.cc (modified) (2 diffs)
- trunk/pdns/pdns/zoneparser-tng.cc (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/pdns/pdns/backends/bind/bindbackend2.cc
r1018 r1026 323 323 void Bind2Backend::insert(shared_ptr<State> stage, int id, const string &qnameu, const QType &qtype, const string &content, int ttl=300, int prio=25) 324 324 { 325 // XXXX WRONG WRONG WRONG REWRITE326 327 325 BB2DomainInfo bb2 = stage->id_zone_map[id]; 328 326 Bind2DNSRecord bdr; … … 761 759 d_handle.qname=qname.substr(0,qname.size()-domain.length()-1); // strip domain name 762 760 763 d_handle.parent=this;764 761 d_handle.qtype=qtype; 765 762 d_handle.domain=qname.substr(qname.size()-domain.length()); … … 777 774 } 778 775 779 d_handle.d_records = state->id_zone_map[iditer->second].d_records; // give it a copy776 d_handle.d_records = state->id_zone_map[iditer->second].d_records; // give it a reference counted copy 780 777 781 778 if(d_handle.d_records->empty()) 782 779 DLOG(L<<"Query with no results"<<endl); 783 780 784 781 pair<vector<Bind2DNSRecord>::const_iterator, vector<Bind2DNSRecord>::const_iterator> range; 785 782 … … 796 793 d_handle.d_iter=range.first; 797 794 d_handle.d_end_iter=range.second; 795 d_handle.mustlog = mustlog; 796 798 797 } 799 798 … … 803 802 Bind2Backend::handle::handle() 804 803 { 805 // d_records=0; 806 count=0; 804 mustlog=false; 807 805 } 808 806 … … 859 857 r.priority=(d_iter)->priority; 860 858 d_iter++; 859 if(mustlog) 860 L<<Logger::Warning<<"Returning: "<< r.qtype.getName()<<" "<<r.content<<endl; 861 861 862 862 863 return true; … … 876 877 d_handle.d_qname_end=d_handle.d_records->end(); // iter now points to a vector of pointers to vector<BBResourceRecords> 877 878 878 d_handle.parent=this;879 879 d_handle.id=id; 880 880 d_handle.d_list=true; trunk/pdns/pdns/backends/bind/bindbackend2.hh
r1018 r1026 139 139 void reset() 140 140 { 141 parent=0;142 141 d_records.reset(); 143 142 qname.clear(); 144 143 mustlog=false; 145 144 } 146 145 147 146 handle(); 148 149 Bind2Backend *parent;150 147 151 148 shared_ptr<vector<Bind2DNSRecord> > d_records; … … 161 158 string domain; 162 159 QType qtype; 160 bool mustlog; 161 163 162 private: 164 int count;165 166 163 bool get_normal(DNSResourceRecord &); 167 164 bool get_list(DNSResourceRecord &); trunk/pdns/pdns/dnsparser.cc
r996 r1026 406 406 unsigned char labellen=content.at(frompos++); 407 407 408 // cerr<<"ret: '"<<ret<<"', Labellen: "<<(int)labellen<<endl;409 408 if(!labellen) { 410 409 if(ret.empty()) … … 418 417 } 419 418 else { 420 // should check for . here and replace by \. 421 ret.append(&content.at(frompos), &content.at(frompos+labellen)); 419 // XXX FIXME THIS MIGHT BE VERY SLOW! 420 ret.reserve(ret.size() + labellen + 2); 421 for(string::size_type n = 0 ; n < labellen; ++n, frompos++) { 422 if(content.at(frompos)=='.') 423 ret.append(1, '\\'); 424 ret.append(1, content[frompos]); 425 } 422 426 ret.append(1,'.'); 423 frompos+=labellen;424 427 } 425 428 } trunk/pdns/pdns/dnswriter.cc
r996 r1026 3 3 #include "dnsparser.hh" 4 4 #include <boost/tokenizer.hpp> 5 #include <boost/algorithm/string.hpp> 5 6 6 7 DNSPacketWriter::DNSPacketWriter(vector<uint8_t>& content, const string& qname, uint16_t qtype, uint16_t qclass, uint8_t opcode) … … 144 145 } 145 146 147 typedef vector<pair<string::size_type, string::size_type> > parts_t; 148 149 bool labeltokUnescape(parts_t& parts, const string& label) 150 { 151 string::size_type epos = label.size(), lpos(0), pos; 152 bool unescapedSomething = false; 153 const char* ptr=label.c_str(); 154 155 parts.clear(); 156 157 for(pos = 0 ; pos < epos; ++pos) { 158 if(ptr[pos]=='\\') { 159 pos++; 160 unescapedSomething = true; 161 continue; 162 } 163 if(ptr[pos]=='.') { 164 parts.push_back(make_pair(lpos, pos)); 165 lpos=pos+1; 166 } 167 } 168 169 if(lpos < pos) 170 parts.push_back(make_pair(lpos, pos)); 171 return unescapedSomething; 172 } 173 146 174 // this is the absolute hottest function in the pdns recursor 147 175 void DNSPacketWriter::xfrLabel(const string& label, bool compress) 148 176 { 149 typedef vector<pair<unsigned int, unsigned int> > parts_t;150 177 parts_t parts; 151 vstringtok(parts, label, "."); // XXX FIXME this should deal with escaped .178 bool unescaped=labeltokUnescape(parts, label); 152 179 153 180 // d_stuff is amount of stuff that is yet to be written out - the dnsrecordheader for example 154 181 unsigned int pos=d_content.size() + d_record.size() + d_stuff; 155 string chopped(label); 156 182 string chopped; 157 183 for(parts_t::const_iterator i=parts.begin(); i!=parts.end(); ++i) { 158 // cerr<<"chopped: '"<<chopped<<"'\n";184 chopped.assign(label.c_str() + i->first); 159 185 lmap_t::iterator li=d_labelmap.end(); 160 186 // see if we've written out this domain before … … 170 196 d_labelmap.push_back(make_pair(chopped, pos)); // if untrue, we need to count - also, don't store offsets > 16384, won't work 171 197 172 d_record.push_back((char)(i->second - i->first)); 173 unsigned int len=d_record.size(); 174 d_record.resize(len + i->second - i->first); 175 memcpy(((&*d_record.begin()) + len), label.c_str() + i-> first, i->second - i->first); 176 // cerr<<"Added: '"<<string(label.c_str() + i->first, i->second - i->first) <<"'\n"; 177 pos+=(i->second - i->first)+1; 178 179 if(i+1 != parts.end()) 180 chopOff(chopped); // www.powerdns.com. -> powerdns.com. -> com. -> . 198 if(unescaped) { 199 string part(label.c_str() + i -> first, i->second - i->first); 200 replace_all(part, "\\.", "."); 201 d_record.push_back(part.size()); 202 unsigned int len=d_record.size(); 203 d_record.resize(len + part.size()); 204 205 memcpy(((&*d_record.begin()) + len), part.c_str(), part.size()); 206 pos+=(part.size())+1; 207 } 208 else { 209 d_record.push_back((char)(i->second - i->first)); 210 unsigned int len=d_record.size(); 211 d_record.resize(len + i->second - i->first); 212 memcpy(((&*d_record.begin()) + len), label.c_str() + i-> first, i->second - i->first); 213 pos+=(i->second - i->first)+1; 214 } 215 181 216 } 182 217 d_record.push_back(0); trunk/pdns/pdns/rcpgenerator.cc
r996 r1026 1 1 /* 2 2 PowerDNS Versatile Database Driven Nameserver 3 Copyright (C) 2005 PowerDNS.COM BV3 Copyright (C) 2005 - 2007 PowerDNS.COM BV 4 4 5 5 This program is free software; you can redistribute it and/or modify … … 138 138 break; 139 139 140 if(strptr[d_pos]=='\\' && d_pos < d_end - 1 )140 if(strptr[d_pos]=='\\' && d_pos < d_end - 1 && strptr[d_pos+1]!='.') // leave the \. escape around 141 141 d_pos++; 142 142 trunk/pdns/pdns/resolver.cc
r1016 r1026 188 188 int res=select(d_sock+1,&rd,0,0,&timeout); 189 189 190 if(!res) 190 if(!res) { 191 191 throw ResolverException("Timeout waiting for answer"); 192 } 192 193 if(res<0) 193 194 throw ResolverException("Error waiting for answer: "+stringerror()); … … 205 206 sendResolve(ip, domain, type); 206 207 try { 207 struct sockaddr_in from;208 return receiveResolve((sockaddr*)&from, sizeof(from));208 ComboAddress from(ip); 209 return receiveResolve((sockaddr*)&from, from.getSocklen()); 209 210 } 210 211 catch(ResolverException &re) { trunk/pdns/pdns/zoneparser-tng.cc
r1015 r1026 66 66 if(!isdigit(lc)) 67 67 switch(lc) { 68 case 'M': 69 val*=60; // minutes, not months! 70 break; 68 71 case 'H': 69 72 val*=3600; … … 74 77 case 'W': 75 78 val*=3600*24*7; 76 break;77 case 'M':78 val*=3600*24*7*4;79 79 break; 80 80 case 'Y': // ? :-) … … 352 352 rr.content+=soaparts[n]; 353 353 } 354 break; 354 355 default:; 355 356 }