for(state_t::const_iterator i = s_state.begin(); i != s_state.end() ; ++i) {
BB2DomainInfo h;
safeGetBBDomainInfo(i->d_id, &h);
- shared_ptr<const recordstorage_t> handle = h.d_records.get();
+ shared_ptr<const recordstorage_t> rhandle = h.d_records.get();
- for(recordstorage_t::const_iterator ri = handle->begin(); result.size() < static_cast<vector<DNSResourceRecord>::size_type>(maxResults) && ri != handle->end(); ri++) {
+ for(recordstorage_t::const_iterator ri = rhandle->begin(); result.size() < static_cast<vector<DNSResourceRecord>::size_type>(maxResults) && ri != rhandle->end(); ri++) {
DNSName name = ri->qname.empty() ? i->d_name : (ri->qname+i->d_name);
if (sm.match(name) || sm.match(ri->content)) {
DNSResourceRecord r;
YAML::Node config;
vector<GeoIPDomain> tmp_domains;
- string mode = getArg("database-cache");
+ string modeStr = getArg("database-cache");
int flags;
- if (mode == "standard")
+ if (modeStr == "standard")
flags = GEOIP_STANDARD;
- else if (mode == "memory")
+ else if (modeStr == "memory")
flags = GEOIP_MEMORY_CACHE;
- else if (mode == "index")
+ else if (modeStr == "index")
flags = GEOIP_INDEX_CACHE;
#ifdef HAVE_MMAP
- else if (mode == "mmap")
+ else if (modeStr == "mmap")
flags = GEOIP_MMAP_CACHE;
#endif
else
- throw PDNSException("Invalid cache mode " + mode + " for GeoIP backend");
+ throw PDNSException("Invalid cache mode " + modeStr + " for GeoIP backend");
s_geoip_files.clear(); // reset pointers
const NetmaskTree<vector<string> >::node_type* node = target->second.lookup(ComboAddress(ip));
if (node == NULL) return; // no hit, again.
- DNSName format;
+ DNSName sformat;
gl.netmask = node->first.getBits();
// note that this means the array format won't work with indirect
for(auto it = node->second.begin(); it != node->second.end(); it++) {
- format = DNSName(format2str(*it, ip, v6, &gl));
+ sformat = DNSName(format2str(*it, ip, v6, &gl));
// see if the record can be found
- if (this->lookup_static(dom, format, qtype, qdomain, ip, gl, v6))
+ if (this->lookup_static(dom, sformat, qtype, qdomain, ip, gl, v6))
return;
}
rr.domain_id = dom.id;
rr.qtype = QType::CNAME;
rr.qname = qdomain;
- rr.content = format.toString();
+ rr.content = sformat.toString();
rr.auth = 1;
rr.ttl = dom.ttl;
rr.scopeMask = gl.netmask;
return ret;
}
-string GeoIPBackend::format2str(string format, const string& ip, bool v6, GeoIPLookup* gl) {
+string GeoIPBackend::format2str(string sformat, const string& ip, bool v6, GeoIPLookup* gl) {
string::size_type cur,last;
time_t t = time((time_t*)NULL);
GeoIPLookup tmp_gl; // largest wins
gmtime_r(&t, >m);
last=0;
- while((cur = format.find("%", last)) != string::npos) {
+ while((cur = sformat.find("%", last)) != string::npos) {
string rep;
int nrep=3;
tmp_gl.netmask = 0;
- if (!format.compare(cur,3,"%cn")) {
+ if (!sformat.compare(cur,3,"%cn")) {
rep = queryGeoIP(ip, v6, Continent, &tmp_gl);
- } else if (!format.compare(cur,3,"%co")) {
+ } else if (!sformat.compare(cur,3,"%co")) {
rep = queryGeoIP(ip, v6, Country, &tmp_gl);
- } else if (!format.compare(cur,3,"%cc")) {
+ } else if (!sformat.compare(cur,3,"%cc")) {
rep = queryGeoIP(ip, v6, Country2, &tmp_gl);
- } else if (!format.compare(cur,3,"%af")) {
+ } else if (!sformat.compare(cur,3,"%af")) {
rep = (v6?"v6":"v4");
- } else if (!format.compare(cur,3,"%as")) {
+ } else if (!sformat.compare(cur,3,"%as")) {
rep = queryGeoIP(ip, v6, ASn, &tmp_gl);
- } else if (!format.compare(cur,3,"%re")) {
+ } else if (!sformat.compare(cur,3,"%re")) {
rep = queryGeoIP(ip, v6, Region, &tmp_gl);
- } else if (!format.compare(cur,3,"%na")) {
+ } else if (!sformat.compare(cur,3,"%na")) {
rep = queryGeoIP(ip, v6, Name, &tmp_gl);
- } else if (!format.compare(cur,3,"%ci")) {
+ } else if (!sformat.compare(cur,3,"%ci")) {
rep = queryGeoIP(ip, v6, City, &tmp_gl);
- } else if (!format.compare(cur,3,"%hh")) {
+ } else if (!sformat.compare(cur,3,"%hh")) {
rep = boost::str(boost::format("%02d") % gtm.tm_hour);
tmp_gl.netmask = (v6?128:32);
- } else if (!format.compare(cur,3,"%yy")) {
+ } else if (!sformat.compare(cur,3,"%yy")) {
rep = boost::str(boost::format("%02d") % (gtm.tm_year + 1900));
tmp_gl.netmask = (v6?128:32);
- } else if (!format.compare(cur,3,"%dd")) {
+ } else if (!sformat.compare(cur,3,"%dd")) {
rep = boost::str(boost::format("%02d") % (gtm.tm_yday + 1));
tmp_gl.netmask = (v6?128:32);
- } else if (!format.compare(cur,4,"%wds")) {
+ } else if (!sformat.compare(cur,4,"%wds")) {
nrep=4;
rep = GeoIP_WEEKDAYS[gtm.tm_wday];
tmp_gl.netmask = (v6?128:32);
- } else if (!format.compare(cur,4,"%mos")) {
+ } else if (!sformat.compare(cur,4,"%mos")) {
nrep=4;
rep = GeoIP_MONTHS[gtm.tm_mon];
tmp_gl.netmask = (v6?128:32);
- } else if (!format.compare(cur,3,"%wd")) {
+ } else if (!sformat.compare(cur,3,"%wd")) {
rep = boost::str(boost::format("%02d") % (gtm.tm_wday + 1));
tmp_gl.netmask = (v6?128:32);
- } else if (!format.compare(cur,3,"%mo")) {
+ } else if (!sformat.compare(cur,3,"%mo")) {
rep = boost::str(boost::format("%02d") % (gtm.tm_mon + 1));
tmp_gl.netmask = (v6?128:32);
- } else if (!format.compare(cur,3,"%ip")) {
+ } else if (!sformat.compare(cur,3,"%ip")) {
rep = ip;
tmp_gl.netmask = (v6?128:32);
- } else if (!format.compare(cur,2,"%%")) {
+ } else if (!sformat.compare(cur,2,"%%")) {
last = cur + 2; continue;
} else {
last = cur + 1; continue;
}
if (tmp_gl.netmask > gl->netmask) gl->netmask = tmp_gl.netmask;
- format.replace(cur, nrep, rep);
+ sformat.replace(cur, nrep, rep);
last = cur + rep.size(); // move to next attribute
}
- return format;
+ return sformat;
}
void GeoIPBackend::reload() {
}
d_res_set = PQexecPrepared(d_db(), d_stmt.c_str(), d_nparams, paramValues, paramLengths, NULL, 0);
ExecStatusType status = PQresultStatus(d_res_set);
- string errmsg(PQresultErrorMessage(d_res_set));
if (status != PGRES_COMMAND_OK && status != PGRES_TUPLES_OK && status != PGRES_NONFATAL_ERROR) {
string errmsg(PQresultErrorMessage(d_res_set));
releaseStatement();
throw PDNSException("Unable to ascertain status of coprocess "+itoa(d_pid)+" from "+itoa(getpid())+": "+string(strerror(errno)));
else if(ret) {
if(WIFEXITED(status)) {
- int ret=WEXITSTATUS(status);
- throw PDNSException("Coprocess exited with code "+itoa(ret));
+ int exitStatus=WEXITSTATUS(status);
+ throw PDNSException("Coprocess exited with code "+itoa(exitStatus));
}
if(WIFSIGNALED(status)) {
int sig=WTERMSIG(status);
#endif
#include "remotebackend.hh"
-PipeConnector::PipeConnector(std::map<std::string,std::string> options) {
- if (options.count("command") == 0) {
+PipeConnector::PipeConnector(std::map<std::string,std::string> optionsMap) {
+ if (optionsMap.count("command") == 0) {
L<<Logger::Error<<"Cannot find 'command' option in connection string"<<endl;
throw PDNSException();
}
- this->command = options.find("command")->second;
- this->options = options;
+ this->command = optionsMap.find("command")->second;
+ this->options = optionsMap;
d_timeout=2000;
- if (options.find("timeout") != options.end()) {
- d_timeout = std::stoi(options.find("timeout")->second);
+ if (optionsMap.find("timeout") != optionsMap.end()) {
+ d_timeout = std::stoi(optionsMap.find("timeout")->second);
}
d_pid = -1;
throw PDNSException("Unable to ascertain status of coprocess "+itoa(d_pid)+" from "+itoa(getpid())+": "+string(strerror(errno)));
else if(ret) {
if(WIFEXITED(status)) {
- int ret=WEXITSTATUS(status);
- throw PDNSException("Coprocess exited with code "+itoa(ret));
+ int exitStatus=WEXITSTATUS(status);
+ throw PDNSException("Coprocess exited with code "+itoa(exitStatus));
}
if(WIFSIGNALED(status)) {
int sig=WTERMSIG(status);
#define UNIX_PATH_MAX 108
#endif
-UnixsocketConnector::UnixsocketConnector(std::map<std::string,std::string> options) {
- if (options.count("path") == 0) {
+UnixsocketConnector::UnixsocketConnector(std::map<std::string,std::string> optionsMap) {
+ if (optionsMap.count("path") == 0) {
L<<Logger::Error<<"Cannot find 'path' option in connection string"<<endl;
throw PDNSException();
}
this->timeout = 2000;
- if (options.find("timeout") != options.end()) {
- this->timeout = std::stoi(options.find("timeout")->second);
+ if (optionsMap.find("timeout") != optionsMap.end()) {
+ this->timeout = std::stoi(optionsMap.find("timeout")->second);
}
- this->path = options.find("path")->second;
- this->options = options;
+ this->path = optionsMap.find("path")->second;
+ this->options = optionsMap;
this->connected = false;
this->fd = -1;
}
uint64_t d_maxEntries{0};
time_t d_lastclean; // doesn't need to be atomic
- unsigned long d_nextclean{4906};
+ unsigned long d_nextclean{4096};
unsigned int d_cleaninterval{4096};
bool d_cleanskipped{false};
while(getline(ifs, line)) {
vector<uint8_t> packet;
boost::trim(line);
- auto p = splitField(line, ' ');
- DNSPacketWriter pw(packet, DNSName(p.first), DNSRecordContent::TypeToNumber(p.second));
+ const auto fields = splitField(line, ' ');
+ DNSPacketWriter pw(packet, DNSName(fields.first), DNSRecordContent::TypeToNumber(fields.second));
pw.getHeader()->rd=wantRecursion;
pw.getHeader()->id=random();
if(pw.getHeader()->id % 2) {
set<DNSName> nsec3set;
if (haveNSEC3 && !narrow) {
- for (auto &rr: rrs) {
+ for (auto &loopRR: rrs) {
bool skip=false;
- DNSName shorter = rr.qname;
+ DNSName shorter = loopRR.qname;
if (shorter != zone && shorter.chopOff() && shorter != zone) {
do {
if(nsset.count(shorter)) {
}
} while(shorter.chopOff() && shorter != zone);
}
- shorter = rr.qname;
- if(!skip && (rr.qtype.getCode() != QType::NS || !isOptOut)) {
+ shorter = loopRR.qname;
+ if(!skip && (loopRR.qtype.getCode() != QType::NS || !isOptOut)) {
do {
if(!nsec3set.count(shorter)) {
try {
errlog("Fatal Lua error: %s", e.what());
std::rethrow_if_nested(e);
- } catch(const std::exception& e) {
- errlog("Details: %s", e.what());
+ } catch(const std::exception& ne) {
+ errlog("Details: %s", ne.what());
}
catch(PDNSException &ae)
{
s_origanswers++;
qids_t::const_iterator iter=qids.find(qi);
if(iter != qids.end()) {
- QuestionData qd=*iter;
- qd.d_origAnswers=mdp.d_answers;
- qd.d_origRcode=mdp.d_header.rcode;
+ QuestionData eqd=*iter;
+ eqd.d_origAnswers=mdp.d_answers;
+ eqd.d_origRcode=mdp.d_header.rcode;
if(!dh->ra) {
s_norecursionavailable++;
- qd.d_norecursionavailable=true;
+ eqd.d_norecursionavailable=true;
}
- qids.replace(iter, qd);
+ qids.replace(iter, eqd);
- if(qd.d_newRcode!=-1) {
+ if(eqd.d_newRcode!=-1) {
measureResultAndClean(iter);
}
cas.insert(ComboAddress(*s));
}
else if(auto v = boost::get<vector<pair<unsigned int, string> > >(&in)) {
- for(const auto& s : *v)
- cas.insert(ComboAddress(s.second));
+ for(const auto& str : *v)
+ cas.insert(ComboAddress(str.second));
}
else
cas.insert(boost::get<ComboAddress>(in));
if(auto rec = std::dynamic_pointer_cast<ARecordContent>(dr.d_content))
ret=rec->getCA(53);
- else if(auto rec = std::dynamic_pointer_cast<AAAARecordContent>(dr.d_content))
- ret=rec->getCA(53);
+ else if(auto aaaarec = std::dynamic_pointer_cast<AAAARecordContent>(dr.d_content))
+ ret=aaaarec->getCA(53);
return ret;
});
if(res < 0)
throw runtime_error("reading packet from remote: "+stringerror());
- string packet(buffer, res);
- MOADNSParser mdp(true, packet);
+ MOADNSParser mdp(true, string(buffer,res));
nif.domain = mdp.d_qname;
nif.origID = mdp.d_header.id;
set<DNSName> proven;
set<DNSName> denied;
namesseen.insert(qname);
- for(const auto &n: namesseen)
+ for(const auto &name: namesseen)
{
- DNSName shorter(n);
+ DNSName shorter(name);
do {
namestocheck.insert(shorter);
} while(shorter.chopOff());
}
- for(const auto &n: namestocheck)
+ for(const auto &name: namestocheck)
{
- proveOrDeny(nsec3s, n, nsec3salt, nsec3iters, proven, denied);
- proveOrDeny(nsec3s, g_wildcarddnsname+n, nsec3salt, nsec3iters, proven, denied);
+ proveOrDeny(nsec3s, name, nsec3salt, nsec3iters, proven, denied);
+ proveOrDeny(nsec3s, g_wildcarddnsname+name, nsec3salt, nsec3iters, proven, denied);
}
if(names.count(qname))
bool doNextcloser = false;
string before, after, hashed;
DNSName unhashed, closest;
- DNSZoneRecord rr;
if (mode == 2 || mode == 3 || mode == 4) {
closest=wildcard;
if (!after.empty()) {
DLOG(L<<"Done calling for matching, hashed: '"<<toBase32Hex(hashed)<<"' before='"<<toBase32Hex(before)<<"', after='"<<toBase32Hex(after)<<"'"<<endl);
emitNSEC3(r, sd, ns3rc, unhashed, before, after, mode);
- } else if(!before.empty())
- r->addRecord(rr);
+ }
}
// add covering NSEC3 RR
}
if(weRedirected) {
- for(auto& rr: rrset) {
- if(rr.dr.d_type == QType::CNAME) {
- r->addRecord(rr);
- target = getRR<CNAMERecordContent>(rr.dr)->getTarget();
+ for(auto& loopRR: rrset) {
+ if(loopRR.dr.d_type == QType::CNAME) {
+ r->addRecord(loopRR);
+ target = getRR<CNAMERecordContent>(loopRR.dr)->getTarget();
retargetcount++;
goto retargeted;
}
}
else if(weDone) {
bool haveRecords = false;
- for(const auto& rr: rrset) {
- if((p->qtype.getCode() == QType::ANY || rr.dr.d_type == p->qtype.getCode()) && rr.dr.d_type && rr.dr.d_type != QType::ALIAS && rr.auth) {
- r->addRecord(rr);
+ for(const auto& loopRR: rrset) {
+ if((p->qtype.getCode() == QType::ANY || loopRR.dr.d_type == p->qtype.getCode()) && loopRR.dr.d_type && loopRR.dr.d_type != QType::ALIAS && loopRR.auth) {
+ r->addRecord(loopRR);
haveRecords = true;
}
}
editSOA(d_dk, sd.qname, r);
- for(const auto& rr: r->getRRS()) {
- if(rr.scopeMask) {
+ for(const auto& loopRR: r->getRRS()) {
+ if(loopRR.scopeMask) {
noCache=true;
break;
}
// Luawrapper nests the exception from Lua, so we unnest it here
try {
std::rethrow_if_nested(e);
- } catch(const std::exception& e) {
- L<<". Extra info: "<<e.what();
+ } catch(const std::exception& ne) {
+ L<<". Extra info: "<<ne.what();
} catch(...) {}
L<<endl;
bool presigned=dk.isPresigned(zone);
bool validKeys=dk.checkKeys(zone);
- DNSResourceRecord rr;
uint64_t numrecords=0, numerrors=0, numwarnings=0;
if (haveNSEC3) {
vector<DNSResourceRecord> records;
if(!suppliedrecords) {
+ DNSResourceRecord drr;
sd.db->list(zone, sd.domain_id, g_verbose);
- while(sd.db->get(rr)) {
- records.push_back(rr);
+ while(sd.db->get(drr)) {
+ records.push_back(drr);
}
}
else
}
cmdline.clear();
ZoneParserTNG zpt(tmpnam, g_rootdnsname);
- DNSResourceRecord rr;
+ DNSResourceRecord zrr;
map<pair<DNSName,uint16_t>, vector<DNSRecord> > grouped;
- while(zpt.get(rr)) {
+ while(zpt.get(zrr)) {
try {
- DNSRecord dr(rr);
+ DNSRecord dr(zrr);
post.push_back(dr);
grouped[{dr.d_name,dr.d_type}].push_back(dr);
}
else if(changed.empty() || c!='a')
goto reAsk2;
- for(const auto& c : changed) {
+ for(const auto& change : changed) {
vector<DNSResourceRecord> vrr;
- for(const DNSRecord& rr : grouped[c.first]) {
- DNSResourceRecord drr = DNSResourceRecord::fromWire(rr);
- drr.domain_id = di.id;
- vrr.push_back(drr);
+ for(const DNSRecord& rr : grouped[change.first]) {
+ DNSResourceRecord crr = DNSResourceRecord::fromWire(rr);
+ crr.domain_id = di.id;
+ vrr.push_back(crr);
}
- di.backend->replaceRRSet(di.id, c.first.first, QType(c.first.second), vrr);
+ di.backend->replaceRRSet(di.id, change.first.first, QType(change.first.second), vrr);
}
rectifyZone(dk, zone);
return EXIT_SUCCESS;
buflen = 0;
};
public:
- P11KitAttribute(CK_ATTRIBUTE_TYPE type, const std::string& value) {
+ P11KitAttribute(CK_ATTRIBUTE_TYPE type_, const std::string& value) {
Init();
- this->type = type;
+ this->type = type_;
setString(value);
}
- P11KitAttribute(CK_ATTRIBUTE_TYPE type, char value) {
+ P11KitAttribute(CK_ATTRIBUTE_TYPE type_, char value) {
Init();
- this->type = type;
+ this->type = type_;
setByte(value);
}
- P11KitAttribute(CK_ATTRIBUTE_TYPE type, unsigned char value) {
+ P11KitAttribute(CK_ATTRIBUTE_TYPE type_, unsigned char value) {
Init();
- this->type = type;
+ this->type = type_;
setByte(value);
}
- P11KitAttribute(CK_ATTRIBUTE_TYPE type, unsigned long value) {
+ P11KitAttribute(CK_ATTRIBUTE_TYPE type_, unsigned long value) {
Init();
- this->type = type;
+ this->type = type_;
setLong(value);
}
}
// then allocate memory
- for(size_t k=0; k < attributes.size(); k++) {
- if (attributes[k].valueType() == Attribute_String) {
- attr[k].pValue = attributes[k].allocate(attr[k].ulValueLen);
+ for(size_t idx=0; idx < attributes.size(); idx++) {
+ if (attributes[idx].valueType() == Attribute_String) {
+ attr[idx].pValue = attributes[idx].allocate(attr[idx].ulValueLen);
}
}
logError("C_GetAttributeValue");
// copy values to map and release allocated memory
- for(size_t k=0; k < attributes.size(); k++) {
- if (attributes[k].valueType() == Attribute_String) {
- attributes[k].commit(attr[k].ulValueLen);
+ for(size_t idx=0; idx < attributes.size(); idx++) {
+ if (attributes[idx].valueType() == Attribute_String) {
+ attributes[idx].commit(attr[idx].ulValueLen);
}
}
size_t found = 0;
for (size_t i = 0; i <= 255; i++) {
retrieved.clear();
- ComboAddress who("192.0.2." + std::to_string(i));
+ ComboAddress whoLoop("192.0.2." + std::to_string(i));
- auto ret = MRC.get(now, power1, QType(QType::A), false, &retrieved, who);
+ auto ret = MRC.get(now, power1, QType(QType::A), false, &retrieved, whoLoop);
if (ret > 0) {
BOOST_REQUIRE_EQUAL(retrieved.size(), 1);
- BOOST_CHECK_EQUAL(getRR<ARecordContent>(retrieved.at(0))->getCA().toString(), who.toString());
+ BOOST_CHECK_EQUAL(getRR<ARecordContent>(retrieved.at(0))->getCA().toString(), whoLoop.toString());
found++;
}
else {
BOOST_AUTO_TEST_CASE(test_cache_min_max_ttl) {
std::unique_ptr<SyncRes> sr;
- const time_t now = time(nullptr);
initSR(sr);
primeHints();
return 0;
});
+ const time_t now = time(nullptr);
SyncRes::s_minimumTTL = 60;
SyncRes::s_maxcachettl = 3600;
BOOST_AUTO_TEST_CASE(test_dnssec_rrsig_negcache_validity) {
std::unique_ptr<SyncRes> sr;
- const time_t now = time(nullptr);
initSR(sr, true);
setDNSSECValidation(sr, DNSSECMode::ValidateAll);
return 0;
});
+ const time_t now = time(nullptr);
vector<DNSRecord> ret;
int res = sr->beginResolve(target, QType(QType::A), QClass::IN, ret);
BOOST_CHECK_EQUAL(res, RCode::NoError);
BOOST_AUTO_TEST_CASE(test_dnssec_rrsig_cache_validity) {
std::unique_ptr<SyncRes> sr;
- const time_t now = time(nullptr);
initSR(sr, true);
setDNSSECValidation(sr, DNSSECMode::ValidateAll);
return 0;
});
+ const time_t now = time(nullptr);
vector<DNSRecord> ret;
int res = sr->beginResolve(target, QType(QType::A), QClass::IN, ret);
BOOST_CHECK_EQUAL(res, RCode::NoError);
n+=numread;
}
- string packet = string(creply, len);
-
- MOADNSParser mdp(false, packet);
+ MOADNSParser mdp(false, string(creply, len));
if (mdp.d_header.rcode != 0) {
throw PDNSException(string("Remote server refused: ") + std::to_string(mdp.d_header.rcode));
}
name=labels.back();
// cerr<<"Set short name to '"<<name<<"'"<<endl;
}
- else
- ; // cerr<<"Short name was already set to '"<<name<<"'"<<endl;
+ else {
+ // cerr<<"Short name was already set to '"<<name<<"'"<<endl;
+ }
if(labels.size()==1) {
if (fullname.empty()) {
}
for(const auto& rec : authorityRecs) {
- DNSRecord dr(*rec);
- dr.d_ttl=j->d_ttl - d_now.tv_sec;
- ret.push_back(dr);
+ DNSRecord authDR(*rec);
+ authDR.d_ttl=j->d_ttl - d_now.tv_sec;
+ ret.push_back(authDR);
}
if(qtype != QType::CNAME) { // perhaps they really wanted a CNAME!
just look for (N)TA
*/
if (cutState == Insecure || cutState == Bogus) {
- dsmap_t ds;
- vState newState = getDSRecords(qname, ds, true, depth);
+ dsmap_t cutDS;
+ vState newState = getDSRecords(qname, cutDS, true, depth);
if (newState == Indeterminate) {
continue;
}
if(rectify) {
// set auth
- for(DNSZoneRecord &zrr : zrrs) {
- zrr.auth=true;
- if (zrr.dr.d_type != QType::NS || zrr.dr.d_name!=target) {
- DNSName shorter(zrr.dr.d_name);
+ for(DNSZoneRecord &loopZRR : zrrs) {
+ loopZRR.auth=true;
+ if (loopZRR.dr.d_type != QType::NS || loopZRR.dr.d_name!=target) {
+ DNSName shorter(loopZRR.dr.d_name);
do {
if (shorter==target) // apex is always auth
break;
- if(nsset.count(shorter) && !(zrr.dr.d_name==shorter && zrr.dr.d_type == QType::DS)) {
- zrr.auth=false;
+ if(nsset.count(shorter) && !(loopZRR.dr.d_name==shorter && loopZRR.dr.d_type == QType::DS)) {
+ loopZRR.auth=false;
break;
}
} while(shorter.chopOff());
// ents are only required for NSEC3 zones
uint32_t maxent = ::arg().asNum("max-ent-entries");
set<DNSName> nsec3set, nonterm;
- for (auto &zrr: zrrs) {
+ for (auto &loopZRR: zrrs) {
bool skip=false;
- DNSName shorter = zrr.dr.d_name;
+ DNSName shorter = loopZRR.dr.d_name;
if (shorter != target && shorter.chopOff() && shorter != target) {
do {
if(nsset.count(shorter)) {
}
} while(shorter.chopOff() && shorter != target);
}
- shorter = zrr.dr.d_name;
- if(!skip && (zrr.dr.d_type != QType::NS || !ns3pr.d_flags)) {
+ shorter = loopZRR.dr.d_name;
+ if(!skip && (loopZRR.dr.d_type != QType::NS || !ns3pr.d_flags)) {
do {
if(!nsec3set.count(shorter)) {
nsec3set.insert(shorter);
}
}
- for(DNSZoneRecord &zrr : zrrs) {
- DNSName shorter(zrr.dr.d_name);
+ for(DNSZoneRecord &loopZRR : zrrs) {
+ DNSName shorter(loopZRR.dr.d_name);
while(shorter != target && shorter.chopOff()) {
if(!qnames.count(shorter) && !nonterm.count(shorter) && nsec3set.count(shorter)) {
if(!(maxent)) {
}
for(const auto& nt : nonterm) {
- DNSZoneRecord zrr;
- zrr.dr.d_name=nt;
- zrr.dr.d_type=QType::ENT;
- zrr.auth=true;
- zrrs.push_back(zrr);
+ DNSZoneRecord tempRR;
+ tempRR.dr.d_name=nt;
+ tempRR.dr.d_type=QType::ENT;
+ tempRR.auth=true;
+ zrrs.push_back(tempRR);
}
}
}
DTime dt;
dt.set();
int records=0;
- for(DNSZoneRecord &zrr : zrrs) {
- if (zrr.dr.d_type == QType::RRSIG) {
- if(presignedZone && NSEC3Zone && getRR<RRSIGRecordContent>(zrr.dr)->d_type == QType::NSEC3) {
- ns3rrs.insert(zrr.dr.d_name.makeRelative(sd.qname));
+ for(DNSZoneRecord &loopZRR : zrrs) {
+ if (loopZRR.dr.d_type == QType::RRSIG) {
+ if(presignedZone && NSEC3Zone && getRR<RRSIGRecordContent>(loopZRR.dr)->d_type == QType::NSEC3) {
+ ns3rrs.insert(loopZRR.dr.d_name.makeRelative(sd.qname));
}
continue;
}
// only skip the DNSKEY, CDNSKEY and CDS if direct-dnskey is enabled, to avoid changing behaviour
// when it is not enabled.
- if(::arg().mustDo("direct-dnskey") && (zrr.dr.d_type == QType::DNSKEY || zrr.dr.d_type == QType::CDNSKEY || zrr.dr.d_type == QType::CDS))
+ if(::arg().mustDo("direct-dnskey") && (loopZRR.dr.d_type == QType::DNSKEY || loopZRR.dr.d_type == QType::CDNSKEY || loopZRR.dr.d_type == QType::CDS))
continue;
records++;
- if(securedZone && (zrr.auth || zrr.dr.d_type == QType::NS)) {
- if (NSEC3Zone || zrr.dr.d_type) {
- keyname = NSEC3Zone ? DNSName(toBase32Hex(hashQNameWithSalt(ns3pr, zrr.dr.d_name))) : zrr.dr.d_name;
+ if(securedZone && (loopZRR.auth || loopZRR.dr.d_type == QType::NS)) {
+ if (NSEC3Zone || loopZRR.dr.d_type) {
+ keyname = NSEC3Zone ? DNSName(toBase32Hex(hashQNameWithSalt(ns3pr, loopZRR.dr.d_name))) : loopZRR.dr.d_name;
NSECXEntry& ne = nsecxrepo[keyname];
ne.d_ttl = sd.default_ttl;
- ne.d_auth = (ne.d_auth || zrr.auth || (NSEC3Zone && (!ns3pr.d_flags || (presignedZone && ns3pr.d_flags))));
- if (zrr.dr.d_type) {
- ne.d_set.insert(zrr.dr.d_type);
+ ne.d_auth = (ne.d_auth || loopZRR.auth || (NSEC3Zone && (!ns3pr.d_flags || (presignedZone && ns3pr.d_flags))));
+ if (loopZRR.dr.d_type) {
+ ne.d_set.insert(loopZRR.dr.d_type);
}
}
}
- if (!zrr.dr.d_type)
+ if (!loopZRR.dr.d_type)
continue; // skip empty non-terminals
- if(zrr.dr.d_type == QType::SOA)
+ if(loopZRR.dr.d_type == QType::SOA)
continue; // skip SOA - would indicate end of AXFR
- if(csp.submit(zrr)) {
+ if(csp.submit(loopZRR)) {
for(;;) {
outpacket->getRRS() = csp.getChunk();
if(!outpacket->getRRS().empty()) {
for(unsigned int n=0; n < 100000; ++n) {
packet.clear();
- DNSPacketWriter dpw1(packet, DNSName(std::to_string(n)+"."+std::to_string(n*2)+"."), QType::AAAA);
+ DNSPacketWriter dpw3(packet, DNSName(std::to_string(n)+"."+std::to_string(n*2)+"."), QType::AAAA);
counts[hashQuestion((char*)&packet[0], packet.size(), 0) % counts.size()]++;
}
BOOST_CHECK(!a(DNSName("www.powerdns.net"), g_rootdnsname));
vector<DNSName> vec;
- for(const std::string& a : {"bert.com.", "alpha.nl.", "articles.xxx.",
+ for(const std::string& b : {"bert.com.", "alpha.nl.", "articles.xxx.",
"Aleph1.powerdns.com.", "ZOMG.powerdns.com.", "aaa.XXX.", "yyy.XXX.",
"test.powerdns.com.", "\\128.com"}) {
- vec.push_back(DNSName(a));
+ vec.push_back(DNSName(b));
}
sort(vec.begin(), vec.end(), CanonDNSNameCompare());
// for(const auto& v : vec)
// cerr<<'"'<<v.toString()<<'"'<<endl;
vector<DNSName> right;
- for(const auto& a: {"bert.com.", "Aleph1.powerdns.com.",
+ for(const auto& b: {"bert.com.", "Aleph1.powerdns.com.",
"test.powerdns.com.",
"ZOMG.powerdns.com.",
"\\128.com.",
"aaa.XXX.",
"articles.xxx.",
"yyy.XXX."})
- right.push_back(DNSName(a));
+ right.push_back(DNSName(b));
BOOST_CHECK(vec==right);
char radix='d';
sscanf(spec.c_str(), "%d,%d,%c", &offset, &width, &radix); // parse format specifier
- char format[12];
- snprintf(format, sizeof(format) - 1, "%%0%d%c", width, radix); // make into printf-style format
+ char sformat[12];
+ snprintf(sformat, sizeof(sformat) - 1, "%%0%d%c", width, radix); // make into printf-style format
char tmp[80];
- snprintf(tmp, sizeof(tmp)-1, format, d_templatecounter + offset); // and do the actual printing
+ snprintf(tmp, sizeof(tmp)-1, sformat, d_templatecounter + offset); // and do the actual printing
outpart+=tmp;
}
else