]> git.pld-linux.org Git - packages/djbdns.git/blobdiff - dnscache-1.05-multiple-ip.patch
- revert, tinydns already depends on perl, sigh
[packages/djbdns.git] / dnscache-1.05-multiple-ip.patch
index 7b6f710823d1ada9df4bb1a55a61dbecae11008c..2dc6ab15e5195e71f0d49fad73a35a6a9ebaa727 100644 (file)
@@ -1,6 +1,6 @@
 diff -urN djbdns-1.05.org/MULTIPLEIP djbdns-1.05/MULTIPLEIP
---- djbdns-1.05.org/MULTIPLEIP Thu Jan  1 01:00:00 1970
-+++ djbdns-1.05/MULTIPLEIP     Sat Apr 28 22:15:42 2001
+--- djbdns-1.05.org/MULTIPLEIP  Thu Jan  1 01:00:00 1970
++++ djbdns-1.05/MULTIPLEIP  Sat Apr 28 22:15:42 2001
 @@ -0,0 +1,10 @@
 +
 +When applied, dnscache will accept a /-delimited list of IP address in $IP
@@ -8,58 +8,58 @@ diff -urN djbdns-1.05.org/MULTIPLEIP djbdns-1.05/MULTIPLEIP
 +external IP 1.2.3.4 which only client group A can reach, and, say,
 +internal IP 4.3.2.1 which only client group B can reach. Assuming 1.2.3.4
 +and 4.3.2.1 are on the same machine, instead of running two independent
-+dnscache instances on 1.2.3.4 and 4.3.2.1, one instance can bind to both 
-+IP's and serve queries from the shared cache. Simply put 1.2.3.4/4.3.2.1 in env/IP. 
++dnscache instances on 1.2.3.4 and 4.3.2.1, one instance can bind to both
++IP's and serve queries from the shared cache. Simply put 1.2.3.4/4.3.2.1 in env/IP.
 +
 +http://danp.net/djbdns/patches.html
-diff -urN djbdns-1.05.org/dnscache.c djbdns-1.05/dnscache.c
---- djbdns-1.05.org/dnscache.c Sun Feb 11 22:11:45 2001
-+++ djbdns-1.05/dnscache.c     Sat Apr 28 22:12:13 2001
-@@ -5,6 +5,7 @@
- #include "strerr.h"
+diff -r -u djbdns+ipv6/dnscache.c djbdns-1.05/dnscache.c
+--- djbdns+ipv6/dnscache.c     2004-09-29 21:17:03.000000000 +0200
++++ djbdns-1.05/dnscache.c     2004-09-29 22:02:38.018542064 +0200
+@@ -6,6 +6,7 @@
  #include "error.h"
  #include "ip4.h"
+ #include "ip6.h"
 +#include "str.h"
  #include "uint16.h"
  #include "uint64.h"
  #include "socket.h"
-@@ -47,12 +48,20 @@
+@@ -52,12 +53,20 @@
  
  
- static char myipoutgoing[4];
--static char myipincoming[4];
+ static char myipoutgoing[16];
+-static char myipincoming[16];
  static char buf[1024];
  uint64 numqueries = 0;
  
 +struct interf {
-+  char ip[4];
++  char ip[16];
 +  int udp53;
 +  int tcp53;
 +  iopause_fd *udp53io;
 +  iopause_fd *tcp53io;
-+  
++
 +  struct interf *next;
-+} ;
++};
  
 -static int udp53;
 +struct interf *interhead = 0;
  
  #define MAXUDP 200
  static struct udpclient {
-@@ -60,6 +69,7 @@
+@@ -65,6 +74,7 @@
    struct taia start;
    uint64 active; /* query number, if active; otherwise 0 */
    iopause_fd *io;
 +  int fd;
-   char ip[4];
+   char ip[16];
    uint16 port;
    char id[2];
-@@ -78,12 +88,12 @@
+@@ -84,12 +94,12 @@
    if (!u[j].active) return;
    response_id(u[j].id);
    if (response_len > 512) response_tc();
--  socket_send4(udp53,response,response_len,u[j].ip,u[j].port);
-+  socket_send4(u[j].fd,response,response_len,u[j].ip,u[j].port);
+-  socket_send6(udp53,response,response_len,u[j].ip,u[j].port,u[j].scope_id);
++  socket_send6(u[j].fd,response,response_len,u[j].ip,u[j].port,u[j].scope_id);
    log_querydone(&u[j].active,response_len);
    u[j].active = 0; --uactive;
  }
@@ -69,35 +69,35 @@ diff -urN djbdns-1.05.org/dnscache.c djbdns-1.05/dnscache.c
  {
    int j;
    int i;
-@@ -108,8 +118,9 @@
+@@ -114,8 +124,9 @@
  
    x = u + j;
    taia_now(&x->start);
-+  x->fd = fd;
++  x->fd=fd;
  
--  len = socket_recv4(udp53,buf,sizeof buf,x->ip,&x->port);
-+  len = socket_recv4(x->fd,buf,sizeof buf,x->ip,&x->port);
+-  len = socket_recv6(udp53,buf,sizeof buf,x->ip,&x->port,&x->scope_id);
++  len = socket_recv6(x->fd,buf,sizeof buf,x->ip,&x->port,&x->scope_id);
    if (len == -1) return;
    if (len >= sizeof buf) return;
    if (x->port < 1024) if (x->port != 53) return;
-@@ -129,8 +140,6 @@
+@@ -134,8 +145,6 @@
+   }
  }
  
 -static int tcp53;
 -
  #define MAXTCP 20
  struct tcpclient {
    struct query q;
-@@ -138,6 +147,7 @@
+@@ -143,6 +152,7 @@
    struct taia timeout;
    uint64 active; /* query number or 1, if active; otherwise 0 */
    iopause_fd *io;
 +  int fd;
-   char ip[4]; /* send response to this address */
+   char ip[16]; /* send response to this address */
    uint16 port; /* send response to this port */
    char id[2];
-@@ -266,7 +276,7 @@
+@@ -272,7 +282,7 @@
    x->state = 0;
  }
  
@@ -106,18 +106,18 @@ diff -urN djbdns-1.05.org/dnscache.c djbdns-1.05/dnscache.c
  {
    int i;
    int j;
-@@ -290,8 +300,9 @@
+@@ -296,8 +306,9 @@
  
    x = t + j;
    taia_now(&x->start);
-+  x->fd = fd;
++  x->fd=fd;
  
--  x->tcp = socket_accept4(tcp53,x->ip,&x->port);
-+  x->tcp = socket_accept4(x->fd,x->ip,&x->port);
+-  x->tcp = socket_accept6(tcp53,x->ip,&x->port,&x->scope_id);
++  x->tcp = socket_accept6(x->fd,x->ip,&x->port,&x->scope_id);
    if (x->tcp == -1) return;
    if (x->port < 1024) if (x->port != 53) { close(x->tcp); return; }
    if (!okclient(x->ip)) { close(x->tcp); return; }
-@@ -304,19 +315,24 @@
+@@ -310,19 +321,24 @@
    log_tcpopen(x->ip,x->port);
  }
  
@@ -145,7 +145,7 @@ diff -urN djbdns-1.05.org/dnscache.c djbdns-1.05/dnscache.c
    for (;;) {
      taia_now(&stamp);
      taia_uint(&deadline,120);
-@@ -324,13 +340,15 @@
+@@ -330,13 +346,15 @@
  
      iolen = 0;
  
@@ -168,7 +168,7 @@ diff -urN djbdns-1.05.org/dnscache.c djbdns-1.05/dnscache.c
  
      for (j = 0;j < MAXUDP;++j)
        if (u[j].active) {
-@@ -372,46 +390,82 @@
+@@ -378,23 +396,30 @@
            t_rw(j);
        }
  
@@ -179,16 +179,17 @@ diff -urN djbdns-1.05.org/dnscache.c djbdns-1.05/dnscache.c
 -    if (tcp53io)
 -      if (tcp53io->revents)
 -      t_new();
+-  }
 +    for (inter = interhead; inter != 0; inter = inter->next) {
-+      if (inter->udp53io)
-+        if (inter->udp53io->revents)
-+        u_new(inter->udp53);
-+
++        if (inter->udp53io)
++          if (inter->udp53io->revents)
++            u_new(inter->udp53);
++      
 +      if (inter->tcp53io)
-+        if (inter->tcp53io->revents)
-+        t_new(inter->tcp53);
-+    }
-   }
++          if (inter->tcp53io->revents)
++            t_new(inter->tcp53);
++          }
++        }
  }
    
 -#define FATAL "dnscache: fatal: "
@@ -205,60 +206,66 @@ diff -urN djbdns-1.05.org/dnscache.c djbdns-1.05/dnscache.c
 +  char iperr[IP4_FMT];
 +  struct interf *inter;
 +  struct interf *itmp;
+   unsigned int i, j, k;
    unsigned long cachesize;
+   static stralloc sa = {0};
+@@ -405,31 +430,50 @@
    x = env_get("IP");
    if (!x)
      strerr_die2x(111,FATAL,"$IP not set");
--  if (!ip4_scan(x,myipincoming))
+-  if (!ip6_scan(x,myipincoming))
 -    strerr_die3x(111,FATAL,"unable to parse IP address ",x);
--  udp53 = socket_udp();
--  if (udp53 == -1)
--    strerr_die2sys(111,FATAL,"unable to create UDP socket: ");
--  if (socket_bind4_reuse(udp53,myipincoming,53) == -1)
--    strerr_die2sys(111,FATAL,"unable to bind UDP socket: ");
--
--  tcp53 = socket_tcp();
--  if (tcp53 == -1)
--    strerr_die2sys(111,FATAL,"unable to create TCP socket: ");
--  if (socket_bind4_reuse(tcp53,myipincoming,53) == -1)
--    strerr_die2sys(111,FATAL,"unable to bind TCP socket: ");
 +  len = str_len(x);
 +  numio = pos = oldpos = 0;
-+  
 +  while (pos < len) {
 +    if (pos) oldpos = pos + 1;
 +    pos = oldpos + str_chr(x + oldpos,'/');
 +    x[pos] = 0;
 +    if (!str_len(x + oldpos)) continue;
-+    
-+    if (!ip4_scan(x + oldpos,iptmp))
++
++    if (!ip6_scan(x + oldpos,iptmp))
 +      strerr_die3x(111,FATAL,"unable to parse IP address ",x + oldpos);
-+      
++
 +    inter = (struct interf *) alloc(sizeof(struct interf));
-+    
++
 +    if (interhead == 0) interhead = inter;
 +    else if (interhead->next == 0) interhead->next = inter;
 +    else {
 +      for (itmp = interhead; itmp->next != 0; itmp = itmp->next);
 +      itmp->next = inter;
 +    }
-+    
+-#if 0
+-  /* if if IP is a mapped-IPv4 address, disable IPv6 functionality */
+-  /* this is actually a bad idea */
+-  if (ip6_isv4mapped(myipincoming))
+-    noipv6 = 1;
+-#endif
+-
+-  udp53 = socket_udp6();
+-  if (udp53 == -1)
+-    strerr_die2sys(111,FATAL,"unable to create UDP socket: ");
+-  if (socket_bind6_reuse(udp53,myipincoming,53,interface) == -1)
+-    strerr_die2sys(111,FATAL,"unable to bind UDP socket: ");
+-
+-  tcp53 = socket_tcp6();
+-  if (tcp53 == -1)
+-    strerr_die2sys(111,FATAL,"unable to create TCP socket: ");
+-  if (socket_bind6_reuse(tcp53,myipincoming,53,interface) == -1)
+-    strerr_die2sys(111,FATAL,"unable to bind TCP socket: ");
 +    inter->next = 0;
-+    
-+    inter->udp53 = socket_udp();
++    inter->udp53 = socket_udp6();
 +    if (inter->udp53 == -1)
 +      strerr_die4sys(111,FATAL,"unable to create UDP socket for IP address ",x + oldpos,": ");
-+    if (socket_bind4_reuse(inter->udp53,iptmp,53) == -1)
++    if (socket_bind6_reuse(inter->udp53,iptmp,53,interface) == -1)
 +      strerr_die4sys(111,FATAL,"unable to bind UDP socket for IP address ",x + oldpos,": ");
-+      
-+    inter->tcp53 = socket_tcp();
++
++    inter->tcp53 = socket_tcp6();
 +    if (inter->tcp53 == -1)
 +      strerr_die4sys(111,FATAL,"unable to create TCP socket for IP address ",x + oldpos,": ");
-+    if (socket_bind4_reuse(inter->tcp53,iptmp,53) == -1)
++    if (socket_bind6_reuse(inter->tcp53,iptmp,53,interface) == -1)
 +      strerr_die4sys(111,FATAL,"unable to bind TCP socket for IP address ",x + oldpos,": ");
-+      
++
 +    numio++;
 +    log_listen(iptmp);
 +  }
@@ -274,7 +281,7 @@ diff -urN djbdns-1.05.org/dnscache.c djbdns-1.05/dnscache.c
  
    byte_zero(seed,sizeof seed);
    read(0,seed,sizeof seed);
-@@ -439,8 +493,11 @@
+@@ -471,8 +515,11 @@
    if (!roots_init())
      strerr_die2sys(111,FATAL,"unable to read servers: ");
  
@@ -288,26 +295,23 @@ diff -urN djbdns-1.05.org/dnscache.c djbdns-1.05/dnscache.c
  
    log_startup();
    doit();
-diff -urN djbdns-1.05.org/log.c djbdns-1.05/log.c
---- djbdns-1.05.org/log.c      Sun Feb 11 22:11:45 2001
-+++ djbdns-1.05/log.c  Sat Apr 28 22:12:13 2001
-@@ -94,6 +94,13 @@
+diff -r -u djbdns+ipv6/log.c djbdns-1.05/log.c
+--- djbdns+ipv6/log.c  2004-09-29 21:17:03.000000000 +0200
++++ djbdns-1.05/log.c  2004-09-29 21:47:02.523655344 +0200
+@@ -285,3 +285,10 @@
+   number(tactive);
    line();
  }
-+void log_listen(const char addr[4])
++
++void log_listen(const char addr[16])
 +{
 +  string("listening on ");
 +  ip(addr);
 +  line();
 +}
-+
- void log_query(uint64 *qnum,const char client[4],unsigned int port,const char id[2],const char *q,const char qtype[2])
- {
-   string("query "); number(*qnum); space();
-diff -urN djbdns-1.05.org/log.h djbdns-1.05/log.h
---- djbdns-1.05.org/log.h      Sun Feb 11 22:11:45 2001
-+++ djbdns-1.05/log.h  Sat Apr 28 22:12:13 2001
+diff -r -u djbdns+ipv6/log.h djbdns-1.05/log.h
+--- djbdns+ipv6/log.h  2001-02-11 22:11:45.000000000 +0100
++++ djbdns-1.05/log.h  2004-09-29 21:18:46.114548728 +0200
 @@ -4,6 +4,7 @@
  #include "uint64.h"
  
This page took 0.150513 seconds and 4 git commands to generate.