Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It compiles on ubuntu 12.02 #3

Merged
merged 1 commit into from
Jun 1, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pdns/dnsname.hh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <set>
#include <deque>
#include <strings.h>
#include <stdexcept>
// #include "dns.hh"
// #include "logger.hh"

Expand Down
11 changes: 6 additions & 5 deletions pdns/lua-auth.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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() );
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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;
}

Expand Down
5 changes: 3 additions & 2 deletions pdns/lua-pdns.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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))
Expand Down
4 changes: 2 additions & 2 deletions pdns/zone2json.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
40 changes: 21 additions & 19 deletions pdns/zone2sql.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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", "");
Expand All @@ -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";
Expand All @@ -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";
Expand All @@ -211,30 +212,30 @@ 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";
}
}
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;
Expand All @@ -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") {
Expand Down Expand Up @@ -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) {
Expand Down