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

PowerDNS / pdns / 19347150143

13 Nov 2025 04:36PM UTC coverage: 61.588% (-11.5%) from 73.059%
19347150143

push

github

web-flow
Merge pull request #16494 from jsoref/codeql-unused-loop-iterator-name

Codeql unused loop iterator name

73081 of 185220 branches covered (39.46%)

Branch coverage included in aggregate %.

155550 of 186007 relevant lines covered (83.63%)

7024283.57 hits per line

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

52.01
/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
  {
48 ✔
81
    AuthLua4::postPrepareContext();
48 ✔
82
  }
83

×
84
  void postLoad() override
48 ✔
85
  {
86
    f_lookup = d_lw->readVariable<boost::optional<lookup_call_t>>("dns_lookup").get_value_or(0);
128 ✔
87
    f_list = d_lw->readVariable<boost::optional<list_call_t>>("dns_list").get_value_or(0);
128 ✔
88
    f_get_all_domains = d_lw->readVariable<boost::optional<get_all_domains_call_t>>("dns_get_all_domains").get_value_or(0);
×
89
    f_get_domaininfo = d_lw->readVariable<boost::optional<get_domaininfo_call_t>>("dns_get_domaininfo").get_value_or(0);
90
    f_get_domain_metadata = d_lw->readVariable<boost::optional<get_domain_metadata_call_t>>("dns_get_domain_metadata").get_value_or(0);
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);
128 ✔
92
    f_get_domain_keys = d_lw->readVariable<boost::optional<get_domain_keys_call_t>>("dns_get_domain_keys").get_value_or(0);
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);
94
    f_set_notified = d_lw->readVariable<boost::optional<set_notified_call_t>>("dns_set_notified").get_value_or(0);
21 ✔
95

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

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

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

21 ✔
107
    /* see if dnssec support is wanted */
21 ✔
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) {
21 !
111
        throw PDNSException("dns_dnssec is true but dns_get_domain_metadata is missing");
21 !
112
      }
113
      if (f_get_before_and_after_names_absolute == nullptr) {
15 !
114
        throw PDNSException("dns_dnssec is true but dns_get_before_and_after_names_absolute is missing");
21 ✔
115
      }
116
      /* domain keys is not strictly speaking necessary for dnssec backend */
21 !
117
      if (f_get_domain_keys == nullptr) {
×
118
        g_log << Logger::Warning << "dns_get_domain_keys missing - cannot do live signing" << endl;
×
119
      }
×
120
    }
21 ✔
121
  }
21 ✔
122

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

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

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

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

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

23 ✔
213
    if (result.which() == 0) {
23 ✔
214
      return false;
5 ✔
215
    }
5 ✔
216

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

23 !
219
    return true;
23 ✔
220
  }
23 ✔
221

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

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

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

×
241
  bool get(DNSResourceRecord& rr) override
242
  {
×
243
    if (d_result.size() == 0) {
✔
244
      return false;
×
245
    }
×
246
    rr = std::move(d_result.front());
×
247
    d_result.pop_front();
×
248
    return true;
249
  }
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);
5 !
259
    }
5 ✔
260
    direct_backend_cmd_call_t f = d_lw->readVariable<boost::optional<direct_backend_cmd_call_t>>(cmd).get_value_or(0);
10 ✔
261
    if (f == nullptr) {
10 !
262
      return cmd + "not found";
×
263
    }
10 !
264
    if (d_debug_log) {
×
265
      g_log << Logger::Debug << "[" << getPrefix() << "] Calling " << cmd << "(" << "parameter=" << par << ")" << endl;
10 !
266
    }
×
267
    return f(par);
×
268
  }
10 ✔
269

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

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

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

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

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

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

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

352
    return true;
×
353
  }
×
354

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

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

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

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

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

6 ✔
399
    return true;
6 ✔
400
  }
401

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

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

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

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

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

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

438
    if (result.which() == 0) {
12 !
439
      return false;
12 ✔
440
    }
12 ✔
441

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

471
    return true;
472
  }
473

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

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

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

489
    before_and_after_names_result_t row = boost::get<before_and_after_names_result_t>(result);
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) {
48 ✔
495
      DNSName value;
496
      if (item.second.which() == 0) {
36 !
497
        value = DNSName(boost::get<string>(item.second));
498
      }
499
      else {
500
        value = DNSName(boost::get<DNSName>(item.second));
501
      }
502
      if (item.first == "unhashed") {
36 ✔
503
        unhashed = value;
504
      }
505
      else if (item.first == "before") {
24 ✔
506
        before = value;
507
      }
508
      else if (item.first == "after") {
12 !
509
        after = value;
510
      }
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
    }
516

517
    if (d_debug_log) {
12 !
518
      g_log << Logger::Debug << "[" << getPrefix() << "] Got result " << "'" << "unhashed=" << unhashed << ",before=" << before << ",after=" << after << "'" << endl;
519
    }
520
    return true;
521
  }
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 TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc