]> git.ipfire.org Git - thirdparty/pdns.git/blame - pdns/dnsdist-lua-vars.cc
Merge branch 'master' into issue-6346
[thirdparty/pdns.git] / pdns / dnsdist-lua-vars.cc
CommitLineData
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"
23
24void setupLuaVars()
25{
26 g_lua.writeVariable("DNSAction", std::unordered_map<string,int>{
27 {"Drop", (int)DNSAction::Action::Drop},
28 {"Nxdomain", (int)DNSAction::Action::Nxdomain},
29 {"Refused", (int)DNSAction::Action::Refused},
30 {"Spoof", (int)DNSAction::Action::Spoof},
31 {"Allow", (int)DNSAction::Action::Allow},
32 {"HeaderModify", (int)DNSAction::Action::HeaderModify},
33 {"Pool", (int)DNSAction::Action::Pool},
34 {"None",(int)DNSAction::Action::None},
35 {"Delay", (int)DNSAction::Action::Delay},
5f23eb98
CH
36 {"Truncate", (int)DNSAction::Action::Truncate},
37 {"ServFail", (int)DNSAction::Action::ServFail}
6bb38cd6
RG
38 });
39
40 g_lua.writeVariable("DNSResponseAction", std::unordered_map<string,int>{
41 {"Allow", (int)DNSResponseAction::Action::Allow },
42 {"Delay", (int)DNSResponseAction::Action::Delay },
43 {"HeaderModify", (int)DNSResponseAction::Action::HeaderModify },
5f23eb98 44 {"ServFail", (int)DNSResponseAction::Action::ServFail },
6bb38cd6
RG
45 {"None", (int)DNSResponseAction::Action::None }
46 });
47
48 g_lua.writeVariable("DNSClass", std::unordered_map<string,int>{
49 {"IN", QClass::IN },
50 {"CHAOS", QClass::CHAOS },
51 {"NONE", QClass::NONE },
52 {"ANY", QClass::ANY }
53 });
54
55 g_lua.writeVariable("DNSOpcode", std::unordered_map<string,int>{
56 {"Query", Opcode::Query },
57 {"IQuery", Opcode::IQuery },
58 {"Status", Opcode::Status },
59 {"Notify", Opcode::Notify },
60 {"Update", Opcode::Update }
61 });
62
63 g_lua.writeVariable("DNSSection", std::unordered_map<string,int>{
64 {"Question", 0 },
65 {"Answer", 1 },
66 {"Authority", 2 },
67 {"Additional",3 }
68 });
69
70 vector<pair<string, int> > rcodes = {{"NOERROR", RCode::NoError },
71 {"FORMERR", RCode::FormErr },
72 {"SERVFAIL", RCode::ServFail },
73 {"NXDOMAIN", RCode::NXDomain },
74 {"NOTIMP", RCode::NotImp },
75 {"REFUSED", RCode::Refused },
76 {"YXDOMAIN", RCode::YXDomain },
77 {"YXRRSET", RCode::YXRRSet },
78 {"NXRRSET", RCode::NXRRSet },
79 {"NOTAUTH", RCode::NotAuth },
d83feb68
CH
80 {"NOTZONE", RCode::NotZone },
81 {"BADVERS", ERCode::BADVERS },
82 {"BADSIG", ERCode::BADSIG },
83 {"BADKEY", ERCode::BADKEY },
84 {"BADTIME", ERCode::BADTIME },
85 {"BADMODE", ERCode::BADMODE },
86 {"BADNAME", ERCode::BADNAME },
87 {"BADALG", ERCode::BADALG },
88 {"BADTRUNC", ERCode::BADTRUNC },
89 {"BADCOOKIE",ERCode::BADCOOKIE },
6bb38cd6
RG
90 };
91 vector<pair<string, int> > dd;
92 for(const auto& n : QType::names)
93 dd.push_back({n.first, n.second});
94 for(const auto& n : rcodes)
95 dd.push_back({n.first, n.second});
96 g_lua.writeVariable("dnsdist", dd);
97}