Skip to content

Instantly share code, notes, and snippets.

@Habbie
Created April 26, 2013 11:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Habbie/5466892 to your computer and use it in GitHub Desktop.
Save Habbie/5466892 to your computer and use it in GitHub Desktop.
Updated patch for snapshot4, also has support for forward-zones-file (separate forwarders with comma)
diff -ru pdns-recursor-3.1.5-snapshot4/pdns_recursor.cc pdns-recursor-3.1.5-snapshot4.multiforward/pdns_recursor.cc
--- pdns-recursor-3.1.5-snapshot4/pdns_recursor.cc 2008-02-10 23:11:27.000000000 +0200
+++ pdns-recursor-3.1.5-snapshot4.multiforward/pdns_recursor.cc 2008-02-18 14:29:16.000000000 +0200
@@ -1507,7 +1507,7 @@
}
else {
L<<Logger::Error<<"Redirecting queries for zone '"<<headers.first<<"' to IP '"<<headers.second<<"'"<<endl;
- ad.d_server=headers.second;
+ stringtok(ad.d_servers, headers.second, ";");
}
SyncRes::s_domainmap[headers.first]=ad;
@@ -1530,7 +1530,7 @@
uint64_t before = SyncRes::s_domainmap.size();
while(linenum++, fgets(line, sizeof(line)-1, fp.get())) {
parts.clear();
- stringtok(parts,line,"=, ");
+ stringtok(parts,line,"= ");
if(parts.empty())
continue;
if(parts.size()<2)
@@ -1538,7 +1538,7 @@
trim(parts[0]);
trim(parts[1]);
parts[0]=toCanonic("", parts[0]);
- ad.d_server=parts[1];
+ stringtok(ad.d_servers, parts[1], ",");
// cerr<<"Inserting '"<<domain<<"' to '"<<ad.d_server<<"'\n";
SyncRes::s_domainmap[parts[0]]=ad;
}
diff -ru pdns-recursor-3.1.5-snapshot4/syncres.cc pdns-recursor-3.1.5-snapshot4.multiforward/syncres.cc
--- pdns-recursor-3.1.5-snapshot4/syncres.cc 2008-02-10 23:11:27.000000000 +0200
+++ pdns-recursor-3.1.5-snapshot4.multiforward/syncres.cc 2008-02-18 14:01:38.000000000 +0200
@@ -202,13 +202,14 @@
string authname(qname);
domainmap_t::const_iterator iter=getBestAuthZone(&authname);
if(iter != s_domainmap.end()) {
- string server=iter->second.d_server;
- if(server.empty()) {
+ const vector<string> & servers = iter->second.d_servers;
+ if(servers.empty()) {
ret.clear();
doOOBResolve(qname, qtype, ret, depth, res);
return res;
}
else {
+ const string & server = servers.front();
LOG<<prefix<<qname<<": forwarding query to hardcoded nameserver '"<<server<<"' for zone '"<<authname<<"'"<<endl;
ComboAddress remoteIP(server, 53);
@@ -376,7 +377,11 @@
domainmap_t::const_iterator iter=getBestAuthZone(&authdomain);
if(iter!=s_domainmap.end()) {
- nsset.insert(iter->second.d_server); // this gets picked up in doResolveAt, if empty it means "we are auth", otherwise it denotes a forward
+ if( iter->second.d_servers.empty() )
+ nsset.insert(string()); // this gets picked up in doResolveAt, if empty it means "we are auth", otherwise it denotes a forward
+ else
+ nsset.insert(iter->second.d_servers.begin(), iter->second.d_servers.end());
+
return authdomain;
}
diff -ru pdns-recursor-3.1.5-snapshot4/syncres.hh pdns-recursor-3.1.5-snapshot4.multiforward/syncres.hh
--- pdns-recursor-3.1.5-snapshot4/syncres.hh 2008-02-10 23:11:27.000000000 +0200
+++ pdns-recursor-3.1.5-snapshot4.multiforward/syncres.hh 2008-02-18 14:01:38.000000000 +0200
@@ -326,7 +326,7 @@
struct AuthDomain
{
- string d_server;
+ vector<string> d_servers;
typedef multi_index_container <
DNSResourceRecord,
indexed_by <
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment