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