]>
git.ipfire.org Git - thirdparty/pdns.git/blob - pdns/dnsdist-lua-vars.cc
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.
23 #include "dnsdist-lua.hh"
24 #include "ednsoptions.hh"
26 #undef BADSIG // signal.h SIG_ERR
30 g_lua
.writeVariable("DNSAction", std::unordered_map
<string
,int>{
31 {"Drop", (int)DNSAction::Action::Drop
},
32 {"Nxdomain", (int)DNSAction::Action::Nxdomain
},
33 {"Refused", (int)DNSAction::Action::Refused
},
34 {"Spoof", (int)DNSAction::Action::Spoof
},
35 {"SpoofRaw", (int)DNSAction::Action::SpoofRaw
},
36 {"Allow", (int)DNSAction::Action::Allow
},
37 {"HeaderModify", (int)DNSAction::Action::HeaderModify
},
38 {"Pool", (int)DNSAction::Action::Pool
},
39 {"None",(int)DNSAction::Action::None
},
40 {"NoOp",(int)DNSAction::Action::NoOp
},
41 {"Delay", (int)DNSAction::Action::Delay
},
42 {"Truncate", (int)DNSAction::Action::Truncate
},
43 {"ServFail", (int)DNSAction::Action::ServFail
},
44 {"NoRecurse", (int)DNSAction::Action::NoRecurse
}
47 g_lua
.writeVariable("DNSResponseAction", std::unordered_map
<string
,int>{
48 {"Allow", (int)DNSResponseAction::Action::Allow
},
49 {"Delay", (int)DNSResponseAction::Action::Delay
},
50 {"Drop", (int)DNSResponseAction::Action::Drop
},
51 {"HeaderModify", (int)DNSResponseAction::Action::HeaderModify
},
52 {"ServFail", (int)DNSResponseAction::Action::ServFail
},
53 {"None", (int)DNSResponseAction::Action::None
}
56 g_lua
.writeVariable("DNSClass", std::unordered_map
<string
,int>{
58 {"CHAOS", QClass::CHAOS
},
59 {"NONE", QClass::NONE
},
63 g_lua
.writeVariable("DNSOpcode", std::unordered_map
<string
,int>{
64 {"Query", Opcode::Query
},
65 {"IQuery", Opcode::IQuery
},
66 {"Status", Opcode::Status
},
67 {"Notify", Opcode::Notify
},
68 {"Update", Opcode::Update
}
71 g_lua
.writeVariable("DNSSection", std::unordered_map
<string
,int>{
78 g_lua
.writeVariable("EDNSOptionCode", std::unordered_map
<string
,int>{
79 {"NSID", EDNSOptionCode::NSID
},
80 {"DAU", EDNSOptionCode::DAU
},
81 {"DHU", EDNSOptionCode::DHU
},
82 {"N3U", EDNSOptionCode::N3U
},
83 {"ECS", EDNSOptionCode::ECS
},
84 {"EXPIRE", EDNSOptionCode::EXPIRE
},
85 {"COOKIE", EDNSOptionCode::COOKIE
},
86 {"TCPKEEPALIVE", EDNSOptionCode::TCPKEEPALIVE
},
87 {"PADDING", EDNSOptionCode::PADDING
},
88 {"CHAIN", EDNSOptionCode::CHAIN
},
89 {"KEYTAG", EDNSOptionCode::KEYTAG
}
92 g_lua
.writeVariable("DNSRCode", std::unordered_map
<string
, int>{
93 {"NOERROR", RCode::NoError
},
94 {"FORMERR", RCode::FormErr
},
95 {"SERVFAIL", RCode::ServFail
},
96 {"NXDOMAIN", RCode::NXDomain
},
97 {"NOTIMP", RCode::NotImp
},
98 {"REFUSED", RCode::Refused
},
99 {"YXDOMAIN", RCode::YXDomain
},
100 {"YXRRSET", RCode::YXRRSet
},
101 {"NXRRSET", RCode::NXRRSet
},
102 {"NOTAUTH", RCode::NotAuth
},
103 {"NOTZONE", RCode::NotZone
},
104 {"BADVERS", ERCode::BADVERS
},
105 {"BADSIG", ERCode::BADSIG
},
106 {"BADKEY", ERCode::BADKEY
},
107 {"BADTIME", ERCode::BADTIME
},
108 {"BADMODE", ERCode::BADMODE
},
109 {"BADNAME", ERCode::BADNAME
},
110 {"BADALG", ERCode::BADALG
},
111 {"BADTRUNC", ERCode::BADTRUNC
},
112 {"BADCOOKIE",ERCode::BADCOOKIE
}
115 vector
<pair
<string
, int> > dd
;
116 for(const auto& n
: QType::names
)
117 dd
.push_back({n
.first
, n
.second
});
118 g_lua
.writeVariable("DNSQType", dd
);
120 g_lua
.executeCode(R
"LUA(
125 local function index (table, key)
126 for tname,t in pairs(tables)
130 warnlog(string.format("access to dnsdist
.%s is deprecated
, please use
%s
.%s
", key, tname, key))
137 setmetatable(dnsdist, { __index = index })
142 g_lua
.writeVariable("DNSCryptExchangeVersion", std::unordered_map
<string
,int>{
143 { "VERSION1", DNSCryptExchangeVersion::VERSION1
},
144 { "VERSION2", DNSCryptExchangeVersion::VERSION2
},