Coverage Report

Created: 2024-04-25 06:25

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