#include "dns.hh"
#include "misc.hh"
+#include "arguments.hh"
#include <stdexcept>
#include <iostream>
#include <boost/algorithm/string.hpp>
// cerr << "returning: '"<<ret<<"'"<<endl;
return ret;
}
+
+void fillSOAData(const string &content, SOAData &data)
+{
+ // content consists of fields separated by spaces:
+ // nameservername hostmaster serial-number [refresh [retry [expire [ minimum] ] ] ]
+
+ // fill out data with some plausible defaults:
+ // 10800 3600 604800 3600
+ data.serial=0;
+ data.refresh=::arg().asNum("soa-refresh-default");
+ data.retry=::arg().asNum("soa-retry-default");
+ data.expire=::arg().asNum("soa-expire-default");
+ data.default_ttl=::arg().asNum("soa-minimum-ttl");
+
+ vector<string>parts;
+ stringtok(parts,content);
+ int pleft=parts.size();
+
+ // cout<<"'"<<content<<"'"<<endl;
+
+ if(pleft)
+ data.nameserver=parts[0];
+
+ if(pleft>1)
+ data.hostmaster=attodot(parts[1]); // ahu@ds9a.nl -> ahu.ds9a.nl, piet.puk@ds9a.nl -> piet\.puk.ds9a.nl
+
+ if(pleft>2)
+ data.serial=strtoul(parts[2].c_str(), NULL, 10);
+
+ if(pleft>3)
+ data.refresh=atoi(parts[3].c_str());
+
+ if(pleft>4)
+ data.retry=atoi(parts[4].c_str());
+
+ if(pleft>5)
+ data.expire=atoi(parts[5].c_str());
+
+ if(pleft>6)
+ data.default_ttl=atoi(parts[6].c_str());
+
+}
+
+string serializeSOAData(const SOAData &d)
+{
+ ostringstream o;
+ // nameservername hostmaster serial-number [refresh [retry [expire [ minimum] ] ] ]
+ o<<d.nameserver<<" "<< d.hostmaster <<" "<< d.serial <<" "<< d.refresh << " "<< d.retry << " "<< d.expire << " "<< d.default_ttl;
+
+ return o.str();
+}
+// the functions below update the 'arcount' and 'ancount', plus they serialize themselves to the stringbuffer
+
+string& attodot(string &str)
+{
+ if(str.find_first_of("@")==string::npos)
+ return str;
+
+ for (unsigned int i = 0; i < str.length(); i++)
+ {
+ if (str[i] == '@') {
+ str[i] = '.';
+ break;
+ } else if (str[i] == '.') {
+ str.insert(i++, "\\");
+ }
+ }
+ return str;
+}
+
/*
PowerDNS Versatile Database Driven Nameserver
- Copyright (C) 2002 PowerDNS.COM BV
+ Copyright (C) 2002 - 2011 PowerDNS.COM BV
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2
extern time_t s_starttime;
std::string questionExpand(const char* packet, uint16_t len, uint16_t& type);
bool dnspacketLessThan(const std::string& a, const std::string& b);
+
+/** helper function for both DNSPacket and addSOARecord() - converts a line into a struct, for easier parsing */
+void fillSOAData(const string &content, SOAData &data);
+
+/** for use by DNSPacket, converts a SOAData class to a ascii line again */
+string serializeSOAData(const SOAData &data);
+string &attodot(string &str); //!< for when you need to insert an email address in the SOA
+
#endif
/*
PowerDNS Versatile Database Driven Nameserver
- Copyright (C) 2001 - 2010 PowerDNS.COM BV
+ Copyright (C) 2001 - 2011 PowerDNS.COM BV
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
d_rrs.push_back(rr);
}
-// the functions below update the 'arcount' and 'ancount', plus they serialize themselves to the stringbuffer
-
-string& attodot(string &str)
-{
- if(str.find_first_of("@")==string::npos)
- return str;
-
- for (unsigned int i = 0; i < str.length(); i++)
- {
- if (str[i] == '@') {
- str[i] = '.';
- break;
- } else if (str[i] == '.') {
- str.insert(i++, "\\");
- }
- }
-
- return str;
-}
-
-void fillSOAData(const string &content, SOAData &data)
-{
- // content consists of fields separated by spaces:
- // nameservername hostmaster serial-number [refresh [retry [expire [ minimum] ] ] ]
-
- // fill out data with some plausible defaults:
- // 10800 3600 604800 3600
- data.serial=0;
- data.refresh=::arg().asNum("soa-refresh-default");
- data.retry=::arg().asNum("soa-retry-default");
- data.expire=::arg().asNum("soa-expire-default");
- data.default_ttl=::arg().asNum("soa-minimum-ttl");
-
- vector<string>parts;
- stringtok(parts,content);
- int pleft=parts.size();
-
- // cout<<"'"<<content<<"'"<<endl;
-
- if(pleft)
- data.nameserver=parts[0];
-
- if(pleft>1)
- data.hostmaster=attodot(parts[1]); // ahu@ds9a.nl -> ahu.ds9a.nl, piet.puk@ds9a.nl -> piet\.puk.ds9a.nl
-
- if(pleft>2)
- data.serial=strtoul(parts[2].c_str(), NULL, 10);
-
- if(pleft>3)
- data.refresh=atoi(parts[3].c_str());
-
- if(pleft>4)
- data.retry=atoi(parts[4].c_str());
-
- if(pleft>5)
- data.expire=atoi(parts[5].c_str());
-
- if(pleft>6)
- data.default_ttl=atoi(parts[6].c_str());
-
-}
-
-string serializeSOAData(const SOAData &d)
-{
- ostringstream o;
- // nameservername hostmaster serial-number [refresh [retry [expire [ minimum] ] ] ]
- o<<d.nameserver<<" "<< d.hostmaster <<" "<< d.serial <<" "<< d.refresh << " "<< d.retry << " "<< d.expire << " "<< d.default_ttl;
-
- return o.str();
-}
static int rrcomp(const DNSResourceRecord &A, const DNSResourceRecord &B)
if(d_dnssecOk) {
if(pos != d_rrs.begin() && (signQType != pos->qtype.getCode() || signQName != pos->qname)) {
- addSignature(::arg()["key-repository"], signQName, wildcardQName, signQType, signTTL, signPlace, toSign, pw);
+ addSignature(signQName, wildcardQName, signQType, signTTL, signPlace, toSign, pw);
}
signQName= pos->qname;
wildcardQName = pos->wildcardname;
// I assume this is some dirty hack to prevent us from signing the last SOA record in an AXFR.. XXX FIXME
if(d_dnssecOk && !(d_tcp && d_rrs.rbegin()->qtype.getCode() == QType::SOA && d_rrs.rbegin()->priority == 1234)) {
// cerr<<"Last signature.. "<<d_tcp<<", "<<d_rrs.rbegin()->priority<<", "<<d_rrs.rbegin()->qtype.getCode()<<", "<< d_rrs.size()<<endl;
- addSignature(::arg()["key-repository"], signQName, wildcardQName, signQType, signTTL, signPlace, toSign, pw);
+ addSignature(signQName, wildcardQName, signQType, signTTL, signPlace, toSign, pw);
}
if(!opts.empty() || d_dnssecOk)
/*
PowerDNS Versatile Database Driven Nameserver
- Copyright (C) 2002 - 2005 PowerDNS.COM BV
+ Copyright (C) 2002 - 2011 PowerDNS.COM BV
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License version 2 as published
class DNSBackend;
-/** helper function for both DNSPacket and addSOARecord() - converts a line into a struct, for easier parsing */
-void fillSOAData(const string &content, SOAData &data);
-/** for use by DNSPacket, converts a SOAData class to a ascii line again */
-string serializeSOAData(const SOAData &data);
-string &attodot(string &str); //!< for when you need to insert an email address in the SOA
//! This class represents DNS packets, either received or to be sent.
class DNSPacket