diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 21:14:49 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 21:14:49 +0000 |
commit | 2f230033794fafdf10822568e763d4db68cf6c6b (patch) | |
tree | 39ca5c2325b7b43c9a28ca6d4ad4026a61e7eb97 /dnsdist-lua.hh | |
parent | Adding debian version 1.8.3-3. (diff) | |
download | dnsdist-2f230033794fafdf10822568e763d4db68cf6c6b.tar.xz dnsdist-2f230033794fafdf10822568e763d4db68cf6c6b.zip |
Merging upstream version 1.9.3.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dnsdist-lua.hh')
-rw-r--r-- | dnsdist-lua.hh | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/dnsdist-lua.hh b/dnsdist-lua.hh index 61a021f..5c35c3f 100644 --- a/dnsdist-lua.hh +++ b/dnsdist-lua.hh @@ -33,7 +33,7 @@ struct ResponseConfig boost::optional<bool> setRA{boost::none}; uint32_t ttl{60}; }; -void setResponseHeadersFromConfig(dnsheader& dh, const ResponseConfig& config); +void setResponseHeadersFromConfig(dnsheader& dnsheader, const ResponseConfig& config); class SpoofAction : public DNSAction { @@ -62,11 +62,11 @@ public: { } - SpoofAction(const vector<std::string>& raws): d_rawResponses(raws) + SpoofAction(const vector<std::string>& raws, std::optional<uint16_t> typeForAny): d_rawResponses(raws), d_rawTypeForAny(typeForAny) { } - DNSAction::Action operator()(DNSQuestion* dq, string* ruleresult) const override; + DNSAction::Action operator()(DNSQuestion* dnsquestion, string* ruleresult) const override; string toString() const override { @@ -84,15 +84,20 @@ public: return ret; } + [[nodiscard]] ResponseConfig& getResponseConfig() + { + return d_responseConfig; + } - ResponseConfig d_responseConfig; private: + ResponseConfig d_responseConfig; static thread_local std::default_random_engine t_randomEngine; std::vector<ComboAddress> d_addrs; std::unordered_set<uint16_t> d_types; std::vector<std::string> d_rawResponses; PacketBuffer d_raw; DNSName d_cname; + std::optional<uint16_t> d_rawTypeForAny{}; }; class LimitTTLResponseAction : public DNSResponseAction, public boost::noncopyable @@ -156,17 +161,18 @@ template <class T> using LuaArray = std::vector<std::pair<int, T>>; template <class T> using LuaAssociativeTable = std::unordered_map<std::string, T>; template <class T> using LuaTypeOrArrayOf = boost::variant<T, LuaArray<T>>; -using luadnsrule_t = boost::variant<string, LuaArray<std::string>, std::shared_ptr<DNSRule>, DNSName, LuaArray<DNSName>>; using luaruleparams_t = LuaAssociativeTable<std::string>; using nmts_t = NetmaskTree<DynBlock, AddressAndPortRange>; -std::shared_ptr<DNSRule> makeRule(const luadnsrule_t& var); +using luadnsrule_t = boost::variant<string, LuaArray<std::string>, std::shared_ptr<DNSRule>, DNSName, LuaArray<DNSName>>; +std::shared_ptr<DNSRule> makeRule(const luadnsrule_t& var, const std::string& calledFrom); + void parseRuleParams(boost::optional<luaruleparams_t>& params, boost::uuids::uuid& uuid, std::string& name, uint64_t& creationOrder); void checkParameterBound(const std::string& parameter, uint64_t value, size_t max = std::numeric_limits<uint16_t>::max()); vector<std::function<void(void)>> setupLua(LuaContext& luaCtx, bool client, bool configCheck, const std::string& config); void setupLuaActions(LuaContext& luaCtx); -void setupLuaBindings(LuaContext& luaCtx, bool client); +void setupLuaBindings(LuaContext& luaCtx, bool client, bool configCheck); void setupLuaBindingsDNSCrypt(LuaContext& luaCtx, bool client); void setupLuaBindingsDNSParser(LuaContext& luaCtx); void setupLuaBindingsDNSQuestion(LuaContext& luaCtx); |