]> granicus.if.org Git - pdns/commitdiff
perform checking on single IP address, no longer use wildcard CNAME.
authorbert hubert <bert.hubert@netherlabs.nl>
Fri, 4 Apr 2014 10:26:18 +0000 (12:26 +0200)
committerbert hubert <bert.hubert@netherlabs.nl>
Fri, 4 Apr 2014 10:26:18 +0000 (12:26 +0200)
pdns/ws-recursor.cc

index 16887c30f039dbbfc192a26fca67215613b71b3d..a437ed687ff97100c5bf44e4d84751378f26f730 100644 (file)
@@ -200,7 +200,17 @@ static void doCreateZone(const Value& document)
   if (kind == "NATIVE") {
     if (rd)
       throw ApiException("kind=Native and recursion_desired are mutually exclusive");
-
+    if(!singleIPTarget.empty()) {
+      try {
+       ComboAddress rem(singleIPTarget);
+       if(rem.sin4.sin_family != AF_INET)
+         throw ApiException("");
+       singleIPTarget = rem.toString();
+      }
+      catch(...) {
+       throw ApiException("Single IP target '"+singleIPTarget+"' is invalid");
+      }
+    }
     string zonefilename = ::arg()["experimental-api-config-dir"] + "/" + confbasename + ".zone";
     ofstream ofzone(zonefilename.c_str());
     if (!ofzone) {
@@ -209,8 +219,8 @@ static void doCreateZone(const Value& document)
     ofzone << "; Generated by pdns-recursor REST API, DO NOT EDIT" << endl;
     ofzone << zonename << "\tIN\tSOA\tlocal.zone.\thostmaster."<<zonename<<" 1 1 1 1 1" << endl;
     if(!singleIPTarget.empty()) {
-      ofzone <<zonename << "\tIN\tA\t"<<singleIPTarget<<endl;
-      ofzone <<"*."<<zonename << "\tIN\tCNAME\t"<<zonename<<endl;
+      ofzone <<zonename << "\t3600\tIN\tA\t"<<singleIPTarget<<endl;
+      ofzone <<"*."<<zonename << "\t3600\tIN\tA\t"<<singleIPTarget<<endl;
     }
     ofzone.close();