Changeset 1819 for trunk/pdns/pdns/slavecommunicator.cc
- Timestamp:
- 01/06/11 19:57:57 (2 years ago)
- Files:
-
- 1 modified
-
trunk/pdns/pdns/slavecommunicator.cc (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pdns/pdns/slavecommunicator.cc
r1717 r1819 1 1 /* 2 2 PowerDNS Versatile Database Driven Nameserver 3 Copyright (C) 2002-20 09PowerDNS.COM BV3 Copyright (C) 2002-2011 PowerDNS.COM BV 4 4 5 5 This program is free software; you can redistribute it and/or modify … … 18 18 #include "packetcache.hh" 19 19 #include "utility.hh" 20 #include "dnssecinfra.hh" 21 #include "dnsseckeeper.hh" 22 #include "base32.hh" 20 23 #include <errno.h> 21 24 #include "communicator.hh" … … 70 73 71 74 UeberBackend *B=dynamic_cast<UeberBackend *>(P.getBackend()); 75 NSEC3PARAMRecordContent ns3pr; 76 bool narrow; 77 DNSSECKeeper dk; 78 bool dnssecZone = false; 79 if(dk.haveActiveKSKFor(domain)) { 80 dnssecZone=true; 81 dk.getNSEC3PARAM(domain, &ns3pr, &narrow); 82 string hashed; 83 if(ns3pr.d_salt.empty()) 84 cerr<<"Adding NSEC ordering information"<<endl; 85 else if(!narrow) 86 cerr<<"Adding NSEC3 hashed ordering information for '"<<domain<<"'"<<endl; 87 else 88 cerr<<"Erasing NSEC3 ordering since we are narrow, only setting 'auth' fields"<<endl; 89 } 72 90 73 91 if(!B->getDomainInfo(domain, di) || !di.backend) { … … 78 96 79 97 Resolver::res_t recs; 80 98 set<string> nsset, qnames; 81 99 while(resolver.axfrChunk(recs)) { 82 100 if(first) { … … 85 103 first=false; 86 104 } 105 87 106 for(Resolver::res_t::iterator i=recs.begin();i!=recs.end();++i) { 88 107 if(!endsOn(i->qname, domain)) { … … 90 109 continue; 91 110 } 111 if(dnssecZone) { 112 if(i->qtype.getCode() == QType::NS && !pdns_iequals(i->qname, domain)) 113 nsset.insert(i->qname); 114 qnames.insert(i->qname); 115 } 92 116 i->domain_id=domain_id; 93 117 if(i->qtype.getCode()>=1024) … … 97 121 } 98 122 } 123 if(dnssecZone) { 124 string hashed; 125 BOOST_FOREACH(const string& qname, qnames) 126 { 127 string shorter(qname); 128 bool auth=true; 129 do { 130 if(nsset.count(shorter)) { 131 auth=false; 132 break; 133 } 134 }while(chopOff(shorter)); 135 136 if(ns3pr.d_salt.empty()) // NSEC 137 di.backend->updateDNSSECOrderAndAuth(domain_id, domain, qname, auth); 138 else { 139 if(!narrow) { 140 hashed=toLower(toBase32Hex(hashQNameWithSalt(ns3pr.d_iterations, ns3pr.d_salt, qname))); 141 cerr<<"'"<<qname<<"' -> '"<< hashed <<"'"<<endl; 142 } 143 di.backend->updateDNSSECOrderAndAuthAbsolute(domain_id, qname, hashed, auth); 144 } 145 } 146 } 147 99 148 di.backend->commitTransaction(); 100 149 di.backend->setFresh(domain_id);