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

PowerDNS / pdns / 12595591960

03 Jan 2025 09:27AM UTC coverage: 62.774% (+2.5%) from 60.245%
12595591960

Pull #15008

github

web-flow
Merge c2a2749d3 into 788f396a7
Pull Request #15008: Do not follow CNAME records for ANY or CNAME queries

30393 of 78644 branches covered (38.65%)

Branch coverage included in aggregate %.

105822 of 138350 relevant lines covered (76.49%)

4613078.44 hits per line

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

30.34
/pdns/responsestats.cc
1
#ifdef HAVE_CONFIG_H
2
#include "config.h"
3
#endif
4

5
#include "responsestats.hh"
6

7
#include <limits>
8
#include <boost/format.hpp>
9

10
#include "namespaces.hh"
11
#include "logger.hh"
12

13
#include "dnsparser.hh"
14

15
static auto sizeBounds()
16
{
2✔
17
  std::vector<uint64_t> bounds;
2✔
18

19
  bounds.push_back(20);
2✔
20
  bounds.push_back(40);
2✔
21
  bounds.push_back(60);
2✔
22
  bounds.push_back(80);
2✔
23
  bounds.push_back(100);
2✔
24
  bounds.push_back(150);
2✔
25
  for (uint64_t n = 200; n < 65000; n += 200) {
650✔
26
    bounds.push_back(n);
648✔
27
  }
648✔
28
  return bounds;
2✔
29
}
2✔
30

31
ResponseStats::ResponseStats() :
32
  d_sizecounters("SizeCounters", sizeBounds())
33
{
2✔
34
  for (auto& entry : d_qtypecounters) {
131,072✔
35
    entry.value = 0;
131,072✔
36
  }
131,072✔
37
  for (auto& entry : d_rcodecounters) {
512✔
38
    entry.value = 0;
512✔
39
  }
512✔
40
}
2✔
41

42
ResponseStats g_rs;
43

44
void ResponseStats::submitResponse(uint16_t qtype, uint16_t respsize, uint8_t rcode, bool udpOrTCP) const
45
{
×
46
  d_rcodecounters.at(rcode).value++;
×
47
  submitResponse(qtype, respsize, udpOrTCP);
×
48
}
×
49

50
void ResponseStats::submitResponse(uint16_t qtype, uint16_t respsize, bool /* udpOrTCP */) const
51
{
×
52
  d_qtypecounters.at(qtype).value++;
×
53
  d_sizecounters(respsize);
×
54
}
×
55

56
map<uint16_t, uint64_t> ResponseStats::getQTypeResponseCounts() const
57
{
×
58
  map<uint16_t, uint64_t> ret;
×
59
  uint64_t count;
×
60
  for (unsigned int i = 0; i < d_qtypecounters.size(); ++i) {
×
61
    count = d_qtypecounters.at(i).value;
×
62
    if (count) {
×
63
      ret[i] = count;
×
64
    }
×
65
  }
×
66
  return ret;
×
67
}
×
68

69
map<uint16_t, uint64_t> ResponseStats::getSizeResponseCounts() const
70
{
×
71
  map<uint16_t, uint64_t> ret;
×
72
  for (const auto& sizecounter : d_sizecounters.getRawData()) {
×
73
    if (sizecounter.d_count) {
×
74
      ret[sizecounter.d_boundary] = sizecounter.d_count;
×
75
    }
×
76
  }
×
77
  return ret;
×
78
}
×
79

80
map<uint8_t, uint64_t> ResponseStats::getRCodeResponseCounts() const
81
{
×
82
  map<uint8_t, uint64_t> ret;
×
83
  uint64_t count;
×
84
  for (unsigned int i = 0; i < d_rcodecounters.size(); ++i) {
×
85
    count = d_rcodecounters.at(i).value;
×
86
    if (count) {
×
87
      ret[i] = count;
×
88
    }
×
89
  }
×
90
  return ret;
×
91
}
×
92

93
string ResponseStats::getQTypeReport() const
94
{
×
95
  auto qtypenums = getQTypeResponseCounts();
×
96
  ostringstream os;
×
97
  boost::format fmt("%s\t%d\n");
×
98
  for (const auto& val : qtypenums) {
×
99
    os << (fmt % DNSRecordContent::NumberToType(val.first) % val.second).str();
×
100
  }
×
101
  return os.str();
×
102
}
×
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