]>
Commit | Line | Data |
---|---|---|
6bb38cd6 RG |
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 | #include "dnsdist.hh" | |
a98a6108 | 23 | #include "ednsoptions.hh" |
6bb38cd6 | 24 | |
8bce9728 RG |
25 | #undef BADSIG // signal.h SIG_ERR |
26 | ||
6bb38cd6 RG |
27 | void setupLuaVars() |
28 | { | |
311f9aaf | 29 | g_lua.writeVariable("DNSAction", std::unordered_map<string,int>{ |
6bb38cd6 RG |
30 | {"Drop", (int)DNSAction::Action::Drop}, |
31 | {"Nxdomain", (int)DNSAction::Action::Nxdomain}, | |
32 | {"Refused", (int)DNSAction::Action::Refused}, | |
33 | {"Spoof", (int)DNSAction::Action::Spoof}, | |
34 | {"Allow", (int)DNSAction::Action::Allow}, | |
35 | {"HeaderModify", (int)DNSAction::Action::HeaderModify}, | |
36 | {"Pool", (int)DNSAction::Action::Pool}, | |
37 | {"None",(int)DNSAction::Action::None}, | |
477c86a0 | 38 | {"NoOp",(int)DNSAction::Action::NoOp}, |
6bb38cd6 | 39 | {"Delay", (int)DNSAction::Action::Delay}, |
5f23eb98 | 40 | {"Truncate", (int)DNSAction::Action::Truncate}, |
3d60b39a | 41 | {"ServFail", (int)DNSAction::Action::ServFail}, |
42 | {"NoRecurse", (int)DNSAction::Action::NoRecurse} | |
6bb38cd6 RG |
43 | }); |
44 | ||
45 | g_lua.writeVariable("DNSResponseAction", std::unordered_map<string,int>{ | |
46 | {"Allow", (int)DNSResponseAction::Action::Allow }, | |
47 | {"Delay", (int)DNSResponseAction::Action::Delay }, | |
311f9aaf | 48 | {"Drop", (int)DNSResponseAction::Action::Drop }, |
6bb38cd6 | 49 | {"HeaderModify", (int)DNSResponseAction::Action::HeaderModify }, |
5f23eb98 | 50 | {"ServFail", (int)DNSResponseAction::Action::ServFail }, |
6bb38cd6 RG |
51 | {"None", (int)DNSResponseAction::Action::None } |
52 | }); | |
53 | ||
54 | g_lua.writeVariable("DNSClass", std::unordered_map<string,int>{ | |
55 | {"IN", QClass::IN }, | |
56 | {"CHAOS", QClass::CHAOS }, | |
57 | {"NONE", QClass::NONE }, | |
58 | {"ANY", QClass::ANY } | |
59 | }); | |
60 | ||
61 | g_lua.writeVariable("DNSOpcode", std::unordered_map<string,int>{ | |
62 | {"Query", Opcode::Query }, | |
63 | {"IQuery", Opcode::IQuery }, | |
64 | {"Status", Opcode::Status }, | |
65 | {"Notify", Opcode::Notify }, | |
66 | {"Update", Opcode::Update } | |
67 | }); | |
68 | ||
69 | g_lua.writeVariable("DNSSection", std::unordered_map<string,int>{ | |
70 | {"Question", 0 }, | |
71 | {"Answer", 1 }, | |
72 | {"Authority", 2 }, | |
73 | {"Additional",3 } | |
74 | }); | |
75 | ||
6bb92a06 | 76 | g_lua.writeVariable("EDNSOptionCode", std::unordered_map<string,int>{ |
a98a6108 PD |
77 | {"NSID", EDNSOptionCode::NSID }, |
78 | {"DAU", EDNSOptionCode::DAU }, | |
79 | {"DHU", EDNSOptionCode::DHU }, | |
80 | {"N3U", EDNSOptionCode::N3U }, | |
81 | {"ECS", EDNSOptionCode::ECS }, | |
82 | {"EXPIRE", EDNSOptionCode::EXPIRE }, | |
83 | {"COOKIE", EDNSOptionCode::COOKIE }, | |
84 | {"TCPKEEPALIVE", EDNSOptionCode::TCPKEEPALIVE }, | |
85 | {"PADDING", EDNSOptionCode::PADDING }, | |
86 | {"CHAIN", EDNSOptionCode::CHAIN }, | |
87 | {"KEYTAG", EDNSOptionCode::KEYTAG } | |
6bb92a06 PD |
88 | }); |
89 | ||
6ee46168 PD |
90 | g_lua.writeVariable("DNSRCode", std::unordered_map<string, int>{ |
91 | {"NOERROR", RCode::NoError }, | |
92 | {"FORMERR", RCode::FormErr }, | |
93 | {"SERVFAIL", RCode::ServFail }, | |
94 | {"NXDOMAIN", RCode::NXDomain }, | |
95 | {"NOTIMP", RCode::NotImp }, | |
96 | {"REFUSED", RCode::Refused }, | |
97 | {"YXDOMAIN", RCode::YXDomain }, | |
98 | {"YXRRSET", RCode::YXRRSet }, | |
99 | {"NXRRSET", RCode::NXRRSet }, | |
100 | {"NOTAUTH", RCode::NotAuth }, | |
101 | {"NOTZONE", RCode::NotZone }, | |
102 | {"BADVERS", ERCode::BADVERS }, | |
103 | {"BADSIG", ERCode::BADSIG }, | |
104 | {"BADKEY", ERCode::BADKEY }, | |
105 | {"BADTIME", ERCode::BADTIME }, | |
106 | {"BADMODE", ERCode::BADMODE }, | |
107 | {"BADNAME", ERCode::BADNAME }, | |
108 | {"BADALG", ERCode::BADALG }, | |
109 | {"BADTRUNC", ERCode::BADTRUNC }, | |
110 | {"BADCOOKIE",ERCode::BADCOOKIE } | |
111 | }); | |
112 | ||
6bb38cd6 RG |
113 | vector<pair<string, int> > dd; |
114 | for(const auto& n : QType::names) | |
115 | dd.push_back({n.first, n.second}); | |
6ee46168 PD |
116 | g_lua.writeVariable("DNSQType", dd); |
117 | ||
118 | g_lua.executeCode(R"LUA( | |
119 | local tables = { | |
120 | DNSQType = DNSQType, | |
121 | DNSRCode = DNSRCode | |
122 | } | |
123 | local function index (table, key) | |
124 | for tname,t in pairs(tables) | |
125 | do | |
126 | local val = t[key] | |
127 | if val then | |
128 | warnlog(string.format("access to dnsdist.%s is deprecated, please use %s.%s", key, tname, key)) | |
129 | return val | |
130 | end | |
131 | end | |
132 | end | |
133 | ||
134 | dnsdist = {} | |
135 | setmetatable(dnsdist, { __index = index }) | |
136 | )LUA" | |
137 | ); | |
433d64e3 RG |
138 | |
139 | #ifdef HAVE_DNSCRYPT | |
140 | g_lua.writeVariable("DNSCryptExchangeVersion", std::unordered_map<string,int>{ | |
141 | { "VERSION1", DNSCryptExchangeVersion::VERSION1 }, | |
142 | { "VERSION2", DNSCryptExchangeVersion::VERSION2 }, | |
143 | }); | |
144 | #endif | |
6bb38cd6 | 145 | } |