Show
Ignore:
Timestamp:
02/13/05 21:56:57 (8 years ago)
Author:
ahu
Message:

Upgrade a few more license statements to be precise about 'version 2'
Add hint that we should use ip_pktinfo in nameserver.hh, upgrade (C)
clean up bindbackend a lot, fix case sensitivity, remove 'WRONG' comments
complete move of debian directory

Files:
1 modified

Legend:

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

    r193 r319  
    11/* 
    22    PowerDNS Versatile Database Driven Nameserver 
    3     Copyright (C) 2002-2003  PowerDNS.COM BV 
     3    Copyright (C) 2002-2005  PowerDNS.COM BV 
    44 
    55    This program is free software; you can redistribute it and/or modify 
     
    1616    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
    1717*/ 
    18 // $Id: bindbackend2.cc,v 1.6 2003/10/04 14:15:46 ahu Exp $  
     18 
    1919#include <errno.h> 
    2020#include <string> 
     
    4747/** new scheme of things: 
    4848    we have zone-id map 
    49     a zone-id has a vector of DNSResourceRecords */ 
     49    a zone-id has a vector of DNSResourceRecords  
     50    on start of query, we find the best zone to answer from 
     51 
     52    handle::get walks this vector linearly... */ 
    5053 
    5154map<string,int> Bind2Backend::s_name_id_map; 
     
    115118bool Bind2Backend::startTransaction(const string &qname, int id) 
    116119{ 
    117  
    118120  BB2DomainInfo &bbd=*s_id_zone_map[d_transaction_id=id]; 
    119121  d_transaction_tmpname=bbd.d_filename+"."+itoa(random()); 
     
    171173  string content=r.content; 
    172174 
    173   // SOA needs stripping too! XXX FIXME 
     175  // SOA needs stripping too! XXX FIXME - also, this should not be here I think 
    174176  switch(r.qtype.getCode()) { 
    175177  case QType::TXT: 
     
    283285      i!=ret.end(); 
    284286      ++i) 
    285     ; // *i=*i; //tolower(*i); 
     287    *i=tolower(*i); 
    286288 
    287289 
     
    299301  rr.qname=canonic(qnameu); 
    300302  rr.qtype=qtype; 
    301   rr.content=content; 
     303  rr.content=canonic(content); // I think this is wrong, the zoneparser should not come up with . terminated stuff XXX FIXME 
    302304  rr.ttl=ttl; 
    303305  rr.priority=prio; 
     
    384386} 
    385387 
    386  
    387  
    388388Bind2Backend::Bind2Backend(const string &suffix) 
    389389{ 
     
    427427   
    428428  loadConfig(); 
    429    
    430429 
    431430  extern DynListener *dl; 
     
    587586    Does not throw errors or anything, may update d_status however */ 
    588587 
    589  
    590588void Bind2Backend::queueReload(BB2DomainInfo *bbd) 
    591589{ 
     
    626624{ 
    627625  d_handle=new Bind2Backend::handle; 
    628   d_handle->d_records=new vector<DNSResourceRecord>; // WRONG 
    629   //  cout<<"Lookup! for "<<qname<<endl; 
    630   string domain=qname; 
     626 
     627  string domain=toLower(qname); 
     628 
     629  if(arg().mustDo("query-logging")) 
     630    L<<"Lookup for '"<<qtype.getName()<<"' of '"<<domain<<"'"<<endl; 
     631 
    631632  while(!s_name_id_map.count(domain) && chopOff(domain)); 
    632633 
    633634  if(!s_name_id_map.count(domain)) { 
    634635    //    cout<<"no such domain: '"<<qname<<"'"<<endl; 
    635     d_handle->d_iter=d_handle->d_records->end();  // WRONG 
    636636    d_handle->d_list=false; 
    637637    d_handle->d_bbd=0; 
     
    641641 
    642642  //  cout<<"domain: '"<<domain<<"', id="<<id<<endl; 
    643    
    644643 
    645644  DLOG(L<<"Bind2Backend constructing handle for search for "<<qtype.getName()<<" for "<< 
     
    649648  d_handle->parent=this; 
    650649  d_handle->qtype=qtype; 
    651   string compressed=toLower(qname); 
    652   d_handle->d_records=s_id_zone_map[id]->d_records; 
     650 
     651  d_handle->d_records=s_id_zone_map[id]->d_records; // give it a copy 
    653652  d_handle->d_bbd=0; 
    654653  if(!d_handle->d_records->empty()) { 
     
    656655    if(!bbd.d_loaded) { 
    657656      delete d_handle; 
    658       throw DBException("Zone temporarily not available (file missing, or master dead)"); // fuck 
     657      throw DBException("Zone temporarily not available (file missing, or master dead)"); // fsck 
    659658    } 
    660659 
     
    662661      L<<Logger::Warning<<"Can't get read lock on zone '"<<bbd.d_name<<"'"<<endl; 
    663662      delete d_handle; 
    664       throw DBException("Temporarily unavailable due to a zone lock"); // fuck 
    665     } 
    666        
    667  
     663      throw DBException("Temporarily unavailable due to a zone lock"); // fsck 
     664    } 
     665     
    668666    if(!bbd.current()) { 
    669667      L<<Logger::Warning<<"Zone '"<<bbd.d_name<<"' ("<<bbd.d_filename<<") needs reloading"<<endl; 
     
    682680{ 
    683681  d_bbd=0; 
     682  d_records=0; 
    684683  count=0; 
    685684} 
     
    687686bool Bind2Backend::get(DNSResourceRecord &r) 
    688687{ 
     688  if(!d_handle->d_records) 
     689    return false; 
     690 
    689691  if(!d_handle->get(r)) { 
    690692    delete d_handle; 
    691693    d_handle=0; 
     694 
     695    if(arg().mustDo("query-logging")) 
     696      L<<"End of answers"<<endl; 
     697 
    692698    return false; 
    693699  } 
     700  if(arg().mustDo("query-logging")) 
     701    L<<"Returning: '"<<r.qtype.getName()<<"' of '"<<r.qname<<"', content: '"<<r.content<<"'"<<endl; 
    694702  return true; 
    695703} 
     
    708716       qname<<"- "<<d_records->size()<<" available!"<<endl); 
    709717   
    710   while(d_iter!=d_records->end() && (d_iter->qname!=qname || !(qtype=="ANY" || (d_iter)->qtype==qtype))) { 
     718  // this is a linear walk!!! XXX FIXME 
     719  while(d_iter!=d_records->end() && (strcasecmp(d_iter->qname.c_str(),qname.c_str()) || !(qtype=="ANY" || (d_iter)->qtype==qtype))) { 
    711720    DLOG(L<<Logger::Warning<<"Skipped "<<qname<<"/"<<QType(d_iter->qtype).getName()<<": '"<<d_iter->content<<"'"<<endl); 
    712721    d_iter++; 
     
    721730  DLOG(L << "Bind2Backend get() returning a rr with a "<<QType(d_iter->qtype).getCode()<<endl); 
    722731 
    723   r.qname=qname; // fill this in 
     732  r.qname=qname; 
    724733   
    725734  r.content=(d_iter)->content;