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

PowerDNS / pdns / 12595591960

03 Jan 2025 09:27AM UTC coverage: 62.774% (+2.5%) from 60.245%
12595591960

Pull #15008

github

web-flow
Merge c2a2749d3 into 788f396a7
Pull Request #15008: Do not follow CNAME records for ANY or CNAME queries

30393 of 78644 branches covered (38.65%)

Branch coverage included in aggregate %.

105822 of 138350 relevant lines covered (76.49%)

4613078.44 hits per line

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

83.17
/pdns/recursordist/rec-main.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

23
#pragma once
24

25
#ifdef HAVE_CONFIG_H
26
#include "config.h"
27
#endif
28

29
#include "logger.hh"
30
#include "logr.hh"
31
#include "lua-recursor4.hh"
32
#include "mplexer.hh"
33
#include "namespaces.hh"
34
#include "rec-lua-conf.hh"
35
#include "rec-protozero.hh"
36
#include "syncres.hh"
37
#include "rec-snmp.hh"
38
#include "rec_channel.hh"
39
#include "threadname.hh"
40
#include "recpacketcache.hh"
41
#include "ratelimitedlog.hh"
42

43
#ifdef NOD_ENABLED
44
#include "nod.hh"
45
#endif /* NOD_ENABLED */
46

47
#include <boost/container/flat_set.hpp>
48

49
extern std::shared_ptr<Logr::Logger> g_slogtcpin;
50
extern std::shared_ptr<Logr::Logger> g_slogudpin;
51

52
//! used to send information to a newborn mthread
53
struct DNSComboWriter
54
{
55
  DNSComboWriter(const std::string& query, const struct timeval& now, shared_ptr<RecursorLua4> luaContext) :
56
    d_mdp(true, query), d_now(now), d_query(query), d_luaContext(std::move(luaContext))
57
  {
244✔
58
  }
244✔
59

60
  DNSComboWriter(const std::string& query, const struct timeval& now, std::unordered_set<std::string>&& policyTags, shared_ptr<RecursorLua4> luaContext, LuaContext::LuaObject&& data, std::vector<DNSRecord>&& records) :
61
    d_mdp(true, query), d_now(now), d_query(query), d_policyTags(std::move(policyTags)), d_gettagPolicyTags(d_policyTags), d_records(std::move(records)), d_luaContext(std::move(luaContext)), d_data(std::move(data))
62
  {
2,173✔
63
  }
2,173✔
64

65
  // The address the query is coming from
66
  void setRemote(const ComboAddress& sa)
67
  {
2,414✔
68
    d_remote = sa;
2,414✔
69
  }
2,414✔
70

71
  // The address we assume the query is coming from, might be set by proxy protocol
72
  void setSource(const ComboAddress& sa)
73
  {
2,415✔
74
    d_source = sa;
2,415✔
75
  }
2,415✔
76

77
  void setMappedSource(const ComboAddress& sa)
78
  {
2,414✔
79
    d_mappedSource = sa;
2,414✔
80
  }
2,414✔
81

82
  void setLocal(const ComboAddress& sa)
83
  {
2,416✔
84
    d_local = sa;
2,416✔
85
  }
2,416✔
86

87
  // The address we assume the query is sent to, might be set by proxy protocol
88
  void setDestination(const ComboAddress& sa)
89
  {
2,417✔
90
    d_destination = sa;
2,417✔
91
  }
2,417✔
92

93
  void setSocket(int sock)
94
  {
2,411✔
95
    d_socket = sock;
2,411✔
96
  }
2,411✔
97

98
  // get a string repesentation of the client address, including proxy info if applicable
99
  string getRemote() const
100
  {
2,372✔
101
    if (d_source == d_remote) {
2,375✔
102
      return d_source.toStringWithPort();
2,349✔
103
    }
2,349✔
104
    return d_source.toStringWithPort() + " (proxied by " + d_remote.toStringWithPort() + ")";
2,147,483,672✔
105
  }
2,372✔
106

107
  std::vector<ProxyProtocolValue> d_proxyProtocolValues;
108
  MOADNSParser d_mdp;
109
  struct timeval d_now;
110

111
  ComboAddress d_remote; // the address the query is coming from
112
  ComboAddress d_source; // the address we assume the query is coming from, might be set by proxy protocol
113
  ComboAddress d_local; // the address we received the query on
114
  ComboAddress d_destination; // the address we assume the query is sent to, might be set by proxy protocol
115
  ComboAddress d_mappedSource; // the source address after being mapped by table based proxy mapping
116
  RecEventTrace d_eventTrace;
117
  boost::uuids::uuid d_uuid;
118
  string d_requestorId;
119
  string d_deviceId;
120
  string d_deviceName;
121
  struct timeval d_kernelTimestamp
122
  {
123
    0, 0
124
  };
125
  std::string d_query;
126
  std::unordered_set<std::string> d_policyTags;
127
  std::unordered_set<std::string> d_gettagPolicyTags;
128
  std::string d_routingTag;
129
  std::vector<DNSRecord> d_records;
130

131
  // d_data is tied to this LuaContext so we need to keep it alive and use it, not a newer one, as long as d_data exists
132
  shared_ptr<RecursorLua4> d_luaContext;
133
  LuaContext::LuaObject d_data;
134

135
  EDNSSubnetOpts d_ednssubnet;
136
  shared_ptr<TCPConnection> d_tcpConnection;
137
  boost::optional<uint16_t> d_extendedErrorCode{boost::none};
138
  string d_extendedErrorExtra;
139
  boost::optional<int> d_rcode{boost::none};
140
  int d_socket{-1};
141
  unsigned int d_tag{0};
142
  uint32_t d_qhash{0};
143
  uint32_t d_ttlCap{std::numeric_limits<uint32_t>::max()};
144
  bool d_variable{false};
145
  bool d_ecsFound{false};
146
  bool d_ecsParsed{false};
147
  bool d_followCNAMERecords{false};
148
  bool d_logResponse{false};
149
  bool d_tcp{false};
150
  bool d_responsePaddingDisabled{false};
151
  std::map<std::string, RecursorLua4::MetaValue> d_meta;
152
};
153

154
extern thread_local unique_ptr<FDMultiplexer> t_fdm;
155
extern uint16_t g_minUdpSourcePort;
156
extern uint16_t g_maxUdpSourcePort;
157
extern bool g_regressionTestMode;
158

159
// you can ask this class for a UDP socket to send a query from
160
// this socket is not yours, don't even think about deleting it
161
// but after you call 'returnSocket' on it, don't assume anything anymore
162
class UDPClientSocks
163
{
164
  unsigned int d_numsocks;
165

166
public:
167
  UDPClientSocks() :
168
    d_numsocks(0)
169
  {
806✔
170
  }
806✔
171

172
  LWResult::Result getSocket(const ComboAddress& toaddr, int* fileDesc);
173

174
  // return a socket to the pool, or simply erase it
175
  void returnSocket(int fileDesc);
176

177
private:
178
  // returns -1 for errors which might go away, throws for ones that won't
179
  static int makeClientSocket(int family);
180
};
181

182
enum class PaddingMode
183
{
184
  Always,
185
  PaddedQueries
186
};
187

188
typedef MTasker<std::shared_ptr<PacketID>, PacketBuffer, PacketIDCompare> MT_t;
189
extern thread_local std::unique_ptr<MT_t> g_multiTasker; // the big MTasker
190
extern std::unique_ptr<RecursorPacketCache> g_packetCache;
191

192
using RemoteLoggerStats_t = std::unordered_map<std::string, RemoteLoggerInterface::Stats>;
193

194
extern bool g_yamlSettings;
195
extern string g_yamlSettingsSuffix;
196
extern bool g_logCommonErrors;
197
extern size_t g_proxyProtocolMaximumSize;
198
extern std::atomic<bool> g_quiet;
199
extern thread_local std::shared_ptr<RecursorLua4> t_pdl;
200
extern bool g_gettagNeedsEDNSOptions;
201
extern NetmaskGroup g_paddingFrom;
202
extern unsigned int g_paddingTag;
203
extern PaddingMode g_paddingMode;
204
extern unsigned int g_maxMThreads;
205
extern bool g_reusePort;
206
extern bool g_anyToTcp;
207
extern size_t g_tcpMaxQueriesPerConn;
208
extern unsigned int g_maxTCPClients;
209
extern unsigned int g_maxTCPPerClient;
210
extern int g_tcpTimeout;
211
extern uint16_t g_udpTruncationThreshold;
212
extern double g_balancingFactor;
213
extern size_t g_maxUDPQueriesPerRound;
214
extern bool g_useKernelTimestamp;
215
extern bool g_allowNoRD;
216
extern unsigned int g_maxChainLength;
217
extern thread_local std::shared_ptr<NetmaskGroup> t_allowFrom;
218
extern thread_local std::shared_ptr<NetmaskGroup> t_allowNotifyFrom;
219
extern thread_local std::shared_ptr<notifyset_t> t_allowNotifyFor;
220
extern thread_local std::unique_ptr<UDPClientSocks> t_udpclientsocks;
221
extern bool g_useIncomingECS;
222
extern boost::optional<ComboAddress> g_dns64Prefix;
223
extern DNSName g_dns64PrefixReverse;
224
extern uint64_t g_latencyStatSize;
225
extern NetmaskGroup g_proxyProtocolACL;
226
extern std::set<ComboAddress> g_proxyProtocolExceptions;
227
extern std::atomic<bool> g_statsWanted;
228
extern uint32_t g_disthashseed;
229
extern int g_argc;
230
extern char** g_argv;
231
extern std::shared_ptr<SyncRes::domainmap_t> g_initialDomainMap; // new threads needs this to be setup
232
extern std::shared_ptr<NetmaskGroup> g_initialAllowFrom; // new thread needs to be setup with this
233
extern std::shared_ptr<NetmaskGroup> g_initialAllowNotifyFrom; // new threads need this to be setup
234
extern std::shared_ptr<notifyset_t> g_initialAllowNotifyFor; // new threads need this to be setup
235
extern thread_local std::shared_ptr<Regex> t_traceRegex;
236
extern thread_local FDWrapper t_tracefd;
237
extern string g_programname;
238
extern string g_pidfname;
239
extern RecursorControlChannel g_rcc; // only active in the handler thread
240

241
extern thread_local std::unique_ptr<ProxyMapping> t_proxyMapping;
242
using ProxyMappingStats_t = std::unordered_map<Netmask, ProxyMappingCounts>;
243
extern pdns::RateLimitedLog g_rateLimitedLogger;
244

245
#ifdef NOD_ENABLED
246
extern bool g_nodEnabled;
247
extern DNSName g_nodLookupDomain;
248
extern bool g_nodLog;
249
extern SuffixMatchNode g_nodDomainWL;
250
extern SuffixMatchNode g_udrDomainWL;
251
extern std::string g_nod_pbtag;
252
extern bool g_udrEnabled;
253
extern bool g_udrLog;
254
extern std::string g_udr_pbtag;
255
extern std::unique_ptr<nod::NODDB> g_nodDBp;
256
extern std::unique_ptr<nod::UniqueResponseDB> g_udrDBp;
257
#endif
258

259
struct ProtobufServersInfo
260
{
261
  std::shared_ptr<std::vector<std::unique_ptr<RemoteLogger>>> servers;
262
  uint64_t generation;
263
  ProtobufExportConfig config;
264
};
265
extern thread_local ProtobufServersInfo t_protobufServers;
266
extern thread_local ProtobufServersInfo t_outgoingProtobufServers;
267

268
#ifdef HAVE_FSTRM
269
struct FrameStreamServersInfo
270
{
271
  std::shared_ptr<std::vector<std::unique_ptr<FrameStreamLogger>>> servers;
272
  uint64_t generation;
273
  FrameStreamExportConfig config;
274
};
275

276
extern thread_local FrameStreamServersInfo t_frameStreamServersInfo;
277
extern thread_local FrameStreamServersInfo t_nodFrameStreamServersInfo;
278
#endif /* HAVE_FSTRM */
279

280
extern boost::container::flat_set<uint16_t> g_avoidUdpSourcePorts;
281

282
/* without reuseport, all listeners share the same sockets */
283
typedef vector<pair<int, std::function<void(int, boost::any&)>>> deferredAdd_t;
284

285
typedef map<ComboAddress, uint32_t, ComboAddress::addressOnlyLessThan> tcpClientCounts_t;
286
extern thread_local std::unique_ptr<tcpClientCounts_t> t_tcpClientCounts;
287

288
inline MT_t* getMT()
289
{
1,907✔
290
  return g_multiTasker ? g_multiTasker.get() : nullptr;
1,907!
291
}
1,907✔
292

293
/* this function is called with both a string and a vector<uint8_t> representing a packet */
294
template <class T>
295
static bool sendResponseOverTCP(const std::unique_ptr<DNSComboWriter>& dc, const T& packet)
296
{
236✔
297
  uint8_t buf[2];
236✔
298
  buf[0] = packet.size() / 256;
236✔
299
  buf[1] = packet.size() % 256;
236✔
300

301
  Utility::iovec iov[2];
236✔
302
  iov[0].iov_base = (void*)buf;
236✔
303
  iov[0].iov_len = 2;
236✔
304
  iov[1].iov_base = (void*)&*packet.begin();
236✔
305
  iov[1].iov_len = packet.size();
236✔
306

307
  int wret = Utility::writev(dc->d_socket, iov, 2);
236✔
308
  bool hadError = true;
236✔
309

310
  if (wret == 0) {
236!
311
    g_log << Logger::Warning << "EOF writing TCP answer to " << dc->getRemote() << endl;
×
312
  }
×
313
  else if (wret < 0) {
236!
314
    int err = errno;
×
315
    g_log << Logger::Warning << "Error writing TCP answer to " << dc->getRemote() << ": " << strerror(err) << endl;
×
316
  }
×
317
  else if ((unsigned int)wret != 2 + packet.size()) {
236!
318
    g_log << Logger::Warning << "Oops, partial answer sent to " << dc->getRemote() << " for " << dc->d_mdp.d_qname << " (size=" << (2 + packet.size()) << ", sent " << wret << ")" << endl;
×
319
  }
×
320
  else {
236✔
321
    hadError = false;
236✔
322
  }
236✔
323

324
  return hadError;
236✔
325
}
236✔
326

327
// For communicating with our threads effectively readonly after
328
// startup.
329
// First we have the handler thread, t_id == 0 (some other helper
330
// threads like SNMP might have t_id == 0 as well) then the
331
// distributor threads if any and finally the workers
332
struct RecThreadInfo
333
{
334
  struct ThreadPipeSet
335
  {
336
    int writeToThread{-1};
337
    int readToThread{-1};
338
    int writeFromThread{-1};
339
    int readFromThread{-1};
340
    int writeQueriesToThread{-1}; // this one is non-blocking
341
    int readQueriesToThread{-1};
342
  };
343

344
public:
345
  static RecThreadInfo& self()
346
  {
16,668✔
347
    return s_threadInfos.at(t_id);
16,668✔
348
  }
16,668✔
349

350
  static RecThreadInfo& info(unsigned int index)
351
  {
6,311✔
352
    return s_threadInfos.at(index);
6,311✔
353
  }
6,311✔
354

355
  static vector<RecThreadInfo>& infos()
356
  {
2,051✔
357
    return s_threadInfos;
2,051✔
358
  }
2,051✔
359

360
  [[nodiscard]] bool isDistributor() const
361
  {
3,611✔
362
    if (t_id == 0) {
3,611!
363
      return false;
×
364
    }
×
365
    return s_weDistributeQueries && listener;
3,611!
366
  }
3,611✔
367

368
  [[nodiscard]] bool isHandler() const
369
  {
54,649✔
370
    if (t_id == 0) {
54,649✔
371
      return true;
5,692✔
372
    }
5,692✔
373
    return handler;
48,957✔
374
  }
54,649✔
375

376
  [[nodiscard]] bool isWorker() const
377
  {
7,330✔
378
    return worker;
7,330✔
379
  }
7,330✔
380

381
  // UDP or TCP listener?
382
  [[nodiscard]] bool isListener() const
383
  {
973✔
384
    return listener;
973✔
385
  }
973✔
386

387
  // A TCP-only listener?
388
  [[nodiscard]] bool isTCPListener() const
389
  {
24✔
390
    return tcplistener;
24✔
391
  }
24✔
392

393
  [[nodiscard]] bool isTaskThread() const
394
  {
24,911✔
395
    return taskThread;
24,911✔
396
  }
24,911✔
397

398
  void setHandler()
399
  {
153✔
400
    handler = true;
153✔
401
  }
153✔
402

403
  void setWorker()
404
  {
486✔
405
    worker = true;
486✔
406
  }
486✔
407

408
  void setListener(bool flag = true)
409
  {
500✔
410
    listener = flag;
500✔
411
  }
500✔
412

413
  void setTCPListener(bool flag = true)
414
  {
153✔
415
    setListener(flag);
153✔
416
    tcplistener = flag;
153✔
417
  }
153✔
418

419
  void setTaskThread()
420
  {
153✔
421
    taskThread = true;
153✔
422
  }
153✔
423

424
  static unsigned int id()
425
  {
13,711✔
426
    return t_id;
13,711✔
427
  }
13,711✔
428

429
  static void setThreadId(unsigned int arg)
430
  {
×
431
    t_id = arg;
×
432
  }
×
433

434
  [[nodiscard]] std::string getName() const
435
  {
276✔
436
    return name;
276✔
437
  }
276✔
438

439
  static unsigned int numHandlers()
440
  {
5,613✔
441
    return 1;
5,613✔
442
  }
5,613✔
443

444
  static unsigned int numTaskThreads()
445
  {
2,614✔
446
    return 1;
2,614✔
447
  }
2,614✔
448

449
  static unsigned int numUDPWorkers()
450
  {
12,892✔
451
    return s_numUDPWorkerThreads;
12,892✔
452
  }
12,892✔
453

454
  static unsigned int numTCPWorkers()
455
  {
3,814✔
456
    return s_numTCPWorkerThreads;
3,814✔
457
  }
3,814✔
458

459
  static unsigned int numDistributors()
460
  {
6,108✔
461
    return s_numDistributorThreads;
6,108✔
462
  }
6,108✔
463

464
  static bool weDistributeQueries()
465
  {
6,287✔
466
    return s_weDistributeQueries;
6,287✔
467
  }
6,287✔
468

469
  static void setWeDistributeQueries(bool flag)
470
  {
153✔
471
    s_weDistributeQueries = flag;
153✔
472
  }
153✔
473

474
  static void setNumUDPWorkerThreads(unsigned int n)
475
  {
153✔
476
    s_numUDPWorkerThreads = n;
153✔
477
  }
153✔
478

479
  static void setNumTCPWorkerThreads(unsigned int n)
480
  {
153✔
481
    s_numTCPWorkerThreads = n;
153✔
482
  }
153✔
483

484
  static void setNumDistributorThreads(unsigned int n)
485
  {
153✔
486
    s_numDistributorThreads = n;
153✔
487
  }
153✔
488

489
  static unsigned int numRecursorThreads()
490
  {
2,002✔
491
    return numHandlers() + numDistributors() + numUDPWorkers() + numTCPWorkers() + numTaskThreads();
2,002✔
492
  }
2,002✔
493

494
  static int runThreads(Logr::log_t);
495
  static void makeThreadPipes(Logr::log_t);
496

497
  void setExitCode(int n)
498
  {
×
499
    exitCode = n;
×
500
  }
×
501

502
  std::set<int>& getTCPSockets()
503
  {
141✔
504
    return tcpSockets;
141✔
505
  }
141✔
506

507
  void setTCPSockets(std::set<int>& socks)
508
  {
12✔
509
    tcpSockets = socks;
12✔
510
  }
12✔
511

512
  deferredAdd_t& getDeferredAdds()
513
  {
842✔
514
    return deferredAdds;
842✔
515
  }
842✔
516

517
  const ThreadPipeSet& getPipes() const
518
  {
14,701✔
519
    return pipes;
14,701✔
520
  }
14,701✔
521

522
  [[nodiscard]] uint64_t getNumberOfDistributedQueries() const
523
  {
189✔
524
    return numberOfDistributedQueries;
189✔
525
  }
189✔
526

527
  void incNumberOfDistributedQueries()
528
  {
4,761✔
529
    numberOfDistributedQueries++;
4,761✔
530
  }
4,761✔
531

532
  MT_t* getMT()
533
  {
×
534
    return mt;
×
535
  }
×
536

537
  void setMT(MT_t* theMT)
538
  {
806✔
539
    mt = theMT;
806✔
540
  }
806✔
541

542
private:
543
  // FD corresponding to TCP sockets this thread is listening on.
544
  // These FDs are also in deferredAdds when we have one socket per
545
  // listener, and in g_deferredAdds instead.
546
  std::set<int> tcpSockets;
547
  // FD corresponding to listening sockets if we have one socket per
548
  // listener (with reuseport), otherwise all listeners share the
549
  // same FD and g_deferredAdds is then used instead
550
  deferredAdd_t deferredAdds;
551

552
  struct ThreadPipeSet pipes;
553
  MT_t* mt{nullptr};
554
  uint64_t numberOfDistributedQueries{0};
555

556
  void start(unsigned int tid, const string& tname, const std::map<unsigned int, std::set<int>>& cpusMap, Logr::log_t);
557

558
  std::string name;
559
  std::thread thread;
560
  int exitCode{0};
561

562
  // handle the web server, carbon, statistics and the control channel
563
  bool handler{false};
564
  // accept incoming queries (and distributes them to the workers if pdns-distributes-queries is set)
565
  bool listener{false};
566
  // accept incoming TCP queries (and distributes them to the workers if pdns-distributes-queries is set)
567
  bool tcplistener{false};
568
  // process queries
569
  bool worker{false};
570
  // run async tasks: from TaskQueue and ZoneToCache
571
  bool taskThread{false};
572

573
  static thread_local unsigned int t_id;
574
  static std::vector<RecThreadInfo> s_threadInfos;
575
  static bool s_weDistributeQueries; // if true, 1 or more threads listen on the incoming query sockets and distribute them to workers
576
  static unsigned int s_numDistributorThreads;
577
  static unsigned int s_numUDPWorkerThreads;
578
  static unsigned int s_numTCPWorkerThreads;
579
};
580

581
struct ThreadMSG
582
{
583
  pipefunc_t func;
584
  bool wantAnswer;
585
};
586

587
void parseACLs();
588
PacketBuffer GenUDPQueryResponse(const ComboAddress& dest, const string& query);
589
bool checkProtobufExport(LocalStateHolder<LuaConfigItems>& luaconfsLocal);
590
bool checkOutgoingProtobufExport(LocalStateHolder<LuaConfigItems>& luaconfsLocal);
591
#ifdef HAVE_FSTRM
592
bool checkFrameStreamExport(LocalStateHolder<LuaConfigItems>& luaconfsLocal, const FrameStreamExportConfig& config, FrameStreamServersInfo& serverInfos);
593
#endif
594
void getQNameAndSubnet(const std::string& question, DNSName* dnsname, uint16_t* qtype, uint16_t* qclass,
595
                       bool& foundECS, EDNSSubnetOpts* ednssubnet, EDNSOptionViewMap* options, boost::optional<uint32_t>& ednsVersion);
596
void protobufLogQuery(LocalStateHolder<LuaConfigItems>& luaconfsLocal, const boost::uuids::uuid& uniqueId, const ComboAddress& remote, const ComboAddress& local, const ComboAddress& mappedSource, const Netmask& ednssubnet, bool tcp, size_t len, const DNSName& qname, uint16_t qtype, uint16_t qclass, const std::unordered_set<std::string>& policyTags, const std::string& requestorId, const std::string& deviceId, const std::string& deviceName, const std::map<std::string, RecursorLua4::MetaValue>& meta, const boost::optional<uint32_t>& ednsVersion, const dnsheader& header);
597
bool isAllowNotifyForZone(DNSName qname);
598
bool checkForCacheHit(bool qnameParsed, unsigned int tag, const string& data,
599
                      DNSName& qname, uint16_t& qtype, uint16_t& qclass,
600
                      const struct timeval& now,
601
                      string& response, uint32_t& qhash,
602
                      RecursorPacketCache::OptPBData& pbData, bool tcp, const ComboAddress& source, const ComboAddress& mappedSource);
603
void protobufLogResponse(pdns::ProtoZero::RecMessage& message);
604
void protobufLogResponse(const struct dnsheader* header, LocalStateHolder<LuaConfigItems>& luaconfsLocal,
605
                         const RecursorPacketCache::OptPBData& pbData, const struct timeval& tv,
606
                         bool tcp, const ComboAddress& source, const ComboAddress& destination,
607
                         const ComboAddress& mappedSource, const EDNSSubnetOpts& ednssubnet,
608
                         const boost::uuids::uuid& uniqueId, const string& requestorId, const string& deviceId,
609
                         const string& deviceName, const std::map<std::string, RecursorLua4::MetaValue>& meta,
610
                         const RecEventTrace& eventTrace,
611
                         const std::unordered_set<std::string>& policyTags);
612
void requestWipeCaches(const DNSName& canon);
613
void startDoResolve(void*);
614
bool expectProxyProtocol(const ComboAddress& from, const ComboAddress& listenAddress);
615
void finishTCPReply(std::unique_ptr<DNSComboWriter>&, bool hadError, bool updateInFlight);
616
void checkFastOpenSysctl(bool active, Logr::log_t);
617
void checkTFOconnect(Logr::log_t);
618
unsigned int makeTCPServerSockets(deferredAdd_t& deferredAdds, std::set<int>& tcpSockets, Logr::log_t, bool doLog, unsigned int instances);
619
void handleNewTCPQuestion(int fileDesc, FDMultiplexer::funcparam_t&);
620

621
unsigned int makeUDPServerSockets(deferredAdd_t& deferredAdds, Logr::log_t, bool doLog, unsigned int instances);
622
string doTraceRegex(FDWrapper file, vector<string>::const_iterator begin, vector<string>::const_iterator end);
623
extern bool g_luaSettingsInYAML;
624
void startLuaConfigDelayedThreads(const LuaConfigItems& luaConfig, uint64_t generation);
625
void activateLuaConfig(LuaConfigItems& lci);
626
unsigned int authWaitTimeMSec(const std::unique_ptr<MT_t>& mtasker);
627

628
#define LOCAL_NETS "127.0.0.0/8, 10.0.0.0/8, 100.64.0.0/10, 169.254.0.0/16, 192.168.0.0/16, 172.16.0.0/12, ::1/128, fc00::/7, fe80::/10"
×
629
#define LOCAL_NETS_INVERSE "!127.0.0.0/8, !10.0.0.0/8, !100.64.0.0/10, !169.254.0.0/16, !192.168.0.0/16, !172.16.0.0/12, !::1/128, !fc00::/7, !fe80::/10"
630
// Bad Nets taken from both:
631
// http://www.iana.org/assignments/iana-ipv4-special-registry/iana-ipv4-special-registry.xhtml
632
// and
633
// http://www.iana.org/assignments/iana-ipv6-special-registry/iana-ipv6-special-registry.xhtml
634
// where such a network may not be considered a valid destination
635
#define BAD_NETS "0.0.0.0/8, 192.0.0.0/24, 192.0.2.0/24, 198.51.100.0/24, 203.0.113.0/24, 240.0.0.0/4, ::/96, ::ffff:0:0/96, 100::/64, 2001:db8::/32"
636
#define DONT_QUERY LOCAL_NETS ", " BAD_NETS
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