[eggheads-patches] PATCH1.4: dnsfixes_1.4.patch

Fabian Knittel fknittel at gmx.de
Sun Oct 10 22:44:02 CST 1999


[ dnsfixes_1.4.patch ]

Outgoing bot links weren't correctly initialised, autolink
wasn't detecting active bot links while resolving and the
dns module was still broken from the last byte order changes.

Symptoms:

   - Sharing problems ("not sharing with you" messages,
     although they were sharing.
   - if the dns module was loaded nothing worked :)
   - bot tried to link to hub repeatedly although it
     was linked already.

Fabian
-------------- next part --------------
diff -urN eggdrop1.4~/doc/UPDATES1.4 eggdrop1.4/doc/UPDATES1.4
--- eggdrop1.4~/doc/UPDATES1.4	Mon Oct 11 02:47:08 1999
+++ eggdrop1.4/doc/UPDATES1.4	Mon Oct 11 03:52:56 1999
@@ -5,6 +5,9 @@
 
 1.4.0
 Foundby   Fixedby   What....
+	  Fabian    outgoing bot links weren't correctly initialised, autolink
+		    wasn't detecting active bot links and the dns module was
+		    still broken from the last byte order changes
 G`Quann	  Fabian    was deleting socket 0 if server connect failed
 arthur2	  Fabian    the dcc[].addr is now consistently host byte order and
 		    all async dns lookup functions accept host byte order IPs
diff -urN eggdrop1.4~/eggdrop.conf.dist eggdrop1.4/eggdrop.conf.dist
--- eggdrop1.4~/eggdrop.conf.dist	Mon Oct 11 02:47:08 1999
+++ eggdrop1.4/eggdrop.conf.dist	Mon Oct 11 03:53:26 1999
@@ -362,7 +362,7 @@
 # this module provides asynchronous dns support. This will avoid long
 # periods where the bot just hangs there, waiting for a hostname to
 # resolve, which often let it timeout on all other connections.
-#loadmodule dns
+loadmodule dns
 
 
 #### CHANNELS MODULE #####
diff -urN eggdrop1.4~/src/botnet.c eggdrop1.4/src/botnet.c
--- eggdrop1.4~/src/botnet.c	Mon Oct 11 02:47:09 1999
+++ eggdrop1.4/src/botnet.c	Mon Oct 11 03:45:34 1999
@@ -922,6 +922,7 @@
       i = new_dcc(&DCC_DNSWAIT, sizeof(struct dns_info));
       dcc[i].timeval = now;
       dcc[i].port = bi->telnet_port;
+      dcc[i].user = u;
       strcpy(dcc[i].nick, nick);
       strcpy(dcc[i].host, bi->address);
       dcc[i].u.dns->ibuf = idx;
@@ -931,6 +932,7 @@
       dcc[i].u.dns->dns_success = (Function) botlink_resolve_success;
       dcc[i].u.dns->dns_failure = (Function) botlink_resolve_failure;
       dcc[i].u.dns->dns_type = RES_IPBYHOST;
+      dcc[i].u.dns->type = &DCC_FORK_BOT;
 
       dns_ipbyhost(bi->address);
     }
@@ -1064,6 +1066,7 @@
   dcc[i].u.dns->dns_success = (Function) tandem_relay_resolve_success;
   dcc[i].u.dns->dns_failure = (Function) tandem_relay_resolve_failure;
   dcc[i].u.dns->dns_type = RES_IPBYHOST;
+  dcc[i].u.dns->type = &DCC_FORK_RELAY;
 
   dns_ipbyhost(bi->address);
 }
diff -urN eggdrop1.4~/src/dcc.c eggdrop1.4/src/dcc.c
--- eggdrop1.4~/src/dcc.c	Mon Oct 11 02:47:09 1999
+++ eggdrop1.4/src/dcc.c	Mon Oct 11 03:23:36 1999
@@ -1105,6 +1105,7 @@
   dcc[i].u.dns->dns_failure = (Function) dcc_telnet_hostresolved;
   dcc[i].u.dns->dns_type = RES_HOSTBYIP;
   dcc[i].u.dns->ibuf = dcc[idx].sock;
+  dcc[i].u.dns->type = &DCC_IDENTWAIT;
 
   dns_hostbyip(ip);
 }
diff -urN eggdrop1.4~/src/dns.c eggdrop1.4/src/dns.c
--- eggdrop1.4~/src/dns.c	Mon Oct 11 02:47:09 1999
+++ eggdrop1.4/src/dns.c	Mon Oct 11 02:57:51 1999
@@ -95,7 +95,6 @@
 {
   int idx;
   
-  ip = my_ntohl(ip);
   for (idx = 0; idx < dcc_total; idx++) {
     if ((dcc[idx].type == &DCC_DNSWAIT) &&
         (dcc[idx].u.dns->dns_type == RES_HOSTBYIP) &&
@@ -118,7 +117,6 @@
 {
   int idx;
   
-  ip = my_ntohl(ip);
   for (idx = 0; idx < dcc_total; idx++) {
     if ((dcc[idx].type == &DCC_DNSWAIT) &&
         (dcc[idx].u.dns->dns_type == RES_IPBYHOST) &&
@@ -154,7 +152,7 @@
     strcpy(s, iptostr(addr));
   }
   /* call hooks */
-  call_hostbyip(addr, s, hp ? 1 : 0);
+  call_hostbyip(ip, s, hp ? 1 : 0);
 }
 
 void block_dns_ipbyhost(char *host)
@@ -170,7 +168,7 @@
 
     in = (struct in_addr *) (hp->h_addr_list[0]);
     ip = (IP) (in->s_addr);
-    call_ipbyhost(host, ip, 1);
+    call_ipbyhost(host, my_ntohl(ip), 1);
   } else {
     call_ipbyhost(host, 0, 0);
   }
diff -urN eggdrop1.4~/src/eggdrop.h eggdrop1.4/src/eggdrop.h
--- eggdrop1.4~/src/eggdrop.h	Mon Oct 11 02:47:09 1999
+++ eggdrop1.4/src/eggdrop.h	Mon Oct 11 03:20:43 1999
@@ -290,6 +290,8 @@
   IP ip;			/* IP address */
   int ibuf;			/* temporary buffer for one integer */
   char dns_type;		/* lookup type, e.g. RES_HOSTBYIP */
+  struct dcc_table *type;	/* type of the dcc table we are making the
+				   lookup for */
 };
 
 /* flags for dns_type */
diff -urN eggdrop1.4~/src/mod/dns.mod/coredns.c eggdrop1.4/src/mod/dns.mod/coredns.c
--- eggdrop1.4~/src/mod/dns.mod/coredns.c	Mon Oct 11 02:47:09 1999
+++ eggdrop1.4/src/mod/dns.mod/coredns.c	Mon Oct 11 03:02:43 1999
@@ -1017,7 +1017,7 @@
     struct resolve *rp;
     
     context;
-    ip = htonl(ip);
+    ip = my_htonl(ip);
     if ((rp = findip(ip))) {
 	if ((rp->state == STATE_FINISHED)
 	    || (rp->state == STATE_FAILED)) {
diff -urN eggdrop1.4~/src/mod/dns.mod/dns.c eggdrop1.4/src/mod/dns.mod/dns.c
--- eggdrop1.4~/src/mod/dns.mod/dns.c	Mon Oct 11 02:47:09 1999
+++ eggdrop1.4/src/mod/dns.mod/dns.c	Mon Oct 11 03:02:28 1999
@@ -50,10 +50,10 @@
 
   if (type == T_PTR) {
     debug2("DNS resolved %s to %s", iptostr(rp->ip), rp->hostn);
-    call_hostbyip(ntohl(rp->ip), rp->hostn, 1);
+    call_hostbyip(my_ntohl(rp->ip), rp->hostn, 1);
   } else if (type == T_A) {
     debug2("DNS resolved %s to %s", rp->hostn, iptostr(rp->ip));
-    call_ipbyhost(rp->hostn, ntohl(rp->ip), 1);
+    call_ipbyhost(rp->hostn, my_ntohl(rp->ip), 1);
   }
 }
 
@@ -68,7 +68,7 @@
 
     debug1("DNS resolve failed for %s", iptostr(rp->ip));
     strcpy(s, iptostr(rp->ip));
-    call_hostbyip(ntohl(rp->ip), s, 0);
+    call_hostbyip(my_ntohl(rp->ip), s, 0);
   }  
   /* T_A */
   else if (rp->hostn) {
diff -urN eggdrop1.4~/src/mod/filesys.mod/filesys.c eggdrop1.4/src/mod/filesys.mod/filesys.c
--- eggdrop1.4~/src/mod/filesys.mod/filesys.c	Mon Oct 11 02:47:09 1999
+++ eggdrop1.4/src/mod/filesys.mod/filesys.c	Mon Oct 11 03:24:31 1999
@@ -632,6 +632,7 @@
       dcc[i].u.dns->dns_type = RES_HOSTBYIP;
       dcc[i].u.dns->dns_success = (Function) filesys_dcc_send_lookupsuccess;
       dcc[i].u.dns->dns_failure = (Function) filesys_dcc_send_lookupfailure;
+      dcc[i].u.dns->type = &DCC_FORK_SEND;
       
       dns_hostbyip(dcc[i].addr);
     }
@@ -660,59 +661,58 @@
   }
 
   changeover_dcc(i, &DCC_FORK_SEND, sizeof(struct xfer_info));
-      if (param[0] == '.')
-	param[0] = '_';
-      strncpy(dcc[i].u.xfer->filename, param, 120);
-      dcc[i].u.xfer->filename[120] = 0;
-      if (upload_to_cd) {
+  if (param[0] == '.')
+    param[0] = '_';
+  strncpy(dcc[i].u.xfer->filename, param, 120);
+  dcc[i].u.xfer->filename[120] = 0;
+  if (upload_to_cd) {
     char *p = get_user(&USERENTRY_DCCDIR, dcc[i].user);
 
-	if (p)
-	  sprintf(dcc[i].u.xfer->dir, "%s%s/", dccdir, p);
-	else
-	  sprintf(dcc[i].u.xfer->dir, "%s", dccdir);
-      } else
-	strcpy(dcc[i].u.xfer->dir, dccin);
+    if (p)
+      sprintf(dcc[i].u.xfer->dir, "%s%s/", dccdir, p);
+    else
+      sprintf(dcc[i].u.xfer->dir, "%s", dccdir);
+  } else
+    strcpy(dcc[i].u.xfer->dir, dccin);
   dcc[i].u.xfer->length = len;
-      sprintf(s1, "%s%s", dcc[i].u.xfer->dir, param);
-      context;      
-      f = fopen(s1, "r");
-      if (f) {
-	fclose(f);
+  sprintf(s1, "%s%s", dcc[i].u.xfer->dir, param);
+  context;      
+  f = fopen(s1, "r");
+  if (f) {
+    fclose(f);
     dprintf(DP_HELP, "NOTICE %s :That file already exists.\n", dcc[i].nick);
-	lostdcc(i);
-      } else {
-	/* check for dcc-sends in process with the same filename */
-	for (j = 0; j < dcc_total; j++)
-	  if (j != i) {
-	    if ((dcc[j].type->flags & (DCT_FILETRAN | DCT_FILESEND))
-		== (DCT_FILETRAN | DCT_FILESEND)) {
-	      if (!strcmp(param, dcc[j].u.xfer->filename)) {
+    lostdcc(i);
+  } else {
+    /* check for dcc-sends in process with the same filename */
+    for (j = 0; j < dcc_total; j++)
+      if (j != i) {
+        if ((dcc[j].type->flags & (DCT_FILETRAN | DCT_FILESEND))
+	    == (DCT_FILETRAN | DCT_FILESEND)) {
+	  if (!strcmp(param, dcc[j].u.xfer->filename)) {
 	    dprintf(DP_HELP, "NOTICE %s :That file is already being sent.\n",
 		    dcc[i].nick);
-		lostdcc(i);
-		return;
-	      }
-	    }
+	    lostdcc(i);
+	    return;
 	  }
-	/* put uploads in /tmp first */
-	sprintf(s1, "%s%s", tempdir, param);
-	dcc[i].u.xfer->f = fopen(s1, "w");
-	if (dcc[i].u.xfer->f == NULL) {
-	  dprintf(DP_HELP,
-		  "NOTICE %s :Can't create that file (temp dir error)\n",
+	}
+      }
+    /* put uploads in /tmp first */
+    sprintf(s1, "%s%s", tempdir, param);
+    dcc[i].u.xfer->f = fopen(s1, "w");
+    if (dcc[i].u.xfer->f == NULL) {
+      dprintf(DP_HELP,
+	      "NOTICE %s :Can't create that file (temp dir error)\n",
 	      dcc[i].nick);
-	  lostdcc(i);
-	} else {
+      lostdcc(i);
+    } else {
       char prt[100], ip[100];
 
-	  dcc[i].timeval = now;
-	  dcc[i].sock = getsock(SOCK_BINARY);
+      dcc[i].timeval = now;
+      dcc[i].sock = getsock(SOCK_BINARY);
       sprintf(prt, "%d", dcc[i].port);
-      sprintf(ip, "%lu", iptolong(my_ntohl(dcc[i].addr)));
-	  if (open_telnet_dcc(dcc[i].sock, ip, prt) < 0) {
-	    dcc[i].type->eof(i);
-      }
+      sprintf(ip, "%lu", iptolong(my_htonl(dcc[i].addr)));
+      if (open_telnet_dcc(dcc[i].sock, ip, prt) < 0)
+	dcc[i].type->eof(i);
     }
   }
 }
diff -urN eggdrop1.4~/src/mod/server.mod/server.c eggdrop1.4/src/mod/server.mod/server.c
--- eggdrop1.4~/src/mod/server.mod/server.c	Mon Oct 11 02:47:09 1999
+++ eggdrop1.4/src/mod/server.mod/server.c	Mon Oct 11 03:25:02 1999
@@ -760,6 +760,7 @@
     dcc[i].u.dns->dns_type = RES_HOSTBYIP;
     dcc[i].u.dns->dns_success = (Function) dcc_chat_success;
     dcc[i].u.dns->dns_failure = (Function) dcc_chat_failure;
+    dcc[i].u.dns->type = &DCC_CHAT_PASS;
 
     dns_hostbyip(dcc[i].addr);
   }
@@ -786,7 +787,7 @@
   }
 
   dcc[i].sock = getsock(0);
-  sprintf(ip, "%lu", iptolong(my_ntohl(dcc[i].addr)));
+  sprintf(ip, "%lu", iptolong(my_htonl(dcc[i].addr)));
   if (open_telnet_dcc(dcc[i].sock, ip, buf) < 0) {
       neterror(buf);
       if(!quiet_reject)
diff -urN eggdrop1.4~/src/mod/server.mod/servmsg.c eggdrop1.4/src/mod/server.mod/servmsg.c
--- eggdrop1.4~/src/mod/server.mod/servmsg.c	Mon Oct 11 02:47:09 1999
+++ eggdrop1.4/src/mod/server.mod/servmsg.c	Mon Oct 11 03:25:34 1999
@@ -1089,6 +1089,7 @@
     dcc[servidx].u.dns->dns_success = (Function) server_resolve_success;
     dcc[servidx].u.dns->dns_failure = (Function) server_resolve_failure;
     dcc[servidx].u.dns->dns_type = RES_IPBYHOST;
+    dcc[servidx].u.dns->type = &SERVER_SOCKET;
 
     /* I'm resolving... don't start another server connect request */
     resolvserv = 1;
diff -urN eggdrop1.4~/src/users.c eggdrop1.4/src/users.c
--- eggdrop1.4~/src/users.c	Mon Oct 11 02:47:09 1999
+++ eggdrop1.4/src/users.c	Mon Oct 11 03:56:04 1999
@@ -1045,6 +1045,9 @@
 	return;
       if (dcc[i].type == &DCC_FORK_BOT)
 	return;
+      if ((dcc[i].type == &DCC_DNSWAIT) &&
+	  (dcc[i].u.dns && (dcc[i].u.dns->type == &DCC_FORK_BOT)))
+	return;
     }
   }
   if (!start) {


More information about the Patches mailing list