]>
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 {"Allow", (int)DNSAction::Action::Allow
},
35 {"HeaderModify", (int)DNSAction::Action::HeaderModify
},
36 {"Pool", (int)DNSAction::Action::Pool
},
37 {"None",(int)DNSAction::Action::None
},
38 {"NoOp",(int)DNSAction::Action::NoOp
},
39 {"Delay", (int)DNSAction::Action::Delay
},
40 {"Truncate", (int)DNSAction::Action::Truncate
},
41 {"ServFail", (int)DNSAction::Action::ServFail
},
42 {"NoRecurse", (int)DNSAction::Action::NoRecurse
}
45 g_lua
.writeVariable("DNSResponseAction", std::unordered_map
<string
,int>{
46 {"Allow", (int)DNSResponseAction::Action::Allow
},
47 {"Delay", (int)DNSResponseAction::Action::Delay
},
48 {"Drop", (int)DNSResponseAction::Action::Drop
},
49 {"HeaderModify", (int)DNSResponseAction::Action::HeaderModify
},
50 {"ServFail", (int)DNSResponseAction::Action::ServFail
},
51 {"None", (int)DNSResponseAction::Action::None
}
54 g_lua
.writeVariable("DNSClass", std::unordered_map
<string
,int>{
56 {"CHAOS", QClass::CHAOS
},
57 {"NONE", QClass::NONE
},
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
}
69 g_lua
.writeVariable("DNSSection", std::unordered_map
<string
,int>{
76 g_lua
.writeVariable("EDNSOptionCode", std::unordered_map
<string
,int>{
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
}
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
}
113 vector
<pair
<string
, int> > dd
;
114 for(const auto& n
: QType::names
)
115 dd
.push_back({n
.first
, n
.second
});
116 g_lua
.writeVariable("DNSQType", dd
);
118 g_lua
.executeCode(R
"LUA(
123 local function index (table, key)
124 for tname,t in pairs(tables)
128 warnlog(string.format("access to dnsdist
.%s is deprecated
, please use
%s
.%s
", key, tname, key))
135 setmetatable(dnsdist, { __index = index })
140 g_lua
.writeVariable("DNSCryptExchangeVersion", std::unordered_map
<string
,int>{
141 { "VERSION1", DNSCryptExchangeVersion::VERSION1
},
142 { "VERSION2", DNSCryptExchangeVersion::VERSION2
},