Changeset 959
- Timestamp:
- 02/18/07 20:49:14 (6 years ago)
- Location:
- trunk/pdns/pdns/backends/bind
- Files:
-
- 4 removed
- 6 modified
-
Makefile.am (modified) (2 diffs)
-
bindbackend.cc (deleted)
-
bindbackend.hh (deleted)
-
bindbackend2.cc (modified) (8 diffs)
-
bindbackend2.hh (modified) (1 diff)
-
bindparser.yy (modified) (2 diffs)
-
zone2ldap.cc (modified) (13 diffs)
-
zone2sql.cc (modified) (9 diffs)
-
zoneparser.hh (deleted)
-
zoneparser2.cc (deleted)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pdns/pdns/backends/bind/Makefile.am
r240 r959 1 1 INCLUDES=-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) 2 noinst_LTLIBRARIES = libbind2backend.la 10 3 11 4 libbind2backend_la_SOURCES=bindbackend2.cc bindbackend2.hh bindparser.yy \ 12 bindlexer.l zoneparser2.cc ../../misc.cc huffman.cc huffman.hh zoneparser.hh\5 bindlexer.l ../../zoneparser-tng.cc ../../misc.cc huffman.cc huffman.hh \ 13 6 bindparser.hh ../../unix_utility.cc 14 7 … … 18 11 bin_PROGRAMS = zone2sql zone2ldap 19 12 20 zone2sql_SOURCES=bindparser.yy bindlexer.l zoneparser2.cc\13 zone2sql_SOURCES=bindparser.yy bindlexer.l \ 21 14 ../../arguments.cc ../../logger.cc zone2sql.cc ../../statbag.cc ../../misc.cc \ 22 15 ../../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 24 18 25 zone2ldap_SOURCES=bindparser.yy bindlexer.l zoneparser2.cc \ 19 20 zone2ldap_SOURCES=bindparser.yy bindlexer.l \ 26 21 ../../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 28 25 29 26 -
trunk/pdns/pdns/backends/bind/bindbackend2.cc
r948 r959 1 1 /* 2 2 PowerDNS Versatile Database Driven Nameserver 3 Copyright (C) 2002-200 6PowerDNS.COM BV3 Copyright (C) 2002-2007 PowerDNS.COM BV 4 4 5 5 This program is free software; you can redistribute it and/or modify … … 34 34 #include "bindbackend2.hh" 35 35 #include "dnspacket.hh" 36 37 #include "zoneparser.hh" 36 #include "zoneparser-tng.hh" 38 37 #include "bindparser.hh" 39 38 #include "logger.hh" … … 322 321 } 323 322 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 329 323 set<string> contents; 330 324 331 325 /** This function adds a record to a domain with a certain id. 332 326 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)327 void Bind2Backend::insert(shared_ptr<State> stage, int id, const string &qnameu, const QType &qtype, const string &content, int ttl=300, int prio=25) 334 328 { 335 329 // XXXX WRONG WRONG WRONG REWRITE … … 353 347 bdr.qname=(records.end()-1)->qname; 354 348 355 bdr.qtype= QType(qtype.c_str()).getCode();349 bdr.qtype=qtype.getCode(); 356 350 bdr.content=canonic(content); // I think this is wrong, the zoneparser should not come up with . terminated stuff XXX FIXME 357 351 set<string>::const_iterator i=contents.find(bdr.content); … … 481 475 } 482 476 483 ZoneParser ZP; 477 484 478 485 479 vector<BindDomainInfo> domains=BP.getDomains(); … … 488 482 489 483 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 493 487 494 488 L<<Logger::Warning<<d_logprefix<<" Parsing "<<domains.size()<<" domain(s), will report when done"<<endl; … … 538 532 bbd->d_records=shared_ptr<vector<Bind2DNSRecord> > (new vector<Bind2DNSRecord>); 539 533 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 541 541 L<<Logger::Info<<d_logprefix<<" sorting '"<<i->name<<"'"<<endl; 542 542 … … 638 638 nukeZoneRecords(bbd); // ? do we need this? 639 639 640 ZoneParser ZP;641 640 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);646 641 647 642 staging->id_zone_map[bbd->d_id]=s_state->id_zone_map[bbd->d_id]; 648 643 staging->id_zone_map[bbd->d_id].d_records=shared_ptr<vector<Bind2DNSRecord> > (new vector<Bind2DNSRecord>); // nuke it 649 644 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 652 651 sort(staging->id_zone_map[bbd->d_id].d_records->begin(), staging->id_zone_map[bbd->d_id].d_records->end()); 653 652 staging->id_zone_map[bbd->d_id].setCtime(); -
trunk/pdns/pdns/backends/bind/bindbackend2.hh
r909 r959 121 121 }; 122 122 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); 124 124 void rediscover(string *status=0); 125 125 -
trunk/pdns/pdns/backends/bind/bindparser.yy
r495 r959 9 9 #include <errno.h> 10 10 #include "misc.hh" 11 #include "zoneparser.hh"12 11 #include "ahuexception.hh" 13 12 using namespace std; … … 127 126 ZONETOK quotedname zone_block 128 127 { 129 s_di.name= ZoneParser::canonic($2);128 s_di.name=stripDot($2); 130 129 131 130 parent->commit(s_di); -
trunk/pdns/pdns/backends/bind/zone2ldap.cc
r681 r959 2 2 * PowerDNS BIND Zone to LDAP converter 3 3 * Copyright (C) 2003 Norbert Sendetzky 4 * Copyright (C) 2007 bert hubert 4 5 * 5 6 * This program is free software; you can redistribute it and/or modify … … 24 25 #include <stdio.h> 25 26 #include "arguments.hh" 26 #include "zoneparser.hh"27 27 #include "bindparser.hh" 28 28 #include "statbag.hh" 29 #include <boost/function.hpp> 29 30 #include "misc.hh" 30 31 #include "dns.hh" 31 32 #include "zoneparser-tng.hh" 32 33 33 34 using std::map; 34 35 using std::string; 35 36 using std::vector; 36 37 38 37 39 38 StatBag S; … … 44 43 map<string,bool> g_objects; 45 44 46 47 48 45 static void callback_simple( unsigned int domain_id, const string &domain, const string &qtype, const string &content, int ttl, int prio ) 49 46 { … … 51 48 string::size_type pos; 52 49 vector<string> parts; 53 string domain2 = ZoneParser::canonic( domain );50 string domain2 = stripDot( domain ); 54 51 55 52 … … 60 57 } 61 58 62 host = ZoneParser::canonic( domain2.substr( 0, pos ) );59 host = stripDot( domain2.substr( 0, pos ) ); 63 60 64 61 cout << "dn: dc="; … … 87 84 cout << qtype << "Record: "; 88 85 if( prio != 0 ) { cout << prio << " "; } 89 cout << ZoneParser::canonic( content ) << endl << endl;86 cout << stripDot( content ) << endl << endl; 90 87 } 91 88 … … 97 94 string dn, net; 98 95 vector<string> parts; 99 string domain2 = ZoneParser::canonic( domain );96 string domain2 = stripDot( domain ); 100 97 101 98 stringtok( parts, domain2, "." ); … … 143 140 cout << qtype << "Record: "; 144 141 if( prio != 0 ) { cout << prio << " "; } 145 cout << ZoneParser::canonic( content ) << endl << endl;142 cout << stripDot( content ) << endl << endl; 146 143 } 147 144 … … 151 148 { 152 149 BindParser BP; 153 ZoneParser ZP;154 150 vector<string> parts; 155 151 … … 182 178 g_basedn = args["basedn"]; 183 179 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; 186 182 if( args["layout"] == "tree" ) 187 183 { 188 ZP.setCallback( &callback_tree );184 callback=callback_tree; 189 185 } 190 186 … … 193 189 BP.setVerbose( args.mustDo( "verbose" ) ); 194 190 BP.parse( args["named-conf"] ); 195 ZP.setDirectory( BP.getDirectory() );191 // ZP.setDirectory( BP.getDirectory() ); 196 192 const vector<BindDomainInfo> &domains = BP.getDomains(); 197 193 … … 204 200 cerr << "Parsing file: " << i->filename << ", domain: " << i->name << endl; 205 201 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); 207 206 } 208 207 } … … 226 225 227 226 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); 230 231 } 231 232 } -
trunk/pdns/pdns/backends/bind/zone2sql.cc
r681 r959 1 1 /* 2 2 PowerDNS Versatile Database Driven Nameserver 3 Copyright (C) 2002 PowerDNS.COM BV3 Copyright (C) 2002 - 2007 PowerDNS.COM BV 4 4 5 5 This program is free software; you can redistribute it and/or modify … … 35 35 #include "dns.hh" 36 36 #include "arguments.hh" 37 #include "zoneparser.hh"38 37 #include "bindparser.hh" 39 38 #include "statbag.hh" 40 39 #include "misc.hh" 41 40 #include "dnspacket.hh" 41 #include "zoneparser-tng.hh" 42 42 43 43 StatBag S; … … 76 76 if(qtype=="SOA") { 77 77 // 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)) { 79 79 dirty_hack_num++; 80 80 cerr<<"Second SOA in zone, raised domain_id"<<endl; … … 90 90 91 91 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; 93 93 } 94 94 else if(mode==ORACLE) { … … 99 99 SOAData soadata; 100 100 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); 103 103 content=DNSPacket::serializeSOAData(soadata); 104 104 105 105 106 lastsoa_qname= ZoneParser::canonic(domain);106 lastsoa_qname=stripDot(domain); 107 107 } 108 108 … … 111 111 if(mode==MYSQL) { 112 112 cout<<"insert into records (domain_id, name,type,content,ttl,prio) values ("<< dirty_hack_num<<", "<< 113 sqlstr( ZoneParser::canonic(domain))<<", "<<113 sqlstr(stripDot(domain))<<", "<< 114 114 sqlstr(qtype)<<", "<< 115 sqlstr( ZoneParser::canonic(content))<<", "<<ttl<<", "<<prio<<");\n";115 sqlstr(stripDot(content))<<", "<<ttl<<", "<<prio<<");\n"; 116 116 } 117 117 if(mode==POSTGRES) { 118 118 cout<<"insert into records (domain_id, name,type,content,ttl,prio) select id ,"<< 119 sqlstr(toLower( ZoneParser::canonic(domain)))<<", "<<119 sqlstr(toLower(stripDot(domain)))<<", "<< 120 120 sqlstr(qtype)<<", "<< 121 sqlstr( ZoneParser::canonic(content))<<", "<<ttl<<", "<<prio<<121 sqlstr(stripDot(content))<<", "<<ttl<<", "<<prio<< 122 122 " from domains where name="<<toLower(sqlstr(lastsoa_qname))<<";\n"; 123 123 } 124 124 else if(mode==ORACLE) { 125 125 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)))<<", "<< 127 127 sqlstr(qtype)<<", "<< 128 sqlstr( ZoneParser::canonic(content))<<", "<<ttl<<", "<<prio<<128 sqlstr(stripDot(content))<<", "<<ttl<<", "<<prio<< 129 129 " from Domains where name="<<toLower(sqlstr(lastsoa_qname))<<";\n"; 130 130 } 131 131 else if(mode==BARE) { 132 132 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"; 135 135 } 136 136 … … 214 214 BP.parse(namedfile.empty() ? "./named.conf" : namedfile); 215 215 216 ZoneParser ZP;217 218 216 const vector<BindDomainInfo> &domains=BP.getDomains(); 219 217 220 218 int numdomains=domains.size(); 221 219 int tick=numdomains/100; 222 ZP.setDirectory(BP.getDirectory()); 223 ZP.setCallback(&callback); 220 // ZP.setDirectory(BP.getDirectory()); 224 221 225 222 for(vector<BindDomainInfo>::const_iterator i=domains.begin(); … … 253 250 lastsoa_qname=i->name; 254 251 } 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); 256 256 } 257 257 catch(AhuException &ae) { … … 269 269 } 270 270 else { 271 ZoneParserTNG zpt(zonefile, arg()["zone-name"]); 272 DNSResourceRecord rr; 271 273 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 276 277 } 277 278 cerr<<"Parsed "<<num_records<<" records"<<endl;