Changes since 2.9.6:
+ * need to do work on ( and ) in zones!
+ - added local-query-address (Mark Bergsma)
+ - zone2sql now removes dots in the SOA record
+ - zone2sql no longer silently tries to read directories
+ - improved error reporting if unable to figure out IP addresses for
+ slaves
+
+Changes since 2.9.5:
- implemented isMaster in bindbackend (we now react to notifies)
- added zoneId to mboxfw stuff - massive speedup
- $GENERATE off by one bug (Christian Laursen)
zone2sql_SOURCES=bindparser.yy bindlexer.l zoneparser2.cc \
../../arguments.cc ../../logger.cc zone2sql.cc ../../statbag.cc ../../misc.cc \
-../../unix_utility.cc ../../qtype.cc
+../../unix_utility.cc ../../qtype.cc ../../dnspacket.cc \
+../../sillyrecords.cc
zone2sql_LDFLAGS=@THREADFLAGS@
*/
/* accepts a named.conf as parameter and outputs heaps of sql */
-// $Id: zone2sql.cc,v 1.5 2003/02/02 22:04:51 ahu Exp $
+// $Id: zone2sql.cc,v 1.6 2003/02/25 12:36:49 ahu Exp $
#ifdef WIN32
# pragma warning ( disable: 4786 )
# include <unistd.h>
#include "bindparser.hh"
#include "statbag.hh"
#include "misc.hh"
+#include "dnspacket.hh"
StatBag S;
static int num_records;
static string lastsoa_qname;
-static void callback(unsigned int domain_id,const string &domain, const string &qtype, const string &content, int ttl, int prio)
+static void callback(unsigned int domain_id,const string &domain, const string &qtype, const string &ocontent, int ttl, int prio)
{
static int lastsoa_domain_id=-1;
+ string content(ocontent);
num_records++;
}
}
}
+ SOAData soadata;
+ DNSPacket::fillSOAData(content, soadata);
+ soadata.hostmaster=ZoneParser::canonic(soadata.hostmaster);
+ soadata.nameserver=ZoneParser::canonic(soadata.nameserver);
+ content=DNSPacket::serializeSOAData(soadata);
+
+
lastsoa_qname=ZoneParser::canonic(domain);
}
arg().set("zone","Zonefile with $ORIGIN to parse")="";
arg().set("zone-name","Specify an $ORIGIN in case it is not present")="";
arg().set("named-conf","Bind 8 named.conf to parse")="";
+ arg().set("soa-minimum-ttl","Do not change")="0";
arg().setCmd("help","Provide a helpful message");
for(vector<Record>::const_iterator i=rec.begin();i!=rec.end();++i)
d_callback(domain_id,i->name, i->qtype,i->content,i->ttl,i->prio);
}
+
+ if(ferror(fds.top())) {
+ fclose(fds.top());
+ fds.pop();
+ throw AhuException("Error reading from file '"+fname+"': "+stringerror());
+ }
fclose(fds.top());
fds.pop();
}
for(vector<Record>::const_iterator i=rec.begin();i!=rec.end();++i)
records.push_back(*i);
}
+
+ if(ferror(fds.top())) {
+ fclose(fds.top());
+ fds.pop();
+ throw AhuException("Error reading from file '"+fname+"': "+stringerror());
+ }
fclose(fds.top());
fds.pop();
}
arg().set("smtpredirector","Our smtpredir MX host")="a.misconfigured.powerdns.smtp.server";
arg().set("local-address","Local IP address to which we bind")="0.0.0.0";
arg().set("local-ipv6","Local IP address to which we bind")="";
+ arg().set("query-local-address","Source IP address for sending queries")="";
arg().set("max-queue-length","Maximum queuelength before considering situation lost")="5000";
arg().set("soa-serial-offset","Make sure that no SOA serial is less than this number")="0";
arg().set("only-soa","Make sure that no SOA serial is less than this number")="org";
for(set<string>::const_iterator j=nsset.begin();j!=nsset.end();++j) {
vector<string>nsips=d_fns.lookup(*j, B);
+ if(nsips.empty())
+ L<<Logger::Warning<<"Unable to queue notification of domain '"<<domain<<"': nameservers do not resolve!"<<endl;
for(vector<string>::const_iterator k=nsips.begin();k!=nsips.end();++k)
ips.insert(*k);
}
memset((char *)&sin,0, sizeof(sin));
sin.sin_family = AF_INET;
- sin.sin_addr.s_addr = INADDR_ANY;
+
+ // Bind to a specific IP (query-local-address) if specified
+ string querylocaladdress(arg()["query-local-address"]);
+ if (querylocaladdress=="") {
+ sin.sin_addr.s_addr = INADDR_ANY;
+ }
+ else
+ {
+ struct hostent *h=0;
+ h=gethostbyname(querylocaladdress.c_str());
+ if(!h) {
+ Utility::closesocket(d_nsock);
+ d_nsock=-1;
+ throw AhuException("Unable to resolve query local address");
+ }
+
+ sin.sin_addr.s_addr = *(int*)h->h_addr;
+ }
+
int n=0;
for(;n<10;n++) {
sin.sin_port = htons(10000+(Utility::random()%50000));
if(n==10) {
Utility::closesocket(d_nsock);
d_nsock=-1;
- throw AhuException(string("binding dnsproxy socket: ")+strerror(errno));
+ throw AhuException(string("binding notify socket: ")+strerror(errno));
}
if( !Utility::setNonBlocking( d_nsock ))
throw AhuException(string("error getting or setting notify socket non-blocking: ")+strerror(errno));
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-// $Id: dnspacket.cc,v 1.16 2003/01/23 15:34:53 ahu Exp $
+// $Id: dnspacket.cc,v 1.17 2003/02/25 12:36:49 ahu Exp $
#include "utility.hh"
#include <cstdio>
stringbuffer=orig.stringbuffer;
d=orig.d;
-
}
int DNSPacket::expand(const unsigned char *begin, const unsigned char *end, string &expanded, int depth)
DNSResourceRecord rr;
if (p->qclass == 3 && p->qtype.getName() == "HINFO") {
- rr.content = "PowerDNS $Id: packethandler.cc,v 1.9 2003/02/04 16:33:47 ahu Exp $";
+ rr.content = "PowerDNS $Id: packethandler.cc,v 1.10 2003/02/25 12:36:49 ahu Exp $";
rr.ttl = 5;
rr.qname=target;
rr.qtype=13; // hinfo
{
DNSResourceRecord rr;
if(p->qtype.getCode()==QType::TXT && target=="version.bind") {// TXT
- rr.content="Served by POWERDNS "VERSION" $Id: packethandler.cc,v 1.9 2003/02/04 16:33:47 ahu Exp $";
+ rr.content="Served by POWERDNS "VERSION" $Id: packethandler.cc,v 1.10 2003/02/25 12:36:49 ahu Exp $";
rr.ttl=5;
rr.qname=target;
rr.qtype=QType::TXT; // TXT
}
}
catch(ResolverException& re) {
- L<<Logger::Error<<"Trying to do additional processing for answer to '"<<p->qdomain<<"' query: "<<re.reason<<endl;
+ // L<<Logger::Error<<"Trying to do additional processing for answer to '"<<p->qdomain<<"' query: "<<re.reason<<endl;
}
}
}
d_sock=socket(AF_INET,SOCK_STREAM,0);
if(d_sock<0)
throw ResolverException("Unable to make a TCP socket for resolver: "+stringerror());
-
+
+ // Use query-local-address as source IP for queries, if specified.
+ string querylocaladdress(arg()["query-local-address"]);
+ if (querylocaladdress!="") {
+ struct sockaddr_in fromaddr;
+ struct hostent *h=0;
+
+ h = gethostbyname(querylocaladdress.c_str());
+ if(!h) {
+ Utility::closesocket(d_sock);
+ d_sock=-1;
+ throw ResolverException("Unable to resolve query local address");
+ }
+
+ fromaddr.sin_family = AF_INET;
+ fromaddr.sin_addr.s_addr = *(int*)h->h_addr;
+ fromaddr.sin_port = 0;
+
+ if (bind(d_sock, (struct sockaddr *)&fromaddr, sizeof(fromaddr)) < 0) {
+ Utility::closesocket(d_sock);
+ d_sock=-1;
+ throw ResolverException("Binding to query-local-address: "+stringerror());
+ }
+ }
+
Utility::setNonBlocking( d_sock );
int err;