]> granicus.if.org Git - pdns/commitdiff
It compiles
authorRuben d'Arco <cyclops@prof-x.net>
Mon, 1 Jun 2015 20:09:54 +0000 (22:09 +0200)
committermind04 <mind04@monshouwer.org>
Tue, 30 Jun 2015 06:12:44 +0000 (08:12 +0200)
pdns/dnsname.hh
pdns/lua-auth.cc
pdns/lua-pdns.cc
pdns/zone2json.cc
pdns/zone2sql.cc

index f75bad92767855e3ec826de3915ba2340642698e..a0e20c1b2099f5edec42b3f009c8a53d3d20405e 100644 (file)
@@ -4,6 +4,7 @@
 #include <set>
 #include <deque>
 #include <strings.h>
+#include <stdexcept>
 // #include "dns.hh"
 // #include "logger.hh"
 
index 91ad918c8e9a894149a4f62994f04241907e9ea8..7b206eed75e30397205b11ca801e2aa1892ad53e 100644 (file)
@@ -68,7 +68,7 @@ bool AuthLua::axfrfilter(const ComboAddress& remote, const DNSName& zone, const
   
   lua_pushstring(d_lua,  remote.toString().c_str() );
   lua_pushstring(d_lua,  zone.toString().c_str() ); // FIXME expose DNSName to Lua?
-  lua_pushstring(d_lua,  in.qname.c_str() );
+  lua_pushstring(d_lua,  in.qname.toString().c_str() );
   lua_pushnumber(d_lua,  in.qtype.getCode() );
   lua_pushnumber(d_lua,  in.ttl );
   lua_pushstring(d_lua,  in.content.c_str() );
@@ -113,7 +113,8 @@ bool AuthLua::axfrfilter(const ComboAddress& remote, const DNSName& zone, const
     if(!getFromTable("ttl", rr.ttl))
       rr.ttl=3600;
 
-    if(!getFromTable("qname", rr.qname))
+    string qname = rr.qname.toString();
+    if(!getFromTable("qname", qname))
       rr.qname = zone;
 
     if(!getFromTable("place", tmpnum))
@@ -155,20 +156,20 @@ static int ldp_setRcode(lua_State *L) {
 
 static int ldp_getQuestion(lua_State *L) {
   DNSPacket *p=ldp_checkDNSPacket(L);
-  lua_pushstring(L, p->qdomain.c_str());
+  lua_pushstring(L, p->qdomain.toString().c_str());
   lua_pushnumber(L, p->qtype.getCode());
   return 2;
 }
 
 static int ldp_getWild(lua_State *L) {
   DNSPacket *p=ldp_checkDNSPacket(L);
-  lua_pushstring(L, p->qdomainwild.c_str());
+  lua_pushstring(L, p->qdomainwild.toString().c_str());
   return 1;
 }
 
 static int ldp_getZone(lua_State *L) {
   DNSPacket *p=ldp_checkDNSPacket(L);
-  lua_pushstring(L, p->qdomainzone.c_str());
+  lua_pushstring(L, p->qdomainzone.toString().c_str());
   return 1;
 }
 
index 7bc06467dbef08d99fb1825aa4f0f56afd381f2c..ed0bda06fd4ee9a307f4b29c22797f6ac4416ffb 100644 (file)
@@ -95,7 +95,7 @@ void pushResourceRecordsTable(lua_State* lua, const vector<DNSResourceRecord>& r
     // "row" table
     lua_newtable(lua);
     
-    lua_pushstring(lua, rr.qname.c_str());
+    lua_pushstring(lua, rr.qname.toString().c_str());
     lua_setfield(lua, -2, "qname");  // pushes value at the top of the stack to the table immediately below that (-1 = top, -2 is below)
     
     lua_pushstring(lua, rr.content.c_str());
@@ -188,7 +188,8 @@ void popResourceRecordsTable(lua_State *lua, const string &query, vector<DNSReso
     if(!getFromTable(lua, "ttl", rr.ttl))
       rr.ttl=3600;
 
-    if(!getFromTable(lua, "qname", rr.qname))
+    string qname = rr.qname.toString();
+    if(!getFromTable(lua, "qname", qname))
       rr.qname = query;
 
     if(!getFromTable(lua, "place", tmpnum))
index cc883d3de15aa45b32a86a2e5916062de23d93b4..72c51ddbc54dc0075746136ff8202d21ea7d859d 100644 (file)
@@ -71,7 +71,7 @@ static void quoteValue(string &value)
 }
 
 
-static string emitRecord(const string& zoneName, const string &qname, const string &qtype, const string &ocontent, int ttl)
+static string emitRecord(const string& zoneName, const DNSName &DNSqname, const string &qtype, const string &ocontent, int ttl)
 {
   int prio=0;
   string retval;
@@ -90,7 +90,7 @@ static string emitRecord(const string& zoneName, const string &qname, const stri
  
   retval = "{";
   retval += "\"name\":\"";
-  retval += qname;
+  retval += DNSqname.toString();
   retval += "\",";
   retval += "\"type\":\"";
   retval += qtype;
index a2a0e8803d49879ba0e269110ef43de0c2a656d8..9548d6cf585a90812697ffb91586d5c17346a813 100644 (file)
@@ -146,8 +146,9 @@ 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, const string& comment="")
+static void emitRecord(const string& zoneName, const DNSName &DNSqname, const string &qtype, const string &ocontent, int ttl, const string& comment="")
 {
+  string qname = stripDot(DNSqname.toString());
   int prio=0;
   int disabled=0;
   string recordcomment;
@@ -158,7 +159,7 @@ static void emitRecord(const string& zoneName, const string &qname, const string
       string json = comment.substr(pos+5);
       rapidjson::Document document;
       if(document.Parse<0>(json.c_str()).HasParseError())
-       throw runtime_error("Could not parse JSON '"+json+"'");
+        throw runtime_error("Could not parse JSON '"+json+"'");
 
       disabled=boolFromJson(document, "disabled", false);
       recordcomment=stringFromJson(document, "comment", "");
@@ -181,14 +182,14 @@ static void emitRecord(const string& zoneName, const string &qname, const string
   }
 
   bool auth = true;
-  if(qtype == "NS" && !pdns_iequals(stripDot(qname), zoneName)) {
+  if(qtype == "NS" && !pdns_iequals(qname, zoneName)) {
     auth=false;
   }
 
   if(g_mode==MYSQL || g_mode==SQLITE) {
     if(!g_doDNSSEC) {
       cout<<"insert into records (domain_id, name, type,content,ttl,prio,disabled) select id ,"<<
-        sqlstr(toLower(stripDot(qname)))<<", "<<
+        sqlstr(toLower(qname))<<", "<<
         sqlstr(qtype)<<", "<<
         sqlstr(stripDotContent(content))<<", "<<ttl<<", "<<prio<<", "<<disabled<<
         " from domains where name="<<toLower(sqlstr(zoneName))<<";\n";
@@ -201,8 +202,8 @@ static void emitRecord(const string& zoneName, const string &qname, const string
     } else
     {
       cout<<"insert into records (domain_id, name, ordername, auth, type,content,ttl,prio,disabled) select id ,"<<
-        sqlstr(toLower(stripDot(qname)))<<", "<<
-        sqlstr(toLower(labelReverse(makeRelative(stripDot(qname), zoneName))))<<", "<<auth<<", "<<
+        sqlstr(toLower(qname))<<", "<<
+        sqlstr(toLower(labelReverse(makeRelative(qname, zoneName))))<<", "<<auth<<", "<<
         sqlstr(qtype)<<", "<<
         sqlstr(stripDotContent(content))<<", "<<ttl<<", "<<prio<<", "<<disabled<<
         " from domains where name="<<toLower(sqlstr(zoneName))<<";\n";
@@ -211,15 +212,15 @@ static void emitRecord(const string& zoneName, const string &qname, const string
   else if(g_mode==POSTGRES) {
     if(!g_doDNSSEC) {
       cout<<"insert into records (domain_id, name,type,content,ttl,prio,disabled) select id ,"<<
-        sqlstr(toLower(stripDot(qname)))<<", "<<
+        sqlstr(toLower(qname))<<", "<<
         sqlstr(qtype)<<", "<<
         sqlstr(stripDotContent(content))<<", "<<ttl<<", "<<prio<<", '"<< (disabled ? 't': 'f')<<
         "' from domains where name="<<toLower(sqlstr(zoneName))<<";\n";
     } else
     {
       cout<<"insert into records (domain_id, name, ordername, auth, type,content,ttl,prio,disabled) select id ,"<<
-        sqlstr(toLower(stripDot(qname)))<<", "<<
-        sqlstr(toLower(labelReverse(makeRelative(stripDot(qname), zoneName))))<<", '"<< (auth  ? 't' : 'f') <<"', "<<
+        sqlstr(toLower(qname))<<", "<<
+        sqlstr(toLower(labelReverse(makeRelative(qname, zoneName))))<<", '"<< (auth  ? 't' : 'f') <<"', "<<
         sqlstr(qtype)<<", "<<
         sqlstr(stripDotContent(content))<<", "<<ttl<<", "<<prio<<", '"<<(disabled ? 't': 'f') <<
         "' from domains where name="<<toLower(sqlstr(zoneName))<<";\n";
@@ -227,14 +228,14 @@ static void emitRecord(const string& zoneName, const string &qname, const string
   }
   else if(g_mode==GORACLE) {
     cout<<"insert into Records (id, domain_id, name, type, content, ttl, prio, disabled) select RECORDS_ID_SEQUENCE.nextval,id ,"<<
-      sqlstr(toLower(stripDot(qname)))<<", "<<
+      sqlstr(toLower(qname))<<", "<<
       sqlstr(qtype)<<", "<<
       sqlstr(stripDotContent(content))<<", "<<ttl<<", "<<prio<<", "<<disabled<<
       " from Domains where name="<<toLower(sqlstr(zoneName))<<";\n";
   }
   else if(g_mode==ORACLE) {
     cout<<"INSERT INTO Records (id, zone_id, fqdn, ttl, type, content) SELECT records_id_seq.nextval, id, "<<
-      sqlstr(toLower(stripDot(qname)))<<", "<<
+      sqlstr(toLower(qname))<<", "<<
       ttl<<", "<<sqlstr(qtype)<<", "<<
       sqlstr(stripDotContent(content))<<
       " FROM Zones WHERE name="<<toLower(sqlstr(zoneName))<<";"<<endl;
@@ -249,7 +250,7 @@ static void emitRecord(const string& zoneName, const string &qname, const string
       cout<<"INSERT INTO rr(zone, name, type, data, aux, ttl) VALUES("<<
       "(SELECT id FROM soa WHERE origin = "<< 
       sqlstr(toLower(zoneNameDot))<<"), "<<
-      sqlstr(toLower(qname))<<", "<<
+      sqlstr(toLower(DNSqname.toString()))<<", "<<
       sqlstr(qtype)<<", "<<sqlstr(content)<<", "<<prio<<", "<<ttl<<");\n";
     }
     else if (qtype == "SOA") {
@@ -398,15 +399,16 @@ try
             
             ZoneParserTNG zpt(i->filename, i->name, BP.getDirectory());
             DNSResourceRecord rr;
-           bool seenSOA=false;
-           string comment;
+            bool seenSOA=false;
+            string comment;
             while(zpt.get(rr, &comment)) {
-             if(filterDupSOA && seenSOA && rr.qtype.getCode() == QType::SOA)
-               continue;
-             if(rr.qtype.getCode() == QType::SOA)
-               seenSOA=true;
+              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, comment);
-           }
+            }
             num_domainsdone++;
           }
           catch(std::exception &ae) {