d_SearchRecordsQuery = getArg("search-records-query");
d_SearchCommentsQuery = getArg("search-comments-query");
- d_IsOurDomainQuery = getArg("is-our-domain-query");
-
d_query_stmt = NULL;
d_NoIdQuery_stmt = NULL;
d_IdQuery_stmt = NULL;
d_DeleteCommentsQuery_stmt = NULL;
d_SearchRecordsQuery_stmt = NULL;
d_SearchCommentsQuery_stmt = NULL;
- d_IsOurDomainQuery_stmt = NULL;
}
void GSQLBackend::setNotified(uint32_t domain_id, uint32_t serial)
bool GSQLBackend::isMaster(const DNSName &domain, const string &ip)
{
- if (!isOurDomain(domain)) return false;
-
try {
d_MasterOfDomainsZoneQuery_stmt->
bind("domain", domain)->
bool GSQLBackend::setMaster(const DNSName &domain, const string &ip)
{
- if (!isOurDomain(domain)) return false;
-
try {
d_UpdateMasterOfZoneQuery_stmt->
bind("master", ip)->
bool GSQLBackend::setKind(const DNSName &domain, const DomainInfo::DomainKind kind)
{
- if (!isOurDomain(domain)) return false;
-
try {
d_UpdateKindOfZoneQuery_stmt->
bind("kind", toUpper(DomainInfo::getKindString(kind)))->
bool GSQLBackend::setAccount(const DNSName &domain, const string &account)
{
- if (!isOurDomain(domain)) return false;
-
try {
d_UpdateAccountOfZoneQuery_stmt->
bind("account", account)->
bool GSQLBackend::getDomainInfo(const DNSName &domain, DomainInfo &di)
{
- if (!isOurDomain(domain)) return false;
-
/* fill DomainInfo from database info:
id,name,master IP(s),last_check,notified_serial,type,account */
try {
{
if(!d_dnssecQueries)
return false;
- if (!isOurDomain(DNSName(""), domain_id)) return false;
if (!ordername.empty()) {
if (qtype == QType::ANY) {
bool GSQLBackend::updateEmptyNonTerminals(uint32_t domain_id, const DNSName& zonename, set<DNSName>& insert, set<DNSName>& erase, bool remove)
{
- if (!isOurDomain(DNSName(""), domain_id)) return false;
-
if(remove) {
try {
d_RemoveEmptyNonTerminalsFromZoneQuery_stmt->
{
if(!d_dnssecQueries)
return false;
- if (!isOurDomain(DNSName(""),id)) return false;
-
// cerr<<"gsql before/after called for id="<<id<<", qname='"<<qname<<"'"<<endl;
after.clear();
{
if(!d_dnssecQueries)
return -1;
- if (!isOurDomain(name)) return false;
try {
d_AddDomainKeyQuery_stmt->
{
if(!d_dnssecQueries)
return false;
- if (!isOurDomain(name)) return false;
try {
d_ActivateDomainKeyQuery_stmt->
{
if(!d_dnssecQueries)
return false;
- if (!isOurDomain(name)) return false;
try {
d_DeactivateDomainKeyQuery_stmt->
{
if(!d_dnssecQueries)
return false;
- if (!isOurDomain(name)) return false;
try {
d_RemoveDomainKeyQuery_stmt->
{
if(!d_dnssecQueries)
return false;
- if (!isOurDomain(name)) return false;
try {
d_ListDomainKeysQuery_stmt->
bool GSQLBackend::getAllDomainMetadata(const DNSName& name, std::map<std::string, std::vector<std::string> >& meta)
{
- if (!isOurDomain(name)) return false;
-
try {
d_GetAllDomainMetadataQuery_stmt->
bind("domain", name)->
{
if(!d_dnssecQueries && isDnssecDomainMetadata(kind))
return false;
- if (!isOurDomain(name)) return false;
try {
d_ClearDomainMetadataQuery_stmt->
bool GSQLBackend::list(const DNSName &target, int domain_id, bool include_disabled)
{
- if (!isOurDomain(target, domain_id)) return false;
-
DLOG(L<<"GSQLBackend constructing handle for list of domain id '"<<domain_id<<"'"<<endl);
try {
}
bool GSQLBackend::listSubZone(const DNSName &zone, int domain_id) {
- if (!isOurDomain(DNSName(""), domain_id)) return false;
string wildzone = "%." + toLower(zone.toStringNoDot());
bool GSQLBackend::replaceRRSet(uint32_t domain_id, const DNSName& qname, const QType& qt, const vector<DNSResourceRecord>& rrset)
{
- if (!isOurDomain(DNSName(""), domain_id)) return false;
-
try {
if (qt != QType::ANY) {
d_DeleteRRSetQuery_stmt->
bool GSQLBackend::feedEnts(int domain_id, map<DNSName,bool>& nonterm)
{
- if (!isOurDomain(DNSName(""), domain_id)) return false;
-
for(const auto& nt: nonterm) {
try {
d_InsertEmptyNonTerminalOrderQuery_stmt->
{
if(!d_dnssecQueries)
return false;
- if (!isOurDomain(DNSName(""), domain_id)) return false;
string ordername;
bool GSQLBackend::startTransaction(const DNSName &domain, int domain_id)
{
- if (domain_id >=0 && !isOurDomain(DNSName(""), domain_id)) return false;
-
try {
d_db->startTransaction();
if(domain_id >= 0) {
bool GSQLBackend::calculateSOASerial(const DNSName& domain, const SOAData& sd, time_t& serial)
{
- if (!isOurDomain(DNSName(""), sd.domain_id)) return false;
if (d_ZoneLastChangeQuery.empty()) {
// query not set => fall back to default impl
return DNSBackend::calculateSOASerial(domain, sd, serial);
}
-
+
try {
d_ZoneLastChangeQuery_stmt->
bind("domain_id", sd.domain_id)->
bool GSQLBackend::listComments(const uint32_t domain_id)
{
- if (!isOurDomain(DNSName(""), domain_id)) return false;
-
try {
d_query_name = "list-comments-query";
d_query_stmt = d_ListCommentsQuery_stmt;
comment.content = row[5];
}
-bool GSQLBackend::isOurDomain(const DNSName &zone, int domain_id) {
- try {
- d_IsOurDomainQuery_stmt->
- bind("id", domain_id)->
- bind("zone", zone)->
- execute()->
- getResult(d_result)->
- reset();
-
- if (!d_result.empty()) {
- d_result.clear();
- return true;
- }
- } catch (SSqlException &e) {
- throw PDNSException("GSQLBackend unable to verify ownership of domain: "+e.txtReason());
- }
-
- return false;
-}
-
SSqlStatement::~SSqlStatement() {
// make sure vtable won't break
}
d_DeleteCommentsQuery_stmt = d_db->prepare(d_DeleteCommentsQuery, 1);
d_SearchRecordsQuery_stmt = d_db->prepare(d_SearchRecordsQuery, 3);
d_SearchCommentsQuery_stmt = d_db->prepare(d_SearchCommentsQuery, 3);
- d_IsOurDomainQuery_stmt = d_db->prepare(d_IsOurDomainQuery, 2);
}
}
release(&d_DeleteCommentsQuery_stmt);
release(&d_SearchRecordsQuery_stmt);
release(&d_SearchCommentsQuery_stmt);
- release(&d_IsOurDomainQuery_stmt);
}
void lookup(const QType &, const DNSName &qdomain, DNSPacket *p=0, int zoneId=-1);
string directBackendCmd(const string &query);
bool searchRecords(const string &pattern, int maxResults, vector<DNSResourceRecord>& result);
bool searchComments(const string &pattern, int maxResults, vector<Comment>& result);
- bool isOurDomain(const DNSName &zone, int domain_id=-1);
+
protected:
string pattern2SQLPattern(const string& pattern);
void extractRecord(const SSqlStatement::row_t& row, DNSResourceRecord& rr);
string d_SearchRecordsQuery;
string d_SearchCommentsQuery;
- string d_IsOurDomainQuery;
-
SSqlStatement* d_query_stmt;
SSqlStatement* d_NoIdQuery_stmt;
SSqlStatement* d_DeleteCommentsQuery_stmt;
SSqlStatement* d_SearchRecordsQuery_stmt;
SSqlStatement* d_SearchCommentsQuery_stmt;
- SSqlStatement* d_IsOurDomainQuery_stmt;
+
protected:
bool d_dnssecQueries;
};