]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
add single-ip-zone creation option
authorbert hubert <bert.hubert@netherlabs.nl>
Fri, 4 Apr 2014 09:08:32 +0000 (11:08 +0200)
committerbert hubert <bert.hubert@netherlabs.nl>
Fri, 4 Apr 2014 09:08:32 +0000 (11:08 +0200)
pdns/ws-recursor.cc

index b44217cd37d263aedc6c186ea803624016aa8042..0741b4dca103657de5d3157f525b3c350e860d20 100644 (file)
@@ -188,10 +188,14 @@ static void doCreateZone(const Value& document)
   if(zonename.empty())
     throw ApiException("Zone name empty");
 
+  if(zonename.find('/') != string::npos) 
+    throw ApiException("Illegal character in zone name");
+
   if (zonename[zonename.size()-1] != '.') {
     zonename += ".";
   }
 
+  string singleIPTarget = stringFromJson(document, "single-ip-target", "");
   string kind = toUpper(stringFromJson(document, "kind"));
   bool rd = boolFromJson(document, "recursion_desired");
   string confbasename = "zone-" + apiZoneNameToId(zonename);
@@ -207,6 +211,10 @@ 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.close();
 
     apiWriteConfigFile(confbasename, "auth-zones+=" + zonename + "=" + zonefilename);