1
#! /bin/sh /usr/share/dpatch/dpatch-run
2
## update-geobackend.dpatch by Matthijs Mohlmann <matthijs@cacholong.nl>
4
## All lines beginning with `## DP:' are a description of the patch.
8
diff -urNad trunk~/modules/geobackend/geobackend.cc trunk/modules/geobackend/geobackend.cc
9
--- trunk~/modules/geobackend/geobackend.cc 2005-11-01 13:10:44.000000000 +0100
10
+++ trunk/modules/geobackend/geobackend.cc 2006-08-13 23:15:30.326980528 +0200
15
-bool GeoBackend::getSOA(const string &name, SOAData &soadata) {
16
- if (toLower(name) != toLower(zoneName))
17
+bool GeoBackend::getSOA(const string &name, SOAData &soadata, DNSPacket *p) {
18
+ if (toLower(name) != toLower(zoneName) || soaMasterServer.empty() || soaHostmaster.empty())
21
soadata.nameserver = soaMasterServer;
25
void GeoBackend::queueNSRecords(const string &qname) {
26
+ // nsRecords may be empty, e.g. when used in overlay mode
28
for (vector<string>::const_iterator i = nsRecords.begin(); i != nsRecords.end(); ++i) {
29
DNSResourceRecord *rr = new DNSResourceRecord;
30
rr->qtype = QType::NS;
32
vector<string> values;
33
stringtok(values, getArg("soa-values"), " ,");
36
+ // No SOA values, probably no SOA record wanted because of overlay mode
39
if (values.size() != 2)
40
throw AhuException("Invalid number of soa-values specified in configuration");
44
void GeoBackend::loadNSRecords() {
45
stringtok(nsRecords, getArg("ns-records"), " ,");
47
- if (nsRecords.empty())
48
- throw AhuException("No NS records specified in configuration");
51
void GeoBackend::loadIPLocationMap() {
54
if (filename[filename.size()-1] != '/')
57
+ if (dent->d_name[0] == '.')
58
+ continue; // skip filenames starting with a dot
60
filename += dent->d_name;
62
if (stat(filename.c_str(), &stbuf) != 0 || !S_ISREG(stbuf.st_mode))
64
+ continue; // skip everything but regular files
66
GeoRecord *gr = new GeoRecord;
67
gr->directorfile = filename;
69
while(getline(ifs, line)) {
70
chomp(line, " \t"); // Erase whitespace
73
- continue; // Skip comments
74
+ if (line.empty() || line[0] == '#')
75
+ continue; // Skip empty lines and comments
78
if (line.substr(0, 7) == "$RECORD") {
79
diff -urNad trunk~/modules/geobackend/geobackend.hh trunk/modules/geobackend/geobackend.hh
80
--- trunk~/modules/geobackend/geobackend.hh 2005-11-01 13:10:43.000000000 +0100
81
+++ trunk/modules/geobackend/geobackend.hh 2006-08-13 23:15:46.882463712 +0200
83
virtual void lookup(const QType &qtype, const string &qdomain, DNSPacket *pkt_p=0, int zoneId=-1);
84
virtual bool list(const string &target, int domain_id);
85
virtual bool get(DNSResourceRecord &r);
86
- virtual bool getSOA(const string &name, SOAData &soadata);
87
+ virtual bool getSOA(const string &name, SOAData &soadata, DNSPacket *p=0);
89
virtual void reload();
90
virtual void rediscover(string *status = 0);