Coverage Report

Created: 2026-06-09 07:00

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/pdns/pdns/dnsdistdist/doq.hh
Line
Count
Source
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
#pragma once
23
24
#include <memory>
25
26
#include "config.h"
27
28
struct DOQServerConfig;
29
struct DownstreamState;
30
31
#ifdef HAVE_DNS_OVER_QUIC
32
33
#include "channel.hh"
34
#include "dnsdist-idstate.hh"
35
#include "doq-common.hh"
36
#include "dolog.hh"
37
#include "iputils.hh"
38
#include "libssl.hh"
39
#include "noinitvector.hh"
40
#include "stat_t.hh"
41
42
struct DOQFrontend
43
{
44
  DOQFrontend();
45
  DOQFrontend(const DOQFrontend&) = delete;
46
  DOQFrontend(DOQFrontend&&) = delete;
47
  DOQFrontend& operator=(const DOQFrontend&) = delete;
48
  DOQFrontend& operator=(DOQFrontend&&) = delete;
49
  ~DOQFrontend();
50
51
  void setup();
52
  void reloadCertificates();
53
  const Logr::Logger& getLogger()
54
  {
55
    return *d_logger;
56
  }
57
58
  std::shared_ptr<const Logr::Logger> d_logger{nullptr};
59
  std::unique_ptr<DOQServerConfig> d_server_config;
60
  dnsdist::doq::QuicheParams d_quicheParams;
61
  ComboAddress d_local;
62
63
#ifdef __linux__
64
  // On Linux this gives us 128k pending queries (default is 8192 queries),
65
  // which should be enough to deal with huge spikes
66
  uint32_t d_internalPipeBufferSize{1024 * 1024};
67
#else
68
  uint32_t d_internalPipeBufferSize{0};
69
#endif
70
71
  pdns::stat_t d_doqUnsupportedVersionErrors{0}; // Unsupported protocol version errors
72
  pdns::stat_t d_doqInvalidTokensReceived{0}; // Discarded received tokens
73
  pdns::stat_t d_validResponses{0}; // Valid responses sent
74
  pdns::stat_t d_errorResponses{0}; // Empty responses (no backend, drops, invalid queries, etc.)
75
};
76
77
struct DOQUnit
78
{
79
  DOQUnit(PacketBuffer&& query_) :
80
    query(std::move(query_))
81
  {
82
  }
83
84
  DOQUnit(const DOQUnit&) = delete;
85
  DOQUnit& operator=(const DOQUnit&) = delete;
86
87
  InternalQueryState ids;
88
  PacketBuffer query;
89
  PacketBuffer response;
90
  PacketBuffer serverConnID;
91
  std::shared_ptr<DownstreamState> downstream{nullptr};
92
  std::shared_ptr<const std::string> sni{nullptr};
93
  DOQServerConfig* dsc{nullptr};
94
  uint64_t streamID{0};
95
  size_t proxyProtocolPayloadSize{0};
96
  /* whether the query was re-sent to the backend over
97
     TCP after receiving a truncated answer over UDP */
98
  bool tcp{false};
99
};
100
101
using DOQUnitUniquePtr = std::unique_ptr<DOQUnit>;
102
103
struct CrossProtocolQuery;
104
struct DNSQuestion;
105
std::unique_ptr<CrossProtocolQuery> getDOQCrossProtocolQueryFromDQ(DNSQuestion& dnsQuestion, bool isResponse);
106
107
void doqThread(ClientState* clientState);
108
109
#else
110
111
struct DOQUnit
112
{
113
};
114
115
struct DOQFrontend
116
{
117
  DOQFrontend()
118
0
  {
119
0
  }
120
  void setup()
121
0
  {
122
0
  }
123
};
124
125
#endif