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

PowerDNS / pdns / 19031394433

03 Nov 2025 10:27AM UTC coverage: 72.82% (+0.08%) from 72.74%
19031394433

Pull #16405

github

web-flow
Merge d30eed73d into 22b7a74ae
Pull Request #16405: dnsdist: Fix the outgoing DoT YAML example

38181 of 63134 branches covered (60.48%)

Branch coverage included in aggregate %.

127131 of 163882 relevant lines covered (77.57%)

12637218.33 hits per line

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

77.65
/pdns/recursordist/sortlist.cc
1
#include "sortlist.hh"
2
#include "dnsrecords.hh"
3

4
void SortList::clear()
5
{
×
6
  d_sortlist.clear();
×
7
}
×
8

9
int SortList::getMaxOrder(const Netmask& formask) const
10
{
2✔
11
  int order = 0;
2✔
12

13
  const auto* place = d_sortlist.lookup(formask);
2✔
14
  if (place != nullptr && place->first == formask) {
2!
15
    for (const auto& node_order : place->second.d_orders) {
×
16
      order = std::max(order, node_order.second);
×
17
    }
×
18
  }
×
19

20
  return order;
2✔
21
}
2✔
22

23
void SortList::addEntry(const Netmask& covers, const Netmask& answermask, int order)
24
{
16✔
25
  if (order < 0) {
16!
26
    order = getMaxOrder(covers);
×
27
    ++order;
×
28
  }
×
29
  //  cout<<"Adding for netmask "<<formask.toString()<<" the order instruction that "<<valmask.toString()<<" is order "<<order<<endl;
30
  d_sortlist.insert(covers).second.d_orders.insert(answermask).second = order;
16✔
31
}
16✔
32

33
std::unique_ptr<SortListOrderCmp> SortList::getOrderCmp(const ComboAddress& who) const
34
{
6,162✔
35
  if (!d_sortlist.match(who)) {
6,163✔
36
    return {};
6,159✔
37
  }
6,159✔
38
  const auto* fnd = d_sortlist.lookup(who);
2,147,483,650✔
39
  //  cerr<<"Returning sort order for "<<who.toString()<<", have "<<fnd->second.d_orders.size()<<" entries"<<endl;
40
  return make_unique<SortListOrderCmp>(fnd->second);
2,147,483,650✔
41
}
6,162✔
42

43
// call this with **stable_sort**
44
bool SortListOrderCmp::operator()(const DNSRecord& lhs, const DNSRecord& rhs) const
45
{
15✔
46
  bool aAddr = (lhs.d_type == QType::A || lhs.d_type == QType::AAAA);
15!
47
  bool bAddr = (rhs.d_type == QType::A || rhs.d_type == QType::AAAA);
15!
48

49
  // anything address related is always 'larger', rest is equal
50
  if (aAddr && !bAddr) {
15✔
51
    return false;
4✔
52
  }
4✔
53
  if (!aAddr && bAddr) {
11✔
54
    return true;
1✔
55
  }
1✔
56
  if (!aAddr && !bAddr) {
10!
57
    return false;
4✔
58
  }
4✔
59

60
  int aOrder = std::numeric_limits<int>::max();
6✔
61
  int bOrder = aOrder;
6✔
62

63
  ComboAddress laddr = getAddr(lhs);
6✔
64
  ComboAddress raddr = getAddr(rhs);
6✔
65

66
  if (d_slo.d_orders.match(laddr)) {
6✔
67
    aOrder = d_slo.d_orders.lookup(laddr)->second;
4✔
68
  }
4✔
69
  if (d_slo.d_orders.match(raddr)) {
6✔
70
    bOrder = d_slo.d_orders.lookup(raddr)->second;
4✔
71
  }
4✔
72
  return aOrder < bOrder;
6✔
73
}
10✔
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