cerr<<"Non DNSSEC zone, only adding empty non-terminals"<<endl;
if(doTransaction)
- sd.db->startTransaction("", -1);
+ sd.db->startTransaction(DNSName(""), -1);
bool realrr=true;
uint32_t maxent = ::arg().asNum("max-ent-entries");
dt.set();
unsigned int hits=0, misses=0;
for(; n < 10000; ++n) {
- const string& domain = domains[random() % domains.size()];
+ DNSName domain(domains[random() % domains.size()]);
B.lookup(QType(QType::NS), domain);
while(B.get(rr)) {
hits++;
}
- B.lookup(QType(QType::A), boost::lexical_cast<string>(random())+"."+domain);
+ B.lookup(QType(QType::A), DNSName(boost::lexical_cast<string>(random()))+domain);
while(B.get(rr)) {
}
misses++;
cout<<"[Warning] DNSKEY record not at apex '"<<rr.qname.toString()<<" IN "<<rr.qtype.getName()<<" "<<rr.content<<"' in zone '"<<zone.toString()<<"', should not be here."<<endl;
numwarnings++;
} else if (rr.qtype.getCode() == QType::NS && DNSName(rr.content).isPartOf(rr.qname)) {
- checkglue.insert(toLower(rr.content));
+ checkglue.insert(DNSName(toLower(rr.content)));
} else if (rr.qtype.getCode() == QType::A || rr.qtype.getCode() == QType::AAAA) {
- glue.insert(toLower(rr.qname.toString()));
+ glue.insert(rr.qname);
}
}
}
rrs[0].content = serializeSOAData(sd);
- sd.db->startTransaction("", -1);
+ sd.db->startTransaction(DNSName(), -1);
if (! sd.db->replaceRRSet(sd.domain_id, zone, rr.qtype, rrs)) {
sd.db->abortTransaction();
return DNSCryptoKeyEngine::testAll();
}
-void testSpeed(DNSSECKeeper& dk, const string& zone, const string& remote, int cores)
+void testSpeed(DNSSECKeeper& dk, const DNSName& zone, const string& remote, int cores)
{
DNSResourceRecord rr;
- rr.qname="blah."+zone;
+ rr.qname=DNSName("blah")+zone;
rr.qtype=QType::A;
rr.ttl=3600;
rr.auth=1;
throw runtime_error("No backends available for DNSSEC key storage");
}
- ChunkedSigningPipe csp(zone, 1, remote, cores);
+ ChunkedSigningPipe csp(DNSName(zone), 1, remote, cores);
vector<DNSResourceRecord> signatures;
uint32_t rnd;
rr.content=tmp;
snprintf(tmp, sizeof(tmp), "r-%u", rnd);
- rr.qname=string(tmp)+"."+zone;
+ rr.qname=DNSName(tmp)+zone;
if(csp.submit(rr))
while(signatures = csp.getChunk(), !signatures.empty())
db->feedRecord(rr);
rr.qtype=QType::A;
- rr.qname="_underscore."+zone;
+ rr.qname=DNSName("_underscore")+zone;
rr.content="127.0.0.1";
db->feedRecord(rr);
- rr.qname="bla."+zone;
+ rr.qname=DNSName("bla")+zone;
cout<<"Committing"<<endl;
db->commitTransaction();
rectifyZone(dk, zone);
cout<<"Checking underscore ordering"<<endl;
DNSName before, after;
- db->getBeforeAndAfterNames(di.id, zone, "z."+zone, before, after);
+ db->getBeforeAndAfterNames(di.id, zone, DNSName("z")+zone, before, after);
cout<<"got '"<<before.toString()<<"' < 'z."<<zone.toString()<<"' < '"<<after.toString()<<"'"<<endl;
- if(before != "_underscore."+zone)
+ if(before != DNSName("_underscore")+zone)
{
cout<<"before is wrong, got '"<<before.toString()<<"', expected '_underscore."<<zone.toString()<<"', aborting"<<endl;
return;
cerr << "Syntax: pdnssec test-schema ZONE"<<endl;
return 0;
}
- testSchema(dk, cmds[1]);
+ testSchema(dk, DNSName(cmds[1]));
return 0;
}
if(cmds[0] == "rectify-zone") {
}
unsigned int exitCode = 0;
for(unsigned int n = 1; n < cmds.size(); ++n)
- if (!rectifyZone(dk, cmds[n])) exitCode = 1;
+ if (!rectifyZone(dk, DNSName(cmds[n])))
+ exitCode = 1;
return exitCode;
}
else if (cmds[0] == "rectify-all-zones") {
return 0;
}
UeberBackend B("default");
- exit(checkZone(dk, B, cmds[1]));
+ exit(checkZone(dk, B, DNSName(cmds[1])));
}
else if(cmds[0] == "bench-db") {
dbBench(cmds.size() > 1 ? cmds[1] : "");
cerr << "Syntax: pdnssec test-speed numcores [signing-server]"<<endl;
return 0;
}
- testSpeed(dk, cmds[1], (cmds.size() > 3) ? cmds[3] : "", atoi(cmds[2].c_str()));
+ testSpeed(dk, DNSName(cmds[1]), (cmds.size() > 3) ? cmds[3] : "", atoi(cmds[2].c_str()));
}
else if(cmds[0] == "verify-crypto") {
if(cmds.size() != 2) {
cerr << "Syntax: pdnssec show-zone ZONE"<<endl;
return 0;
}
- const string& zone=cmds[1];
- if (!showZone(dk, zone)) return 1;
+ if (!showZone(dk, DNSName(cmds[1]))) return 1;
}
else if(cmds[0] == "disable-dnssec") {
if(cmds.size() != 2) {
cerr << "Syntax: pdnssec disable-dnssec ZONE"<<endl;
return 0;
}
- const string& zone=cmds[1];
+ DNSName zone(cmds[1]);
if(!disableDNSSECOnZone(dk, zone)) {
cerr << "Cannot disable DNSSEC on " << zone << endl;
return 1;
cerr << "Syntax: pdnssec activate-zone-key ZONE KEY-ID"<<endl;
return 0;
}
- const string& zone=cmds[1];
+ DNSName zone(cmds[1]);
unsigned int id=atoi(cmds[2].c_str());
if(!id)
{
cerr << "Syntax: pdnssec deactivate-zone-key ZONE KEY-ID"<<endl;
return 0;
}
- const string& zone=cmds[1];
+ DNSName zone(cmds[1]);
unsigned int id=atoi(cmds[2].c_str());
if(!id)
{
cerr << "Syntax: pdnssec add-zone-key ZONE zsk|ksk [bits] [rsasha1|rsasha256|rsasha512|gost|ecdsa256|ecdsa384]"<<endl;
return 0;
}
- const string& zone=cmds[1];
+ DNSName zone(cmds[1]);
UeberBackend B("default");
DomainInfo di;
cerr<<"Syntax: pdnssec remove-zone-key ZONE KEY-ID"<<endl;
return 0;
}
- const string& zone=cmds[1];
+ DNSName zone(cmds[1]);
unsigned int id=atoi(cmds[2].c_str());
if (!dk.removeKey(zone, id)) {
cerr<<"Cannot remove key " << id << " from " << zone <<endl;
cerr<<"Syntax: pdnssec delete-zone ZONE"<<endl;
return 0;
}
- exit(deleteZone(cmds[1]));
+ exit(deleteZone(DNSName(cmds[1])));
}
else if(cmds[0] == "create-zone") {
if(cmds.size() != 2) {
cerr<<"Syntax: pdnssec create-zone ZONE"<<endl;
return 0;
}
- exit(createZone(cmds[1]));
+ exit(createZone(DNSName(cmds[1])));
}
else if(cmds[0] == "list-zone") {
if(cmds.size() != 2) {
if(cmds[1]==".")
cmds[1].clear();
- exit(listZone(cmds[1]));
+ exit(listZone(DNSName(cmds[1])));
}
else if(cmds[0] == "load-zone") {
if(cmds.size() != 3) {
if(cmds[1]==".")
cmds[1].clear();
- exit(loadZone(cmds[1], cmds[2]));
+ exit(loadZone(DNSName(cmds[1]), cmds[2]));
}
else if(cmds[0] == "secure-zone") {
if(cmds.size() < 2) {
cerr << "Syntax: pdnssec secure-zone ZONE"<<endl;
return 0;
}
- vector<string> mustRectify;
+ vector<DNSName> mustRectify;
dk.startTransaction();
unsigned int zoneErrors=0;
for(unsigned int n = 1; n < cmds.size(); ++n) {
- const string& zone=cmds[n];
+ DNSName zone(cmds[n]);
if(secureZone(dk, zone)) {
mustRectify.push_back(zone);
} else {
}
dk.commitTransaction();
- BOOST_FOREACH(string& zone, mustRectify)
+ for(const auto& zone : mustRectify)
rectifyZone(dk, zone);
if (zoneErrors) {
cerr<<"Syntax: pdnssec set-presigned ZONE"<<endl;
return 0;
}
- if (! dk.setPresigned(cmds[1])) {
+ if (! dk.setPresigned(DNSName(cmds[1]))) {
cerr << "Could not set presigned on for " << cmds[1] << endl;
return 1;
}
cerr<<"Syntax: pdnssec unset-presigned ZONE"<<endl;
return 0;
}
- if (! dk.unsetPresigned(cmds[1])) {
+ if (! dk.unsetPresigned(DNSName(cmds[1]))) {
cerr << "Could not unset presigned on for " << cmds[1] << endl;
return 1;
}
return 0;
}
DNSName zone(cmds[1]);
- string& record=cmds[2];
+ DNSName record(cmds[2]);
NSEC3PARAMRecordContent ns3pr;
bool narrow;
if(!dk.getNSEC3PARAM(zone, &ns3pr, &narrow)) {
cerr<<"Syntax: pdnssec unset-nsec3 ZONE"<<endl;
return 0;
}
- if ( ! dk.unsetNSEC3PARAM(cmds[1])) {
+ if ( ! dk.unsetNSEC3PARAM(DNSName(cmds[1]))) {
cerr<<"Cannot unset NSEC3 param for " << cmds[1] << endl;
return 1;
}
string zone=cmds[1];
unsigned int id=atoi(cmds[2].c_str());
- DNSSECPrivateKey dpk=dk.getKeyById(zone, id);
+ DNSSECPrivateKey dpk=dk.getKeyById(DNSName(zone), id);
cout << dpk.getKey()->convertToISC() <<endl;
}
else if(cmds[0]=="increase-serial") {
cerr<<"Syntax: pdnssec increase-serial ZONE"<<endl;
return 0;
}
- return increaseSerial(cmds[1], dk);
+ return increaseSerial(DNSName(cmds[1]), dk);
}
else if(cmds[0]=="import-zone-key-pem") {
if(cmds.size() < 4) {
else
dpk.d_flags = 257; // ksk
- if(!dk.addKey(zone, dpk)) {
+ if(!dk.addKey(DNSName(zone), dpk)) {
cerr<<"Adding key failed, perhaps DNSSEC not enabled in configuration?"<<endl;
exit(1);
}
exit(1);
}
}
- if(!dk.addKey(zone, dpk, active)) {
+ if(!dk.addKey(DNSName(zone), dpk, active)) {
cerr<<"Adding key failed, perhaps DNSSEC not enabled in configuration?"<<endl;
exit(1);
}
exit(1);
}
- string zone=cmds[1];
+ DNSName zone(cmds[1]);
unsigned int id=atoi(cmds[2].c_str());
DNSSECPrivateKey dpk=dk.getKeyById(zone, id);
cout << zone<<" IN DNSKEY "<<dpk.getDNSKEY().getZoneRepresentation() <<endl;
cerr << "Syntax: " << cmds[0] << " name (hmac-md5|hmac-sha1|hmac-sha224|hmac-sha256|hmac-sha384|hmac-sha512)" << endl;
return 0;
}
- string name = cmds[1];
+ DNSName name(cmds[1]);
string algo = cmds[2];
string key;
char tmpkey[64];
key = Base64Encode(std::string(tmpkey, klen));
UeberBackend B("default");
- if (B.setTSIGKey(name, algo, key)) {
+ if (B.setTSIGKey(name, DNSName(algo), key)) { // you are feeling bored, put up DNSName(algo) up earlier
cout << "Create new TSIG key " << name << " " << algo << " " << key << endl;
} else {
cout << "Failure storing new TSIG key " << name << " " << algo << " " << key << endl;
cerr << "Syntax: " << cmds[0] << " name algorithm key" << endl;
return 0;
}
- string name = cmds[1];
+ DNSName name(cmds[1]);
string algo = cmds[2];
string key = cmds[3];
UeberBackend B("default");
- if (B.setTSIGKey(name, algo, key)) {
+ if (B.setTSIGKey(name, DNSName(algo), key)) {
cout << "Imported TSIG key " << name << " " << algo << endl;
} else {
cout << "Failure importing TSIG key " << name << " " << algo << endl;
cerr << "Syntax: " << cmds[0] << " name" << endl;
return 0;
}
- string name = cmds[1];
+ DNSName name(cmds[1]);
UeberBackend B("default");
if (B.deleteTSIGKey(name)) {
cerr << "Syntax: " << cmds[0] << " zone name [master|slave]" << endl;
return 0;
}
- string zname = cmds[1];
+ DNSName zname(cmds[1]);
string name = cmds[2];
if (cmds[3] == "master")
metaKey = "TSIG-ALLOW-AXFR";
cerr << "Syntax: " << cmds[0] << " zone name [master|slave]" << endl;
return 0;
}
- string zname = cmds[1];
+ DNSName zname(cmds[1]);
string name = cmds[2];
if (cmds[3] == "master")
metaKey = "TSIG-ALLOW-AXFR";
cerr << "Syntax: " << cmds[0] << " zone [kind kind ..]" << endl;
return 1;
}
- string zone = cmds[1];
+ DNSName zone(cmds[1]);
vector<string> keys;
DomainInfo di;
cerr << "Syntax: " << cmds[0] << " zone kind [value value ..]" << endl;
return 1;
}
- string zone = cmds[1];
+ DNSName zone(cmds[1]);
string kind = cmds[2];
vector<string> meta(cmds.begin() + 3, cmds.end());