]> git.ipfire.org Git - thirdparty/pdns.git/blob - pdns/lua-auth4.hh
rec: mention rust compiler in compiling docs
[thirdparty/pdns.git] / pdns / lua-auth4.hh
1 #pragma once
2 #include "iputils.hh"
3 #include "dnsname.hh"
4 #include "dnspacket.hh"
5 #include "dnsparser.hh"
6 #include <unordered_map>
7 #ifdef HAVE_CONFIG_H
8 #include "config.h"
9 #endif
10 #include "lua-base4.hh"
11
12 class AuthLua4 : public BaseLua4
13 {
14 public:
15 AuthLua4();
16 bool updatePolicy(const DNSName &qname, const QType& qtype, const DNSName &zonename, const DNSPacket& packet);
17 bool axfrfilter(const ComboAddress&, const DNSName&, const DNSResourceRecord&, std::vector<DNSResourceRecord>&);
18 LuaContext* getLua();
19
20 std::unique_ptr<DNSPacket> prequery(const DNSPacket& p);
21
22 ~AuthLua4() override; // this is so unique_ptr works with an incomplete type
23 protected:
24 void postPrepareContext() override;
25 void postLoad() override;
26
27 private:
28 struct UpdatePolicyQuery {
29 DNSName qname;
30 DNSName zonename;
31 uint16_t qtype;
32 ComboAddress local, remote;
33 Netmask realRemote;
34 DNSName tsigName;
35 std::string peerPrincipal;
36 };
37
38 typedef std::function<bool(const UpdatePolicyQuery&)> luacall_update_policy_t;
39 typedef std::function<std::tuple<int, std::unordered_map<int, std::unordered_map<std::string,boost::variant<unsigned int,std::string> > > >(const ComboAddress&, const DNSName&, const DNSResourceRecord&)> luacall_axfr_filter_t;
40 typedef std::function<bool(DNSPacket*)> luacall_prequery_t;
41
42 luacall_update_policy_t d_update_policy;
43 luacall_axfr_filter_t d_axfr_filter;
44 luacall_prequery_t d_prequery;
45 };
46 std::vector<shared_ptr<DNSRecordContent>> luaSynth(const std::string& code, const DNSName& qname,
47 const DNSName& zone, int zoneid, const DNSPacket& dnsp, uint16_t qtype, unique_ptr<AuthLua4>& LUA);