From: bert hubert Date: Thu, 24 Apr 2014 07:23:14 +0000 (+0200) Subject: make json-comments optional & off by default, remove switch from zoneparser-tng,... X-Git-Tag: rec-3.6.0-rc1~43^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2d70950393d94a5e3f19bdf1d3d0183e753294f0;p=pdns make json-comments optional & off by default, remove switch from zoneparser-tng, turn on with get() --- diff --git a/pdns/zone2sql.cc b/pdns/zone2sql.cc index 87dd76d35..5a585cf37 100644 --- a/pdns/zone2sql.cc +++ b/pdns/zone2sql.cc @@ -141,13 +141,13 @@ static void emitDomain(const string& domain, const vector *masters = 0) } } } - +bool g_doJSONComments; static void emitRecord(const string& zoneName, const string &qname, const string &qtype, const string &ocontent, int ttl, int prio, const string& comment="") { int disabled=0; string recordcomment; - if(!comment.empty()) { + if(g_doJSONComments & !comment.empty()) { string::size_type pos = comment.find("json={"); if(pos!=string::npos) { string json = comment.substr(pos+5); @@ -293,6 +293,7 @@ try ::arg().setSwitch("verbose","Verbose comments on operation")="no"; ::arg().setSwitch("dnssec","Add DNSSEC related data")="no"; ::arg().setSwitch("slave","Keep BIND slaves as slaves. Only works with named-conf.")="no"; + ::arg().setSwitch("json-comments","Parse json={} field for disabled & comments")="no"; ::arg().setSwitch("transactions","If target SQL supports it, use transactions")="no"; ::arg().setSwitch("on-error-resume-next","Continue after errors")="no"; ::arg().setSwitch("filter-duplicate-soa","Filter second SOA in zone")="yes"; @@ -321,8 +322,9 @@ try } bool filterDupSOA = ::arg().mustDo("filter-duplicate-soa"); - + g_doJSONComments=::arg().mustDo("json-comments"); + if(::arg().mustDo("gmysql")) g_mode=MYSQL; else if(::arg().mustDo("gpgsql")) @@ -387,12 +389,13 @@ try ZoneParserTNG zpt(i->filename, i->name, BP.getDirectory()); DNSResourceRecord rr; bool seenSOA=false; - while(zpt.get(rr)) { + string comment; + while(zpt.get(rr, &comment)) { if(filterDupSOA && seenSOA && rr.qtype.getCode() == QType::SOA) continue; if(rr.qtype.getCode() == QType::SOA) seenSOA=true; - emitRecord(i->name, rr.qname, rr.qtype.getName(), rr.content, rr.ttl, rr.priority); + emitRecord(i->name, rr.qname, rr.qtype.getName(), rr.content, rr.ttl, rr.priority, comment); } num_domainsdone++; } diff --git a/pdns/zoneparser-tng.hh b/pdns/zoneparser-tng.hh index 8a865d30b..fed46496f 100644 --- a/pdns/zoneparser-tng.hh +++ b/pdns/zoneparser-tng.hh @@ -35,7 +35,6 @@ public: ZoneParserTNG(const string& fname, const string& zname="", const string& reldir=""); ~ZoneParserTNG(); - void enableComments(); bool get(DNSResourceRecord& rr, std::string* comment=0); typedef runtime_error exception; typedef deque > parts_t;