]>
Commit | Line | Data |
---|---|---|
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 |
37 | extern GlobalStateHolder<SuffixMatchNode> g_dontThrottleNames; |
38 | extern GlobalStateHolder<NetmaskGroup> g_dontThrottleNetmasks; | |
39 | ||
f6f016d1 BH |
40 | /** this class is used both to send and answer channel commands to the PowerDNS Recursor */ |
41 | class RecursorControlChannel | |
42 | { | |
43 | public: | |
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 |
58 | private: |
59 | struct sockaddr_un d_local; | |
f6f016d1 BH |
60 | }; |
61 | ||
1d5b3ce6 BH |
62 | class RecursorControlParser |
63 | { | |
64 | public: | |
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 |
73 | enum class StatComponent { API, Carbon, RecControl, SNMP }; |
74 | ||
75 | std::map<std::string, std::string> getAllStatsMap(StatComponent component); | |
69b8131b | 76 | extern std::mutex g_carbon_config_lock; |
c5c066bf PD |
77 | std::vector<std::pair<DNSName, uint16_t> >* pleaseGetQueryRing(); |
78 | std::vector<std::pair<DNSName, uint16_t> >* pleaseGetServfailQueryRing(); | |
66f2e6ad | 79 | std::vector<std::pair<DNSName, uint16_t> >* pleaseGetBogusQueryRing(); |
509196af | 80 | std::vector<ComboAddress>* pleaseGetRemotes(); |
81 | std::vector<ComboAddress>* pleaseGetServfailRemotes(); | |
66f2e6ad | 82 | std::vector<ComboAddress>* pleaseGetBogusRemotes(); |
509196af | 83 | std::vector<ComboAddress>* pleaseGetLargeAnswerRemotes(); |
621ccf89 | 84 | std::vector<ComboAddress>* pleaseGetTimeouts(); |
c5c066bf | 85 | DNSName getRegisteredName(const DNSName& dom); |
9f89a5f1 | 86 | std::atomic<unsigned long>* getDynMetric(const std::string& str); |
d705aad9 | 87 | optional<uint64_t> getStatByName(const std::string& name); |
72259676 RG |
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 | ||
b0b37121 | 92 | void registerAllStats(); |
5e08df89 | 93 | |
9f374187 FL |
94 | void doExitGeneric(bool nicely); |
95 | void doExit(); | |
96 | void doExitNicely(); |