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

PowerDNS / pdns / 15291964337

28 May 2025 05:06AM UTC coverage: 63.684% (-0.01%) from 63.696%
15291964337

Pull #15386

github

web-flow
Merge 6fb61e7c4 into dea9fd450
Pull Request #15386: [auth] make pdnsutil add-record perform the same checks as the REST API

42358 of 101406 branches covered (41.77%)

Branch coverage included in aggregate %.

70 of 73 new or added lines in 2 files covered. (95.89%)

12075 existing lines in 167 files now uncovered.

130668 of 170290 relevant lines covered (76.73%)

4391294.89 hits per line

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

50.35
/pdns/statnode.cc
1
#include "statnode.hh"
2

3
StatNode::Stat StatNode::print(unsigned int depth, Stat newstat, bool silent) const
4
{
×
5
  if(!silent) {
×
6
    cout<<string(depth, ' ');
×
7
    cout<<name<<": "<<endl;
×
8
  }
×
9
  Stat childstat;
×
10
  childstat.queries += s.queries;
×
11
  childstat.noerrors += s.noerrors;
×
12
  childstat.nxdomains += s.nxdomains;
×
13
  childstat.servfails += s.servfails;
×
14
  childstat.drops += s.drops;
×
15
  childstat.bytes += s.bytes;
×
16
  childstat.hits += s.hits;
×
17

18
  if(children.size()>1024 && !silent) {
×
19
    cout<<string(depth, ' ')<<name<<": too many to print"<<endl;
×
20
  }
×
21
  for(const children_t::value_type& child :  children) {
×
22
    childstat=child.second.print(depth+8, childstat, silent || children.size()>1024);
×
23
  }
×
24
  if(!silent || children.size()>1)
×
25
    cout<<string(depth, ' ')<<childstat.queries<<" queries, " << 
×
26
      childstat.noerrors<<" noerrors, "<< 
×
27
      childstat.nxdomains<<" nxdomains, "<< 
×
28
      childstat.servfails<<" servfails, "<< 
×
29
      childstat.drops<<" drops, "<<
×
30
      childstat.bytes<<" bytes, "<<
×
31
      childstat.hits<<" hits"<<endl;
×
32

33
  newstat+=childstat;
×
34

35
  return newstat;
×
36
}
×
37

38
void StatNode::visit(const visitor_t& visitor, Stat& newstat, unsigned int depth) const
UNCOV
39
{
545✔
UNCOV
40
  Stat childstat(s);
545✔
41

UNCOV
42
  for (const auto& child : children) {
545✔
UNCOV
43
    child.second.visit(visitor, childstat, depth+8);
538✔
UNCOV
44
  }
538✔
45

UNCOV
46
  visitor(this, s, childstat);
545✔
47

UNCOV
48
  newstat += childstat;
545✔
UNCOV
49
}
545✔
50

51
void StatNode::submit(const DNSName& domain, int rcode, unsigned int bytes, bool hit, const std::optional<ComboAddress>& remote)
UNCOV
52
{
516✔
53
  //  cerr<<"FIRST submit called on '"<<domain<<"'"<<endl;
UNCOV
54
  std::vector<string> tmp = domain.getRawLabels();
516✔
UNCOV
55
  if (tmp.empty()) {
516!
56
    return;
×
57
  }
×
58

UNCOV
59
  auto last = tmp.end() - 1;
516✔
UNCOV
60
  children[*last].submit(last, tmp.begin(), "", rcode, bytes, remote, 1, hit);
516✔
UNCOV
61
}
516✔
62

63
/* www.powerdns.com. -> 
64
   .                 <- fullnames
65
   com.
66
   powerdns.com
67
   www.powerdns.com. 
68
*/
69

70
void StatNode::submit(std::vector<string>::const_iterator end, std::vector<string>::const_iterator begin, const std::string& domain, int rcode, unsigned int bytes, const std::optional<ComboAddress>& remote, unsigned int count, bool hit)
UNCOV
71
{
2,068✔
72
  //  cerr<<"Submit called for domain='"<<domain<<"': ";
73
  //  for(const std::string& n :  labels) 
74
  //    cerr<<n<<".";
75
  //  cerr<<endl;
UNCOV
76
  if (name.empty()) {
2,068✔
77

UNCOV
78
    name=*end;
538✔
79
    //    cerr<<"Set short name to '"<<name<<"'"<<endl;
UNCOV
80
  }
538✔
UNCOV
81
  else {
1,530✔
82
    //    cerr<<"Short name was already set to '"<<name<<"'"<<endl;
UNCOV
83
  }
1,530✔
84

UNCOV
85
  if (end == begin) {
2,068✔
UNCOV
86
    if (fullname.empty()) {
516!
UNCOV
87
      size_t needed = name.size() + 1 + domain.size();
516✔
UNCOV
88
      if (fullname.capacity() < needed) {
516!
UNCOV
89
        fullname.reserve(needed);
516✔
UNCOV
90
      }
516✔
UNCOV
91
      fullname = name;
516✔
UNCOV
92
      fullname.append(".");
516✔
UNCOV
93
      fullname.append(domain);
516✔
UNCOV
94
      labelsCount = count;
516✔
UNCOV
95
    }
516✔
96
    //    cerr<<"Hit the end, set our fullname to '"<<fullname<<"'"<<endl<<endl;
UNCOV
97
    s.queries++;
516✔
UNCOV
98
    s.bytes += bytes;
516✔
UNCOV
99
    if (rcode < 0) {
516!
100
      s.drops++;
×
101
    }
×
UNCOV
102
    else if (rcode == RCode::NoError) {
516!
UNCOV
103
      s.noerrors++;
516✔
UNCOV
104
    }
516✔
105
    else if (rcode == RCode::ServFail) {
×
106
      s.servfails++;
×
107
    }
×
108
    else if (rcode == RCode::NXDomain) {
×
109
      s.nxdomains++;
×
110
    }
×
111

UNCOV
112
    if (remote) {
516!
113
      s.remotes[*remote]++;
×
114
    }
×
115

UNCOV
116
    if (hit) {
516!
117
      ++s.hits;
×
118
    }
×
UNCOV
119
  }
516✔
UNCOV
120
  else {
1,552✔
UNCOV
121
    if (fullname.empty()) {
1,552✔
UNCOV
122
      size_t needed = name.size() + 1 + domain.size();
22✔
UNCOV
123
      if (fullname.capacity() < needed) {
22✔
UNCOV
124
        fullname.reserve(needed);
10✔
UNCOV
125
      }
10✔
UNCOV
126
      fullname = name;
22✔
UNCOV
127
      fullname.append(".");
22✔
UNCOV
128
      fullname.append(domain);
22✔
UNCOV
129
      labelsCount = count;
22✔
UNCOV
130
    }
22✔
131
    //    cerr<<"Not yet end, set our fullname to '"<<fullname<<"', recursing"<<endl;
UNCOV
132
    --end;
1,552✔
UNCOV
133
    children[*end].submit(end, begin, fullname, rcode, bytes, remote, count+1, hit);
1,552✔
UNCOV
134
  }
1,552✔
UNCOV
135
}
2,068✔
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