[Pdns-users] Patch to powerdns for autoserial with gsql backend
bert hubert
ahu at ds9a.nl
Sun Feb 29 20:58:16 UTC 2004
On Sun, Feb 29, 2004 at 02:36:58PM -0500, Derrik Pates wrote:
> Ok, I am attaching a revised version of the autoserial patch. I built a
> version of PowerDNS 2.9.16 with this patch included, and it gets the
> domain serials correctly, and builds cleanly. Let me know if you think
> it needs any extra tweaking.
We're almost there :-)
> +// Implementing this as an alternative to my previous tactic, as suggested
> +// by Bert. This would be easier if I could just call the superclass method...
You can, just call DNSBackend::getSOA(domain, sd) - not sure if that fits in
entirely though.
> +bool GSQLBackend::getSOA(const string &domain, SOAData &sd)
> +{
> + this->lookup(QType(QType::SOA),domain,0);
> +
> + DNSResourceRecord rr;
> +
> + int hits=0;
> +
> + while (this->get(rr)) {
> + hits++;
> + DNSPacket::fillSOAData(rr.content, sd);
> + sd.domain_id=rr.domain_id;
> + sd.ttl=rr.ttl;
> + }
> +
> + if (!hits)
> + return false;
> +
> + if (sd.nameserver.empty())
> + sd.nameserver=arg()["default-soa-name"];
> +
> + if(sd.hostmaster.empty())
> + sd.hostmaster="hostmaster."+domain;
> +
> + if (!sd.serial) { // try to get the serial number automagically
> + char output[1024];
> +
> + // We do this by asking the backend what the max serial number is among
> + // all the records it knows for the domain we're looking at.
> + snprintf(output, sizeof(output)-1, d_ZoneSerialQuery.c_str(), sd.domain_id);
> +
> + try {
> + d_db->doQuery(output, d_result);
> + } catch (SSqlException &e) {
> + throw AhuException("Database error trying to query serial for domain_id "+itoa(sd.domain_id)+": "+e.txtReason());
> + }
> +
> + if (!d_result.empty())
> + sd.serial = atoi(d_result[0][0].c_str());
> + }
You can probably call DNSBackend::getSOA here.
--
http://www.PowerDNS.com Open source, database driven DNS Software
http://lartc.org Linux Advanced Routing & Traffic Control HOWTO
More information about the Pdns-users
mailing list