Coverage Report

Created: 2026-10-03 06:24

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/pdns/pdns/dnsdistdist/dnsdist-svc.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 <optional>
25
#include <set>
26
#include <string>
27
#include <vector>
28
#include <unordered_map>
29
#include <boost/variant.hpp>
30
31
#include "dnsname.hh"
32
#include "iputils.hh"
33
34
struct SVCRecordParameters
35
{
36
  SVCRecordParameters()
37
0
  {
38
0
  }
39
40
  std::set<uint16_t> mandatoryParams;
41
  std::vector<std::string> alpns;
42
  std::vector<ComboAddress> ipv4hints;
43
  std::vector<ComboAddress> ipv6hints;
44
  std::vector<std::pair<uint16_t, std::string>> additionalParams;
45
  std::string ech;
46
  DNSName target;
47
  std::optional<uint16_t> port{std::nullopt};
48
  uint16_t priority{0};
49
  bool noDefaultAlpn{false};
50
};
51
52
using svcParamsLua_t = std::unordered_map<
53
  std::string,
54
  boost::variant<
55
    uint16_t,
56
    bool,
57
    std::string,
58
    std::vector<std::pair<int, std::string>>,
59
    std::vector<std::pair<int, ComboAddress>>>>;
60
61
struct SVCRecordParameters parseSVCParameters(const svcParamsLua_t& params);
62
63
bool generateSVCPayload(std::vector<uint8_t>& payload, uint16_t priority, const DNSName& target, const std::set<uint16_t>& mandatoryParams, const std::vector<std::string>& alpns, bool noDefaultAlpn, std::optional<uint16_t> port, const std::string& ech, const std::vector<ComboAddress>& ipv4hints, const std::vector<ComboAddress>& ipv6hints, const std::vector<std::pair<uint16_t, std::string>>& additionalParams);
64
65
bool generateSVCPayload(std::vector<uint8_t>& payload, const SVCRecordParameters& parameters);
66
67
struct DNSQuestion;
68
namespace dnsdist
69
{
70
struct ResponseConfig;
71
}
72
73
namespace dnsdist::svc
74
{
75
bool generateSVCResponse(DNSQuestion& dnsQuestion, const std::vector<std::vector<uint8_t>>& svcRecordPayloads, const std::set<std::pair<DNSName, ComboAddress>>& additionals4, const std::set<std::pair<DNSName, ComboAddress>>& additionals6, const dnsdist::ResponseConfig& d_responseConfig);
76
bool generateSVCResponse(DNSQuestion& dnsQuestion, uint32_t ttl, const std::vector<SVCRecordParameters>& parameters);
77
}