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

PowerDNS / pdns / 13012068652

28 Jan 2025 01:59PM UTC coverage: 64.71% (+0.01%) from 64.699%
13012068652

Pull #14724

github

web-flow
Merge b15562560 into db18c3a17
Pull Request #14724: dnsdist: Add meson support

38328 of 90334 branches covered (42.43%)

Branch coverage included in aggregate %.

361 of 513 new or added lines in 35 files covered. (70.37%)

42 existing lines in 13 files now uncovered.

128150 of 166934 relevant lines covered (76.77%)

4540890.91 hits per line

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

73.45
/pdns/dnsdistdist/test-dnsdistnghttp2_common.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
class MockupTLSCtx : public TLSCtx
25
{
26
public:
27
  ~MockupTLSCtx()
28
  {
×
29
  }
×
30

31
  std::unique_ptr<TLSConnection> getConnection(int socket, const struct timeval& timeout, time_t now) override
32
  {
7✔
33
    (void)timeout;
7✔
34
    (void)now;
7✔
35
    return std::make_unique<MockupTLSConnection>(socket);
7✔
36
  }
7✔
37

38
  std::unique_ptr<TLSConnection> getClientConnection(const std::string& host, bool hostIsAddr, int socket, const struct timeval& timeout) override
39
  {
17✔
40
    (void)host;
17✔
41
    (void)hostIsAddr;
17✔
42
    (void)timeout;
17✔
43
    return std::make_unique<MockupTLSConnection>(socket, true, d_needProxyProtocol);
17✔
44
  }
17✔
45

46
  void rotateTicketsKey(time_t now) override
47
  {
×
NEW
48
    (void)now;
×
UNCOV
49
  }
×
50

51
  size_t getTicketsKeysCount() override
52
  {
×
53
    return 0;
×
54
  }
×
55

56
  std::string getName() const override
57
  {
×
58
    return "Mockup TLS";
×
59
  }
×
60

61
  bool d_needProxyProtocol{false};
62
};
63

64
class MockupFDMultiplexer : public FDMultiplexer
65
{
66
public:
67
  MockupFDMultiplexer()
68
  {
17✔
69
  }
17✔
70

71
  ~MockupFDMultiplexer()
72
  {
17✔
73
  }
17✔
74

75
  int run(struct timeval* tv, int timeout = 500) override
76
  {
23✔
77
    (void)timeout;
23✔
78
    int ret = 0;
23✔
79

80
    gettimeofday(tv, nullptr); // MANDATORY
23✔
81

82
    /* 'ready' might be altered by a callback while we are iterating */
83
    const auto readyFDs = ready;
23✔
84
    for (const auto fd : readyFDs) {
25✔
85
      {
25✔
86
        const auto& it = d_readCallbacks.find(fd);
25✔
87

88
        if (it != d_readCallbacks.end()) {
25✔
89
          it->d_callback(it->d_fd, it->d_parameter);
22✔
90
        }
22✔
91
      }
25✔
92

93
      {
25✔
94
        const auto& it = d_writeCallbacks.find(fd);
25✔
95

96
        if (it != d_writeCallbacks.end()) {
25✔
97
          it->d_callback(it->d_fd, it->d_parameter);
2✔
98
        }
2✔
99
      }
25✔
100
    }
25✔
101

102
    return ret;
23✔
103
  }
23✔
104

105
  void getAvailableFDs(std::vector<int>& fds, int timeout) override
106
  {
×
NEW
107
    (void)fds;
×
NEW
108
    (void)timeout;
×
UNCOV
109
  }
×
110

111
  void addFD(int fd, FDMultiplexer::EventKind kind) override
112
  {
119✔
113
    (void)fd;
119✔
114
    (void)kind;
119✔
115
  }
119✔
116

117
  void removeFD(int fd, FDMultiplexer::EventKind) override
118
  {
119✔
119
    (void)fd;
119✔
120
  }
119✔
121

122
  string getName() const override
123
  {
×
124
    return "mockup";
×
125
  }
×
126

127
  void setReady(int fd)
128
  {
28✔
129
    ready.insert(fd);
28✔
130
  }
28✔
131

132
  void setNotReady(int fd)
133
  {
5✔
134
    ready.erase(fd);
5✔
135
  }
5✔
136

137
private:
138
  std::set<int> ready;
139
};
140

141
static bool isIPv6Supported()
142
{
2✔
143
  try {
2✔
144
    ComboAddress addr("[2001:db8:53::1]:53");
2✔
145
    auto socket = std::make_unique<Socket>(addr.sin4.sin_family, SOCK_STREAM, 0);
2✔
146
    socket->setNonBlocking();
2✔
147
    int res = SConnectWithTimeout(socket->getHandle(), addr, timeval{0, 0});
2✔
148
    if (res == 0 || res == EINPROGRESS) {
2!
149
      return true;
×
150
    }
×
151
    return false;
2✔
152
  }
2✔
153
  catch (const std::exception& e) {
2✔
154
    return false;
2✔
155
  }
2✔
156
}
2✔
157

158
static ComboAddress getBackendAddress(const std::string& lastDigit, uint16_t port)
159
{
40✔
160
  static const bool useV6 = isIPv6Supported();
40✔
161

162
  if (useV6) {
40!
163
    return ComboAddress("2001:db8:53::" + lastDigit, port);
×
164
  }
×
165

166
  return ComboAddress("192.0.2." + lastDigit, port);
40✔
167
}
40✔
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