Changeset 959

Show
Ignore:
Timestamp:
02/18/07 20:49:14 (6 years ago)
Author:
ahu
Message:

remove bind1backend, remove old zoneparser, switch rest to zoneparser-tng

Location:
trunk/pdns/pdns/backends/bind
Files:
4 removed
6 modified

Legend:

Unmodified
Added
Removed
  • trunk/pdns/pdns/backends/bind/Makefile.am

    r240 r959  
    11INCLUDES=-I../.. 
    2 noinst_LTLIBRARIES = libbindbackend.la libbind2backend.la 
    3  
    4 libbindbackend_la_SOURCES=bindbackend.cc bindbackend.hh bindparser.yy \ 
    5 bindlexer.l zoneparser2.cc ../../misc.cc huffman.cc huffman.hh zoneparser.hh \ 
    6 bindparser.hh ../../unix_utility.cc 
    7  
    8 libbindbackend_la_CXXFLAGS=$(AM_CXXFLAGS) 
    9 libbindbackend_la_CFLAGS=$(AM_CFLAGS) 
     2noinst_LTLIBRARIES = libbind2backend.la 
    103 
    114libbind2backend_la_SOURCES=bindbackend2.cc bindbackend2.hh bindparser.yy \ 
    12 bindlexer.l zoneparser2.cc ../../misc.cc huffman.cc huffman.hh zoneparser.hh \ 
     5bindlexer.l ../../zoneparser-tng.cc ../../misc.cc huffman.cc huffman.hh \ 
    136bindparser.hh ../../unix_utility.cc 
    147 
     
    1811bin_PROGRAMS = zone2sql zone2ldap 
    1912 
    20 zone2sql_SOURCES=bindparser.yy bindlexer.l zoneparser2.cc \ 
     13zone2sql_SOURCES=bindparser.yy bindlexer.l \ 
    2114../../arguments.cc ../../logger.cc zone2sql.cc ../../statbag.cc ../../misc.cc \ 
    2215../../unix_utility.cc ../../qtype.cc ../../dnspacket.cc \ 
    23 ../../sillyrecords.cc 
     16../../sillyrecords.cc  ../../zoneparser-tng.cc ../../dnsrecords.cc \ 
     17../../dnswriter.cc ../../rcpgenerator.cc ../../dnsparser.cc ../../base64.cc 
    2418 
    25 zone2ldap_SOURCES=bindparser.yy bindlexer.l zoneparser2.cc \ 
     19 
     20zone2ldap_SOURCES=bindparser.yy bindlexer.l \ 
    2621../../arguments.cc ../../logger.cc zone2ldap.cc ../../statbag.cc ../../misc.cc \ 
    27 ../../unix_utility.cc ../../qtype.cc 
     22../../unix_utility.cc ../../qtype.cc  ../../zoneparser-tng.cc ../../dnsrecords.cc \ 
     23../../dnswriter.cc ../../rcpgenerator.cc ../../dnsparser.cc ../../base64.cc 
     24 
    2825 
    2926 
  • trunk/pdns/pdns/backends/bind/bindbackend2.cc

    r948 r959  
    11/* 
    22    PowerDNS Versatile Database Driven Nameserver 
    3     Copyright (C) 2002-2006  PowerDNS.COM BV 
     3    Copyright (C) 2002-2007  PowerDNS.COM BV 
    44 
    55    This program is free software; you can redistribute it and/or modify 
     
    3434#include "bindbackend2.hh" 
    3535#include "dnspacket.hh" 
    36  
    37 #include "zoneparser.hh" 
     36#include "zoneparser-tng.hh" 
    3837#include "bindparser.hh" 
    3938#include "logger.hh" 
     
    322321} 
    323322 
    324 static void InsertionCallback(shared_ptr<Bind2Backend::State> stage, unsigned int domain_id, const string &domain, const string &qtype, const string &content, int ttl, int prio) 
    325 { 
    326   us->insert(stage, domain_id, domain, qtype, content, ttl, prio); 
    327 } 
    328  
    329323set<string> contents; 
    330324 
    331325/** This function adds a record to a domain with a certain id.  
    332326    Much of the complication is due to the efforts to benefit from std::string reference counting copy on write semantics */ 
    333 void Bind2Backend::insert(shared_ptr<State> stage, int id, const string &qnameu, const string &qtype, const string &content, int ttl=300, int prio=25) 
     327void Bind2Backend::insert(shared_ptr<State> stage, int id, const string &qnameu, const QType &qtype, const string &content, int ttl=300, int prio=25) 
    334328{ 
    335329  // XXXX WRONG WRONG WRONG REWRITE 
     
    353347    bdr.qname=(records.end()-1)->qname; 
    354348 
    355   bdr.qtype=QType(qtype.c_str()).getCode(); 
     349  bdr.qtype=qtype.getCode(); 
    356350  bdr.content=canonic(content); // I think this is wrong, the zoneparser should not come up with . terminated stuff XXX FIXME 
    357351  set<string>::const_iterator i=contents.find(bdr.content); 
     
    481475    } 
    482476 
    483     ZoneParser ZP; 
     477 
    484478       
    485479    vector<BindDomainInfo> domains=BP.getDomains(); 
     
    488482 
    489483    d_binddirectory=BP.getDirectory(); 
    490     ZP.setDirectory(d_binddirectory); 
    491     ZoneParser::callback_t func=boost::bind(&InsertionCallback, staging, _1, _2, _3, _4, _5, _6); 
    492     ZP.setCallback(func);   
     484    //    ZP.setDirectory(d_binddirectory); 
     485    //    ZoneParser::callback_t func=boost::bind(&InsertionCallback, staging, _1, _2, _3, _4, _5, _6); 
     486 
    493487 
    494488    L<<Logger::Warning<<d_logprefix<<" Parsing "<<domains.size()<<" domain(s), will report when done"<<endl; 
     
    538532            bbd->d_records=shared_ptr<vector<Bind2DNSRecord> > (new vector<Bind2DNSRecord>);  
    539533 
    540             ZP.parse(i->filename, i->name, bbd->d_id); // calls callback for us 
     534            ZoneParserTNG zpt(i->filename, i->name, BP.getDirectory()); 
     535            DNSResourceRecord rr; 
     536            while(zpt.get(rr)) { 
     537              insert(staging, bbd->d_id, rr.qname, rr.qtype, rr.content, rr.ttl, rr.priority); 
     538            } 
     539 
     540            //      ZP.parse(i->filename, i->name, bbd->d_id); // calls callback for us 
    541541            L<<Logger::Info<<d_logprefix<<" sorting '"<<i->name<<"'"<<endl; 
    542542 
     
    638638    nukeZoneRecords(bbd); // ? do we need this? 
    639639     
    640     ZoneParser ZP; 
    641640    us=this; 
    642  
    643     ZP.setDirectory(d_binddirectory); 
    644     ZoneParser::callback_t func=boost::bind(&InsertionCallback, staging, _1, _2, _3, _4, _5, _6); 
    645     ZP.setCallback(func);   
    646641 
    647642    staging->id_zone_map[bbd->d_id]=s_state->id_zone_map[bbd->d_id]; 
    648643    staging->id_zone_map[bbd->d_id].d_records=shared_ptr<vector<Bind2DNSRecord> > (new vector<Bind2DNSRecord>);  // nuke it 
    649644 
    650     ZP.parse(bbd->d_filename, bbd->d_name, bbd->d_id); 
    651      
     645    ZoneParserTNG zpt(bbd->d_filename, bbd->d_name, d_binddirectory); 
     646    DNSResourceRecord rr; 
     647    while(zpt.get(rr)) { 
     648      insert(staging, bbd->d_id, rr.qname, rr.qtype, rr.content, rr.ttl, rr.priority); 
     649    } 
     650         
    652651    sort(staging->id_zone_map[bbd->d_id].d_records->begin(), staging->id_zone_map[bbd->d_id].d_records->end()); 
    653652    staging->id_zone_map[bbd->d_id].setCtime(); 
  • trunk/pdns/pdns/backends/bind/bindbackend2.hh

    r909 r959  
    121121  }; 
    122122 
    123   void insert(shared_ptr<State> stage, int id, const string &qname, const string &qtype, const string &content, int ttl, int prio);   
     123  void insert(shared_ptr<State> stage, int id, const string &qname, const QType &qtype, const string &content, int ttl, int prio);   
    124124  void rediscover(string *status=0); 
    125125 
  • trunk/pdns/pdns/backends/bind/bindparser.yy

    r495 r959  
    99#include <errno.h> 
    1010#include "misc.hh" 
    11 #include "zoneparser.hh" 
    1211#include "ahuexception.hh" 
    1312using namespace std; 
     
    127126        ZONETOK quotedname zone_block 
    128127        { 
    129                 s_di.name=ZoneParser::canonic($2); 
     128                s_di.name=stripDot($2); 
    130129                 
    131130                parent->commit(s_di); 
  • trunk/pdns/pdns/backends/bind/zone2ldap.cc

    r681 r959  
    22 *  PowerDNS BIND Zone to LDAP converter 
    33 *  Copyright (C) 2003  Norbert Sendetzky 
     4 *  Copyright (C) 2007  bert hubert 
    45 * 
    56 *  This program is free software; you can redistribute it and/or modify 
     
    2425#include <stdio.h> 
    2526#include "arguments.hh" 
    26 #include "zoneparser.hh" 
    2727#include "bindparser.hh" 
    2828#include "statbag.hh" 
     29#include <boost/function.hpp> 
    2930#include "misc.hh" 
    3031#include "dns.hh" 
    31  
     32#include "zoneparser-tng.hh" 
    3233 
    3334using std::map; 
    3435using std::string; 
    3536using std::vector; 
    36  
    37  
    3837 
    3938StatBag S; 
     
    4443map<string,bool> g_objects; 
    4544 
    46  
    47  
    4845static void callback_simple( unsigned int domain_id, const string &domain, const string &qtype, const string &content, int ttl, int prio ) 
    4946{ 
     
    5148        string::size_type pos; 
    5249        vector<string> parts; 
    53         string domain2 = ZoneParser::canonic( domain ); 
     50        string domain2 = stripDot( domain ); 
    5451 
    5552 
     
    6057        } 
    6158 
    62         host = ZoneParser::canonic( domain2.substr( 0, pos ) ); 
     59        host = stripDot( domain2.substr( 0, pos ) ); 
    6360 
    6461        cout << "dn: dc="; 
     
    8784        cout << qtype << "Record: "; 
    8885        if( prio != 0 ) { cout << prio << " "; } 
    89         cout << ZoneParser::canonic( content ) << endl << endl; 
     86        cout << stripDot( content ) << endl << endl; 
    9087} 
    9188 
     
    9794        string dn, net; 
    9895        vector<string> parts; 
    99         string domain2 = ZoneParser::canonic( domain ); 
     96        string domain2 = stripDot( domain ); 
    10097 
    10198        stringtok( parts, domain2, "." ); 
     
    143140        cout << qtype << "Record: "; 
    144141        if( prio != 0 ) { cout << prio << " "; } 
    145         cout << ZoneParser::canonic( content ) << endl << endl; 
     142        cout << stripDot( content ) << endl << endl; 
    146143} 
    147144 
     
    151148{ 
    152149        BindParser BP; 
    153         ZoneParser ZP; 
    154150        vector<string> parts; 
    155151 
     
    182178                g_basedn = args["basedn"]; 
    183179                g_dnsttl = args.mustDo( "dnsttl" ); 
    184  
    185                 ZP.setCallback( &callback_simple ); 
     180                typedef boost::function<void(unsigned int, const string &, const string &, const string &, int, int)> callback_t; 
     181                callback_t callback = callback_simple; 
    186182                if( args["layout"] == "tree" ) 
    187183                { 
    188                         ZP.setCallback( &callback_tree ); 
     184                        callback=callback_tree; 
    189185                } 
    190186 
     
    193189                        BP.setVerbose( args.mustDo( "verbose" ) ); 
    194190                        BP.parse( args["named-conf"] ); 
    195                         ZP.setDirectory( BP.getDirectory() ); 
     191//                      ZP.setDirectory( BP.getDirectory() ); 
    196192                        const vector<BindDomainInfo> &domains = BP.getDomains(); 
    197193 
     
    204200                                                cerr << "Parsing file: " << i->filename << ", domain: " << i->name << endl; 
    205201                                                g_zonename = i->name; 
    206                                                 ZP.parse( i->filename, i->name, 0 ); 
     202                                                ZoneParserTNG zpt(i->filename, i->name, BP.getDirectory()); 
     203                                                DNSResourceRecord rr; 
     204                                                while(zpt.get(rr)) 
     205                                                        callback(0, rr.qname, rr.qtype.getName(), rr.content, rr.ttl, rr.priority); 
    207206                                        } 
    208207                                } 
     
    226225 
    227226                        g_zonename = args["zone-name"]; 
    228                         ZP.setDirectory( "." ); 
    229                         ZP.parse( args["zone-file"], args["zone-name"], 0 ); 
     227                        ZoneParserTNG zpt(args["zone-file"], args["zone-name"]); 
     228                        DNSResourceRecord rr; 
     229                        while(zpt.get(rr)) 
     230                                callback(0, rr.qname, rr.qtype.getName(), rr.content, rr.ttl, rr.priority); 
    230231                } 
    231232        } 
  • trunk/pdns/pdns/backends/bind/zone2sql.cc

    r681 r959  
    11/* 
    22    PowerDNS Versatile Database Driven Nameserver 
    3     Copyright (C) 2002 PowerDNS.COM BV 
     3    Copyright (C) 2002 - 2007 PowerDNS.COM BV 
    44 
    55    This program is free software; you can redistribute it and/or modify 
     
    3535#include "dns.hh" 
    3636#include "arguments.hh" 
    37 #include "zoneparser.hh" 
    3837#include "bindparser.hh" 
    3938#include "statbag.hh" 
    4039#include "misc.hh" 
    4140#include "dnspacket.hh" 
     41#include "zoneparser-tng.hh" 
    4242 
    4343StatBag S; 
     
    7676  if(qtype=="SOA") { 
    7777    //    cerr<<"Juh: "<<dirty_hack_num<<", "<<lastsoa_domain_id<<", "<<lastsoa_qname<<", "<<domain<<endl; 
    78     if(dirty_hack_num==lastsoa_domain_id && lastsoa_qname!=ZoneParser::canonic(domain)) { 
     78    if(dirty_hack_num==lastsoa_domain_id && lastsoa_qname!=stripDot(domain)) { 
    7979      dirty_hack_num++; 
    8080      cerr<<"Second SOA in zone, raised domain_id"<<endl; 
     
    9090         
    9191        if(mode==POSTGRES) { 
    92           cout<<"insert into domains (name,type) values ("<<toLower(sqlstr(ZoneParser::canonic(domain)))<<",'NATIVE');"<<endl; 
     92          cout<<"insert into domains (name,type) values ("<<toLower(sqlstr(stripDot(domain)))<<",'NATIVE');"<<endl; 
    9393        } 
    9494        else if(mode==ORACLE) { 
     
    9999    SOAData soadata; 
    100100    DNSPacket::fillSOAData(content, soadata); 
    101     soadata.hostmaster=ZoneParser::canonic(soadata.hostmaster); 
    102     soadata.nameserver=ZoneParser::canonic(soadata.nameserver); 
     101    soadata.hostmaster=stripDot(soadata.hostmaster); 
     102    soadata.nameserver=stripDot(soadata.nameserver); 
    103103    content=DNSPacket::serializeSOAData(soadata); 
    104104 
    105105 
    106     lastsoa_qname=ZoneParser::canonic(domain); 
     106    lastsoa_qname=stripDot(domain); 
    107107  } 
    108108   
     
    111111  if(mode==MYSQL) { 
    112112    cout<<"insert into records (domain_id, name,type,content,ttl,prio) values ("<< dirty_hack_num<<", "<< 
    113       sqlstr(ZoneParser::canonic(domain))<<", "<< 
     113      sqlstr(stripDot(domain))<<", "<< 
    114114      sqlstr(qtype)<<", "<< 
    115       sqlstr(ZoneParser::canonic(content))<<", "<<ttl<<", "<<prio<<");\n"; 
     115      sqlstr(stripDot(content))<<", "<<ttl<<", "<<prio<<");\n"; 
    116116  } 
    117117  if(mode==POSTGRES) { 
    118118    cout<<"insert into records (domain_id, name,type,content,ttl,prio) select id ,"<< 
    119       sqlstr(toLower(ZoneParser::canonic(domain)))<<", "<< 
     119      sqlstr(toLower(stripDot(domain)))<<", "<< 
    120120      sqlstr(qtype)<<", "<< 
    121       sqlstr(ZoneParser::canonic(content))<<", "<<ttl<<", "<<prio<<  
     121      sqlstr(stripDot(content))<<", "<<ttl<<", "<<prio<<  
    122122      " from domains where name="<<toLower(sqlstr(lastsoa_qname))<<";\n"; 
    123123  } 
    124124  else if(mode==ORACLE) { 
    125125    cout<<"insert into Records (id,ZoneId, name,type,content,TimeToLive,Priority) select RECORDS_ID_SEQUENCE.nextval,id ,"<< 
    126       sqlstr(toLower(ZoneParser::canonic(domain)))<<", "<< 
     126      sqlstr(toLower(stripDot(domain)))<<", "<< 
    127127      sqlstr(qtype)<<", "<< 
    128       sqlstr(ZoneParser::canonic(content))<<", "<<ttl<<", "<<prio<<  
     128      sqlstr(stripDot(content))<<", "<<ttl<<", "<<prio<<  
    129129      " from Domains where name="<<toLower(sqlstr(lastsoa_qname))<<";\n"; 
    130130  } 
    131131  else if(mode==BARE) { 
    132132    cout<< dirty_hack_num<<"\t"<< 
    133       sqlstr(ZoneParser::canonic(domain))<<"\t"<< 
    134       sqlstr(qtype)<<"\t"<<sqlstr(ZoneParser::canonic(content))<<"\t"<<prio<<"\t"<<ttl<<"\n"; 
     133      sqlstr(stripDot(domain))<<"\t"<< 
     134      sqlstr(qtype)<<"\t"<<sqlstr(stripDot(content))<<"\t"<<prio<<"\t"<<ttl<<"\n"; 
    135135  } 
    136136 
     
    214214      BP.parse(namedfile.empty() ? "./named.conf" : namedfile); 
    215215     
    216       ZoneParser ZP; 
    217      
    218216      const vector<BindDomainInfo> &domains=BP.getDomains(); 
    219217 
    220218      int numdomains=domains.size(); 
    221219      int tick=numdomains/100; 
    222       ZP.setDirectory(BP.getDirectory()); 
    223       ZP.setCallback(&callback);   
     220      //      ZP.setDirectory(BP.getDirectory()); 
    224221     
    225222      for(vector<BindDomainInfo>::const_iterator i=domains.begin(); 
     
    253250              lastsoa_qname=i->name; 
    254251            } 
    255             ZP.parse(i->filename,i->name,0); 
     252            ZoneParserTNG zpt(i->filename, i->name, BP.getDirectory()); 
     253            DNSResourceRecord rr; 
     254            while(zpt.get(rr))  
     255              callback(0, rr.qname, rr.qtype.getName(), rr.content, rr.ttl, rr.priority); 
    256256          } 
    257257          catch(AhuException &ae) { 
     
    269269    } 
    270270    else { 
     271      ZoneParserTNG zpt(zonefile, arg()["zone-name"]); 
     272      DNSResourceRecord rr; 
    271273      dirty_hack_num=-1; // trigger first SOA output 
    272       ZoneParser ZP; 
    273       ZP.setDirectory("."); 
    274       ZP.setCallback(&callback);   
    275       ZP.parse(zonefile,arg()["zone-name"],0); 
     274      while(zpt.get(rr))  
     275        callback(0, rr.qname, rr.qtype.getName(), rr.content, rr.ttl, rr.priority); 
     276 
    276277    } 
    277278    cerr<<"Parsed "<<num_records<<" records"<<endl;