]> git.ipfire.org Git - thirdparty/pdns.git/blob - pdns/rec_channel.hh
limit compression pointers to 14 bits
[thirdparty/pdns.git] / pdns / rec_channel.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 #include <string>
26 #include <map>
27 #include <vector>
28 #include <inttypes.h>
29 #include <sys/un.h>
30 #include <pthread.h>
31 #include "iputils.hh"
32 #include "dnsname.hh"
33 #include "sholder.hh"
34 #include <atomic>
35
36 extern GlobalStateHolder<SuffixMatchNode> g_dontThrottleNames;
37 extern GlobalStateHolder<NetmaskGroup> g_dontThrottleNetmasks;
38
39 /** this class is used both to send and answer channel commands to the PowerDNS Recursor */
40 class RecursorControlChannel
41 {
42 public:
43 RecursorControlChannel();
44
45 ~RecursorControlChannel();
46
47 int listen(const std::string& filename);
48 void connect(const std::string& path, const std::string& filename);
49
50 uint64_t getStat(const std::string& name);
51
52 void send(const std::string& msg, const std::string* remote=nullptr, unsigned int timeout=5);
53 std::string recv(std::string* remote=0, unsigned int timeout=5);
54
55 int d_fd;
56 private:
57 struct sockaddr_un d_local;
58 };
59
60 class RecursorControlParser
61 {
62 public:
63 RecursorControlParser()
64 {
65 }
66 static void nop(void){}
67 typedef void func_t(void);
68 std::string getAnswer(const std::string& question, func_t** func);
69 };
70
71 enum class StatComponent { API, Carbon, RecControl, SNMP };
72
73 std::map<std::string, std::string> getAllStatsMap(StatComponent component);
74 extern pthread_mutex_t g_carbon_config_lock;
75 std::vector<std::pair<DNSName, uint16_t> >* pleaseGetQueryRing();
76 std::vector<std::pair<DNSName, uint16_t> >* pleaseGetServfailQueryRing();
77 std::vector<std::pair<DNSName, uint16_t> >* pleaseGetBogusQueryRing();
78 std::vector<ComboAddress>* pleaseGetRemotes();
79 std::vector<ComboAddress>* pleaseGetServfailRemotes();
80 std::vector<ComboAddress>* pleaseGetBogusRemotes();
81 std::vector<ComboAddress>* pleaseGetLargeAnswerRemotes();
82 std::vector<ComboAddress>* pleaseGetTimeouts();
83 DNSName getRegisteredName(const DNSName& dom);
84 std::atomic<unsigned long>* getDynMetric(const std::string& str);
85 optional<uint64_t> getStatByName(const std::string& name);
86 bool isStatBlacklisted(StatComponent component, const std::string& name);
87 void blacklistStat(StatComponent component, const string& name);
88 void blacklistStats(StatComponent component, const string& stats);
89
90 void registerAllStats();
91