]> granicus.if.org Git - pdns/commitdiff
make json-comments optional & off by default, remove switch from zoneparser-tng,...
authorbert hubert <bert.hubert@netherlabs.nl>
Thu, 24 Apr 2014 07:23:14 +0000 (09:23 +0200)
committerbert hubert <bert.hubert@netherlabs.nl>
Thu, 24 Apr 2014 07:23:14 +0000 (09:23 +0200)
pdns/zone2sql.cc
pdns/zoneparser-tng.hh

index 87dd76d35dfb50eab2a7bd9ef53041d5f7bf3fee..5a585cf37febaf4e23a8f154e80e5eaf7daa5cec 100644 (file)
@@ -141,13 +141,13 @@ static void emitDomain(const string& domain, const vector<string> *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++;
           }
index 8a865d30b24c13da571e1934a8535e4b929dfd5f..fed46496fb19cc7c898b12da360b935ea095c84c 100644 (file)
@@ -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<pair<string::size_type, string::size_type> > parts_t;