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

PowerDNS / pdns / 18903493638

29 Oct 2025 09:39AM UTC coverage: 73.004%. Remained the same
18903493638

Pull #16388

github

web-flow
Merge 1bddbd8fe into 82ea647b4
Pull Request #16388: gh actions build-packages: fix pattern for the download-artifacts action and publication issues

38272 of 63120 branches covered (60.63%)

Branch coverage included in aggregate %.

127434 of 163861 relevant lines covered (77.77%)

6052684.91 hits per line

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

86.36
/pdns/ednscookies.hh
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 <string>
25

26
union ComboAddress;
27

28
struct EDNSCookiesOpt
29
{
30
  static const size_t EDNSCookieSecretSize = 32;
31
  static const size_t EDNSCookieOptSize = 24;
32

33
  EDNSCookiesOpt() = default;
1,876,947✔
34
  EDNSCookiesOpt(const std::string& option);
35
  EDNSCookiesOpt(const char* option, unsigned int len);
36

37
  bool makeFromString(const std::string& option);
38
  bool makeFromString(const char* option, unsigned int len);
39

40
  [[nodiscard]] size_t size() const
41
  {
2✔
42
    return server.size() + client.size();
2✔
43
  }
2✔
44

45
  [[nodiscard]] bool isWellFormed() const
46
  {
166✔
47
    // RFC7873 section 5.2.2
48
    //    In summary, valid cookie lengths are 8 and 16 to 40 inclusive.
49
    // That's the total size. We account for client and server size seperately
50
    return (
166✔
51
      client.size() == 8 && (server.empty() || (server.size() >= 8 && server.size() <= 32)));
166✔
52
  }
166✔
53

54
  [[nodiscard]] bool isValid(const std::string& secret, const ComboAddress& source) const;
55
  void makeClientCookie();
56
  bool makeServerCookie(const std::string& secret, const ComboAddress& source);
57

58
  [[nodiscard]] std::string makeOptString() const;
59
  [[nodiscard]] std::string toDisplayString() const;
60
  [[nodiscard]] std::string getServer() const
61
  {
×
62
    return server;
×
63
  }
×
64
  [[nodiscard]] std::string getClient() const
65
  {
66✔
66
    return client;
66✔
67
  }
66✔
68

69
private:
70
  [[nodiscard]] bool shouldRefresh() const;
71

72
  // the client cookie
73
  std::string client;
74
  // the server cookie
75
  std::string server;
76

77
  void getEDNSCookiesOptFromString(const char* option, unsigned int len);
78
};
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