#include "dnspacket.hh"
#include "dns.hh"
-bool DNSBackend::getAuth(DNSPacket *p, SOAData *sd, const DNSName &target)
+bool DNSBackend::getAuth(const DNSName &target, SOAData *sd)
{
return this->getSOA(target, *sd);
}
virtual void getAllDomains(vector<DomainInfo> *domains, bool include_disabled=false) { }
/** Determines if we are authoritative for a zone, and at what level */
- virtual bool getAuth(DNSPacket *p, SOAData *sd, const DNSName &target);
+ virtual bool getAuth(const DNSName &target, SOAData *sd);
struct KeyData {
std::string content;
return r;
}
- if(!B.getAuth(p, &sd, target)) {
+ if(!B.getAuth(target, p->qtype, &sd)) {
DLOG(L<<Logger::Error<<"We have no authority over zone '"<<target<<"'"<<endl);
if(!retargetcount) {
r->setA(false); // drop AA if we never had a SOA in the first place
}
}
-bool UeberBackend::getAuth(DNSPacket *p, SOAData *sd, const DNSName &target)
+bool UeberBackend::getAuth(const DNSName &target, const QType& qtype, SOAData* sd, bool cachedOk)
{
bool found = false;
int cstat;
do {
// Check cache
- if(sd->db != (DNSBackend *)-1 && (d_cache_ttl || d_negcache_ttl)) {
+ if(cachedOk && (d_cache_ttl || d_negcache_ttl)) {
d_question.qtype = QType::SOA;
d_question.qname = choppedOff;
d_question.zoneId = -1;
break;
} else {
DLOG(L<<Logger::Error<<"lookup: "<<choppedOff<<endl);
- if((*i)->getAuth(p, sd, choppedOff)) {
+ if((*i)->getAuth(choppedOff, sd)) {
DLOG(L<<Logger::Error<<"got: "<<sd->qname<<endl);
j->first = sd->qname.wirelength();
j->second = *sd;
}
found:
- if(found == (p->qtype == QType::DS)){
+ if(found == (qtype == QType::DS)){
DLOG(L<<Logger::Error<<"found: "<<sd->qname<<endl);
return true;
} else {
void lookup(const QType &, const DNSName &qdomain, DNSPacket *pkt_p=0, int zoneId=-1);
- bool getAuth(DNSPacket *p, SOAData *sd, const DNSName &target);
+ /** Determines if we are authoritative for a zone, and at what level */
+ bool getAuth(const DNSName &target, const QType &qtype, SOAData* sd, bool cachedOk=true);
bool getSOA(const DNSName &domain, SOAData &sd);
bool getSOAUncached(const DNSName &domain, SOAData &sd); // same, but ignores cache
bool get(DNSZoneRecord &r);
makePtr(rr, &ptr);
// verify that there's a zone for the PTR
- DNSPacket fakePacket(false);
SOAData sd;
- fakePacket.qtype = QType::PTR;
- if (!B.getAuth(&fakePacket, &sd, ptr.qname))
+ if (!B.getAuth(ptr.qname, QType(QType::PTR), &sd, false))
throw ApiException("Could not find domain for PTR '"+ptr.qname.toString()+"' requested for '"+ptr.content+"'");
ptr.domain_id = sd.domain_id;
static void storeChangedPTRs(UeberBackend& B, vector<DNSResourceRecord>& new_ptrs) {
for(const DNSResourceRecord& rr : new_ptrs) {
- DNSPacket fakePacket(false);
SOAData sd;
- sd.db = (DNSBackend *)-1; // getAuth() cache bypass
- fakePacket.qtype = QType::PTR;
-
- if (!B.getAuth(&fakePacket, &sd, rr.qname))
+ if (!B.getAuth(rr.qname, QType(QType::PTR), &sd, false))
throw ApiException("Could not find domain for PTR '"+rr.qname.toString()+"' requested for '"+rr.content+"' (while saving)");
string soa_edit_api_kind;