class DNSBackend
{
public:
-
+ virtual unsigned int getCapabilities()=0;
virtual void lookup(const QType &qtype, const string &qdomain, int zoneId=-1, DNSPacket *pkt_p=nullptr)=0;
virtual bool list(const string &target, int domain_id)=0;
virtual bool get(DNSResourceRecord &r)=0;
virtual bool getSOA(const string &name, SOAData &soadata);
};
-Note that the first three methods must be implemented. ``getSOA()`` has
+Note that the first four methods must be implemented. ``getSOA()`` has
a useful default implementation.
The semantics are simple. Each instance of your class only handles one
class RandomBackend : public DNSBackend
{
public:
+ unsigned int getCapabilities() override { return 0; }
+
bool list(const string &target, int id)
{
- return false; // we don't support AXFR
+ return false; // we don't support pdnsutil list-zone or AXFR
}
void lookup(const QType &type, const string &qdomain, int zoneId, DNSPacket *p)
as 'overlay', makes the zone incompatible with some operations that
assume that a single zone is always entirely stored in the same backend.
Such operations include zone transfers, listing and editing zone content via
- the API or :doc:`pdnsutil <pdnsutil>`.
+ the API or :doc:`pdnsutil <../manpages/pdnsutil.1>`.
.. warning::
When the content of a zone is spread across multiple backends, all the types
Methods
~~~~~~~
+.. cpp:function:: unsigned int getCapabilities()
+
+ This function returns a bitmask representing various capabilities of
+ the backend. The currently used capabilities are:
+
+* `CAP_DNSSEC` Backend implements :ref:`backend-dnssec`.
+* `CAP_LIST` Backend implements `list`, for AXFR or `pdnsutil list-zone`
+
.. cpp:function:: void DNSBackend::lookup(const QType &qtype, const string &qdomain, int zoneId=-1, DNSPacket *pkt=nullptr)
This function is used to initiate a straight lookup for a record of name
/* ... */
}
+.. _backend-dnssec:
+
DNSSEC support
--------------
class DNSBackend {
public:
+ virtual unsigned int getCapabilities();
+
/* ... */
- virtual bool doesDNSSEC();
virtual bool getBeforeAndAfterNamesAbsolute(uint32_t id, const DNSName& qname, DNSName& unhashed, DNSName& before, DNSName& after);
/* update operations */
/* ... */
}
-.. cpp:function:: virtual bool doesDNSSEC()
-
- Returns true if that backend supports DNSSEC.
+In addition to these methods, the return value of `getCapabilities` must
+contain `CAP_DNSSEC` if that backend supports DNSSEC.
.. cpp:function:: virtual bool getBeforeAndAfterNamesAbsolute(uint32_t id, const DNSName& qname, DNSName& unhashed, DNSName& before, DNSName& after)
public:
Bind2Backend(const string& suffix = "", bool loadZones = true);
~Bind2Backend() override;
+ unsigned int getCapabilities() override;
void getUnfreshSecondaryInfos(vector<DomainInfo>* unfreshDomains) override;
void getUpdatedPrimaries(vector<DomainInfo>& changedDomains, std::unordered_set<DNSName>& catalogs, CatalogHashMap& catalogHashes) override;
bool getDomainInfo(const DNSName& domain, DomainInfo& di, bool getSerial = true) override;
bool setTSIGKey(const DNSName& name, const DNSName& algorithm, const string& content) override;
bool deleteTSIGKey(const DNSName& name) override;
bool getTSIGKeys(std::vector<struct TSIGKey>& keys) override;
- bool doesDNSSEC() override;
// end of DNSSEC
typedef multi_index_container<BB2DomainInfo,
}
}
-bool Bind2Backend::doesDNSSEC()
+unsigned int Bind2Backend::getCapabilities()
{
- return d_hybrid;
+ if (d_hybrid) {
+ return CAP_DNSSEC | CAP_LIST;
+ }
+ else {
+ return CAP_LIST;
+ }
}
bool Bind2Backend::getNSEC3PARAM(const DNSName& /* name */, NSEC3PARAMRecordContent* /* ns3p */)
d_getTSIGKeysQuery_stmt.reset();
}
-bool Bind2Backend::doesDNSSEC()
+unsigned int Bind2Backend::getCapabilities()
{
- return d_dnssecdb || d_hybrid;
+ if (d_dnssecdb || d_hybrid) {
+ return CAP_DNSSEC | CAP_LIST;
+ }
+ return CAP_LIST;
}
bool Bind2Backend::getNSEC3PARAM(const DNSName& name, NSEC3PARAMRecordContent* ns3p)
GeoIPBackend(const std::string& suffix = "");
~GeoIPBackend() override;
+ unsigned int getCapabilities() override
+ {
+ if (d_dnssec) {
+ return CAP_DNSSEC;
+ }
+ else {
+ return 0;
+ }
+ }
+
void lookup(const QType& qtype, const DNSName& qdomain, int zoneId, DNSPacket* pkt_p = nullptr) override;
bool list(const DNSName& /* target */, int /* domain_id */, bool /* include_disabled */ = false) override { return false; } // not supported
bool get(DNSResourceRecord& r) override;
void getAllDomains(vector<DomainInfo>* domains, bool getSerial, bool include_disabled) override;
// dnssec support
- bool doesDNSSEC() override { return d_dnssec; };
bool getAllDomainMetadata(const DNSName& name, std::map<std::string, std::vector<std::string>>& meta) override;
bool getDomainMetadata(const DNSName& name, const std::string& kind, std::vector<std::string>& meta) override;
bool getDomainKeys(const DNSName& name, std::vector<DNSBackend::KeyData>& keys) override;
~LdapBackend() override;
// Native backend
+ unsigned int getCapabilities() override { return CAP_LIST; }
bool list(const DNSName& target, int domain_id, bool include_disabled = false) override;
void lookup(const QType& qtype, const DNSName& qdomain, int zoneid, DNSPacket* p = nullptr) override;
bool get(DNSResourceRecord& rr) override;
explicit LMDBBackend(const string& suffix = "");
~LMDBBackend();
+ unsigned int getCapabilities() override { return CAP_DNSSEC | CAP_DIRECT | CAP_LIST; }
bool list(const DNSName& target, int id, bool include_disabled) override;
bool getDomainInfo(const DNSName& domain, DomainInfo& di, bool getserial = true) override;
bool updateEmptyNonTerminals(uint32_t domain_id, set<DNSName>& insert, set<DNSName>& erase, bool remove) override;
- bool doesDNSSEC() override
- {
- return true;
- }
-
// other
string directBackendCmd(const string& query) override;
}
}
- bool doesDNSSEC() override
+ unsigned int getCapabilities() override
{
- return d_dnssec;
+ if (d_dnssec) {
+ return CAP_DNSSEC | CAP_DIRECT | CAP_LIST;
+ }
+ else {
+ return CAP_DIRECT | CAP_LIST;
+ }
}
void parseLookup(const lookup_result_t& result)
public:
PipeBackend(const string& suffix = "");
~PipeBackend() override;
+
+ unsigned int getCapabilities() override { return CAP_DIRECT | CAP_LIST; }
void lookup(const QType&, const DNSName& qdomain, int zoneId, DNSPacket* p = nullptr) override;
bool list(const DNSName& target, int domain_id, bool include_disabled = false) override;
bool get(DNSResourceRecord& r) override;
return this->send(query) && this->recv(answer);
}
-bool RemoteBackend::doesDNSSEC()
+unsigned int RemoteBackend::getCapabilities()
{
- return d_dnssec;
+ if (d_dnssec) {
+ return CAP_DNSSEC | CAP_DIRECT | CAP_LIST;
+ }
+ return CAP_DIRECT | CAP_LIST;
}
bool RemoteBackend::getTSIGKey(const DNSName& name, DNSName& algorithm, std::string& content)
RemoteBackend(const std::string& suffix = "");
~RemoteBackend() override;
+ unsigned int getCapabilities() override;
void lookup(const QType& qtype, const DNSName& qdomain, int zoneId = -1, DNSPacket* pkt_p = nullptr) override;
bool get(DNSResourceRecord& rr) override;
bool list(const DNSName& target, int domain_id, bool include_disabled = false) override;
bool unpublishDomainKey(const DNSName& name, unsigned int id) override;
bool getDomainInfo(const DNSName& domain, DomainInfo& di, bool getSerial = true) override;
void setNotified(uint32_t id, uint32_t serial) override;
- bool doesDNSSEC() override;
bool autoPrimaryBackend(const string& ip, const DNSName& domain, const vector<DNSResourceRecord>& nsset, string* nameserver, string* account, DNSBackend** ddb) override;
bool createSecondaryDomain(const string& ip, const DNSName& domain, const string& nameserver, const string& account) override;
bool replaceRRSet(uint32_t domain_id, const DNSName& qname, const QType& qt, const vector<DNSResourceRecord>& rrset) override;
public:
// Methods for simple operation
TinyDNSBackend(const string& suffix);
+
+ unsigned int getCapabilities() override { return CAP_LIST; }
void lookup(const QType& qtype, const DNSName& qdomain, int zoneId, DNSPacket* pkt_p = nullptr) override;
bool list(const DNSName& target, int domain_id, bool include_disabled = false) override;
bool get(DNSResourceRecord& rr) override;
return true;
}
-bool GSQLBackend::doesDNSSEC()
+unsigned int GSQLBackend::getCapabilities()
{
- return d_dnssecQueries;
+ if (d_dnssecQueries) {
+ return CAP_DNSSEC | CAP_COMMENTS | CAP_DIRECT | CAP_LIST;
+ }
+ return CAP_COMMENTS | CAP_DIRECT | CAP_LIST;
}
bool GSQLBackend::getBeforeAndAfterNamesAbsolute(uint32_t id, const DNSName& qname, DNSName& unhashed, DNSName& before, DNSName& after)
}
public:
+ unsigned int getCapabilities() override;
void lookup(const QType &, const DNSName &qdomain, int zoneId, DNSPacket *p=nullptr) override;
bool list(const DNSName &target, int domain_id, bool include_disabled=false) override;
bool get(DNSResourceRecord &r) override;
bool updateDNSSECOrderNameAndAuth(uint32_t domain_id, const DNSName& qname, const DNSName& ordername, bool auth, const uint16_t=QType::ANY) override;
bool updateEmptyNonTerminals(uint32_t domain_id, set<DNSName>& insert ,set<DNSName>& erase, bool remove) override;
- bool doesDNSSEC() override;
bool replaceRRSet(uint32_t domain_id, const DNSName& qname, const QType& qt, const vector<DNSResourceRecord>& rrset) override;
bool listSubZone(const DNSName &zone, int domain_id) override;
class DNSBackend
{
public:
+ enum Capabilities : unsigned int
+ {
+ CAP_DNSSEC = 1 << 0, // Backend supports DNSSEC
+ CAP_COMMENTS = 1 << 1, // Backend supports comments
+ CAP_DIRECT = 1 << 2, // Backend supports direct commands
+ CAP_LIST = 1 << 3, // Backend supports record enumeration
+ };
+
+ virtual unsigned int getCapabilities() = 0;
+
//! lookup() initiates a lookup. A lookup without results should not throw!
virtual void lookup(const QType& qtype, const DNSName& qdomain, int zoneId = -1, DNSPacket* pkt_p = nullptr) = 0;
virtual bool get(DNSResourceRecord&) = 0; //!< retrieves one DNSResource record, returns false if no more were available
return false;
}
- virtual bool doesDNSSEC()
+ bool doesDNSSEC()
{
- return false;
+ return (getCapabilities() & CAP_DNSSEC) != 0;
}
// end DNSSEC
{
}
+ unsigned int getCapabilities() override { return CAP_LIST; }
+
bool findZone(const DNSName& qdomain, int zoneId, std::shared_ptr<RecordStorage>& records, uint64_t& currentZoneId) const
{
currentZoneId = -1;