]>
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 | */ | |
684d5f6b | 22 | #pragma once |
0bd2e252 RG |
23 | #include <set> |
24 | ||
684d5f6b | 25 | #include "sholder.hh" |
26 | #include "sortlist.hh" | |
ad42489c | 27 | #include "filterpo.hh" |
52ad9eea | 28 | #include "validate.hh" |
e807cd1e | 29 | #include "rec-zonetocache.hh" |
62b191dc | 30 | #include "logging.hh" |
afaf1b5d | 31 | #include "fstrm_logger.hh" |
ad42489c | 32 | |
63341e8d RG |
33 | struct ProtobufExportConfig |
34 | { | |
a7f98e34 | 35 | std::set<uint16_t> exportTypes = {QType::A, QType::AAAA, QType::CNAME}; |
b773359c | 36 | std::vector<ComboAddress> servers; |
63341e8d RG |
37 | uint64_t maxQueuedEntries{100}; |
38 | uint16_t timeout{2}; | |
39 | uint16_t reconnectWaitTime{1}; | |
40 | bool asyncConnect{false}; | |
41 | bool enabled{false}; | |
f1c7929a RG |
42 | bool logQueries{true}; |
43 | bool logResponses{true}; | |
44 | bool taggedOnly{false}; | |
e81063e5 | 45 | bool logMappedFrom{false}; |
63341e8d RG |
46 | }; |
47 | ||
babe9430 OM |
48 | bool operator==(const ProtobufExportConfig& configA, const ProtobufExportConfig& configB); |
49 | bool operator!=(const ProtobufExportConfig& configA, const ProtobufExportConfig& configB); | |
50 | ||
b9fa43e0 OM |
51 | struct FrameStreamExportConfig |
52 | { | |
dea8a6bc | 53 | std::vector<string> servers; |
b9fa43e0 | 54 | bool enabled{false}; |
573f4ff0 OM |
55 | bool logQueries{true}; |
56 | bool logResponses{true}; | |
9489e2b5 CHB |
57 | bool logNODs{true}; |
58 | bool logUDRs{false}; | |
573f4ff0 OM |
59 | unsigned bufferHint{0}; |
60 | unsigned flushTimeout{0}; | |
61 | unsigned inputQueueSize{0}; | |
62 | unsigned outputQueueSize{0}; | |
63 | unsigned queueNotifyThreshold{0}; | |
64 | unsigned reopenInterval{0}; | |
b9fa43e0 OM |
65 | }; |
66 | ||
afaf1b5d FM |
67 | bool operator==(const FrameStreamExportConfig& configA, const FrameStreamExportConfig& configB); |
68 | bool operator!=(const FrameStreamExportConfig& configA, const FrameStreamExportConfig& configB); | |
69 | ||
a7f98e34 O |
70 | struct TrustAnchorFileInfo |
71 | { | |
e4ae55e5 PL |
72 | uint32_t interval{24}; |
73 | std::string fname; | |
74 | }; | |
75 | ||
1fc89740 OM |
76 | enum class AdditionalMode : uint8_t |
77 | { | |
c21f8271 OM |
78 | Ignore, |
79 | CacheOnly, | |
80 | CacheOnlyRequireAuth, | |
81 | ResolveImmediately, | |
82 | ResolveDeferred | |
83 | }; | |
84 | ||
c375521b OM |
85 | struct ProxyMappingCounts |
86 | { | |
87 | uint64_t netmaskMatches{}; | |
88 | uint64_t suffixMatches{}; | |
89 | }; | |
90 | ||
20bfad6d OM |
91 | struct ProxyByTableValue |
92 | { | |
93 | ComboAddress address; | |
94 | boost::optional<SuffixMatchNode> suffixMatchNode; | |
c375521b | 95 | mutable ProxyMappingCounts stats{}; |
20bfad6d OM |
96 | }; |
97 | ||
98 | using ProxyMapping = NetmaskTree<ProxyByTableValue, Netmask>; | |
e81063e5 | 99 | |
a7f98e34 | 100 | class LuaConfigItems |
684d5f6b | 101 | { |
102 | public: | |
103 | LuaConfigItems(); | |
104 | SortList sortlist; | |
ad42489c | 105 | DNSFilterEngine dfe; |
e4ae55e5 | 106 | TrustAnchorFileInfo trustAnchorFileInfo; // Used to update the Trust Anchors from file periodically |
a7f98e34 O |
107 | map<DNSName, dsmap_t> dsAnchors; |
108 | map<DNSName, std::string> negAnchors; | |
b8d0d0db | 109 | map<DNSName, RecZoneToCache::Config> ztcConfigs; |
c21f8271 | 110 | std::map<QType, std::pair<std::set<QType>, AdditionalMode>> allowAdditionalQTypes; |
13dacc77 RG |
111 | ProtobufExportConfig protobufExportConfig; |
112 | ProtobufExportConfig outgoingProtobufExportConfig; | |
b9fa43e0 | 113 | FrameStreamExportConfig frameStreamExportConfig; |
9489e2b5 | 114 | FrameStreamExportConfig nodFrameStreamExportConfig; |
62b191dc | 115 | std::shared_ptr<Logr::Logger> d_slog; |
63341e8d RG |
116 | /* we need to increment this every time the configuration |
117 | is reloaded, so we know if we need to reload the protobuf | |
118 | remote loggers */ | |
63341e8d | 119 | uint64_t generation{0}; |
e1c8a4bb RG |
120 | uint8_t protobufMaskV4{32}; |
121 | uint8_t protobufMaskV6{128}; | |
684d5f6b | 122 | }; |
123 | ||
124 | extern GlobalStateHolder<LuaConfigItems> g_luaconfs; | |
e6ec15bf RG |
125 | |
126 | struct luaConfigDelayedThreads | |
127 | { | |
4da91ffa | 128 | // Please make sure that the tuple below only contains value types since they are used as parameters in a thread ct |
a7f98e34 | 129 | std::vector<std::tuple<std::vector<ComboAddress>, boost::optional<DNSFilterEngine::Policy>, bool, uint32_t, size_t, TSIGTriplet, size_t, ComboAddress, uint16_t, uint32_t, std::shared_ptr<SOARecordContent>, std::string>> rpzPrimaryThreads; |
e6ec15bf RG |
130 | }; |
131 | ||
e81063e5 | 132 | void loadRecursorLuaConfig(const std::string& fname, luaConfigDelayedThreads& delayedThreads, ProxyMapping&); |
e6ec15bf | 133 | void startLuaConfigDelayedThreads(const luaConfigDelayedThreads& delayedThreads, uint64_t generation); |