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

PowerDNS / pdns / 18464791347

13 Oct 2025 11:49AM UTC coverage: 64.043% (-0.008%) from 64.051%
18464791347

push

github

web-flow
Merge pull request #16240 from miodvallat/lua_and_order

auth: boring changes to lua backend

42896 of 101718 branches covered (42.17%)

Branch coverage included in aggregate %.

74 of 167 new or added lines in 1 file covered. (44.31%)

37 existing lines in 8 files now uncovered.

130290 of 168702 relevant lines covered (77.23%)

5255354.44 hits per line

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

53.26
/modules/lua2backend/lua2api2.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
 * MERCHANTAPILITY 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 "boost/algorithm/string/join.hpp"
24
#include "pdns/arguments.hh"
25

26
#include "pdns/dnsbackend.hh"
27
#include "pdns/lua-auth4.hh"
28

29
class Lua2BackendAPIv2 : public DNSBackend, AuthLua4
30
{
31
private:
32
  typedef std::function<void()> init_call_t;
33
  typedef std::function<void()> deinit_call_t;
34

35
  typedef std::vector<std::pair<string, string>> lookup_context_t;
36

37
  typedef std::vector<std::pair<int, std::vector<std::pair<string, boost::variant<bool, int, DNSName, string, QType>>>>> lookup_result_t;
38
  typedef std::function<lookup_result_t(const QType& qtype, const DNSName& qname, domainid_t domain_id, const lookup_context_t& ctx)> lookup_call_t;
39

40
  typedef boost::variant<bool, lookup_result_t> list_result_t;
41
  typedef std::function<list_result_t(const DNSName& qname, domainid_t domain_id)> list_call_t;
42

43
  typedef vector<pair<string, boost::variant<bool, long, string, vector<string>>>> domaininfo_result_t;
44
  typedef boost::variant<bool, domaininfo_result_t> get_domaininfo_result_t;
45
  typedef vector<pair<DNSName, domaininfo_result_t>> get_all_domains_result_t;
46
  typedef std::function<get_domaininfo_result_t(const DNSName& domain)> get_domaininfo_call_t;
47
  typedef std::function<get_all_domains_result_t()> get_all_domains_call_t;
48

49
  typedef vector<pair<int, string>> domain_metadata_result_t;
50
  typedef boost::variant<bool, domain_metadata_result_t> get_domain_metadata_result_t;
51
  typedef boost::variant<bool, vector<pair<string, domain_metadata_result_t>>> get_all_domain_metadata_result_t;
52
  typedef std::function<get_domain_metadata_result_t(const DNSName& domain, const string& kind)> get_domain_metadata_call_t;
53
  typedef std::function<get_all_domain_metadata_result_t(const DNSName& domain)> get_all_domain_metadata_call_t;
54

55
  typedef vector<pair<string, boost::variant<bool, int, string>>> keydata_result_t;
56
  typedef boost::variant<bool, vector<pair<int, keydata_result_t>>> get_domain_keys_result_t;
57
  typedef std::function<get_domain_keys_result_t(const DNSName& domain)> get_domain_keys_call_t;
58

59
  typedef std::vector<std::pair<string, boost::variant<string, DNSName>>> before_and_after_names_result_t;
60
  typedef boost::variant<bool, before_and_after_names_result_t> get_before_and_after_names_absolute_result_t;
61
  typedef std::function<get_before_and_after_names_absolute_result_t(domainid_t id, const DNSName& qname)> get_before_and_after_names_absolute_call_t;
62

63
  typedef std::function<void(domainid_t, long)> set_notified_call_t;
64

65
  typedef std::function<string(const string& cmd)> direct_backend_cmd_call_t;
66

67
public:
68
  Lua2BackendAPIv2(const string& suffix)
69
  {
21✔
70
    d_include_path = ::arg()["lua-global-include-dir"];
21✔
71
    setArgPrefix("lua2" + suffix);
21✔
72
    d_debug_log = mustDo("query-logging");
21✔
73
    prepareContext();
21✔
74
    loadFile(getArg("filename"));
21✔
75
  }
21✔
76

77
  ~Lua2BackendAPIv2() override;
78

79
  void postPrepareContext() override
80
  {
21✔
81
    AuthLua4::postPrepareContext();
21✔
82
  }
21✔
83

84
  void postLoad() override
85
  {
21✔
86
    f_lookup = d_lw->readVariable<boost::optional<lookup_call_t>>("dns_lookup").get_value_or(0);
21✔
87
    f_list = d_lw->readVariable<boost::optional<list_call_t>>("dns_list").get_value_or(0);
21✔
88
    f_get_all_domains = d_lw->readVariable<boost::optional<get_all_domains_call_t>>("dns_get_all_domains").get_value_or(0);
21✔
89
    f_get_domaininfo = d_lw->readVariable<boost::optional<get_domaininfo_call_t>>("dns_get_domaininfo").get_value_or(0);
21✔
90
    f_get_domain_metadata = d_lw->readVariable<boost::optional<get_domain_metadata_call_t>>("dns_get_domain_metadata").get_value_or(0);
21✔
91
    f_get_all_domain_metadata = d_lw->readVariable<boost::optional<get_all_domain_metadata_call_t>>("dns_get_all_domain_metadata").get_value_or(0);
21✔
92
    f_get_domain_keys = d_lw->readVariable<boost::optional<get_domain_keys_call_t>>("dns_get_domain_keys").get_value_or(0);
21✔
93
    f_get_before_and_after_names_absolute = d_lw->readVariable<boost::optional<get_before_and_after_names_absolute_call_t>>("dns_get_before_and_after_names_absolute").get_value_or(0);
21✔
94
    f_set_notified = d_lw->readVariable<boost::optional<set_notified_call_t>>("dns_set_notified").get_value_or(0);
21✔
95

96
    auto init = d_lw->readVariable<boost::optional<init_call_t>>("dns_init").get_value_or(0);
21✔
97
    if (init) {
21!
98
      init();
×
NEW
99
    }
×
100

101
    f_deinit = d_lw->readVariable<boost::optional<deinit_call_t>>("dns_deinit").get_value_or(0);
21✔
102

103
    if (f_lookup == nullptr) {
21!
104
      throw PDNSException("dns_lookup missing");
×
NEW
105
    }
×
106

107
    /* see if dnssec support is wanted */
108
    d_dnssec = d_lw->readVariable<boost::optional<bool>>("dns_dnssec").get_value_or(false);
21✔
109
    if (d_dnssec) {
21✔
110
      if (f_get_domain_metadata == nullptr) {
14!
111
        throw PDNSException("dns_dnssec is true but dns_get_domain_metadata is missing");
×
NEW
112
      }
×
113
      if (f_get_before_and_after_names_absolute == nullptr) {
14!
UNCOV
114
        throw PDNSException("dns_dnssec is true but dns_get_before_and_after_names_absolute is missing");
×
NEW
115
      }
×
116
      /* domain keys is not strictly speaking necessary for dnssec backend */
117
      if (f_get_domain_keys == nullptr) {
14!
118
        g_log << Logger::Warning << "dns_get_domain_keys missing - cannot do live signing" << endl;
×
NEW
119
      }
×
120
    }
14✔
121
  }
21✔
122

123
  unsigned int getCapabilities() override
124
  {
6✔
125
    unsigned int caps = CAP_DIRECT | CAP_LIST;
6✔
126
    if (d_dnssec) {
6!
127
      caps |= CAP_DNSSEC;
6✔
128
    }
6✔
129
    if (f_get_all_domains != nullptr) {
6!
130
      caps |= CAP_SEARCH;
6✔
131
    }
6✔
132
    return caps;
6✔
133
  }
6✔
134

135
  void parseLookup(const lookup_result_t& result)
136
  {
29✔
137
    for (const auto& row : result) {
103✔
138
      DNSResourceRecord rec;
103✔
139
      for (const auto& item : row.second) {
437✔
140
        if (item.first == "type") {
437✔
141
          if (item.second.which() == 1) {
103!
142
            rec.qtype = QType(boost::get<int>(item.second));
×
NEW
143
          }
×
144
          else if (item.second.which() == 3) {
103!
UNCOV
145
            rec.qtype = boost::get<string>(item.second);
×
NEW
146
          }
×
147
          else if (item.second.which() == 4) {
103!
148
            rec.qtype = boost::get<QType>(item.second);
103✔
149
          }
103✔
NEW
150
          else {
×
UNCOV
151
            throw PDNSException("Unsupported value for type");
×
NEW
152
          }
×
153
        }
103✔
154
        else if (item.first == "name") {
334✔
155
          if (item.second.which() == 3) {
103!
156
            rec.qname = DNSName(boost::get<string>(item.second));
×
NEW
157
          }
×
158
          else if (item.second.which() == 2) {
103!
159
            rec.qname = boost::get<DNSName>(item.second);
103✔
160
          }
103✔
NEW
161
          else {
×
UNCOV
162
            throw PDNSException("Unsupported value for name");
×
NEW
163
          }
×
164
        }
103✔
165
        else if (item.first == "domain_id") {
231✔
166
          rec.domain_id = boost::get<int>(item.second);
25✔
167
        }
25✔
168
        else if (item.first == "auth") {
206!
UNCOV
169
          rec.auth = boost::get<bool>(item.second);
×
NEW
170
        }
×
171
        else if (item.first == "last_modified") {
206!
UNCOV
172
          rec.last_modified = static_cast<time_t>(boost::get<int>(item.second));
×
NEW
173
        }
×
174
        else if (item.first == "ttl") {
206✔
175
          rec.ttl = boost::get<int>(item.second);
103✔
176
        }
103✔
177
        else if (item.first == "content") {
103!
178
          rec.setContent(boost::get<string>(item.second));
103✔
179
        }
103✔
NEW
180
        else if (item.first == "scopeMask") {
×
181
          rec.scopeMask = boost::get<int>(item.second);
×
NEW
182
        }
×
NEW
183
        else {
×
UNCOV
184
          g_log << Logger::Warning << "Unsupported key '" << item.first << "' in lookup or list result" << endl;
×
NEW
185
        }
×
186
      }
437✔
187
      if (d_debug_log) {
103!
NEW
188
        g_log << Logger::Debug << "[" << getPrefix() << "] Got result " << "'" << rec.qname << " IN " << rec.qtype.toString() << " " << rec.ttl << " " << rec.getZoneRepresentation() << "'" << endl;
×
UNCOV
189
      }
×
190
      d_result.push_back(rec);
103✔
191
    }
103✔
192
    if (d_result.empty() && d_debug_log) {
29!
193
      g_log << Logger::Debug << "[" << getPrefix() << "] Got empty result" << endl;
×
NEW
194
    }
×
195
  }
29✔
196

197
  bool list(const ZoneName& target, domainid_t domain_id, bool /* include_disabled */ = false) override
198
  {
6✔
199
    if (f_list == nullptr) {
6!
200
      g_log << Logger::Error << "[" << getPrefix() << "] dns_list missing - cannot do AXFR" << endl;
×
201
      return false;
×
202
    }
×
203

204
    if (d_result.size() != 0) {
6!
205
      throw PDNSException("list attempted while another was running");
×
NEW
206
    }
×
207

208
    if (d_debug_log) {
6!
NEW
209
      g_log << Logger::Debug << "[" << getPrefix() << "] Calling " << "list" << "(" << "target=" << target << ",domain_id=" << domain_id << ")" << endl;
×
NEW
210
    }
×
211
    list_result_t result = f_list(target.operator const DNSName&(), domain_id);
6✔
212

213
    if (result.which() == 0) {
6!
214
      return false;
×
NEW
215
    }
×
216

217
    parseLookup(boost::get<lookup_result_t>(result));
6✔
218

219
    return true;
6✔
220
  }
6✔
221

222
  void lookup(const QType& qtype, const DNSName& qname, domainid_t domain_id, DNSPacket* p = nullptr) override
223
  {
23✔
224
    if (d_result.size() != 0) {
23!
225
      throw PDNSException("lookup attempted while another was running");
×
NEW
226
    }
×
227

228
    lookup_context_t ctx;
23✔
229
    if (p != NULL) {
23✔
230
      ctx.emplace_back(lookup_context_t::value_type{"source_address", p->getInnerRemote().toString()});
5✔
231
      ctx.emplace_back(lookup_context_t::value_type{"real_source_address", p->getRealRemote().toString()});
5✔
232
    }
5✔
233

234
    if (d_debug_log) {
23!
NEW
235
      g_log << Logger::Debug << "[" << getPrefix() << "] Calling " << "lookup" << "(" << "qtype=" << qtype.toString() << ",qname=" << qname << ",domain_id=" << domain_id << ")" << endl;
×
NEW
236
    }
×
237
    lookup_result_t result = f_lookup(qtype, qname, domain_id, ctx);
23✔
238
    parseLookup(result);
23✔
239
  }
23✔
240

241
  bool get(DNSResourceRecord& rr) override
242
  {
132✔
243
    if (d_result.size() == 0) {
132✔
244
      return false;
29✔
245
    }
29✔
246
    rr = std::move(d_result.front());
103✔
247
    d_result.pop_front();
103✔
248
    return true;
103✔
249
  }
132✔
250

251
  string directBackendCmd(const string& querystr) override
252
  {
×
253
    string::size_type pos = querystr.find_first_of(" \t");
×
254
    string cmd = querystr;
×
255
    string par = "";
×
256
    if (pos != string::npos) {
×
257
      cmd = querystr.substr(0, pos);
×
258
      par = querystr.substr(pos + 1);
×
259
    }
×
260
    direct_backend_cmd_call_t f = d_lw->readVariable<boost::optional<direct_backend_cmd_call_t>>(cmd).get_value_or(0);
×
261
    if (f == nullptr) {
×
262
      return cmd + "not found";
×
263
    }
×
NEW
264
    if (d_debug_log) {
×
NEW
265
      g_log << Logger::Debug << "[" << getPrefix() << "] Calling " << cmd << "(" << "parameter=" << par << ")" << endl;
×
NEW
266
    }
×
267
    return f(par);
×
268
  }
×
269

270
  void setNotified(domainid_t id, uint32_t serial) override
271
  {
×
NEW
272
    if (f_set_notified == NULL) {
×
273
      return;
×
NEW
274
    }
×
NEW
275
    if (d_debug_log) {
×
NEW
276
      g_log << Logger::Debug << "[" << getPrefix() << "] Calling " << "dns_set_notified" << "(" << "id=" << id << ",serial=" << serial << ")" << endl;
×
NEW
277
    }
×
278
    f_set_notified(id, serial);
×
279
  }
×
280

281
  void parseDomainInfo(const domaininfo_result_t& row, DomainInfo& di)
282
  {
5✔
283
    di.id = UnknownDomainID;
5✔
284
    for (const auto& item : row) {
10✔
285
      if (item.first == "account") {
10!
286
        di.account = boost::get<string>(item.second);
×
NEW
287
      }
×
288
      else if (item.first == "last_check") {
10!
UNCOV
289
        di.last_check = static_cast<time_t>(boost::get<long>(item.second));
×
NEW
290
      }
×
291
      else if (item.first == "masters") {
10!
NEW
292
        for (const auto& primary : boost::get<vector<string>>(item.second)) {
×
UNCOV
293
          di.primaries.push_back(ComboAddress(primary, 53));
×
NEW
294
        }
×
NEW
295
      }
×
296
      else if (item.first == "id") {
10✔
297
        di.id = static_cast<domainid_t>(boost::get<long>(item.second));
5✔
298
      }
5✔
299
      else if (item.first == "notified_serial") {
5!
UNCOV
300
        di.notified_serial = static_cast<unsigned int>(boost::get<long>(item.second));
×
NEW
301
      }
×
302
      else if (item.first == "serial") {
5!
303
        di.serial = static_cast<unsigned int>(boost::get<long>(item.second));
5✔
304
      }
5✔
NEW
305
      else if (item.first == "kind") {
×
306
        di.kind = DomainInfo::stringToKind(boost::get<string>(item.second));
×
NEW
307
      }
×
NEW
308
      else {
×
UNCOV
309
        g_log << Logger::Warning << "Unsupported key '" << item.first << "' in domaininfo result" << endl;
×
NEW
310
      }
×
311
    }
10✔
312
    di.backend = this;
5✔
313
    if (d_debug_log) {
5!
NEW
314
      g_log << Logger::Debug << "[" << getPrefix() << "] Got result " << "'" << "zone=" << di.zone << ",serial=" << di.serial << ",kind=" << di.getKindString() << "'" << endl;
×
NEW
315
    }
×
316
  }
5✔
317

318
  bool getDomainInfo(const ZoneName& domain, DomainInfo& di, bool /* getSerial */ = true) override
319
  {
6✔
320
    if (f_get_domaininfo == nullptr) {
6✔
321
      // use getAuth instead... but getAuth wraps getSOA which will call
322
      // getDomainInfo if this is a domain variant, so protect against this
323
      // would-be infinite recursion.
324
      if (domain.hasVariant()) {
3!
325
        g_log << Logger::Info << "Unable to return domain information for '" << domain.toLogString() << "' due to unimplemented dns_get_domaininfo" << endl;
×
326
        return false;
×
327
      }
×
328
      SOAData sd;
3✔
329
      if (!getAuth(domain, &sd)) {
3!
330
        return false;
×
NEW
331
      }
×
332

333
      di.id = sd.domain_id;
3✔
334
      di.zone = domain;
3✔
335
      di.backend = this;
3✔
336
      di.serial = sd.serial;
3✔
337
      return true;
3✔
338
    }
3✔
339

340
    if (d_debug_log) {
3!
NEW
341
      g_log << Logger::Debug << "[" << getPrefix() << "] Calling " << "get_domaininfo" << "(" << "domain=" << domain << ")" << endl;
×
NEW
342
    }
×
343
    get_domaininfo_result_t result = f_get_domaininfo(domain.operator const DNSName&());
3✔
344

345
    if (result.which() == 0) {
3!
346
      return false;
×
NEW
347
    }
×
348

349
    di.zone = domain;
3✔
350
    parseDomainInfo(boost::get<domaininfo_result_t>(result), di);
3✔
351

352
    return true;
3✔
353
  }
3✔
354

355
  void getAllDomains(vector<DomainInfo>* domains, bool /* getSerial */, bool /* include_disabled */) override
356
  {
1✔
357
    if (f_get_all_domains == nullptr) {
1!
358
      return;
×
NEW
359
    }
×
360

361
    if (d_debug_log) {
1!
NEW
362
      g_log << Logger::Debug << "[" << getPrefix() << "] Calling " << "get_all_domains" << "(" << "" << ")" << endl;
×
NEW
363
    }
×
364
    for (const auto& row : f_get_all_domains()) {
2✔
365
      DomainInfo di;
2✔
366
      di.zone = ZoneName(row.first);
2✔
367
      if (d_debug_log) {
2!
NEW
368
        g_log << Logger::Debug << "[" << getPrefix() << "] Got result " << "'" << di.zone << "'" << endl;
×
NEW
369
      }
×
370
      parseDomainInfo(row.second, di);
2✔
371
      domains->push_back(di);
2✔
372
    }
2✔
373
  }
1✔
374

375
  bool getAllDomainMetadata(const ZoneName& name, std::map<std::string, std::vector<std::string>>& meta) override
376
  {
6✔
377
    if (f_get_all_domain_metadata == nullptr) {
6!
378
      return false;
6✔
379
    }
6✔
380

NEW
381
    if (d_debug_log) {
×
NEW
382
      g_log << Logger::Debug << "[" << getPrefix() << "] Calling " << "get_all_domain_metadata" << "(" << "name=" << name << ")" << endl;
×
NEW
383
    }
×
384
    get_all_domain_metadata_result_t result = f_get_all_domain_metadata(name.operator const DNSName&());
×
NEW
385
    if (result.which() == 0) {
×
386
      return false;
×
NEW
387
    }
×
388

389
    for (const auto& row : boost::get<vector<pair<string, domain_metadata_result_t>>>(result)) {
×
390
      meta[row.first].clear();
×
NEW
391
      for (const auto& item : row.second) {
×
392
        meta[row.first].push_back(item.second);
×
NEW
393
      }
×
NEW
394
      if (d_debug_log) {
×
NEW
395
        g_log << Logger::Debug << "[" << getPrefix() << "] Got result " << "'" << "kind=" << row.first << ",value=" << boost::algorithm::join(meta[row.first], ", ") << "'" << endl;
×
NEW
396
      }
×
UNCOV
397
    }
×
398

399
    return true;
×
400
  }
×
401

402
  bool getDomainMetadata(const ZoneName& name, const std::string& kind, std::vector<std::string>& meta) override
403
  {
×
NEW
404
    if (f_get_domain_metadata == nullptr) {
×
405
      return false;
×
NEW
406
    }
×
407

NEW
408
    if (d_debug_log) {
×
NEW
409
      g_log << Logger::Debug << "[" << getPrefix() << "] Calling " << "get_domain_metadata" << "(" << "name=" << name << ",kind=" << kind << ")" << endl;
×
NEW
410
    }
×
411
    get_domain_metadata_result_t result = f_get_domain_metadata(name.operator const DNSName&(), kind);
×
NEW
412
    if (result.which() == 0) {
×
413
      return false;
×
NEW
414
    }
×
415

416
    meta.clear();
×
NEW
417
    for (const auto& item : boost::get<domain_metadata_result_t>(result)) {
×
418
      meta.push_back(item.second);
×
NEW
419
    }
×
420

NEW
421
    if (d_debug_log) {
×
NEW
422
      g_log << Logger::Debug << "[" << getPrefix() << "] Got result " << "'" << "value=" << boost::algorithm::join(meta, ", ") << "'" << endl;
×
NEW
423
    }
×
424
    return true;
×
425
  }
×
426

427
  bool getDomainKeys(const ZoneName& name, std::vector<DNSBackend::KeyData>& keys) override
428
  {
6✔
429
    if (f_get_domain_keys == nullptr) {
6✔
430
      return false;
3✔
431
    }
3✔
432

433
    if (d_debug_log) {
3!
NEW
434
      g_log << Logger::Debug << "[" << getPrefix() << "] Calling " << "get_domain_keys" << "(" << "name=" << name << ")" << endl;
×
NEW
435
    }
×
436
    get_domain_keys_result_t result = f_get_domain_keys(name.operator const DNSName&());
3✔
437

438
    if (result.which() == 0) {
3!
439
      return false;
×
NEW
440
    }
×
441

442
    for (const auto& row : boost::get<vector<pair<int, keydata_result_t>>>(result)) {
6✔
443
      DNSBackend::KeyData key;
6✔
444
      key.published = true;
6✔
445
      for (const auto& item : row.second) {
24✔
446
        if (item.first == "content") {
24✔
447
          key.content = boost::get<string>(item.second);
6✔
448
        }
6✔
449
        else if (item.first == "id") {
18✔
450
          key.id = static_cast<unsigned int>(boost::get<int>(item.second));
6✔
451
        }
6✔
452
        else if (item.first == "flags") {
12✔
453
          key.flags = static_cast<unsigned int>(boost::get<int>(item.second));
6✔
454
        }
6✔
455
        else if (item.first == "active") {
6!
456
          key.active = boost::get<bool>(item.second);
6✔
457
        }
6✔
NEW
458
        else if (item.first == "published") {
×
459
          key.published = boost::get<bool>(item.second);
×
NEW
460
        }
×
NEW
461
        else {
×
UNCOV
462
          g_log << Logger::Warning << "[" << getPrefix() << "] Unsupported key '" << item.first << "' in keydata result" << endl;
×
NEW
463
        }
×
464
      }
24✔
465
      if (d_debug_log) {
6!
NEW
466
        g_log << Logger::Debug << "[" << getPrefix() << "] Got result " << "'" << "id=" << key.id << ",flags=" << key.flags << ",active=" << (key.active ? "true" : "false") << ",published=" << (key.published ? "true" : "false") << "'" << endl;
×
UNCOV
467
      }
×
468
      keys.emplace_back(std::move(key));
6✔
469
    }
6✔
470

471
    return true;
3✔
472
  }
3✔
473

474
  bool getBeforeAndAfterNamesAbsolute(domainid_t id, const DNSName& qname, DNSName& unhashed, DNSName& before, DNSName& after) override
475
  {
12✔
476
    if (f_get_before_and_after_names_absolute == nullptr) {
12!
477
      return false;
×
NEW
478
    }
×
479

480
    if (d_debug_log) {
12!
NEW
481
      g_log << Logger::Debug << "[" << getPrefix() << "] Calling " << "get_before_and_after_names_absolute" << "(" << "id=<<" << id << ",qname=" << qname << ")" << endl;
×
NEW
482
    }
×
483
    get_before_and_after_names_absolute_result_t result = f_get_before_and_after_names_absolute(id, qname);
12✔
484

485
    if (result.which() == 0) {
12!
486
      return false;
×
NEW
487
    }
×
488

489
    before_and_after_names_result_t row = boost::get<before_and_after_names_result_t>(result);
12✔
490
    if (row.size() != 3) {
12!
491
      g_log << Logger::Error << "Invalid result from dns_get_before_and_after_names_absolute, expected array with 3 items, got " << row.size() << "item(s)" << endl;
×
492
      return false;
×
493
    }
×
494
    for (const auto& item : row) {
36✔
495
      DNSName value;
36✔
496
      if (item.second.which() == 0) {
36!
497
        value = DNSName(boost::get<string>(item.second));
×
NEW
498
      }
×
499
      else {
36✔
500
        value = DNSName(boost::get<DNSName>(item.second));
36✔
501
      }
36✔
502
      if (item.first == "unhashed") {
36✔
503
        unhashed = value;
12✔
504
      }
12✔
505
      else if (item.first == "before") {
24✔
506
        before = value;
12✔
507
      }
12✔
508
      else if (item.first == "after") {
12!
509
        after = value;
12✔
510
      }
12✔
511
      else {
×
512
        g_log << Logger::Error << "Invalid result from dns_get_before_and_after_names_absolute, unexpected key " << item.first << endl;
×
513
        return false;
×
514
      }
×
515
    }
36✔
516

517
    if (d_debug_log) {
12!
NEW
518
      g_log << Logger::Debug << "[" << getPrefix() << "] Got result " << "'" << "unhashed=" << unhashed << ",before=" << before << ",after=" << after << "'" << endl;
×
NEW
519
    }
×
520
    return true;
12✔
521
  }
12✔
522

523
private:
524
  std::list<DNSResourceRecord> d_result;
525
  bool d_debug_log{false};
526
  bool d_dnssec{false};
527

528
  lookup_call_t f_lookup;
529
  list_call_t f_list;
530

531
  get_domaininfo_call_t f_get_domaininfo;
532
  get_all_domains_call_t f_get_all_domains;
533

534
  get_domain_metadata_call_t f_get_domain_metadata;
535
  get_all_domain_metadata_call_t f_get_all_domain_metadata;
536

537
  get_domain_keys_call_t f_get_domain_keys;
538

539
  get_before_and_after_names_absolute_call_t f_get_before_and_after_names_absolute;
540

541
  set_notified_call_t f_set_notified;
542

543
  deinit_call_t f_deinit;
544
};
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

© 2025 Coveralls, Inc