• 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

90.18
/pdns/dnsdistdist/dnsdist-rule-chains.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 "dnsdist-rule-chains.hh"
24

25
namespace dnsdist::rules
26
{
27
static const std::vector<ResponseRuleChainDescription> s_responseRuleChains{
28
  {"", "response", "response-rules", ResponseRuleChain::ResponseRules},
29
  {"CacheHit", "cache hit", "cache-hit-response-rules", ResponseRuleChain::CacheHitResponseRules},
30
  {"CacheInserted", "cache inserted", "cache-inserted-response-rules", ResponseRuleChain::CacheInsertedResponseRules},
31
  {"SelfAnswered", "self-answered", "self-answered-response-rules", ResponseRuleChain::SelfAnsweredResponseRules},
32
  {"XFR", "xfr", "xfr-response-rules", ResponseRuleChain::XFRResponseRules},
33
  {"Timeout", "timeout", "timeout-response-rules", ResponseRuleChain::TimeoutResponseRules},
34
};
35

36
const std::vector<ResponseRuleChainDescription>& getResponseRuleChainDescriptions()
37
{
2,609✔
38
  return s_responseRuleChains;
2,609✔
39
}
2,609✔
40

41
static const std::vector<RuleChainDescription> s_ruleChains{
42
  {"", "", "rules", RuleChain::Rules},
43
  {"CacheMiss", "cache-miss", "cache-miss-rules", RuleChain::CacheMissRules},
44
};
45

46
const std::vector<RuleChainDescription>& getRuleChainDescriptions()
47
{
2,609✔
48
  return s_ruleChains;
2,609✔
49
}
2,609✔
50

51
std::vector<RuleAction>& getRuleChain(RuleChains& chains, RuleChain chain)
52
{
893✔
53
  switch (chain) {
893!
54
  case RuleChain::Rules:
885✔
55
    return chains.d_ruleActions;
885✔
56
  case RuleChain::CacheMissRules:
8✔
57
    return chains.d_cacheMissRuleActions;
8✔
58
  }
893✔
59

60
  throw std::runtime_error("Trying to accept an invalid rule chain");
×
61
}
893✔
62

63
const std::vector<RuleAction>& getRuleChain(const RuleChains& chains, RuleChain chain)
64
{
6,817✔
65
  switch (chain) {
6,817!
66
  case RuleChain::Rules:
6,321✔
67
    return chains.d_ruleActions;
6,321✔
68
  case RuleChain::CacheMissRules:
496✔
69
    return chains.d_cacheMissRuleActions;
496✔
70
  }
6,817✔
71

72
  throw std::runtime_error("Trying to accept an invalid rule chain");
×
73
}
6,817✔
74

75
std::vector<ResponseRuleAction>& getRuleChain(RuleChains& chains, ResponseRuleChain chain)
76
{
×
77
  return getResponseRuleChain(chains, chain);
×
78
}
×
79

80
const std::vector<ResponseRuleAction>& getRuleChain(const RuleChains& chains, ResponseRuleChain chain)
81
{
2✔
82
  return getResponseRuleChain(chains, chain);
2✔
83
}
2✔
84

85
std::vector<ResponseRuleAction>& getResponseRuleChain(RuleChains& chains, ResponseRuleChain chain)
86
{
169✔
87
  switch (chain) {
169!
88
  case ResponseRuleChain::ResponseRules:
139✔
89
    return chains.d_respruleactions;
139✔
90
  case ResponseRuleChain::CacheHitResponseRules:
10✔
91
    return chains.d_cachehitrespruleactions;
10✔
92
  case ResponseRuleChain::CacheInsertedResponseRules:
2✔
93
    return chains.d_cacheInsertedRespRuleActions;
2✔
94
  case ResponseRuleChain::SelfAnsweredResponseRules:
8✔
95
    return chains.d_selfansweredrespruleactions;
8✔
96
  case ResponseRuleChain::XFRResponseRules:
2✔
97
    return chains.d_XFRRespRuleActions;
2✔
98
  case ResponseRuleChain::TimeoutResponseRules:
8✔
99
    return chains.d_TimeoutRespRuleActions;
8✔
100
  }
169✔
101

102
  throw std::runtime_error("Trying to accept an invalid response rule chain");
×
103
}
169✔
104

105
const std::vector<ResponseRuleAction>& getResponseRuleChain(const RuleChains& chains, ResponseRuleChain chain)
106
{
9,522✔
107
  switch (chain) {
9,522!
108
  case ResponseRuleChain::ResponseRules:
5,492✔
109
    return chains.d_respruleactions;
5,492✔
110
  case ResponseRuleChain::CacheHitResponseRules:
1,277✔
111
    return chains.d_cachehitrespruleactions;
1,277✔
112
  case ResponseRuleChain::CacheInsertedResponseRules:
465✔
113
    return chains.d_cacheInsertedRespRuleActions;
465✔
114
  case ResponseRuleChain::SelfAnsweredResponseRules:
1,277✔
115
    return chains.d_selfansweredrespruleactions;
1,277✔
116
  case ResponseRuleChain::XFRResponseRules:
690✔
117
    return chains.d_XFRRespRuleActions;
690✔
118
  case ResponseRuleChain::TimeoutResponseRules:
321✔
119
    return chains.d_TimeoutRespRuleActions;
321✔
120
  }
9,522✔
121

122
  throw std::runtime_error("Trying to accept an invalid response rule chain");
×
123
}
9,522✔
124

125
void add(RuleChains& chains, RuleChain identifier, const std::shared_ptr<DNSRule>& selector, const std::shared_ptr<DNSAction>& action, std::string&& name, const boost::uuids::uuid& uuid, uint64_t creationOrder)
126
{
888✔
127
  auto& chain = getRuleChain(chains, identifier);
888✔
128
  chain.push_back({selector, action, std::move(name), uuid, creationOrder});
888✔
129
}
888✔
130

131
void add(RuleChains& chains, ResponseRuleChain identifier, const std::shared_ptr<DNSRule>& selector, const std::shared_ptr<DNSResponseAction>& action, std::string&& name, const boost::uuids::uuid& uuid, uint64_t creationOrder)
132
{
167✔
133
  auto& chain = getResponseRuleChain(chains, identifier);
167✔
134
  chain.push_back({selector, action, std::move(name), uuid, creationOrder});
167✔
135
}
167✔
136

137
}
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