]> granicus.if.org Git - pdns/commitdiff
Merge pull request #5057 from rgacogne/rpz-ttl
authorPieter Lexis <pieterlexis@users.noreply.github.com>
Fri, 17 Mar 2017 14:09:08 +0000 (15:09 +0100)
committerGitHub <noreply@github.com>
Fri, 17 Mar 2017 14:09:08 +0000 (15:09 +0100)
rec: Use the RPZ zone's TTL and add a new `maxTTL` setting

1  2 
docs/markdown/recursor/settings.md
pdns/rec-lua-conf.cc
regression-tests.recursor/config.sh

Simple merge
index dce282cffcbe3f7624596161cafc9963e383e3bc,1bd32db6aa5772ceecdaadfa99c734bf0c8d4ae0..5f816584aa3d118be69dfc182e421a5e8ebd9987
@@@ -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<string,boost::variant<uint32_t, string> >& have, std::string& polName, boost::optional<DNSFilterEngine::Policy>& defpol, uint32_t& maxTTL, size_t& zoneSizeHint)
+ {
+   if(have.count("policyName")) {
+     polName = boost::get<std::string>(constGet(have, "policyName"));
+   }
+   if(have.count("defpol")) {
+     defpol=DNSFilterEngine::Policy();
+     defpol->d_kind = (DNSFilterEngine::PolicyKind)boost::get<uint32_t>(constGet(have, "defpol"));
+     defpol->d_name = std::make_shared<std::string>(polName);
+     if(defpol->d_kind == DNSFilterEngine::PolicyKind::Custom) {
+       defpol->d_custom=
+         shared_ptr<DNSRecordContent>(
+           DNSRecordContent::mastermake(QType::CNAME, 1,
+                                        boost::get<string>(constGet(have,"defcontent"))
+             )
+           );
+       if(have.count("defttl"))
+         defpol->d_ttl = static_cast<int32_t>(boost::get<uint32_t>(constGet(have, "defttl")));
+       else
+         defpol->d_ttl = -1; // get it from the zone
+     }
+   }
+   if(have.count("maxTTL")) {
+     maxTTL = boost::get<uint32_t>(constGet(have, "maxTTL"));
+   }
+   if(have.count("zoneSizeHint")) {
+     zoneSizeHint = static_cast<size_t>(boost::get<uint32_t>(constGet(have, "zoneSizeHint")));
+   }
+ }
  void loadRecursorLuaConfig(const std::string& fname, bool checkOnly)
  {
    LuaConfigItems lci;
Simple merge