From c3b85638b2df1e6dfc55bc820e4d836da7a138ed Mon Sep 17 00:00:00 2001 From: Pavel Boldin Date: Sat, 11 May 2013 19:00:44 +0400 Subject: [PATCH] Bind: Added 'ignore' option for non-zone domains. Now having non-zone record in BIND-type zone file will cause pdns to ignore only this record, not the whole domain. --- pdns/backends/bind/bindbackend2.cc | 15 +++++++++++---- pdns/backends/bind/bindbackend2.hh | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/pdns/backends/bind/bindbackend2.cc b/pdns/backends/bind/bindbackend2.cc index 9d6a4305b..a342660ba 100644 --- a/pdns/backends/bind/bindbackend2.cc +++ b/pdns/backends/bind/bindbackend2.cc @@ -411,7 +411,7 @@ static string canonic(string ret) /** THIS IS AN INTERNAL FUNCTION! It does moadnsparser prio impedence matching This function adds a record to a domain with a certain id. Much of the complication is due to the efforts to benefit from std::string reference counting copy on write semantics */ -void Bind2Backend::insert(shared_ptr stage, int id, const string &qnameu, const QType &qtype, const string &content, int ttl, int prio, const std::string& hashed) +void Bind2Backend::insert(shared_ptr stage, int id, const string &qnameu, const QType &qtype, const string &content, int ttl, int prio, const std::string& hashed, const bool ignore_non_zone) { BB2DomainInfo bb2 = stage->id_zone_map[id]; Bind2DNSRecord bdr; @@ -425,8 +425,15 @@ void Bind2Backend::insert(shared_ptr stage, int id, const string &qnameu, bdr.qname.clear(); else if(bdr.qname.length() > bb2.d_name.length() && dottedEndsOn(bdr.qname, bb2.d_name)) bdr.qname.resize(bdr.qname.length() - (bb2.d_name.length() + 1)); - else - throw PDNSException("Trying to insert non-zone data, name='"+bdr.qname+"', qtype="+qtype.getName()+", zone='"+bb2.d_name+"'"); + else { + string msg = "Trying to insert non-zone data, name='"+bdr.qname+"', qtype="+qtype.getName()+", zone='"+bb2.d_name+"'"; + if(ignore_non_zone) { + L< stage, int id, bool nse rr.qname=qname+"."+bb2.d_name+"."; if(nsec3zone) hashed=toBase32Hex(hashQNameWithSalt(ns3pr.d_iterations, ns3pr.d_salt, rr.qname)); - insert(stage, id, rr.qname, rr.qtype, rr.content, rr.ttl, rr.priority, hashed); + insert(stage, id, rr.qname, rr.qtype, rr.content, rr.ttl, rr.priority, hashed, false); } } diff --git a/pdns/backends/bind/bindbackend2.hh b/pdns/backends/bind/bindbackend2.hh index 36a2769c8..5d30c4700 100644 --- a/pdns/backends/bind/bindbackend2.hh +++ b/pdns/backends/bind/bindbackend2.hh @@ -173,7 +173,7 @@ public: id_zone_map_t id_zone_map; }; - static void insert(shared_ptr stage, int id, const string &qname, const QType &qtype, const string &content, int ttl=300, int prio=25, const std::string& hashed=string()); + static void insert(shared_ptr stage, int id, const string &qname, const QType &qtype, const string &content, int ttl=300, int prio=25, const std::string& hashed=string(), const bool ignore_non_zone = true); void rediscover(string *status=0); bool isMaster(const string &name, const string &ip); -- 2.50.1