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