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

PowerDNS / pdns / 18837422702

27 Oct 2025 10:15AM UTC coverage: 73.025% (+0.02%) from 73.004%
18837422702

Pull #16375

github

web-flow
Merge 2f23fc90d into 82ea647b4
Pull Request #16375: dnsdist: Include a Date: response header for rejected HTTP1 requests

38279 of 63122 branches covered (60.64%)

Branch coverage included in aggregate %.

0 of 11 new or added lines in 1 file covered. (0.0%)

10680 existing lines in 98 files now uncovered.

127481 of 163870 relevant lines covered (77.79%)

5384548.9 hits per line

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

76.47
/pdns/dnsdistdist/dnsdist-dnsquestion.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
#include "dnsdist.hh"
23
#include "dnsdist-configuration.hh"
24
#include "dnsdist-dnsparser.hh"
25

26
std::string DNSQuestion::getTrailingData() const
27
{
12✔
28
  // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
29
  const auto* message = reinterpret_cast<const char*>(this->getData().data());
12✔
30
  const uint16_t messageLen = getDNSPacketLength(message, this->getData().size());
12✔
31
  // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic)
32
  return {message + messageLen, this->getData().size() - messageLen};
12✔
33
}
12✔
34

35
bool DNSQuestion::setTrailingData(const std::string& tail)
36
{
14✔
37
  // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
38
  const char* message = reinterpret_cast<const char*>(this->data.data());
14✔
39
  const uint16_t messageLen = getDNSPacketLength(message, this->data.size());
14✔
40
  this->data.resize(messageLen);
14✔
41
  if (!tail.empty()) {
14✔
42
    if (!hasRoomFor(tail.size())) {
12✔
UNCOV
43
      return false;
2✔
UNCOV
44
    }
2✔
45
    this->data.insert(this->data.end(), tail.begin(), tail.end());
10✔
46
  }
10✔
47
  return true;
12✔
48
}
14✔
49

50
bool DNSQuestion::editHeader(const std::function<bool(dnsheader&)>& editFunction)
51
{
×
52
  if (data.size() < sizeof(dnsheader)) {
×
53
    throw std::runtime_error("Trying to access the dnsheader of a too small (" + std::to_string(data.size()) + ") DNSQuestion buffer");
×
54
  }
×
55
  return dnsdist::PacketMangling::editDNSHeaderFromPacket(data, editFunction);
×
56
}
×
57

58
DNSQuestion::DNSQuestion(InternalQueryState& ids_, PacketBuffer& data_) :
59
  data(data_), ids(ids_), ecsPrefixLength(ids.origRemote.sin4.sin_family == AF_INET ? dnsdist::configuration::getCurrentRuntimeConfiguration().d_ECSSourcePrefixV4 : dnsdist::configuration::getCurrentRuntimeConfiguration().d_ECSSourcePrefixV6), ecsOverride(dnsdist::configuration::getCurrentRuntimeConfiguration().d_ecsOverride)
2,470,944✔
60
{
2,470,944✔
61
}
2,470,944✔
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