return true;
}
-bool GSQLBackend::getDomainInfo(const string &domain, DomainInfo &di)
+bool GSQLBackend::getDomainInfo(const DNSName &domain, DomainInfo &di)
{
/* fill DomainInfo from database info:
id,name,master IP(s),last_check,notified_serial,type,account */
try {
d_InfoOfDomainsZoneQuery_stmt->
- bind("domain", toLower(domain))->
+ bind("domain", domain)->
execute()->
getResult(d_result)->
reset();
di.serial = 0;
try {
SOAData sd;
- if(!getSOA(domain,sd))
- L<<Logger::Notice<<"No serial for '"<<domain<<"' found - zone is missing?"<<endl;
+ if(!getSOA(domain, sd))
+ L<<Logger::Notice<<"No serial for '"<<domain.toString()<<"' found - zone is missing?"<<endl;
else
di.serial = sd.serial;
}
catch(PDNSException &ae){
- L<<Logger::Error<<"Error retrieving serial for '"<<domain<<"': "<<ae.reason<<endl;
+ L<<Logger::Error<<"Error retrieving serial for '"<<domain.toString()<<"': "<<ae.reason<<endl;
}
di.kind = DomainInfo::stringToKind(type);
return true;
}
-int GSQLBackend::addDomainKey(const string& name, const KeyData& key)
+int GSQLBackend::addDomainKey(const DNSName& name, const KeyData& key)
{
if(!d_dnssecQueries)
return -1;
bind("flags", key.flags)->
bind("active", key.active)->
bind("content", key.content)->
- bind("domain", toLower(name))->
+ bind("domain", name)->
execute()->
reset();
}
return 1; // XXX FIXME, no idea how to get the id
}
-bool GSQLBackend::activateDomainKey(const string& name, unsigned int id)
+bool GSQLBackend::activateDomainKey(const DNSName& name, unsigned int id)
{
if(!d_dnssecQueries)
return false;
try {
d_ActivateDomainKeyQuery_stmt->
- bind("domain", toLower(name))->
+ bind("domain", name)->
bind("key_id", id)->
execute()->
reset();
return true;
}
-bool GSQLBackend::deactivateDomainKey(const string& name, unsigned int id)
+bool GSQLBackend::deactivateDomainKey(const DNSName& name, unsigned int id)
{
if(!d_dnssecQueries)
return false;
try {
d_DeactivateDomainKeyQuery_stmt->
- bind("domain", toLower(name))->
+ bind("domain", name)->
bind("key_id", id)->
execute()->
reset();
return true;
}
-bool GSQLBackend::removeDomainKey(const string& name, unsigned int id)
+bool GSQLBackend::removeDomainKey(const DNSName& name, unsigned int id)
{
if(!d_dnssecQueries)
return false;
try {
d_RemoveDomainKeyQuery_stmt->
- bind("domain", toLower(name))->
+ bind("domain", name)->
bind("key_id", id)->
execute()->
reset();
return true;
}
-bool GSQLBackend::getTSIGKey(const string& name, string* algorithm, string* content)
+bool GSQLBackend::getTSIGKey(const DNSName& name, DNSName* algorithm, string* content)
{
try {
d_getTSIGKeyQuery_stmt->
- bind("key_name", toLower(name))->
+ bind("key_name", name)->
execute();
SSqlStatement::row_t row;
content->clear();
while(d_getTSIGKeyQuery_stmt->hasNextRow()) {
d_getTSIGKeyQuery_stmt->nextRow(row);
- if(row.size() >= 2 && (algorithm->empty() || pdns_iequals(*algorithm, row[0]))) {
+ if(row.size() >= 2 && (!algorithm->countLabels() || *algorithm==row[0])) {
*algorithm = row[0];
*content = row[1];
}
return !content->empty();
}
-bool GSQLBackend::setTSIGKey(const string& name, const string& algorithm, const string& content)
+bool GSQLBackend::setTSIGKey(const DNSName& name, const DNSName& algorithm, const string& content)
{
try {
d_setTSIGKeyQuery_stmt->
- bind("key_name", toLower(name))->
- bind("algorithm", toLower(algorithm))->
+ bind("key_name", name)->
+ bind("algorithm", algorithm)->
bind("content", content)->
execute()->
reset();
return true;
}
-bool GSQLBackend::deleteTSIGKey(const string& name)
+bool GSQLBackend::deleteTSIGKey(const DNSName& name)
{
try {
d_deleteTSIGKeyQuery_stmt->
- bind("key_name", toLower(name))->
+ bind("key_name", name)->
execute()->
reset();
}
return keys.empty();
}
-bool GSQLBackend::getDomainKeys(const string& name, unsigned int kind, std::vector<KeyData>& keys)
+bool GSQLBackend::getDomainKeys(const DNSName& name, unsigned int kind, std::vector<KeyData>& keys)
{
if(!d_dnssecQueries)
return false;
try {
d_ListDomainKeysQuery_stmt->
- bind("domain", toLower(name))->
+ bind("domain", name)->
execute();
SSqlStatement::row_t row;
return true;
}
-void GSQLBackend::alsoNotifies(const string &domain, set<string> *ips)
+void GSQLBackend::alsoNotifies(const DNSName &domain, set<string> *ips)
{
vector<string> meta;
getDomainMetadata(domain, "ALSO-NOTIFY", meta);
}
}
-bool GSQLBackend::getAllDomainMetadata(const string& name, std::map<std::string, std::vector<std::string> >& meta)
+bool GSQLBackend::getAllDomainMetadata(const DNSName& name, std::map<std::string, std::vector<std::string> >& meta)
{
try {
d_GetAllDomainMetadataQuery_stmt->
- bind("domain", toLower(name))->
+ bind("domain", name)->
execute();
SSqlStatement::row_t row;
}
-bool GSQLBackend::getDomainMetadata(const string& name, const std::string& kind, std::vector<std::string>& meta)
+bool GSQLBackend::getDomainMetadata(const DNSName& name, const std::string& kind, std::vector<std::string>& meta)
{
if(!d_dnssecQueries && isDnssecDomainMetadata(kind))
return false;
try {
d_GetDomainMetadataQuery_stmt->
- bind("domain", toLower(name))->
+ bind("domain", name)->
bind("kind", kind)->
execute();
return true;
}
-bool GSQLBackend::setDomainMetadata(const string& name, const std::string& kind, const std::vector<std::string>& meta)
+bool GSQLBackend::setDomainMetadata(const DNSName& name, const std::string& kind, const std::vector<std::string>& meta)
{
if(!d_dnssecQueries && isDnssecDomainMetadata(kind))
return false;
try {
d_ClearDomainMetadataQuery_stmt->
- bind("domain", toLower(name))->
+ bind("domain", name)->
bind("kind", kind)->
execute()->
reset();
d_SetDomainMetadataQuery_stmt->
bind("kind", kind)->
bind("content", value)->
- bind("domain", toLower(name))->
+ bind("domain", name)->
execute()->
reset();
}
d_query_stmt = d_NoIdQuery_stmt;
d_query_stmt->
bind("qtype", qtype.getName())->
- bind("qname", qname); // DNSNameFIXME: toLower()?
+ bind("qname", qname);
} else {
d_query_stmt = d_IdQuery_stmt;
d_query_stmt->
return true;
}
-bool GSQLBackend::listSubZone(const string &zone, int domain_id) {
- string wildzone = "%." + zone;
+bool GSQLBackend::listSubZone(const DNSName &zone, int domain_id) {
+
+ string wildzone = "%." + stripDot(zone.toString()); // tolower()?
try {
d_query_stmt = d_listSubZoneQuery_stmt;
}
}
-bool GSQLBackend::replaceRRSet(uint32_t domain_id, const string& qname, const QType& qt, const vector<DNSResourceRecord>& rrset)
+bool GSQLBackend::replaceRRSet(uint32_t domain_id, const DNSName& qname, const QType& qt, const vector<DNSResourceRecord>& rrset)
{
try {
if (qt != QType::ANY) {
}
}
-bool GSQLBackend::replaceComments(const uint32_t domain_id, const string& qname, const QType& qt, const vector<Comment>& comments)
+bool GSQLBackend::replaceComments(const uint32_t domain_id, const DNSName& qname, const QType& qt, const vector<Comment>& comments)
{
try {
d_DeleteCommentRRsetQuery_stmt->
bind("domain_id",domain_id)->
- bind("qname",toLower(qname))->
+ bind("qname", qname)->
bind("qtype",qt.getName())->
execute()->
reset();
bool get(DNSResourceRecord &r);
void getAllDomains(vector<DomainInfo> *domains, bool include_disabled=false);
bool isMaster(const string &domain, const string &ip);
- void alsoNotifies(const string &domain, set<string> *ips);
+ void alsoNotifies(const DNSName &domain, set<string> *ips);
bool startTransaction(const string &domain, int domain_id=-1);
bool commitTransaction();
bool abortTransaction();
void setFresh(uint32_t domain_id);
void getUnfreshSlaveInfos(vector<DomainInfo> *domains);
void getUpdatedMasters(vector<DomainInfo> *updatedDomains);
- bool getDomainInfo(const string &domain, DomainInfo &di);
+ bool getDomainInfo(const DNSName &domain, DomainInfo &di);
void setNotified(uint32_t domain_id, uint32_t serial);
bool setMaster(const string &domain, const string &ip);
bool setKind(const string &domain, const DomainInfo::DomainKind kind);
virtual bool calculateSOASerial(const string& domain, const SOAData& sd, time_t& serial);
- bool replaceRRSet(uint32_t domain_id, const string& qname, const QType& qt, const vector<DNSResourceRecord>& rrset);
- bool listSubZone(const string &zone, int domain_id);
- int addDomainKey(const string& name, const KeyData& key);
- bool getDomainKeys(const string& name, unsigned int kind, std::vector<KeyData>& keys);
- bool getAllDomainMetadata(const string& name, std::map<std::string, std::vector<std::string> >& meta);
- bool getDomainMetadata(const string& name, const std::string& kind, std::vector<std::string>& meta);
- bool setDomainMetadata(const string& name, const std::string& kind, const std::vector<std::string>& meta);
- bool clearDomainAllMetadata(const string& domain);
+ bool replaceRRSet(uint32_t domain_id, const DNSName& qname, const QType& qt, const vector<DNSResourceRecord>& rrset);
+ bool listSubZone(const DNSName &zone, int domain_id);
+ int addDomainKey(const DNSName& name, const KeyData& key);
+ bool getDomainKeys(const DNSName& name, unsigned int kind, std::vector<KeyData>& keys);
+ bool getAllDomainMetadata(const DNSName& name, std::map<std::string, std::vector<std::string> >& meta);
+ bool getDomainMetadata(const DNSName& name, const std::string& kind, std::vector<std::string>& meta);
+ bool setDomainMetadata(const DNSName& name, const std::string& kind, const std::vector<std::string>& meta);
+ bool clearDomainAllMetadata(const DNSName& domain);
- bool removeDomainKey(const string& name, unsigned int id);
- bool activateDomainKey(const string& name, unsigned int id);
- bool deactivateDomainKey(const string& name, unsigned int id);
+ bool removeDomainKey(const DNSName& name, unsigned int id);
+ bool activateDomainKey(const DNSName& name, unsigned int id);
+ bool deactivateDomainKey(const DNSName& name, unsigned int id);
- bool getTSIGKey(const string& name, string* algorithm, string* content);
- bool setTSIGKey(const string& name, const string& algorithm, const string& content);
- bool deleteTSIGKey(const string& name);
+ bool getTSIGKey(const DNSName& name, DNSName* algorithm, string* content);
+ bool setTSIGKey(const DNSName& name, const DNSName& algorithm, const string& content);
+ bool deleteTSIGKey(const DNSName& name);
bool getTSIGKeys(std::vector< struct TSIGKey > &keys);
bool listComments(const uint32_t domain_id);
bool getComment(Comment& comment);
void feedComment(const Comment& comment);
- bool replaceComments(const uint32_t domain_id, const string& qname, const QType& qt, const vector<Comment>& comments);
+ bool replaceComments(const uint32_t domain_id, const DNSName& qname, const QType& qt, const vector<Comment>& comments);
private:
DNSName d_qname;