reset();
}
catch (SSqlException &e) {
- throw PDNSException("MyDNSBackend unable to get soa for domain "+name.toString()+": "+e.txtReason());
+ throw PDNSException("MyDNSBackend unable to get soa for domain "+name.toLogString()+": "+e.txtReason());
}
if (d_result.empty()) {
reset();
}
catch (SSqlException &e) {
- throw PDNSException("MyDNSBackend unable to lookup "+qname.toString()+": "+e.txtReason());
+ throw PDNSException("MyDNSBackend unable to lookup "+qname.toLogString()+": "+e.txtReason());
}
if (d_result.empty() == false) {
reset();
}
catch (SSqlException &e) {
- throw PDNSException("MyDNSBackend unable to lookup "+qname.toString()+": "+e.txtReason());
+ throw PDNSException("MyDNSBackend unable to lookup "+qname.toLogString()+": "+e.txtReason());
}
if(d_result.empty()) {
}
}
catch (SSqlException &e) {
- throw PDNSException("MyDNSBackend unable to lookup "+qname.toString()+": "+e.txtReason());
+ throw PDNSException("MyDNSBackend unable to lookup "+qname.toLogString()+": "+e.txtReason());
}
d_qname = qname.toString();
std::string keyStr = qname.toDNSStringLC();
if (keyStr.size() > sizeof(key.qname)) {
- throw std::runtime_error("Invalid QName to block " + qname.toString());
+ throw std::runtime_error("Invalid QName to block " + qname.toLogString());
}
memcpy(key.qname, keyStr.c_str(), keyStr.size());
{
std::unique_lock<std::mutex> lock(d_mutex);
if (d_qNamesCount >= d_maxQNames) {
- throw std::runtime_error("Table full when trying to block " + qname.toString());
+ throw std::runtime_error("Table full when trying to block " + qname.toLogString());
}
int res = bpf_lookup_elem(d_qnamemap.fd, &key, &value);
if (res != -1) {
- throw std::runtime_error("Trying to block an already blocked qname: " + qname.toString());
+ throw std::runtime_error("Trying to block an already blocked qname: " + qname.toLogString());
}
res = bpf_update_elem(d_qnamemap.fd, &key, &value, BPF_NOEXIST);
}
if (res != 0) {
- throw std::runtime_error("Error adding blocked qname " + qname.toString() + ": " + std::string(strerror(errno)));
+ throw std::runtime_error("Error adding blocked qname " + qname.toLogString() + ": " + std::string(strerror(errno)));
}
}
}
(void) qtype;
if (keyStr.size() > sizeof(key.qname)) {
- throw std::runtime_error("Invalid QName to block " + qname.toString());
+ throw std::runtime_error("Invalid QName to block " + qname.toLogString());
}
memcpy(key.qname, keyStr.c_str(), keyStr.size());
d_qNamesCount--;
}
else {
- throw std::runtime_error("Error removing qname address " + qname.toString() + ": " + std::string(strerror(errno)));
+ throw std::runtime_error("Error removing qname address " + qname.toLogString() + ": " + std::string(strerror(errno)));
}
}
}
return dpk;
}
- throw runtime_error("Can't find a key with id "+std::to_string(id)+" for zone '"+zname.toString()+"'");
+ throw runtime_error("Can't find a key with id "+std::to_string(id)+" for zone '"+zname.toLogString()+"'");
}
{
string error_msg = "";
if (!checkNSEC3PARAM(ns3p, error_msg))
- throw runtime_error("NSEC3PARAMs provided for zone '"+zname.toString()+"' are invalid: " + error_msg);
+ throw runtime_error("NSEC3PARAMs provided for zone '"+zname.toLogString()+"' are invalid: " + error_msg);
clearCaches(zname);
string descr = ns3p.getZoneRepresentation();
if(dr.d_type == QType::TSIG && dr.d_class == QClass::ANY) {
if(dr.d_place != DNSResourceRecord::ADDITIONAL || n != (unsigned int)(d_header.ancount + d_header.nscount + d_header.arcount) - 1) {
- throw MOADNSException("Packet ("+d_qname.toString()+"|#"+std::to_string(d_qtype)+") has a TSIG record in an invalid position.");
+ throw MOADNSException("Packet ("+d_qname.toLogString()+"|#"+std::to_string(d_qtype)+") has a TSIG record in an invalid position.");
}
d_tsigPos = recordStartPos + sizeof(struct dnsheader);
}
{
TSIGHashEnum algo;
if (!getTSIGHashEnum(trc.d_algoName, algo)) {
- throw PDNSException(string("Unsupported TSIG HMAC algorithm ") + trc.d_algoName.toString());
+ throw PDNSException(string("Unsupported TSIG HMAC algorithm ") + trc.d_algoName.toLogString());
}
string toSign = makeTSIGPayload(tsigprevious, reinterpret_cast<const char*>(pw.getContent().data()), pw.getContent().size(), tsigkeyname, trc, timersonly);
if (algo == TSIG_GSS) {
if (!gss_add_signature(tsigkeyname, toSign, trc.d_mac)) {
- throw PDNSException(string("Could not add TSIG signature with algorithm 'gss-tsig' and key name '")+tsigkeyname.toString()+string("'"));
+ throw PDNSException(string("Could not add TSIG signature with algorithm 'gss-tsig' and key name '")+tsigkeyname.toLogString()+string("'"));
}
} else {
trc.d_mac = calculateHMAC(tsigsecret, toSign, algo);
TSIGHashEnum algo;
if (!getTSIGHashEnum(trc.d_algoName, algo)) {
- throw std::runtime_error("Unsupported TSIG HMAC algorithm " + trc.d_algoName.toString());
+ throw std::runtime_error("Unsupported TSIG HMAC algorithm " + trc.d_algoName.toLogString());
}
TSIGHashEnum expectedAlgo;
if (!getTSIGHashEnum(tt.algo, expectedAlgo)) {
- throw std::runtime_error("Unsupported TSIG HMAC algorithm expected " + tt.algo.toString());
+ throw std::runtime_error("Unsupported TSIG HMAC algorithm expected " + tt.algo.toLogString());
}
if (algo != expectedAlgo) {
- throw std::runtime_error("Signature with TSIG key '"+tt.name.toString()+"' does not match the expected algorithm (" + tt.algo.toString() + " / " + trc.d_algoName.toString() + ")");
+ throw std::runtime_error("Signature with TSIG key '"+tt.name.toLogString()+"' does not match the expected algorithm (" + tt.algo.toLogString() + " / " + trc.d_algoName.toLogString() + ")");
}
string tsigMsg;
if (algo == TSIG_GSS) {
GssContext gssctx(tt.name);
if (!gss_verify_signature(tt.name, tsigMsg, theirMAC)) {
- throw std::runtime_error("Signature with TSIG key '"+tt.name.toString()+"' failed to validate");
+ throw std::runtime_error("Signature with TSIG key '"+tt.name.toLogString()+"' failed to validate");
}
} else {
string ourMac = calculateHMAC(tt.secret, tsigMsg, algo);
if(!constantTimeStringEquals(ourMac, theirMAC)) {
- throw std::runtime_error("Signature with TSIG key '"+tt.name.toString()+"' failed to validate");
+ throw std::runtime_error("Signature with TSIG key '"+tt.name.toLogString()+"' failed to validate");
}
}
auto sr = getRR<SOARecordContent>(records[pos]);
if (!sr) {
- throw std::runtime_error("Error getting the content of the first SOA record of this IXFR sequence for zone '"+zone.toString()+"' from master '"+master.toStringWithPort()+"'");
+ throw std::runtime_error("Error getting the content of the first SOA record of this IXFR sequence for zone '"+zone.toLogString()+"' from master '"+master.toStringWithPort()+"'");
}
// cerr<<"Serial is "<<sr->d_st.serial<<", final serial is "<<masterSOA->d_st.serial<<endl;
}
if (pos >= records.size()) {
- throw std::runtime_error("No SOA record to finish the removals part of the IXFR sequence of zone '" + zone.toString() + "' from " + master.toStringWithPort());
+ throw std::runtime_error("No SOA record to finish the removals part of the IXFR sequence of zone '" + zone.toLogString() + "' from " + master.toStringWithPort());
}
sr = getRR<SOARecordContent>(records[pos]);
if (!sr) {
- throw std::runtime_error("Invalid SOA record to finish the removals part of the IXFR sequence of zone '" + zone.toString() + "' from " + master.toStringWithPort());
+ throw std::runtime_error("Invalid SOA record to finish the removals part of the IXFR sequence of zone '" + zone.toLogString() + "' from " + master.toStringWithPort());
}
// this is the serial of the zone after the removals
}
if (pos >= records.size()) {
- throw std::runtime_error("No SOA record to finish the additions part of the IXFR sequence of zone '" + zone.toString() + "' from " + master.toStringWithPort());
+ throw std::runtime_error("No SOA record to finish the additions part of the IXFR sequence of zone '" + zone.toLogString() + "' from " + master.toStringWithPort());
}
sr = getRR<SOARecordContent>(records[pos]);
if (!sr) {
- throw std::runtime_error("Invalid SOA record to finish the additions part of the IXFR sequence of zone '" + zone.toString() + "' from " + master.toStringWithPort());
+ throw std::runtime_error("Invalid SOA record to finish the additions part of the IXFR sequence of zone '" + zone.toLogString() + "' from " + master.toStringWithPort());
}
if (sr->d_st.serial != newSerial) {
- throw std::runtime_error("Invalid serial (" + std::to_string(sr->d_st.serial) + ", expecting " + std::to_string(newSerial) + ") in the SOA record finishing the additions part of the IXFR sequence of zone '" + zone.toString() + "' from " + master.toStringWithPort());
+ throw std::runtime_error("Invalid serial (" + std::to_string(sr->d_st.serial) + ", expecting " + std::to_string(newSerial) + ") in the SOA record finishing the additions part of the IXFR sequence of zone '" + zone.toLogString() + "' from " + master.toStringWithPort());
}
if (newSerial == masterSOA->d_st.serial) {
// this was the last sequence
if (pos != (records.size() - 1)) {
- throw std::runtime_error("Trailing records after the last IXFR sequence of zone '" + zone.toString() + "' from " + master.toStringWithPort());
+ throw std::runtime_error("Trailing records after the last IXFR sequence of zone '" + zone.toLogString() + "' from " + master.toStringWithPort());
}
}
try {
trc.d_algoName = getTSIGAlgoName(the);
} catch(PDNSException& pe) {
- throw std::runtime_error("TSIG algorithm '"+tt.algo.toString()+"' is unknown.");
+ throw std::runtime_error("TSIG algorithm '"+tt.algo.toLogString()+"' is unknown.");
}
trc.d_time = time((time_t*)NULL);
trc.d_fudge = 300;
break;
if (maxReceivedBytes > 0 && (maxReceivedBytes - receivedBytes) < (size_t) len)
- throw std::runtime_error("Reached the maximum number of received bytes in an IXFR delta for zone '"+zone.toString()+"' from master "+master.toStringWithPort());
+ throw std::runtime_error("Reached the maximum number of received bytes in an IXFR delta for zone '"+zone.toLogString()+"' from master "+master.toStringWithPort());
char reply[len];
readn2(s.getHandle(), reply, len);
MOADNSParser mdp(false, string(reply, len));
if(mdp.d_header.rcode)
- throw std::runtime_error("Got an error trying to IXFR zone '"+zone.toString()+"' from master '"+master.toStringWithPort()+"': "+RCode::to_s(mdp.d_header.rcode));
+ throw std::runtime_error("Got an error trying to IXFR zone '"+zone.toLogString()+"' from master '"+master.toStringWithPort()+"': "+RCode::to_s(mdp.d_header.rcode));
// cout<<"Got a response, rcode: "<<mdp.d_header.rcode<<", got "<<mdp.d_answers.size()<<" answers"<<endl;
if(!masterSOA) {
// we have not seen the first SOA record yet
if (r.first.d_type != QType::SOA) {
- throw std::runtime_error("The first record of the IXFR answer for zone '"+zone.toString()+"' from master '"+master.toStringWithPort()+"' is not a SOA ("+QType(r.first.d_type).getName()+")");
+ throw std::runtime_error("The first record of the IXFR answer for zone '"+zone.toLogString()+"' from master '"+master.toStringWithPort()+"' is not a SOA ("+QType(r.first.d_type).getName()+")");
}
auto sr = getRR<SOARecordContent>(r.first);
if (!sr) {
- throw std::runtime_error("Error getting the content of the first SOA record of the IXFR answer for zone '"+zone.toString()+"' from master '"+master.toStringWithPort()+"'");
+ throw std::runtime_error("Error getting the content of the first SOA record of the IXFR answer for zone '"+zone.toLogString()+"' from master '"+master.toStringWithPort()+"'");
}
if(sr->d_st.serial == std::dynamic_pointer_cast<SOARecordContent>(oursr.d_content)->d_st.serial) {
if(r.first.d_type == QType::OPT)
continue;
- throw std::runtime_error("Unexpected record (" +QType(r.first.d_type).getName()+") in non-answer section ("+std::to_string(r.first.d_place)+")in IXFR response for zone '"+zone.toString()+"' from master '"+master.toStringWithPort());
+ throw std::runtime_error("Unexpected record (" +QType(r.first.d_type).getName()+") in non-answer section ("+std::to_string(r.first.d_place)+")in IXFR response for zone '"+zone.toLogString()+"' from master '"+master.toStringWithPort());
}
r.first.d_name.makeUsRelative(zone);
const auto it = keys.find(signer);
if (it == keys.cend()) {
- throw std::runtime_error("No DNSKEY found for " + signer.toString() + ", unable to compute the requested RRSIG");
+ throw std::runtime_error("No DNSKEY found for " + signer.toLogString() + ", unable to compute the requested RRSIG");
}
size_t recordsCount = records.size();
{
const auto it = keys.find(signer);
if (it == keys.cend()) {
- throw std::runtime_error("No DNSKEY found for " + signer.toString());
+ throw std::runtime_error("No DNSKEY found for " + signer.toLogString());
}
DNSRecord rec;
dr.d_place=DNSResourceRecord::ANSWER;
}
catch(std::exception &e) {
- throw PDNSException("Error parsing record '"+rr.qname.toString()+"' of type "+rr.qtype.getName()+" in zone '"+headers.first+"' from file '"+headers.second+"': "+e.what());
+ throw PDNSException("Error parsing record '"+rr.qname.toLogString()+"' of type "+rr.qtype.getName()+" in zone '"+headers.first+"' from file '"+headers.second+"': "+e.what());
}
catch(...) {
- throw PDNSException("Error parsing record '"+rr.qname.toString()+"' of type "+rr.qtype.getName()+" in zone '"+headers.first+"' from file '"+headers.second+"'");
+ throw PDNSException("Error parsing record '"+rr.qname.toLogString()+"' of type "+rr.qtype.getName()+" in zone '"+headers.first+"' from file '"+headers.second+"'");
}
ad.d_records.insert(dr);
if(mdp.d_header.qdcount != 1)
throw ResolverException("resolver: received answer with wrong number of questions ("+itoa(mdp.d_header.qdcount)+")");
if(mdp.d_qname != origQname)
- throw ResolverException(string("resolver: received an answer to another question (")+mdp.d_qname.toString()+"!="+ origQname.toString()+".)");
+ throw ResolverException(string("resolver: received an answer to another question (")+mdp.d_qname.toLogString()+"!="+ origQname.toLogString()+".)");
}
vector<DNSResourceRecord> ret;
}
}
if(!gotSOA)
- throw ResolverException("Query to '" + fromaddr.toString() + "' for SOA of '" + domain->toString() + "' did not return a SOA");
+ throw ResolverException("Query to '" + fromaddr.toString() + "' for SOA of '" + domain->toLogString() + "' did not return a SOA");
return true;
}
int ret = resolve(ipport, domain, QType::SOA, &res);
if(ret || res.empty())
- throw ResolverException("Query to '" + ipport + "' for SOA of '" + domain.toString() + "' produced no answers");
+ throw ResolverException("Query to '" + ipport + "' for SOA of '" + domain.toLogString() + "' produced no answers");
if(res[0].qtype.getCode() != QType::SOA)
- throw ResolverException("Query to '" + ipport + "' for SOA of '" + domain.toString() + "' produced a "+res[0].qtype.getName()+" record");
+ throw ResolverException("Query to '" + ipport + "' for SOA of '" + domain.toLogString() + "' produced a "+res[0].qtype.getName()+" record");
vector<string>parts;
stringtok(parts, res[0].content);
if(parts.size()<3)
- throw ResolverException("Query to '" + ipport + "' for SOA of '" + domain.toString() + "' produced an unparseable response");
+ throw ResolverException("Query to '" + ipport + "' for SOA of '" + domain.toLogString() + "' produced an unparseable response");
try {
*serial=pdns_stou(parts[2]);
}
catch(const std::out_of_range& oor) {
- throw ResolverException("Query to '" + ipport + "' for SOA of '" + domain.toString() + "' produced an unparseable serial");
+ throw ResolverException("Query to '" + ipport + "' for SOA of '" + domain.toLogString() + "' produced an unparseable serial");
}
}
* Terrible right?
*/
if(parts.size() < 2 || parts.size() > 9)
- throw PDNSException("Invalid IP address in RPZ: "+name.toString());
+ throw PDNSException("Invalid IP address in RPZ: "+name.toLogString());
bool isV6 = (stoi(parts[0]) > 32);
bool hadZZ = false;
if (pdns_iequals(part,"zz")) {
if (hadZZ)
- throw PDNSException("more than one 'zz' label found in RPZ name"+name.toString());
+ throw PDNSException("more than one 'zz' label found in RPZ name"+name.toLogString());
part = "";
isV6 = true;
hadZZ = true;
}
if (isV6 && parts.size() < 9 && !hadZZ)
- throw PDNSException("No 'zz' label found in an IPv6 RPZ name shorter than 9 elements: "+name.toString());
+ throw PDNSException("No 'zz' label found in an IPv6 RPZ name shorter than 9 elements: "+name.toLogString());
if (parts.size() == 5 && !isV6)
return Netmask(parts[4]+"."+parts[3]+"."+parts[2]+"."+parts[1]+"/"+parts[0]);
}
}
catch(const PDNSException& pe) {
- throw PDNSException("Issue parsing '"+drr.qname.toString()+"' '"+drr.content+"' at "+zpt.getLineOfFile()+": "+pe.reason);
+ throw PDNSException("Issue parsing '"+drr.qname.toLogString()+"' '"+drr.content+"' at "+zpt.getLineOfFile()+": "+pe.reason);
}
}
}
}
}
catch(PDNSException& e) {
- throw runtime_error("While attempting to query freshness of '"+dni.di.zone.toString()+"': "+e.reason);
+ throw runtime_error("While attempting to query freshness of '"+dni.di.zone.toLogString()+"': "+e.reason);
}
}
void SyncRes::computeZoneCuts(const DNSName& begin, const DNSName& end, unsigned int depth)
{
if(!begin.isPartOf(end)) {
- LOG(d_prefix<<" "<<begin.toLogString()<<" is not part of "<<end.toString()<<endl);
- throw PDNSException(begin.toLogString() + " is not part of " + end.toString());
+ LOG(d_prefix<<" "<<begin.toLogString()<<" is not part of "<<end.toLogString()<<endl);
+ throw PDNSException(begin.toLogString() + " is not part of " + end.toLogString());
}
if (d_cutStates.count(begin) != 0) {
if (checkTSIG) {
if (theirMac.empty()) {
- throw std::runtime_error("No TSIG on AXFR response from "+d_remote.toStringWithPort()+" , should be signed with TSIG key '"+d_tt.name.toString()+"'");
+ throw std::runtime_error("No TSIG on AXFR response from "+d_remote.toStringWithPort()+" , should be signed with TSIG key '"+d_tt.name.toLogString()+"'");
}
try {
{
vector<DNSName> ret;
if(!begin.isPartOf(end))
- throw PDNSException(end.toLogString() + "is not part of " + begin.toString());
+ throw PDNSException(end.toLogString() + "is not part of " + begin.toLogString());
DNSName qname(end);
vector<string> labelsToAdd = begin.makeRelative(end).getRawLabels();
{
auto iter = SyncRes::t_sstorage.domainmap->find(zonename);
if (iter == SyncRes::t_sstorage.domainmap->end())
- throw ApiException("Could not find domain '"+zonename.toString()+"'");
+ throw ApiException("Could not find domain '"+zonename.toLogString()+"'");
const SyncRes::AuthDomain& zone = iter->second;
SyncRes::domainmap_t::const_iterator iter = SyncRes::t_sstorage.domainmap->find(zonename);
if (iter == SyncRes::t_sstorage.domainmap->end())
- throw ApiException("Could not find domain '"+zonename.toString()+"'");
+ throw ApiException("Could not find domain '"+zonename.toLogString()+"'");
if(req->method == "PUT" && !::arg().mustDo("api-readonly")) {
Json document = req->json();
try {
recparts[1] = toCanonic(d_zonename, recparts[1]).toStringRootDot();
} catch (std::exception &e) {
- throw PDNSException("Error in record '" + rr.qname.toString() + " " + rr.qtype.getName() + "': " + e.what());
+ throw PDNSException("Error in record '" + rr.qname.toLogString() + " " + rr.qtype.getName() + "': " + e.what());
}
}
rr.content=recparts[0]+" "+recparts[1];
try {
recparts[3] = toCanonic(d_zonename, recparts[3]).toStringRootDot();
} catch (std::exception &e) {
- throw PDNSException("Error in record '" + rr.qname.toString() + " " + rr.qtype.getName() + "': " + e.what());
+ throw PDNSException("Error in record '" + rr.qname.toLogString() + " " + rr.qtype.getName() + "': " + e.what());
}
}
rr.content=recparts[0]+" "+recparts[1]+" "+recparts[2]+" "+recparts[3];
try {
rr.content = toCanonic(d_zonename, rr.content).toStringRootDot();
} catch (std::exception &e) {
- throw PDNSException("Error in record '" + rr.qname.toString() + " " + rr.qtype.getName() + "': " + e.what());
+ throw PDNSException("Error in record '" + rr.qname.toLogString() + " " + rr.qtype.getName() + "': " + e.what());
}
break;
case QType::AFSDB:
try {
recparts[1]=toCanonic(d_zonename, recparts[1]).toStringRootDot();
} catch (std::exception &e) {
- throw PDNSException("Error in record '" + rr.qname.toString() + " " + rr.qtype.getName() + "': " + e.what());
+ throw PDNSException("Error in record '" + rr.qname.toLogString() + " " + rr.qtype.getName() + "': " + e.what());
}
} else {
- throw PDNSException("AFSDB record for "+rr.qname.toString()+" invalid");
+ throw PDNSException("AFSDB record for "+rr.qname.toLogString()+" invalid");
}
rr.content.clear();
for(string::size_type n = 0; n < recparts.size(); ++n) {
case QType::SOA:
stringtok(recparts, rr.content);
if(recparts.size() > 7)
- throw PDNSException("SOA record contents for "+rr.qname.toString()+" contains too many parts");
+ throw PDNSException("SOA record contents for "+rr.qname.toLogString()+" contains too many parts");
if(recparts.size() > 1) {
try {
recparts[0]=toCanonic(d_zonename, recparts[0]).toStringRootDot();
recparts[1]=toCanonic(d_zonename, recparts[1]).toStringRootDot();
} catch (std::exception &e) {
- throw PDNSException("Error in record '" + rr.qname.toString() + " " + rr.qtype.getName() + "': " + e.what());
+ throw PDNSException("Error in record '" + rr.qname.toLogString() + " " + rr.qtype.getName() + "': " + e.what());
}
}
rr.content.clear();