• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

PowerDNS / pdns / 17941943036

23 Sep 2025 09:42AM UTC coverage: 65.321% (+3.5%) from 61.793%
17941943036

push

github

web-flow
Merge pull request #16163 from omoerbeek/link-ai-policy

PR template: Make the mention of the AI policy a link

42049 of 92930 branches covered (45.25%)

Branch coverage included in aggregate %.

128027 of 167439 relevant lines covered (76.46%)

4168390.92 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/modules/tinydnsbackend/tinydnsbackend.hh
1
/*
2
 * This file is part of PowerDNS or dnsdist.
3
 * Copyright -- PowerDNS.COM B.V. and its contributors
4
 *
5
 * This program is free software; you can redistribute it and/or modify
6
 * it under the terms of version 2 of the GNU General Public License as
7
 * published by the Free Software Foundation.
8
 *
9
 * In addition, for the avoidance of any doubt, permission is granted to
10
 * link this program with OpenSSL and to (re)distribute the binaries
11
 * produced as the result of such linking.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program; if not, write to the Free Software
20
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21
 */
22
#pragma once
23
#include "pdns/dnsbackend.hh"
24
#include "pdns/logger.hh"
25
#include "pdns/iputils.hh"
26
#include "pdns/dnspacket.hh"
27
#include <sys/types.h>
28
#include <sys/stat.h>
29
#include <fcntl.h>
30
#include "pdns/cdb.hh"
31
#include "pdns/lock.hh"
32
#include <boost/multi_index_container.hpp>
33
#include <boost/multi_index/hashed_index.hpp>
34
#include <boost/multi_index/member.hpp>
35

36
using namespace ::boost;
37
using namespace ::boost::multi_index;
38

39
struct TinyDomainInfo
40
{
41
  domainid_t id;
42
  uint32_t notified_serial;
43
  ZoneName zone;
44

45
  bool operator<(const TinyDomainInfo& tdi) const
46
  {
×
47
    return zone < tdi.zone;
×
48
  }
×
49
};
50

51
struct TDI_SerialModifier
52
{
53
  TDI_SerialModifier(const int newSerial) :
54
    d_newSerial(newSerial) {}
×
55

56
  void operator()(TinyDomainInfo& tdi)
57
  {
×
58
    tdi.notified_serial = d_newSerial;
×
59
  }
×
60

61
private:
62
  int d_newSerial;
63
};
64

65
class TinyDNSBackend : public DNSBackend
66
{
67
public:
68
  // Methods for simple operation
69
  TinyDNSBackend(const string& suffix);
70

71
  unsigned int getCapabilities() override { return CAP_LIST | CAP_SEARCH; }
×
72
  void lookup(const QType& qtype, const DNSName& qdomain, domainid_t zoneId, DNSPacket* pkt_p = nullptr) override;
73
  bool list(const ZoneName& target, domainid_t domain_id, bool include_disabled = false) override;
74
  bool get(DNSResourceRecord& rr) override;
75
  bool getDomainInfo(const ZoneName& domain, DomainInfo& di, bool getSerial = true) override;
76
  void getAllDomains(vector<DomainInfo>* domains, bool getSerial, bool include_disabled) override;
77

78
  // Primary mode operation
79
  void getUpdatedPrimaries(vector<DomainInfo>& domains, std::unordered_set<DNSName>& catalogs, CatalogHashMap& catalogHashes) override;
80
  void setNotified(domainid_t id, uint32_t serial) override;
81

82
private:
83
  //TypeDefs
84
  struct tag_zone
85
  {
86
  };
87
  struct tag_domainid
88
  {
89
  };
90
  typedef multi_index_container<
91
    TinyDomainInfo,
92
    indexed_by<
93
      hashed_unique<tag<tag_zone>, member<TinyDomainInfo, ZoneName, &TinyDomainInfo::zone>>,
94
      hashed_unique<tag<tag_domainid>, member<TinyDomainInfo, domainid_t, &TinyDomainInfo::id>>>>
95
    TDI_t;
96
  typedef map<string, TDI_t> TDI_suffix_t;
97
  typedef TDI_t::index<tag_zone>::type TDIByZone_t;
98
  typedef TDI_t::index<tag_domainid>::type TDIById_t;
99

100
  vector<string> getLocations();
101
  static TDI_t::iterator updateState(DomainInfo& domain, TDI_t* state);
102
  void getAllDomains_locked(vector<DomainInfo>* domains, bool getSerial);
103

104
  //data member variables
105
  uint64_t d_taiepoch;
106
  QType d_qtype;
107
  std::unique_ptr<CDB> d_cdbReader;
108
  domainid_t d_currentDomain{UnknownDomainID}; // domain id to return with data obtained from d_cdbReader above.
109
  DNSPacket* d_dnspacket; // used for location and edns-client support.
110
  bool d_isWildcardQuery; // Indicate if the query received was a wildcard query.
111
  bool d_isAxfr; // Indicate if we received a list() and not a lookup().
112
  bool d_isGetDomains{false};
113
  bool d_locations;
114
  bool d_ignorebogus;
115
  string d_suffix;
116

117
  // Statics
118
  static LockGuarded<TDI_suffix_t> s_domainInfo;
119
  static domainid_t s_lastId; // used to give a domain an id.
120
};
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc