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) {
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();