d_RemoveDomainKeyQuery = getArg("remove-domain-key-query");
d_getTSIGKeyQuery = getArg("get-tsig-key-query");
+ d_setTSIGKeyQuery = getArg("set-tsig-key-query");
+ d_deleteTSIGKeyQuery = getArg("delete-tsig-key-query");
+ d_getTSIGKeysQuery = getArg("get-tsig-keys-query");
}
}
return !content->empty();
}
+bool GSQLBackend::setTSIGKey(const string& name, const string& algorithm, const string& content)
+{
+ if(!d_dnssecQueries)
+ return false;
+
+ char output[1024];
+ snprintf(output,sizeof(output)-1,d_setTSIGKeyQuery.c_str(), sqlEscape(toLower(name)).c_str(), sqlEscape(toLower(algorithm)).c_str(), sqlEscape(content).c_str());
+ try {
+ d_db->doCommand(output);
+ }
+ catch (SSqlException &e) {
+ throw AhuException("GSQLBackend unable to store named TSIG key: "+e.txtReason());
+ }
+ return true;
+}
+
+bool GSQLBackend::deleteTSIGKey(const string& name)
+{
+ if(!d_dnssecQueries)
+ return false;
+
+ char output[1024];
+ snprintf(output,sizeof(output)-1,d_deleteTSIGKeyQuery.c_str(), sqlEscape(toLower(name)).c_str());
+ try {
+ d_db->doCommand(output);
+ }
+ catch (SSqlException &e) {
+ throw AhuException("GSQLBackend unable to store named TSIG key: "+e.txtReason());
+ }
+ return true;
+}
+
+bool GSQLBackend::getTSIGKeys(std::vector< struct TSIGKey > &keys)
+{
+ if(!d_dnssecQueries)
+ return false;
+
+ char output[1024];
+ snprintf(output,sizeof(output)-1,"%s",d_getTSIGKeysQuery.c_str());
+
+ try {
+ d_db->doQuery(output);
+ }
+ catch (SSqlException &e) {
+ throw AhuException("GSQLBackend unable to retrieve named TSIG key: "+e.txtReason());
+ }
+
+ SSql::row_t row;
+
+ while(d_db->getRow(row)) {
+ struct TSIGKey key;
+ key.name = row[0];
+ key.algorithm = row[1];
+ key.key = row[2];
+ }
+
+ return keys.empty();
+}
+
bool GSQLBackend::getDomainKeys(const string& name, unsigned int kind, std::vector<KeyData>& keys)
{
if(!d_dnssecQueries)
bool deactivateDomainKey(const string& 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 getTSIGKeys(std::vector< struct TSIGKey > &keys);
+
private:
string d_qname;
QType d_qtype;
string d_DeactivateDomainKeyQuery;
string d_getTSIGKeyQuery;
+ string d_setTSIGKeyQuery;
+ string d_deleteTSIGKeyQuery;
+ string d_getTSIGKeysQuery;
string d_getAllDomainsQuery;