"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "pdns/lua-recursor4.hh" between
pdns-auth-4.1.13.tar.gz and pdns-auth-4.2.0.tar.gz

About: PowerDNS Authoritative Nameserver is a versatile nameserver which supports a large number of backends (that can either be plain zone files or be more dynamic in nature).

lua-recursor4.hh  (pdns-auth-4.1.13):lua-recursor4.hh  (pdns-auth-4.2.0)
skipping to change at line 24 skipping to change at line 24
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
#pragma once #pragma once
#include <unordered_map>
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include "config.h" #include "config.h"
#endif #endif
#include "iputils.hh" #include "iputils.hh"
#include "dnsname.hh" #include "dnsname.hh"
#include "namespaces.hh" #include "namespaces.hh"
#include "dnsrecords.hh" #include "dnsrecords.hh"
#include "filterpo.hh" #include "filterpo.hh"
#include "ednsoptions.hh" #include "ednsoptions.hh"
#include "validate.hh" #include "validate.hh"
#include "lua-base4.hh"
#include <unordered_map>
#include "lua-recursor4-ffi.hh"
string GenUDPQueryResponse(const ComboAddress& dest, const string& query); string GenUDPQueryResponse(const ComboAddress& dest, const string& query);
unsigned int getRecursorThreadId(); unsigned int getRecursorThreadId();
class LuaContext; // pdns_ffi_param_t is a lightuserdata
template<>
#if defined(HAVE_LUA) struct LuaContext::Pusher<pdns_ffi_param*> {
#undef L static const int minSize = 1;
#include "ext/luawrapper/include/LuaContext.hpp" static const int maxSize = 1;
#define L theL()
#endif static PushedObject push(lua_State* state, pdns_ffi_param* ptr) noexcept {
lua_pushlightuserdata(state, ptr);
return PushedObject{state, 1};
}
};
class RecursorLua4 : public boost::noncopyable class RecursorLua4 : public BaseLua4
{ {
private:
std::unique_ptr<LuaContext> d_lw; // this is way on top because it must get de
stroyed _last_
public: public:
explicit RecursorLua4(const std::string& fname); RecursorLua4();
~RecursorLua4(); // this is so unique_ptr works with an incomplete type ~RecursorLua4(); // this is so unique_ptr works with an incomplete type
struct DNSQuestion struct DNSQuestion
{ {
DNSQuestion(const ComboAddress& rem, const ComboAddress& loc, const DNSName& query, uint16_t type, bool tcp, bool& variable_, bool& wantsRPZ_): qname(query) , qtype(type), local(loc), remote(rem), isTcp(tcp), variable(variable_), wantsRP Z(wantsRPZ_) DNSQuestion(const ComboAddress& rem, const ComboAddress& loc, const DNSName& query, uint16_t type, bool tcp, bool& variable_, bool& wantsRPZ_, bool& logResp onse_): qname(query), qtype(type), local(loc), remote(rem), isTcp(tcp), variable (variable_), wantsRPZ(wantsRPZ_), logResponse(logResponse_)
{ {
} }
const DNSName& qname; const DNSName& qname;
const uint16_t qtype; const uint16_t qtype;
const ComboAddress& local; const ComboAddress& local;
const ComboAddress& remote; const ComboAddress& remote;
const struct dnsheader* dh{nullptr}; const struct dnsheader* dh{nullptr};
const bool isTcp; const bool isTcp;
const std::vector<pair<uint16_t, string>>* ednsOptions{nullptr}; const std::vector<pair<uint16_t, string>>* ednsOptions{nullptr};
const uint16_t* ednsFlags{nullptr}; const uint16_t* ednsFlags{nullptr};
vector<DNSRecord>* currentRecords{nullptr}; vector<DNSRecord>* currentRecords{nullptr};
DNSFilterEngine::Policy* appliedPolicy{nullptr}; DNSFilterEngine::Policy* appliedPolicy{nullptr};
std::vector<std::string>* policyTags{nullptr}; std::vector<std::string>* policyTags{nullptr};
std::unordered_map<std::string,bool>* discardedPolicies{nullptr}; std::unordered_map<std::string,bool>* discardedPolicies{nullptr};
std::string requestorId; std::string requestorId;
std::string deviceId; std::string deviceId;
vState validationState{Indeterminate}; vState validationState{Indeterminate};
bool& variable; bool& variable;
bool& wantsRPZ; bool& wantsRPZ;
bool& logResponse;
unsigned int tag{0}; unsigned int tag{0};
void addAnswer(uint16_t type, const std::string& content, boost::optional<in t> ttl, boost::optional<string> name); void addAnswer(uint16_t type, const std::string& content, boost::optional<in t> ttl, boost::optional<string> name);
void addRecord(uint16_t type, const std::string& content, DNSResourceRecord: :Place place, boost::optional<int> ttl, boost::optional<string> name); void addRecord(uint16_t type, const std::string& content, DNSResourceRecord: :Place place, boost::optional<int> ttl, boost::optional<string> name);
vector<pair<int,DNSRecord> > getRecords() const; vector<pair<int,DNSRecord> > getRecords() const;
boost::optional<dnsheader> getDH() const; boost::optional<dnsheader> getDH() const;
vector<pair<uint16_t, string> > getEDNSOptions() const; vector<pair<uint16_t, string> > getEDNSOptions() const;
boost::optional<string> getEDNSOption(uint16_t code) const; boost::optional<string> getEDNSOption(uint16_t code) const;
boost::optional<Netmask> getEDNSSubnet() const; boost::optional<Netmask> getEDNSSubnet() const;
vector<string> getEDNSFlags() const; vector<string> getEDNSFlags() const;
skipping to change at line 109 skipping to change at line 113
string udpQuery; string udpQuery;
ComboAddress udpQueryDest; ComboAddress udpQueryDest;
string udpAnswer; string udpAnswer;
string udpCallback; string udpCallback;
LuaContext::LuaObject data; LuaContext::LuaObject data;
DNSName followupName; DNSName followupName;
}; };
unsigned int gettag(const ComboAddress& remote, const Netmask& ednssubnet, con unsigned int gettag(const ComboAddress& remote, const Netmask& ednssubnet, con
st ComboAddress& local, const DNSName& qname, uint16_t qtype, std::vector<std::s st ComboAddress& local, const DNSName& qname, uint16_t qtype, std::vector<std::s
tring>* policyTags, LuaContext::LuaObject& data, const std::map<uint16_t, EDNSOp tring>* policyTags, LuaContext::LuaObject& data, const EDNSOptionViewMap&, bool
tionView>&, bool tcp, std::string& requestorId, std::string& deviceId); tcp, std::string& requestorId, std::string& deviceId) const;
unsigned int gettag_ffi(const ComboAddress& remote, const Netmask& ednssubnet,
const ComboAddress& local, const DNSName& qname, uint16_t qtype, std::vector<st
d::string>* policyTags, LuaContext::LuaObject& data, const EDNSOptionViewMap&, b
ool tcp, std::string& requestorId, std::string& deviceId, uint32_t& ttlCap, bool
& variable, bool& logQuery) const;
bool prerpz(DNSQuestion& dq, int& ret); void maintenance() const;
bool preresolve(DNSQuestion& dq, int& ret); bool prerpz(DNSQuestion& dq, int& ret) const;
bool nxdomain(DNSQuestion& dq, int& ret); bool preresolve(DNSQuestion& dq, int& ret) const;
bool nodata(DNSQuestion& dq, int& ret); bool nxdomain(DNSQuestion& dq, int& ret) const;
bool postresolve(DNSQuestion& dq, int& ret); bool nodata(DNSQuestion& dq, int& ret) const ;
bool postresolve(DNSQuestion& dq, int& ret) const;
bool preoutquery(const ComboAddress& ns, const ComboAddress& requestor, const bool preoutquery(const ComboAddress& ns, const ComboAddress& requestor, const
DNSName& query, const QType& qtype, bool isTcp, vector<DNSRecord>& res, int& ret DNSName& query, const QType& qtype, bool isTcp, vector<DNSRecord>& res, int& ret
); ) const;
bool ipfilter(const ComboAddress& remote, const ComboAddress& local, const str bool ipfilter(const ComboAddress& remote, const ComboAddress& local, const str
uct dnsheader&); uct dnsheader&) const;
bool needDQ() const bool needDQ() const
{ {
return (d_prerpz || return (d_prerpz ||
d_preresolve || d_preresolve ||
d_nxdomain || d_nxdomain ||
d_nodata || d_nodata ||
d_postresolve); d_postresolve);
} }
typedef std::function<std::tuple<unsigned int,boost::optional<std::unordered_m ap<int,string> >,boost::optional<LuaContext::LuaObject>,boost::optional<std::str ing>,boost::optional<std::string> >(ComboAddress, Netmask, ComboAddress, DNSName , uint16_t, const std::map<uint16_t, EDNSOptionView>&, bool)> gettag_t; typedef std::function<std::tuple<unsigned int,boost::optional<std::unordered_m ap<int,string> >,boost::optional<LuaContext::LuaObject>,boost::optional<std::str ing>,boost::optional<std::string> >(ComboAddress, Netmask, ComboAddress, DNSName , uint16_t, const EDNSOptionViewMap&, bool)> gettag_t;
gettag_t d_gettag; // public so you can query if we have this hooked gettag_t d_gettag; // public so you can query if we have this hooked
typedef std::function<boost::optional<LuaContext::LuaObject>(pdns_ffi_param_t*
)> gettag_ffi_t;
gettag_ffi_t d_gettag_ffi;
protected:
virtual void postPrepareContext() override;
virtual void postLoad() override;
private: private:
typedef std::function<void()> luamaintenance_t;
luamaintenance_t d_maintenance;
typedef std::function<bool(DNSQuestion*)> luacall_t; typedef std::function<bool(DNSQuestion*)> luacall_t;
luacall_t d_prerpz, d_preresolve, d_nxdomain, d_nodata, d_postresolve, d_preou tquery, d_postoutquery; luacall_t d_prerpz, d_preresolve, d_nxdomain, d_nodata, d_postresolve, d_preou tquery, d_postoutquery;
bool genhook(luacall_t& func, DNSQuestion& dq, int& ret); bool genhook(const luacall_t& func, DNSQuestion& dq, int& ret) const;
typedef std::function<bool(ComboAddress,ComboAddress, struct dnsheader)> ipfil ter_t; typedef std::function<bool(ComboAddress,ComboAddress, struct dnsheader)> ipfil ter_t;
ipfilter_t d_ipfilter; ipfilter_t d_ipfilter;
}; };
 End of changes. 16 change blocks. 
32 lines changed or deleted 49 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)