]> git.ipfire.org Git - thirdparty/pdns.git/blame - pdns/rec_channel.hh
Limit the number of queries sent out to get NS addresses per query.
[thirdparty/pdns.git] / pdns / rec_channel.hh
CommitLineData
12471842
PL
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 */
5e08df89
RG
22
23#pragma once
24
f6f016d1 25#include <string>
1d5b3ce6 26#include <map>
3457a2a0 27#include <vector>
2b808f13 28#include <inttypes.h>
a254e9b6 29#include <sys/un.h>
8657c2af 30#include <signal.h>
c684d7ad 31#include <pthread.h>
509196af 32#include "iputils.hh"
c5c066bf 33#include "dnsname.hh"
0c366a8e 34#include "sholder.hh"
27ae5181 35#include <atomic>
f6f016d1 36
0c366a8e
PL
37extern GlobalStateHolder<SuffixMatchNode> g_dontThrottleNames;
38extern GlobalStateHolder<NetmaskGroup> g_dontThrottleNetmasks;
39
f6f016d1
BH
40/** this class is used both to send and answer channel commands to the PowerDNS Recursor */
41class RecursorControlChannel
42{
43public:
a254e9b6
BH
44 RecursorControlChannel();
45
46 ~RecursorControlChannel();
a2bfc3ff 47
f6f016d1 48 int listen(const std::string& filename);
aaacf7f2 49 void connect(const std::string& path, const std::string& filename);
f6f016d1
BH
50
51 uint64_t getStat(const std::string& name);
1d5b3ce6 52
11d641f2 53 void send(const std::string& msg, const std::string* remote=nullptr, unsigned int timeout=5);
61203240 54 std::string recv(std::string* remote=0, unsigned int timeout=5);
1d5b3ce6 55
f6f016d1 56 int d_fd;
8657c2af 57 static volatile sig_atomic_t stop;
a2bfc3ff
BH
58private:
59 struct sockaddr_un d_local;
f6f016d1
BH
60};
61
1d5b3ce6
BH
62class RecursorControlParser
63{
64public:
b0b37121
RG
65 RecursorControlParser()
66 {
67 }
aaacf7f2
BH
68 static void nop(void){}
69 typedef void func_t(void);
70 std::string getAnswer(const std::string& question, func_t** func);
1d5b3ce6
BH
71};
72
72259676
RG
73enum class StatComponent { API, Carbon, RecControl, SNMP };
74
75std::map<std::string, std::string> getAllStatsMap(StatComponent component);
69b8131b 76extern std::mutex g_carbon_config_lock;
c5c066bf
PD
77std::vector<std::pair<DNSName, uint16_t> >* pleaseGetQueryRing();
78std::vector<std::pair<DNSName, uint16_t> >* pleaseGetServfailQueryRing();
66f2e6ad 79std::vector<std::pair<DNSName, uint16_t> >* pleaseGetBogusQueryRing();
509196af 80std::vector<ComboAddress>* pleaseGetRemotes();
81std::vector<ComboAddress>* pleaseGetServfailRemotes();
66f2e6ad 82std::vector<ComboAddress>* pleaseGetBogusRemotes();
509196af 83std::vector<ComboAddress>* pleaseGetLargeAnswerRemotes();
621ccf89 84std::vector<ComboAddress>* pleaseGetTimeouts();
c5c066bf 85DNSName getRegisteredName(const DNSName& dom);
9f89a5f1 86std::atomic<unsigned long>* getDynMetric(const std::string& str);
d705aad9 87optional<uint64_t> getStatByName(const std::string& name);
72259676
RG
88bool isStatBlacklisted(StatComponent component, const std::string& name);
89void blacklistStat(StatComponent component, const string& name);
90void blacklistStats(StatComponent component, const string& stats);
91
b0b37121 92void registerAllStats();
5e08df89 93
9f374187
FL
94void doExitGeneric(bool nicely);
95void doExit();
96void doExitNicely();