]> granicus.if.org Git - pdns/commitdiff
fix up TTL for RPZ zones, and allow override from config
authorbert hubert <bert.hubert@netherlabs.nl>
Tue, 1 Dec 2015 21:13:01 +0000 (22:13 +0100)
committerbert hubert <bert.hubert@netherlabs.nl>
Tue, 1 Dec 2015 21:13:01 +0000 (22:13 +0100)
pdns/filterpo.hh
pdns/pdns_recursor.cc
pdns/rec-lua-conf.cc
pdns/rpzloader.cc

index 95810eb879515fdccf3895fa40de581ff6fb7b2d..8eb198edbd4899fabaf562f74b2d6f7303974754 100644 (file)
@@ -51,6 +51,7 @@ public:
     }
     PolicyKind d_kind;
     std::shared_ptr<DNSRecordContent> d_custom;
+    int d_ttl;
   };
 
   DNSFilterEngine();
index 261dbc5109ce6d7f302d80024e1b5bb31a875ba6..da2b23b9f314c4609976c5d2af48b8576ac4b69f 100644 (file)
@@ -694,7 +694,7 @@ void startDoResolve(void *p)
       res=RCode::NoError;
       spoofed.d_name=dc->d_mdp.d_qname;
       spoofed.d_type=dfepol.d_custom->getType();
-      spoofed.d_ttl = 1234;
+      spoofed.d_ttl = dfepol.d_ttl;
       spoofed.d_class = 1;
       spoofed.d_content = dfepol.d_custom;
       spoofed.d_place = DNSResourceRecord::ANSWER;
@@ -754,7 +754,7 @@ void startDoResolve(void *p)
        res=RCode::NoError;
        spoofed.d_name=dc->d_mdp.d_qname;
        spoofed.d_type=dfepol.d_custom->getType();
-       spoofed.d_ttl = 1234;
+       spoofed.d_ttl = dfepol.d_ttl;
        spoofed.d_class = 1;
        spoofed.d_content = dfepol.d_custom;
        spoofed.d_place = DNSResourceRecord::ANSWER;
index 55c05f6372e860a457725da00b8801570b70e2e2..6b298c20535c4c890b6946cc007eddc36df26dc4 100644 (file)
@@ -98,6 +98,11 @@ void loadRecursorLuaConfig(const std::string& fname)
                                                                          boost::get<string>(constGet(have,"defcontent"))
                                                                          )
                                             );
+        
+             if(have.count("defttl"))
+               defpol->d_ttl = boost::get<int>(constGet(have, "defttl"));
+             else
+               defpol->d_ttl = -1; // get it from the zone
            }
          }
            
@@ -127,6 +132,11 @@ void loadRecursorLuaConfig(const std::string& fname)
                                                                          boost::get<string>(constGet(have,"defcontent"))
                                                                          )
                                             );
+             if(have.count("defttl"))
+               defpol->d_ttl = boost::get<int>(constGet(have, "defttl"));
+             else
+               defpol->d_ttl = -1; // get it from the zone
+
            }
          }
            
index bfdfd13aea2b9346c9d5eac2a8a4ab251f48af02..118e07097b8c716ebc63f2e9f94f10cf4f3e507c 100644 (file)
@@ -59,6 +59,9 @@ void RPZRecordToPolicy(const DNSRecord& dr, DNSFilterEngine& target, bool addOrR
     // cerr<<"Wants custom "<<dr.d_content->getZoneRepresentation()<<" for "<<dr.d_name<<": ";
   }
 
+  if(pol.d_ttl < 0)
+    pol.d_ttl = dr.d_ttl;
+
   // now to DO something with that
   
   if(dr.d_name.isPartOf(rpzNSDname)) {