return true;
}
-bool Bind2Backend::feedRecord(const DNSResourceRecord &rr, string *ordername)
+bool Bind2Backend::feedRecord(const DNSResourceRecord &rr, const DNSName &ordername)
{
BB2DomainInfo bbd;
safeGetBBDomainInfo(d_transaction_id, &bbd);
void setFresh(uint32_t domain_id);
void setNotified(uint32_t id, uint32_t serial);
bool startTransaction(const DNSName &qname, int id);
- bool feedRecord(const DNSResourceRecord &rr, string *ordername=0);
+ bool feedRecord(const DNSResourceRecord &rr, const DNSName &ordername);
bool commitTransaction();
bool abortTransaction();
void alsoNotifies(const DNSName &domain, set<string> *ips);
bool startTransaction(const DNSName &qname, int id) override;
bool commitTransaction() override;
bool abortTransaction() override;
- bool feedRecord(const DNSResourceRecord &rr, string *ordername=0) override;
+ bool feedRecord(const DNSResourceRecord &rr, const DNSName &ordername) override;
// SUPERMASTER BACKEND
virtual bool startTransaction(const string &qname, int id);
virtual bool commitTransaction();
virtual bool abortTransaction();
- virtual bool feedRecord(const DNSResourceRecord &rr, string* ordername=0);
+ virtual bool feedRecord(const DNSResourceRecord &rr, DNSName &ordername);
virtual bool getDomainInfo(const string &domain, DomainInfo &di);
virtual bool isMaster(const string &name, const string &ip);
return ok;
}
-bool LUABackend::feedRecord(const DNSResourceRecord &rr, string *ordername) {
+bool LUABackend::feedRecord(const DNSResourceRecord &rr, const DNSName &ordername) {
if (f_lua_feedrecord == 0)
return false;
-bool OdbxBackend::feedRecord( const DNSResourceRecord& rr, string *ordername )
+bool OdbxBackend::feedRecord( const DNSResourceRecord& rr, const DNSName ordername )
{
try
{
bool isMaster( const string& domain, const string& ip );
bool getDomainInfo( const string& domain, DomainInfo& di );
- bool feedRecord( const DNSResourceRecord& rr, string *ordername=0 );
+ bool feedRecord( const DNSResourceRecord& rr, const DNSName ordername );
bool createSlaveDomain( const string& ip, const string& domain, const string &nameserver, const string& account );
bool superMasterBackend( const string& ip, const string& domain, const vector<DNSResourceRecord>& nsset, string *nameserver, string* account, DNSBackend** ddb );
}
bool
-OracleBackend::feedRecord (const DNSResourceRecord &rr, string *ordername)
+OracleBackend::feedRecord (const DNSResourceRecord &rr, const DNSName ordername)
{
sword rc;
OCIStmt *stmt;
void setNotified(uint32_t zoneId, uint32_t serial);
bool list(const DNSName& domain, int zoneId, bool include_disabled=false);
bool startTransaction(const DNSName& domain, int zoneId);
- bool feedRecord(const DNSResourceRecord &rr, string* ordername);
+ bool feedRecord(const DNSResourceRecord &rr, const DNSName ordername);
bool commitTransaction();
bool abortTransaction();
bool superMasterBackend(const string &ip, const DNSName& domain,
return true;
}
-bool RemoteBackend::feedRecord(const DNSResourceRecord &rr, string *ordername) {
+bool RemoteBackend::feedRecord(const DNSResourceRecord &rr, const DNSName ordername) {
Json query = Json::object{
{ "method", "feedRecord" },
{ "parameters", Json::object{
{ "content", rr.content },
{ "ttl", static_cast<int>(rr.ttl) },
{ "auth", rr.auth },
- { "ordername", (ordername==nullptr?Json():*ordername) }
+ { "ordername", (ordername.empty()?Json():ordername.toString()) }
}},
{ "trxid", static_cast<double>(d_trxid) },
}}
virtual bool superMasterBackend(const string &ip, const DNSName& domain, const vector<DNSResourceRecord>&nsset, string *nameserver, string *account, DNSBackend **ddb);
virtual bool createSlaveDomain(const string &ip, const DNSName& domain, const string& nameserver, const string &account);
virtual bool replaceRRSet(uint32_t domain_id, const DNSName& qname, const QType& qt, const vector<DNSResourceRecord>& rrset);
- virtual bool feedRecord(const DNSResourceRecord &r, string *ordername);
+ virtual bool feedRecord(const DNSResourceRecord &r, const DNSName ordername);
virtual bool feedEnts(int domain_id, map<DNSName,bool>& nonterm);
virtual bool feedEnts3(int domain_id, const DNSName& domain, map<DNSName,bool>& nonterm, const NSEC3PARAMRecordContent& ns3prc, bool narrow);
virtual bool startTransaction(const DNSName& domain, int domain_id);
rr.qclass = QClass::IN;
rr.ttl = 300;
rr.content = "ns1.example.com. hostmaster.example.com. 2013013441 7200 3600 1209600 300";
- BOOST_CHECK(be->feedRecord(rr, NULL));
+ BOOST_CHECK(be->feedRecord(rr, DNSName()));
rr.qname = DNSName("replace.example.com.");
rr.qtype = QType::A;
rr.qclass = QClass::IN;
rr.ttl = 300;
rr.content = "127.0.0.1";
- BOOST_CHECK(be->feedRecord(rr, NULL));
+ BOOST_CHECK(be->feedRecord(rr, DNSName()));
be->commitTransaction();
}
}
}
for(const auto& rr: rrset) {
- feedRecord(rr);
+ feedRecord(rr, DNSName());
}
return true;
}
-bool GSQLBackend::feedRecord(const DNSResourceRecord &r, string *ordername)
+bool GSQLBackend::feedRecord(const DNSResourceRecord &r, const DNSName &ordername)
{
int prio=0;
string content(r.content);
bind("disabled",r.disabled)->
bind("qname",r.qname);
- if (ordername == NULL)
- d_InsertRecordQuery_stmt->bindNull("ordername");
+ if (!ordername.empty())
+ d_InsertRecordQuery_stmt->bind("ordername", ordername.labelReverse().makeLowerCase().toString(" ", false));
else
- d_InsertRecordQuery_stmt->bind("ordername",*ordername);
+ d_InsertRecordQuery_stmt->bindNull("ordername");
if (d_dnssecQueries)
d_InsertRecordQuery_stmt->bind("auth", r.auth);
bool startTransaction(const DNSName &domain, int domain_id=-1);
bool commitTransaction();
bool abortTransaction();
- bool feedRecord(const DNSResourceRecord &r, string *ordername=0);
+ bool feedRecord(const DNSResourceRecord &r, const DNSName &ordername);
bool feedEnts(int domain_id, map<DNSName,bool>& nonterm);
bool feedEnts3(int domain_id, const DNSName &domain, map<DNSName,bool> &nonterm, const NSEC3PARAMRecordContent& ns3prc, bool narrow);
bool createDomain(const DNSName &domain, const string &type, const string &masters, const string &account);
}
//! feeds a record to a zone, needs a call to startTransaction first
- virtual bool feedRecord(const DNSResourceRecord &rr, string *ordername=0)
+ virtual bool feedRecord(const DNSResourceRecord &rr, const DNSName &ordername)
{
return false; // no problem!
}
else
haveSOA = true;
}
- db->feedRecord(rr);
+ db->feedRecord(rr, DNSName());
}
db->commitTransaction();
return EXIT_SUCCESS;
rr.content = DNSRecordContent::mastermake(rr.qtype.getCode(), 1, serializeSOAData(sd))->getZoneRepresentation(true);
rr.domain_id = di.id;
di.backend->startTransaction(zone, di.id);
- di.backend->feedRecord(rr);
+ di.backend->feedRecord(rr, DNSName());
if(!nsname.empty()) {
cout<<"Also adding one NS record"<<endl;
rr.qtype=QType::NS;
rr.content=nsname.toStringNoDot();
- di.backend->feedRecord(rr);
+ di.backend->feedRecord(rr, DNSName());
}
di.backend->commitTransaction();
rr.auth=1;
rr.content="ns1.example.com. ahu.example.com. 2012081039 7200 3600 1209600 3600";
cout<<"Feeding SOA"<<endl;
- db->feedRecord(rr);
+ db->feedRecord(rr, DNSName());
rr.qtype=QType::TXT;
// 300 As
rr.content="\"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\"";
cout<<"Feeding overlong TXT"<<endl;
- db->feedRecord(rr);
+ db->feedRecord(rr, DNSName());
cout<<"Committing"<<endl;
db->commitTransaction();
cout<<"Querying TXT"<<endl;
rr.auth=1;
rr.content="ns1.example.com. ahu.example.com. 2012081039 7200 3600 1209600 3600";
cout<<"Feeding SOA"<<endl;
- db->feedRecord(rr);
+ db->feedRecord(rr, DNSName());
rr.qtype=QType::A;
rr.qname=DNSName("_underscore")+zone;
rr.content="127.0.0.1";
- db->feedRecord(rr);
+ db->feedRecord(rr, DNSName());
rr.qname=DNSName("bla")+zone;
cout<<"Committing"<<endl;
if (!src->list(di.zone, di.id, true)) throw PDNSException("Failed to list records");
nr=0;
while(src->get(rr)) {
- if (!tgt->feedRecord(rr)) throw PDNSException("Failed to feed record");
+ if (!tgt->feedRecord(rr, DNSName())) throw PDNSException("Failed to feed record");
nr++;
}
// move comments
auto newRec = DNSResourceRecord::fromWire(*rr);
newRec.domain_id = di->id;
newRec.auth = (rr->d_name == di->zone || rrType.getCode() != QType::NS);
- di->backend->feedRecord(newRec);
+ di->backend->feedRecord(newRec, DNSName());
changedRecords++;
bool doent=true;
uint32_t maxent = ::arg().asNum("max-ent-entries");
- string ordername;
- DNSName shorter;
+ DNSName shorter, ordername;
set<DNSName> rrterm;
map<DNSName,bool> nonterm;
bool auth;
if (!rr.auth && rr.qtype.getCode() == QType::NS) {
if (zs.isNSEC3)
- ordername=toBase32Hex(hashQNameWithSalt(zs.ns3pr, rr.qname));
- auth=(!zs.isNSEC3 || !zs.optOutFlag || zs.secured.count(DNSName(ordername)));
+ ordername=DNSName(toBase32Hex(hashQNameWithSalt(zs.ns3pr, rr.qname)));
+ auth=(!zs.isNSEC3 || !zs.optOutFlag || zs.secured.count(ordername));
} else
auth=rr.auth;
if (zs.isDnssecZone && rr.qtype.getCode() != QType::RRSIG) {
if (zs.isNSEC3) {
// NSEC3
- ordername=toBase32Hex(hashQNameWithSalt(zs.ns3pr, rr.qname));
- if(!zs.isNarrow && (rr.auth || (rr.qtype.getCode() == QType::NS && (!zs.optOutFlag || zs.secured.count(DNSName(ordername)))))) {
- di.backend->feedRecord(rr, &ordername);
+ ordername=DNSName(toBase32Hex(hashQNameWithSalt(zs.ns3pr, rr.qname)));
+ if(!zs.isNarrow && (rr.auth || (rr.qtype.getCode() == QType::NS && (!zs.optOutFlag || zs.secured.count(ordername))))) {
+ di.backend->feedRecord(rr, ordername);
} else
- di.backend->feedRecord(rr);
+ di.backend->feedRecord(rr, DNSName());
} else {
// NSEC
if (rr.auth || rr.qtype.getCode() == QType::NS) {
- ordername=rr.qname.makeRelative(domain).makeLowerCase().labelReverse().toString(" ", false);
- di.backend->feedRecord(rr, &ordername);
+ ordername=rr.qname.makeRelative(domain);
+ di.backend->feedRecord(rr, ordername);
} else
- di.backend->feedRecord(rr);
+ di.backend->feedRecord(rr, DNSName());
}
} else
- di.backend->feedRecord(rr);
+ di.backend->feedRecord(rr, DNSName());
}
// Insert empty non-terminals
for(auto rr : new_records) {
rr.domain_id = di.id;
- di.backend->feedRecord(rr);
+ di.backend->feedRecord(rr, DNSName());
}
for(Comment& c : new_comments) {
c.domain_id = di.id;