From: Pieter Lexis Date: Fri, 17 Mar 2017 14:09:08 +0000 (+0100) Subject: Merge pull request #5057 from rgacogne/rpz-ttl X-Git-Tag: rec-4.1.0-alpha1~201 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=45a02de5a2ac74021c9c893aa35a865ff0d414bb;p=thirdparty%2Fpdns.git Merge pull request #5057 from rgacogne/rpz-ttl rec: Use the RPZ zone's TTL and add a new `maxTTL` setting --- 45a02de5a2ac74021c9c893aa35a865ff0d414bb diff --cc pdns/rec-lua-conf.cc index dce282cffc,1bd32db6aa..5f816584aa --- a/pdns/rec-lua-conf.cc +++ b/pdns/rec-lua-conf.cc @@@ -50,7 -52,45 +50,38 @@@ typename C::value_type::second_type con return iter->second; } -#ifndef HAVE_LUA -void loadRecursorLuaConfig(const std::string& fname, bool checkOnly) -{ - if(!fname.empty()) - throw PDNSException("Asked to load a Lua configuration file '"+fname+"' in binary without Lua support"); -} -#else + static void parseRPZParameters(const std::unordered_map >& have, std::string& polName, boost::optional& defpol, uint32_t& maxTTL, size_t& zoneSizeHint) + { + if(have.count("policyName")) { + polName = boost::get(constGet(have, "policyName")); + } + if(have.count("defpol")) { + defpol=DNSFilterEngine::Policy(); + defpol->d_kind = (DNSFilterEngine::PolicyKind)boost::get(constGet(have, "defpol")); + defpol->d_name = std::make_shared(polName); + if(defpol->d_kind == DNSFilterEngine::PolicyKind::Custom) { + defpol->d_custom= + shared_ptr( + DNSRecordContent::mastermake(QType::CNAME, 1, + boost::get(constGet(have,"defcontent")) + ) + ); + + if(have.count("defttl")) + defpol->d_ttl = static_cast(boost::get(constGet(have, "defttl"))); + else + defpol->d_ttl = -1; // get it from the zone + } + } + if(have.count("maxTTL")) { + maxTTL = boost::get(constGet(have, "maxTTL")); + } + if(have.count("zoneSizeHint")) { + zoneSizeHint = static_cast(boost::get(constGet(have, "zoneSizeHint"))); + } + } + void loadRecursorLuaConfig(const std::string& fname, bool checkOnly) { LuaConfigItems lci;