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

PowerDNS / pdns / 19741624072

27 Nov 2025 03:45PM UTC coverage: 73.086% (+0.02%) from 73.065%
19741624072

Pull #16570

github

web-flow
Merge 08a2cdb1d into f94a3f63f
Pull Request #16570: rec: rewrite all unwrap calls in web.rs

38523 of 63408 branches covered (60.75%)

Branch coverage included in aggregate %.

128044 of 164496 relevant lines covered (77.84%)

6531485.83 hits per line

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

84.44
/pdns/dnsdistdist/dnsdist-protocols.cc
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
 * MERCHANTABILITY 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

23
#include <algorithm>
24
#include <stdexcept>
25

26
#include "dnsdist-protocols.hh"
27

28
namespace dnsdist
29
{
30
const std::array<std::string, Protocol::s_numberOfProtocols> Protocol::s_names = {
31
  "DoUDP",
32
  "DoTCP",
33
  "DNSCryptUDP",
34
  "DNSCryptTCP",
35
  "DoT",
36
  "DoH",
37
  "DoQ",
38
  "DoH3"};
39

40
const std::array<std::string, Protocol::s_numberOfProtocols> Protocol::s_prettyNames = {
41
  "Do53 UDP",
42
  "Do53 TCP",
43
  "DNSCrypt UDP",
44
  "DNSCrypt TCP",
45
  "DNS over TLS",
46
  "DNS over HTTPS",
47
  "DNS over QUIC",
48
  "DNS over HTTP/3"};
49

50
Protocol::Protocol(const std::string& protocol)
51
{
24✔
52
  const auto& namesIt = std::find(s_names.begin(), s_names.end(), protocol);
24✔
53
  if (namesIt == s_names.end()) {
24!
54
    throw std::runtime_error("Unknown protocol name: '" + protocol + "'");
×
55
  }
×
56

57
  auto index = std::distance(s_names.begin(), namesIt);
24✔
58
  d_protocol = static_cast<Protocol::typeenum>(index);
24✔
59
}
24✔
60

61
bool Protocol::operator==(Protocol::typeenum type) const
62
{
83,902✔
63
  return d_protocol == type;
83,902✔
64
}
83,902✔
65

66
bool Protocol::operator!=(Protocol::typeenum type) const
67
{
3,704✔
68
  return d_protocol != type;
3,704✔
69
}
3,704✔
70

71
bool Protocol::operator==(const Protocol& rhs) const
72
{
42✔
73
  return d_protocol == rhs.d_protocol;
42✔
74
}
42✔
75

76
bool Protocol::operator!=(const Protocol& rhs) const
77
{
×
78
  return d_protocol != rhs.d_protocol;
×
79
}
×
80

81
const std::string& Protocol::toString() const
82
{
1,089✔
83
  return s_names.at(static_cast<uint8_t>(d_protocol));
1,089✔
84
}
1,089✔
85

86
const std::string& Protocol::toPrettyString() const
87
{
275✔
88
  return s_prettyNames.at(static_cast<uint8_t>(d_protocol));
275✔
89
}
275✔
90

91
bool Protocol::isUDP() const
92
{
392✔
93
  return d_protocol == DoUDP || d_protocol == DNSCryptUDP;
392!
94
}
392✔
95

96
bool Protocol::isEncrypted() const
97
{
69✔
98
  return d_protocol != DoUDP && d_protocol != DoTCP;
69✔
99
}
69✔
100

101
uint8_t Protocol::toNumber() const
102
{
18✔
103
  return static_cast<uint8_t>(d_protocol);
18✔
104
}
18✔
105
}
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