]> git.ipfire.org Git - thirdparty/pdns.git/blob - pdns/rec_channel.hh
Standardize license text in all PDNS files
[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 #ifndef PDNS_REC_CHANNEL
23 #define PDNS_REC_CHANNEL
24 #include <string>
25 #include <map>
26 #include <vector>
27 #include <inttypes.h>
28 #include <sys/un.h>
29 #include <pthread.h>
30 #include "iputils.hh"
31 #include "dnsname.hh"
32 #include <atomic>
33
34 /** this class is used both to send and answer channel commands to the PowerDNS Recursor */
35 class RecursorControlChannel
36 {
37 public:
38 RecursorControlChannel();
39
40 ~RecursorControlChannel();
41
42 int listen(const std::string& filename);
43 void connect(const std::string& path, const std::string& filename);
44
45 uint64_t getStat(const std::string& name);
46
47 void send(const std::string& msg, const std::string* remote=0);
48 std::string recv(std::string* remote=0, unsigned int timeout=5);
49
50 int d_fd;
51 private:
52 struct sockaddr_un d_local;
53 };
54
55 class RecursorControlParser
56 {
57 public:
58 RecursorControlParser();
59 static void nop(void){}
60 typedef void func_t(void);
61 std::string getAnswer(const std::string& question, func_t** func);
62 private:
63 static bool s_init;
64 };
65
66 std::map<std::string, std::string> getAllStatsMap();
67 extern pthread_mutex_t g_carbon_config_lock;
68 void sortPublicSuffixList();
69 std::vector<std::pair<DNSName, uint16_t> >* pleaseGetQueryRing();
70 std::vector<std::pair<DNSName, uint16_t> >* pleaseGetServfailQueryRing();
71 std::vector<ComboAddress>* pleaseGetRemotes();
72 std::vector<ComboAddress>* pleaseGetServfailRemotes();
73 std::vector<ComboAddress>* pleaseGetLargeAnswerRemotes();
74 DNSName getRegisteredName(const DNSName& dom);
75 std::atomic<unsigned long>* getDynMetric(const std::string& str);
76 #endif