2 * This file is part of PowerDNS or dnsdist.
3 * Copyright -- PowerDNS.COM B.V. and its contributors
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.
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.
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.
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.
37 extern GlobalStateHolder<SuffixMatchNode> g_dontThrottleNames;
38 extern GlobalStateHolder<NetmaskGroup> g_dontThrottleNetmasks;
40 /** this class is used both to send and answer channel commands to the PowerDNS Recursor */
41 class RecursorControlChannel
44 RecursorControlChannel();
46 ~RecursorControlChannel();
48 int listen(const std::string& filename);
49 void connect(const std::string& path, const std::string& filename);
51 uint64_t getStat(const std::string& name);
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);
57 static volatile sig_atomic_t stop;
59 struct sockaddr_un d_local;
62 class RecursorControlParser
65 RecursorControlParser()
68 static void nop(void){}
69 typedef void func_t(void);
70 std::string getAnswer(const std::string& question, func_t** func);
73 enum class StatComponent { API, Carbon, RecControl, SNMP };
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);
92 void registerAllStats();
94 void doExitGeneric(bool nicely);