From b56497f3b4b84e6ecc918d68a74bfa8949c38847 Mon Sep 17 00:00:00 2001 From: Ruben d'Arco Date: Mon, 1 Jun 2015 22:09:54 +0200 Subject: [PATCH] It compiles --- pdns/dnsname.hh | 1 + pdns/lua-auth.cc | 11 ++++++----- pdns/lua-pdns.cc | 5 +++-- pdns/zone2json.cc | 4 ++-- pdns/zone2sql.cc | 40 +++++++++++++++++++++------------------- 5 files changed, 33 insertions(+), 28 deletions(-) diff --git a/pdns/dnsname.hh b/pdns/dnsname.hh index 1892a8f90d2d..7dc2e8c54ffe 100644 --- a/pdns/dnsname.hh +++ b/pdns/dnsname.hh @@ -4,6 +4,7 @@ #include #include #include +#include // #include "dns.hh" // #include "logger.hh" diff --git a/pdns/lua-auth.cc b/pdns/lua-auth.cc index 91ad918c8e9a..7b206eed75e3 100644 --- a/pdns/lua-auth.cc +++ b/pdns/lua-auth.cc @@ -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; } diff --git a/pdns/lua-pdns.cc b/pdns/lua-pdns.cc index 7bc06467dbef..ed0bda06fd4e 100644 --- a/pdns/lua-pdns.cc +++ b/pdns/lua-pdns.cc @@ -95,7 +95,7 @@ void pushResourceRecordsTable(lua_State* lua, const vector& 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 *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))<<", "<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) {