From 3876ee44173178b17f9ca24850965d35ebe1367b Mon Sep 17 00:00:00 2001 From: bert hubert Date: Tue, 1 Dec 2015 22:13:01 +0100 Subject: [PATCH] fix up TTL for RPZ zones, and allow override from config --- pdns/filterpo.hh | 1 + pdns/pdns_recursor.cc | 4 ++-- pdns/rec-lua-conf.cc | 10 ++++++++++ pdns/rpzloader.cc | 3 +++ 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/pdns/filterpo.hh b/pdns/filterpo.hh index 95810eb87..8eb198edb 100644 --- a/pdns/filterpo.hh +++ b/pdns/filterpo.hh @@ -51,6 +51,7 @@ public: } PolicyKind d_kind; std::shared_ptr d_custom; + int d_ttl; }; DNSFilterEngine(); diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index 261dbc510..da2b23b9f 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -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; diff --git a/pdns/rec-lua-conf.cc b/pdns/rec-lua-conf.cc index 55c05f637..6b298c205 100644 --- a/pdns/rec-lua-conf.cc +++ b/pdns/rec-lua-conf.cc @@ -98,6 +98,11 @@ void loadRecursorLuaConfig(const std::string& fname) boost::get(constGet(have,"defcontent")) ) ); + + if(have.count("defttl")) + defpol->d_ttl = boost::get(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(constGet(have,"defcontent")) ) ); + if(have.count("defttl")) + defpol->d_ttl = boost::get(constGet(have, "defttl")); + else + defpol->d_ttl = -1; // get it from the zone + } } diff --git a/pdns/rpzloader.cc b/pdns/rpzloader.cc index bfdfd13ae..118e07097 100644 --- a/pdns/rpzloader.cc +++ b/pdns/rpzloader.cc @@ -59,6 +59,9 @@ void RPZRecordToPolicy(const DNSRecord& dr, DNSFilterEngine& target, bool addOrR // cerr<<"Wants custom "<getZoneRepresentation()<<" for "<