Changeset 494

Show
Ignore:
Timestamp:
09/24/05 19:27:19 (8 years ago)
Author:
ahu
Message:

fix parsing of NAPTR records in bind-style zonefiles
slight speedup in domain lookups
improve query-logging details for bindbackend

Location:
trunk/pdns/pdns/backends/bind
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/pdns/pdns/backends/bind/bindbackend2.cc

    r484 r494  
    5050*/ 
    5151 
    52 map<string,int> Bind2Backend::s_name_id_map; 
     52Bind2Backend::name_id_map_t Bind2Backend::s_name_id_map; 
    5353 
    5454// this map contains BB2DomainInfo structs, each of which contains a *pointer* to domain data 
     
    656656  string domain=toLower(qname); 
    657657 
    658   if(arg().mustDo("query-logging")) 
    659     L<<"Lookup for '"<<qtype.getName()<<"' of '"<<domain<<"'"<<endl; 
     658  bool mustlog=arg().mustDo("query-logging"); 
     659  if(mustlog)  
     660    L<<Logger::Warning<<"Lookup for '"<<qtype.getName()<<"' of '"<<domain<<"'"<<endl; 
    660661 
    661662  while(!s_name_id_map.count(domain) && chopOff(domain)); 
    662663 
    663   if(!s_name_id_map.count(domain)) { 
     664  name_id_map_t::const_iterator iditer=s_name_id_map.find(domain); 
     665 
     666  if(iditer==s_name_id_map.end()) { 
     667    if(mustlog) 
     668      L<<Logger::Warning<<"Found no authoritative zone for "<<qname<<endl; 
    664669    d_handle.d_list=false; 
    665670    return; 
    666671  } 
    667   unsigned int id=s_name_id_map[domain]; 
    668  
    669   d_handle.id=id; 
     672  //  unsigned int id=*iditer; 
     673  if(mustlog) 
     674    L<<Logger::Warning<<"Found data in zone '"<<domain<<"' with id "<<iditer->second<<endl; 
     675     
     676  d_handle.id=iditer->second; 
    670677   
    671678  DLOG(L<<"Bind2Backend constructing handle for search for "<<qtype.getName()<<" for "<< 
     
    675682    d_handle.qname=qname.substr(0,qname.size()-domain.length()-1); // strip domain name 
    676683 
    677    
    678684  d_handle.parent=this; 
    679685  d_handle.qtype=qtype; 
    680686  d_handle.domain=qname.substr(qname.size()-domain.length()); 
    681687 
    682   d_handle.d_records=s_id_zone_map[id].d_records; // give it a copy 
     688  d_handle.d_records=s_id_zone_map[iditer->second].d_records; // give it a copy 
    683689  if(!d_handle.d_records->empty()) { 
    684     BB2DomainInfo& bbd=s_id_zone_map[id]; 
     690    BB2DomainInfo& bbd=s_id_zone_map[iditer->second]; 
    685691    if(!bbd.d_loaded) { 
    686692      d_handle.reset(); 
  • trunk/pdns/pdns/backends/bind/bindbackend2.hh

    r484 r494  
    162162  }; 
    163163 
    164   static map<string,int> s_name_id_map;  //!< convert a name to a domain id 
     164  typedef map<string,int> name_id_map_t; 
     165  static name_id_map_t s_name_id_map;  //!< convert a name to a domain id 
    165166 
    166167  typedef map<uint32_t, BB2DomainInfo> id_zone_map_t; 
  • trunk/pdns/pdns/backends/bind/zoneparser2.cc

    r479 r494  
    182182  rec.ttl=ttl; 
    183183  rec.prio=prio; 
     184 
     185  //  cerr<<"filled with type: "<<rec.qtype<<", "<<QType::chartocode(qtype.c_str())<<": "<<content<<endl; 
    184186  recs.push_back(rec); 
    185187} 
     
    233235 
    234236  vector<string> parts; 
    235   stringtok(parts,tline," \t\"");  // THIS IS WRONG, THE " SHOULD BE TREATED! XXX FIXME 
     237  stringtok(parts,tline," \t");  // we used to strip " here 
    236238  if(parts[0][0]!='$' && !isspace(parts[0][0])) 
    237239    lastfirstword=parts[0]; 
     
    531533 
    532534 
    533 //  cerr<<qname<<", "<<qclass<<", "<<qtype<<", "<<ttl<<", rest from field "<<cpos<<endl; 
     535  //  cerr<<qname<<", "<<qclass<<", "<<qtype<<", "<<ttl<<", rest from field "<<cpos<<endl; 
    534536           
    535537  int left=words.size()-cpos; 
    536538  string content; 
    537539 
    538    if((qtype=="MX" && left==2) || (qtype=="SRV" && left==4)){ 
    539      int prio=atoi(words[cpos++].c_str());left--; 
    540      content=words[cpos++];left--; 
    541       
    542      while(left--) 
    543        content+=" "+words[cpos++]; 
    544       
     540  if((qtype=="MX" && left==2) || (qtype=="SRV" && left==4)){ 
     541    int prio=atoi(words[cpos++].c_str());left--; 
     542    content=words[cpos++];left--; 
     543     
     544    while(left--) 
     545      content+=" "+words[cpos++]; 
     546     
    545547    if(content=="@") 
    546548      content=d_origin; 
     
    567569    if(qtype=="SOA") 
    568570      soaCanonic(content); 
    569      
     571    if(qtype=="TXT" && content.size() > 2) {  // strip quotes from TXT 
     572      if(content[0]=='"') 
     573        content=content.substr(1); 
     574      if(content[content.size()-1]=='"') 
     575        content.resize(content.size()-1); 
     576    } 
     577       
    570578    fillRec(qname, qtype, content,ttl, 0, rec); 
    571579    return true;