]> granicus.if.org Git - pdns/commitdiff
implement 'forward-zones-file' for large amounts of forwarded zones, remove TSC manip...
authorBert Hubert <bert.hubert@netherlabs.nl>
Mon, 19 Feb 2007 21:04:32 +0000 (21:04 +0000)
committerBert Hubert <bert.hubert@netherlabs.nl>
Mon, 19 Feb 2007 21:04:32 +0000 (21:04 +0000)
git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@963 d19b8d6e-7fed-0310-83ef-9ca221ded41b

pdns/docs/pdns.sgml
pdns/docs/pdns_recursor.1.txt
pdns/misc.hh
pdns/pdns_recursor.cc

index 3d2d2986ac2e7344f45af87e5e3a97cd69991b8f..2ca238aad7bff1b6dfe30823cf19aee0c69e038e 100644 (file)
@@ -6844,6 +6844,15 @@ local0.err                        /var/log/pdns.err
              </para>
            </listitem>
          </varlistentry>
+         <varlistentry>
+           <term>forward-zones-file</term>
+           <listitem>
+             <para>
+               Same as <command>forward-zones</command>, parsed from a file. Only 1 zone is allowed per line, specified as follows:
+               <command>ds9a.nl=213.244.168.210</command>. Available since 3.1.5.
+             </para>
+           </listitem>
+         </varlistentry>
 
          <varlistentry>
            <term>hint-file</term>
index 5b33f6ff2313137991d51fa59e8bdc0b2da57a91..66ffed48242c3112811e80fec5aa972a27b1ec8b 100644 (file)
@@ -89,6 +89,11 @@ For authoritative listing of options, consult the documentation referenced above
            auth-zones= ds9a.nl=213.244.168.210, powerdns.com=127.0.0.1.
            Available since 3.1.
 
+--forward-zones-file::
+           listed here will be forwarded to the IP address listed.
+           One zone per line, like: ds9a.nl=213.244.168.210
+           Available since 3.1.5
+
 --hint-file::
        If set, load root hints from this file
 
index 2ee9dcfa8f2c2e79d594fd79eb0943dcb0c13a4e..f7a2b66bc68d69b0613a06216eff531bfcb9d9ee 100644 (file)
@@ -19,7 +19,7 @@
 #ifndef MISC_HH
 #define MISC_HH
 
-#if 1
+#if 0
 #define RDTSC(qp) \
 do { \
   unsigned long lowPart, highPart;                                     \
index 82c7ce8d15ea41de8fefdecbdf12a7296aba1aa1..648453703f43cdb7404eb9368b1e1cf4264fc16f 100644 (file)
@@ -819,10 +819,10 @@ void handleNewUDPQuestion(int fd, boost::any& var)
   char data[1500];
   ComboAddress fromaddr;
   socklen_t addrlen=sizeof(fromaddr);
-  uint64_t tsc1, tsc2;
+  //  uint64_t tsc1, tsc2;
 
   if((len=recvfrom(fd, data, sizeof(data), 0, (sockaddr *)&fromaddr, &addrlen)) >= 0) {
-    RDTSC(tsc1);      
+    //    RDTSC(tsc1);      
     g_stats.addRemote(fromaddr);
 
     if(g_allowFrom && !g_allowFrom->match(&fromaddr)) {
@@ -841,6 +841,7 @@ void handleNewUDPQuestion(int fd, boost::any& var)
       }
       else {
        ++g_stats.qcounter;
+#if 0
        uint16_t type;
        char qname[256];
         try {
@@ -892,6 +893,7 @@ void handleNewUDPQuestion(int fd, boost::any& var)
             g_stats.noShuntWrongQuestion++;
         }
       slow:
+#endif
        DNSComboWriter* dc = new DNSComboWriter(data, len, g_now);
        dc->setSocket(fd);
        dc->setRemote(&fromaddr);
@@ -1481,6 +1483,37 @@ void parseAuthAndForwards()
     }
   }
   
+  if(!::arg()["forward-zones-file"].empty()) {
+    L<<Logger::Warning<<"Reading zone forwarding information from '"<<::arg()["forward-zones-file"]<<"'"<<endl;
+    SyncRes::AuthDomain ad;
+    FILE *rfp=fopen(::arg()["forward-zones-file"].c_str(), "r");
+
+    if(!rfp)
+      throw AhuException("Error opening forward-zones-file '"+::arg()["forward-zones-file"]+"': "+stringerror());
+
+    shared_ptr<FILE> fp=shared_ptr<FILE>(rfp, fclose);
+    
+    char line[1024];
+    vector<string> parts;
+    int linenum=0;
+    uint64_t before = SyncRes::s_domainmap.size();
+    while(linenum++, fgets(line, sizeof(line)-1, fp.get())) {
+      parts.clear();
+      stringtok(parts,line,"=, ");
+      if(parts.empty())
+       continue;
+      if(parts.size()<2) 
+       throw AhuException("Error parsing line "+lexical_cast<string>(linenum)+" of " +::arg()["forward-zones-file"]);
+      trim(parts[0]);
+      trim(parts[1]);
+      parts[0]=toCanonic("", parts[0]);
+      ad.d_server=parts[1];
+      //      cerr<<"Inserting '"<<domain<<"' to '"<<ad.d_server<<"'\n";
+      SyncRes::s_domainmap[parts[0]]=ad;
+    }
+    L<<Logger::Warning<<"Done parsing " << SyncRes::s_domainmap.size() - before<<" forwarding instructions"<<endl;
+  }
+
   if(::arg().mustDo("export-etc-hosts")) {
     string line;
     string fname;
@@ -1607,7 +1640,6 @@ int serviceMain(int argc, char*argv[])
     SyncRes::s_serverID=tmp;
   }
   
-  
   parseAuthAndForwards();
   
   g_stats.remotes.resize(::arg().asNum("remotes-ringbuffer-entries"));
@@ -1801,6 +1833,7 @@ int main(int argc, char **argv)
     ::arg().set("single-socket", "If set, only use a single socket for outgoing queries")="off";
     ::arg().set("auth-zones", "Zones for which we have authoritative data, comma separated domain=file pairs ")="";
     ::arg().set("forward-zones", "Zones for which we forward queries, comma separated domain=ip pairs")="";
+    ::arg().set("forward-zones-file", "File with domain=ip pairs for forwarding")="";
     ::arg().set("export-etc-hosts", "If we should serve up contents from /etc/hosts")="off";
     ::arg().set("serve-rfc1918", "If we should be authoritative for RFC 1918 private IP space")="";
     ::arg().set("auth-can-lower-ttl", "If we follow RFC 2181 to the letter, an authoritative server can lower the TTL of NS records")="off";