Ticket #304: patch-also-notify-20100610.diff
| File patch-also-notify-20100610.diff, 10.0 KB (added by anon, 3 years ago) |
|---|
-
pdns/backends/bind/bindbackend2.cc
old new 228 228 shared_ptr<State> state = s_state; 229 229 230 230 for(id_zone_map_t::const_iterator i = state->id_zone_map.begin(); i != state->id_zone_map.end() ; ++i) { 231 if(!i->second.d_masters.empty() )231 if(!i->second.d_masters.empty() && this->alsoNotify.empty() && i->second.d_also_notify.empty()) 232 232 continue; 233 233 soadata.serial=0; 234 234 try { … … 307 307 return false; 308 308 } 309 309 310 void Bind2Backend::alsoNotifies(const string &domain, set<string> *ips) 311 { 312 shared_ptr<State> state = s_state; 313 // combine global list with local list 314 for(set<string>::iterator i = this->alsoNotify.begin(); i != this->alsoNotify.end(); i++) { 315 (*ips).insert(*i); 316 } 317 for(id_zone_map_t::const_iterator i = state->id_zone_map.begin(); i != state->id_zone_map.end() ; ++i) { 318 if(i->second.d_name==domain) { 319 for(set<string>::iterator it = i->second.d_also_notify.begin(); it != i->second.d_also_notify.end(); it++) { 320 (*ips).insert(*it); 321 } 322 return; 323 } 324 } 325 } 310 326 311 327 //! lowercase, strip trailing . 312 328 static string canonic(string ret) … … 512 528 } 513 529 514 530 vector<BindDomainInfo> domains=BP.getDomains(); 515 531 this->alsoNotify = BP.getAlsoNotify(); 532 516 533 s_binddirectory=BP.getDirectory(); 517 534 // ZP.setDirectory(d_binddirectory); 518 535 … … 567 584 bbd->d_name=i->name; 568 585 bbd->d_filename=i->filename; 569 586 bbd->d_masters=i->masters; 587 bbd->d_also_notify=i->alsoNotify; 570 588 571 589 if(!bbd->d_loaded || !bbd->current()) { 572 590 // L<<Logger::Info<<d_logprefix<<" parsing '"<<i->name<<"' from file '"<<i->filename<<"'"<<endl; -
pdns/backends/bind/bindbackend2.hh
old new 84 84 unsigned int d_id; //!< internal id of the domain 85 85 time_t d_lastcheck; //!< last time domain was checked for freshness 86 86 vector<string> d_masters; //!< IP address of the master of this domain 87 set<string> d_also_notify; //!< IP list of hosts to also notify 87 88 88 89 uint32_t d_lastnotified; //!< Last serial number we notified our slaves of 89 90 … … 121 122 bool commitTransaction(); 122 123 bool abortTransaction(); 123 124 125 void alsoNotifies(const string &domain, set<string> *ips); 126 124 127 typedef map<string, int, CIStringCompare> name_id_map_t; 125 128 typedef map<uint32_t, BB2DomainInfo> id_zone_map_t; 126 129 … … 184 187 static string s_binddirectory; //!< this is used to store the 'directory' setting of the bind configuration 185 188 string d_logprefix; 186 189 190 set<string> alsoNotify; //!< this is used to store the also-notify list of interested peers. 191 187 192 int d_transaction_id; 188 193 string d_transaction_tmpname; 189 194 -
pdns/backends/bind/bindlexer.l
old new 109 109 110 110 file return FILETOK; 111 111 options return OPTIONSTOK; 112 also-notify return ALSONOTIFYTOK; 112 113 acl return ACLTOK; 113 114 logging return LOGGINGTOK; 114 115 directory return DIRECTORYTOK; -
pdns/backends/bind/bindparser.yy
old new 72 72 bind_directory=d_dir.c_str(); 73 73 } 74 74 75 void BindParser::addAlsoNotify(const string & host) 76 { 77 alsoNotify.insert(host); 78 } 79 75 80 const string &BindParser::getDirectory() 76 81 { 77 82 return d_dir; … … 101 106 %} 102 107 103 108 %token AWORD QUOTEDWORD OBRACE EBRACE SEMICOLON ZONETOK FILETOK OPTIONSTOK 104 %token DIRECTORYTOK ACLTOK LOGGINGTOK CLASSTOK TYPETOK MASTERTOK 109 %token DIRECTORYTOK ACLTOK LOGGINGTOK CLASSTOK TYPETOK MASTERTOK ALSONOTIFYTOK 105 110 106 111 %% 107 112 … … 147 152 LOGGINGTOK OBRACE options_commands EBRACE 148 153 ; 149 154 155 150 156 acl_command: 151 157 ACLTOK quotedname acl_block | ACLTOK filename acl_block 152 158 ; … … 168 174 options_command SEMICOLON options_commands 169 175 ; 170 176 171 options_command: command | options_directory_command 177 options_command: command | options_directory_command | also_notify_command 172 178 ; 173 179 174 180 options_directory_command: DIRECTORYTOK quotedname … … 178 184 } 179 185 ; 180 186 187 also_notify_command: ALSONOTIFYTOK OBRACE also_notify_list EBRACE 188 ; 189 190 also_notify_list: 191 | 192 also_notify SEMICOLON also_notify_list 193 ; 181 194 195 also_notify: AWORD 196 { 197 parent->addAlsoNotify($1); 198 free($1); 199 } 200 ; 182 201 terms: /* empty */ 183 202 | 184 203 terms term … … 199 218 zone_commands zone_command SEMICOLON 200 219 ; 201 220 202 zone_command: command | zone_file_command | zone_type_command | zone_masters_command 221 zone_command: command | zone_file_command | zone_type_command | zone_masters_command | zone_also_notify_command 203 222 ; 204 223 205 224 zone_masters_command: MASTERTOK OBRACE masters EBRACE 206 225 ; 207 226 227 zone_also_notify_command: ALSONOTIFYTOK OBRACE zone_also_notify_list EBRACE 228 ; 229 230 zone_also_notify_list: 231 | 232 zone_also_notify SEMICOLON zone_also_notify_list 233 ; 234 235 zone_also_notify: AWORD 236 { 237 s_di.alsoNotify.insert($1); 238 free($1); 239 } 240 ; 241 208 242 masters: /* empty */ 209 243 | 210 244 masters master SEMICOLON … … 243 277 ; 244 278 245 279 filename: AWORD 246 ; 247 No newline at end of file 280 ; -
pdns/backends/bind/bindparser.hh
old new 21 21 #include <string> 22 22 #include <map> 23 23 #include <vector> 24 #include <set> 24 25 25 26 using namespace std; 26 27 … … 34 35 { 35 36 name=filename=type=""; 36 37 masters.clear(); 38 alsoNotify.clear(); 37 39 d_dev=0; 38 40 d_ino=0; 39 41 } … … 41 43 string viewName; 42 44 string filename; 43 45 vector<string> masters; 46 set<string> alsoNotify; 44 47 string type; 45 48 46 49 dev_t d_dev; … … 78 81 const string &getDirectory(); 79 82 const vector<BindDomainInfo>& getDomains(); 80 83 void setVerbose(bool verbose); 84 void addAlsoNotify(const string &host); 85 set<string> & getAlsoNotify() { return this->alsoNotify; } 81 86 private: 82 87 string d_dir; 83 88 bool d_verbose; 84 89 typedef map<string,string> zonedomain_t; 85 90 set<string> alsoNotify; 86 91 vector<BindDomainInfo> d_zonedomains; 87 92 }; 88 93 -
pdns/ueberbackend.cc
old new 284 284 PC.insert(q.qname, q.qtype, PacketCache::QUERYCACHE, rr.serialize(), queryttl, q.zoneId); 285 285 } 286 286 287 void UeberBackend::alsoNotifies(const string &domain, set<string> *ips) 288 { 289 for ( vector< DNSBackend * >::iterator i = backends.begin(); i != backends.end(); ++i ) 290 (*i)->alsoNotifies(domain,ips); 291 } 287 292 288 293 UeberBackend::~UeberBackend() 289 294 { -
pdns/ueberbackend.hh
old new 124 124 void getUnfreshSlaveInfos(vector<DomainInfo>* domains); 125 125 void getUpdatedMasters(vector<DomainInfo>* domains); 126 126 bool getDomainInfo(const string &domain, DomainInfo &di); 127 void alsoNotifies(const string &domain, set<string> *ips); 127 128 void rediscover(string* status=0); 128 129 void reload(); 129 130 private: -
pdns/common_startup.cc
old new 80 80 ::arg().set("launch","Which backends to launch and order to query them in")=""; 81 81 ::arg().setSwitch("disable-axfr","Disable zonetransfers but do allow TCP queries")="no"; 82 82 ::arg().set("allow-axfr-ips","Allow zonetransfers only to these subnets")="0.0.0.0/0"; 83 ::arg().set("also-notify","Global setting for also-notify domains")=""; 83 84 ::arg().set("slave-cycle-interval","Reschedule failed SOA serial checks once every .. seconds")="60"; 84 85 85 86 ::arg().set("tcp-control-address","If set, PowerDNS can be controlled over TCP on this address")=""; -
pdns/communicator.cc
old new 163 163 for(vector<string>::const_iterator k=nsips.begin();k!=nsips.end();++k) 164 164 ips.insert(*k); 165 165 } 166 166 167 // inject also-notify from backends and global config 168 169 set<string>alsoNotify; 170 B->alsoNotifies(domain, &alsoNotify); 171 172 for(vector<string>::const_iterator k=d_an.begin();k!=d_an.end();k++) 173 alsoNotify.insert(*k); 174 175 for(set<string>::const_iterator k=alsoNotify.begin();k!=alsoNotify.end();++k) 176 ips.insert(*k); 177 167 178 // make calls to d_nq.add(domain, ip); 168 179 for(set<string>::const_iterator j=ips.begin();j!=ips.end();++j) { 169 180 L<<Logger::Warning<<"Queued notification of domain '"<<domain<<"' to "<<*j<<endl; 170 181 d_nq.add(domain,*j); 171 182 } 172 173 set<string>alsoNotify;174 B->alsoNotifies(domain, &alsoNotify);175 176 for(set<string>::const_iterator j=alsoNotify.begin();j!=alsoNotify.end();++j) {177 L<<Logger::Warning<<"Queued also-notification of domain '"<<domain<<"' to "<<*j<<endl;178 d_nq.add(domain,*j);179 }180 183 } 181 184 182 185 bool CommunicatorClass::notifyDomain(const string &domain) … … 425 428 signal(SIGPIPE,SIG_IGN); 426 429 #endif // WIN32 427 430 L<<Logger::Error<<"Master/slave communicator launching"<<endl; 431 432 // parse d_an 433 if (!::arg()["also-notify"].empty()) { 434 vector<string> parts; 435 stringtok( parts, ::arg()["also-notify"], ", \t" ); 436 for( vector<string>::const_iterator i = parts.begin(); i != parts.end(); ++i ) 437 d_an.push_back( *i ); // add to also-notify list 438 } 439 428 440 PacketHandler P; 429 441 d_tickinterval=::arg().asNum("slave-cycle-interval"); 430 442 makeNotifySocket(); -
pdns/communicator.hh
old new 165 165 Semaphore d_any_sem; 166 166 time_t d_tickinterval; 167 167 NotificationQueue d_nq; 168 vector<string> d_an; // also notify list 168 169 bool d_masterschanged, d_slaveschanged; 169 170 }; 170 171