Переглянути джерело

* Made tandem->version a buffer[121]
* Removed a bunch of hub-only code for leaf bots in transfer.mod


svn: 937

Bryan Drewery 22 роки тому
батько
коміт
efdcaf4d73

+ 4 - 5
src/botnet.c

@@ -72,7 +72,8 @@ void addbot(char *who, char *from, char *next, char flag, int vlocalhub, time_t
   ptr2->share = flag;
   ptr2->share = flag;
   ptr2->localhub = vlocalhub;
   ptr2->localhub = vlocalhub;
   ptr2->buildts = vbuildts;
   ptr2->buildts = vbuildts;
-  ptr2->version = vversion ? strdup(vversion) : NULL;
+  if (vversion && vversion[0])
+    strncpyz(ptr2->version, vversion, 121);
   ptr2->next = *ptr;
   ptr2->next = *ptr;
   *ptr = ptr2;
   *ptr = ptr2;
   /* May be via itself */
   /* May be via itself */
@@ -111,8 +112,8 @@ void updatebot(int idx, char *who, char share, int vlocalhub, time_t vbuildts, c
       ptr->localhub = vlocalhub;
       ptr->localhub = vlocalhub;
     if (vbuildts)
     if (vbuildts)
       ptr->buildts = vbuildts;
       ptr->buildts = vbuildts;
-    if (vversion)
-      ptr->version = vversion;
+    if (vversion && vversion[0])
+      strncpyz(ptr->version, vversion, 121);
     botnet_send_update(idx, ptr);
     botnet_send_update(idx, ptr);
   }
   }
 }
 }
@@ -308,8 +309,6 @@ void rembot(char *who)
 
 
   ptr2 = *ptr;
   ptr2 = *ptr;
   *ptr = ptr2->next;
   *ptr = ptr2->next;
-  if (ptr2->version && ptr2->version != "")
-    free(ptr2->version);
   free(ptr2);
   free(ptr2);
   tands--;
   tands--;
 
 

+ 7 - 4
src/mod/share.mod/share.c

@@ -962,13 +962,14 @@ share_userfileq(int idx, char *par)
     if (!ok)
     if (!ok)
       dprintf(idx, "s un Already sharing.\n");
       dprintf(idx, "s un Already sharing.\n");
     else {
     else {
+      dcc[idx].u.bot->uff_flags |= (UFF_OVERRIDE | UFF_INVITE | UFF_EXEMPT );
       dprintf(idx, "s uy overbots invites exempts\n");
       dprintf(idx, "s uy overbots invites exempts\n");
       /* Set stat-getting to astatic void race condition (robey 23jun1996) */
       /* Set stat-getting to astatic void race condition (robey 23jun1996) */
       dcc[idx].status |= STAT_SHARE | STAT_GETTING | STAT_AGGRESSIVE;
       dcc[idx].status |= STAT_SHARE | STAT_GETTING | STAT_AGGRESSIVE;
 #ifdef HUB
 #ifdef HUB
-      putlog(LOG_BOTS, "@", "Downloading user file from %s", dcc[idx].nick);
+      putlog(LOG_BOTS, "*", "Downloading user file from %s", dcc[idx].nick);
 #else /* !HUB */
 #else /* !HUB */
-      putlog(LOG_BOTS, "@", "Downloading user file via uplink.");
+      putlog(LOG_BOTS, "*", "Downloading user file via uplink.");
 #endif /* HUB */
 #endif /* HUB */
     }
     }
   }
   }
@@ -1032,7 +1033,7 @@ share_version(int idx, char *par)
 {
 {
   /* Cleanup any share flags */
   /* Cleanup any share flags */
   dcc[idx].status &= ~(STAT_SHARE | STAT_GETTING | STAT_SENDING | STAT_OFFERED | STAT_AGGRESSIVE);
   dcc[idx].status &= ~(STAT_SHARE | STAT_GETTING | STAT_SENDING | STAT_OFFERED | STAT_AGGRESSIVE);
-  dcc[idx].u.bot->uff_flags = 0;
+  dcc[idx].u.bot->uff_flags |= (UFF_OVERRIDE | UFF_INVITE | UFF_EXEMPT );
   if (bot_aggressive_to(dcc[idx].user)) {
   if (bot_aggressive_to(dcc[idx].user)) {
     dprintf(idx, "s u?\n");
     dprintf(idx, "s u?\n");
     dcc[idx].status |= STAT_OFFERED;
     dcc[idx].status |= STAT_OFFERED;
@@ -1078,10 +1079,10 @@ share_end(int idx, char *par)
   dcc[idx].u.bot->uff_flags = 0;
   dcc[idx].u.bot->uff_flags = 0;
 }
 }
 
 
+/* FIXME: REMOVE THE FEATS CRAP AFTER EVERYONE UPGRADE TO 1.1.6 */
 static void
 static void
 share_feats(int idx, char *par)
 share_feats(int idx, char *par)
 {
 {
-   dcc[idx].u.bot->uff_flags |= (UFF_OVERRIDE | UFF_INVITE | UFF_EXEMPT );
 }
 }
 
 
 
 
@@ -1629,6 +1630,7 @@ share_report(int idx, int details)
             }
             }
           if (!ok)
           if (!ok)
             dprintf(idx, "Download userlist from %s (negotiating " "botentries)\n", dcc[i].nick);
             dprintf(idx, "Download userlist from %s (negotiating " "botentries)\n", dcc[i].nick);
+#ifdef HUB
         } else if (dcc[i].status & STAT_SENDING) {
         } else if (dcc[i].status & STAT_SENDING) {
           for (j = 0; j < dcc_total; j++) {
           for (j = 0; j < dcc_total; j++) {
             if (((dcc[j].type->flags & (DCT_FILETRAN | DCT_FILESEND))
             if (((dcc[j].type->flags & (DCT_FILETRAN | DCT_FILESEND))
@@ -1645,6 +1647,7 @@ share_report(int idx, int details)
           dprintf(idx, "    Passively sharing with %s.\n", dcc[i].nick);
           dprintf(idx, "    Passively sharing with %s.\n", dcc[i].nick);
         } else if (dcc[i].status & STAT_SHARE) {
         } else if (dcc[i].status & STAT_SHARE) {
           dprintf(idx, "    Aggressively sharing with %s.\n", dcc[i].nick);
           dprintf(idx, "    Aggressively sharing with %s.\n", dcc[i].nick);
+#endif /* HUB */
         }
         }
       }
       }
   }
   }

+ 22 - 6
src/mod/transfer.mod/transfer.c

@@ -31,7 +31,9 @@
 
 
 extern int		bupdating;
 extern int		bupdating;
 
 
+#ifdef HUB
 static int copy_to_tmp = 1;	/* Copy files to /tmp before transmitting? */
 static int copy_to_tmp = 1;	/* Copy files to /tmp before transmitting? */
+#endif /* HUB */
 static int wait_dcc_xfer = 40;	/* Timeout time on DCC xfers */
 static int wait_dcc_xfer = 40;	/* Timeout time on DCC xfers */
 static int dcc_limit = 4;	/* Maximum number of simultaneous file
 static int dcc_limit = 4;	/* Maximum number of simultaneous file
 				   downloads allowed */
 				   downloads allowed */
@@ -42,12 +44,14 @@ static int quiet_reject = 1;        /* Quietly reject dcc chat or sends from
 /*
 /*
  * Prototypes
  * Prototypes
  */
  */
+struct dcc_table DCC_SEND;
+#ifdef HUB
 static void wipe_tmp_filename(char *, int);
 static void wipe_tmp_filename(char *, int);
 static int at_limit(char *);
 static int at_limit(char *);
 static void dcc_get_pending(int, char *, int);
 static void dcc_get_pending(int, char *, int);
-struct dcc_table DCC_SEND;
 struct dcc_table DCC_GET;
 struct dcc_table DCC_GET;
 struct dcc_table DCC_GET_PENDING;
 struct dcc_table DCC_GET_PENDING;
+#endif /* HUB */
 
 
 static fileq_t *fileq = NULL;
 static fileq_t *fileq = NULL;
 
 
@@ -55,7 +59,7 @@ static fileq_t *fileq = NULL;
 /*
 /*
  *   Misc functions
  *   Misc functions
  */
  */
-
+#ifdef HUB
 static void wipe_tmp_filename(char *fn, int idx)
 static void wipe_tmp_filename(char *fn, int idx)
 {
 {
   int i, ok = 1;
   int i, ok = 1;
@@ -231,7 +235,6 @@ static void send_next_file(char *to)
   return;
   return;
 }
 }
 
 
-
 /*
 /*
  *    DCC routines
  *    DCC routines
  */
  */
@@ -267,6 +270,7 @@ static unsigned long pump_file_to_sock(FILE *file, long sock,
   }
   }
   return pending_data;
   return pending_data;
 }
 }
+#endif /* HUB */
 
 
 void eof_dcc_fork_send(int idx)
 void eof_dcc_fork_send(int idx)
 {
 {
@@ -460,6 +464,7 @@ static void eof_dcc_send(int idx)
   }
   }
 }
 }
 
 
+#ifdef HUB
 /* Determine byte order. Used for resend DCC startup packets.
 /* Determine byte order. Used for resend DCC startup packets.
  */
  */
 static inline u_8bit_t byte_order_test(void)
 static inline u_8bit_t byte_order_test(void)
@@ -605,6 +610,7 @@ void dcc_get(int idx, char *buf, int len)
 	  y = x;
 	  y = x;
       if (y != 0)
       if (y != 0)
 	dcc[y].status &= ~STAT_SENDING;
 	dcc[y].status &= ~STAT_SENDING;
+
       putlog(LOG_BOTS, "*", TRANSFER_COMPLETED_USERFILE, dcc[y].nick);
       putlog(LOG_BOTS, "*", TRANSFER_COMPLETED_USERFILE, dcc[y].nick);
       unlink(dcc[idx].u.xfer->filename);
       unlink(dcc[idx].u.xfer->filename);
       /* Any sharebot things that were queued: */
       /* Any sharebot things that were queued: */
@@ -723,6 +729,7 @@ void eof_dcc_get(int idx)
   if (!at_limit(xnick))
   if (!at_limit(xnick))
     send_next_file(xnick);
     send_next_file(xnick);
 }
 }
+#endif /* HUB */
 
 
 void dcc_send(int idx, char *buf, int len)
 void dcc_send(int idx, char *buf, int len)
 {
 {
@@ -761,6 +768,7 @@ void dcc_send(int idx, char *buf, int len)
   }
   }
 }
 }
 
 
+#ifdef HUB
 static void transfer_get_timeout(int i)
 static void transfer_get_timeout(int i)
 {
 {
   char xx[1024] = "";
   char xx[1024] = "";
@@ -838,6 +846,7 @@ static void transfer_get_timeout(int i)
   if (!at_limit(xx))
   if (!at_limit(xx))
     send_next_file(xx);
     send_next_file(xx);
 }
 }
+#endif /* HUB */
 
 
 void tout_dcc_send(int idx)
 void tout_dcc_send(int idx)
 {
 {
@@ -883,6 +892,7 @@ void tout_dcc_send(int idx)
   lostdcc(idx);
   lostdcc(idx);
 }
 }
 
 
+#ifdef HUB
 void display_dcc_get(int idx, char *buf)
 void display_dcc_get(int idx, char *buf)
 {
 {
   if (dcc[idx].status == dcc[idx].u.xfer->length)
   if (dcc[idx].status == dcc[idx].u.xfer->length)
@@ -898,6 +908,7 @@ void display_dcc_get_p(int idx, char *buf)
   sprintf(buf,TRANSFER_SEND_WAITED, now - dcc[idx].timeval,
   sprintf(buf,TRANSFER_SEND_WAITED, now - dcc[idx].timeval,
 	  dcc[idx].u.xfer->origname);
 	  dcc[idx].u.xfer->origname);
 }
 }
+#endif /* HUB */
 
 
 void display_dcc_send(int idx, char *buf)
 void display_dcc_send(int idx, char *buf)
 {
 {
@@ -928,6 +939,7 @@ void out_dcc_xfer(int idx, char *buf, void *x)
 {
 {
 }
 }
 
 
+#ifdef HUB
 static void outdone_dcc_xfer(int idx)
 static void outdone_dcc_xfer(int idx)
 {
 {
   if (dcc[idx].u.xfer->block_pending)
   if (dcc[idx].u.xfer->block_pending)
@@ -935,6 +947,7 @@ static void outdone_dcc_xfer(int idx)
 	    pump_file_to_sock(dcc[idx].u.xfer->f, dcc[idx].sock,
 	    pump_file_to_sock(dcc[idx].u.xfer->f, dcc[idx].sock,
 			      dcc[idx].u.xfer->block_pending);
 			      dcc[idx].u.xfer->block_pending);
 }
 }
+#endif /* HUB */
 
 
 struct dcc_table DCC_SEND =
 struct dcc_table DCC_SEND =
 {
 {
@@ -981,6 +994,7 @@ void dcc_fork_send(int idx, char *x, int y)
   tlen = 0;
   tlen = 0;
 }
 }
 
 
+#ifdef HUB
 struct dcc_table DCC_GET =
 struct dcc_table DCC_GET =
 {
 {
   "GET",
   "GET",
@@ -1175,8 +1189,9 @@ int raw_dcc_send(char *filename, char *nick, char *from, char *dir)
 {
 {
   return raw_dcc_resend_send(filename, nick, from, dir, 0);
   return raw_dcc_resend_send(filename, nick, from, dir, 0);
 }
 }
+#endif /* HUB */
 
 
-
+#ifdef LEAF
 /*
 /*
  *    CTCP functions
  *    CTCP functions
  */
  */
@@ -1231,7 +1246,7 @@ static int server_transfer_setup(char *mod)
   /* add_builtins("ctcp", transfer_ctcps); */
   /* add_builtins("ctcp", transfer_ctcps); */
   return 1;
   return 1;
 }
 }
-
+#endif /* LEAF */
 /*
 /*
  *   Module functions
  *   Module functions
  */
  */
@@ -1247,6 +1262,7 @@ void transfer_report(int idx, int details)
 void transfer_init()
 void transfer_init()
 {
 {
   fileq = NULL;
   fileq = NULL;
-
+#ifdef LEAF
   server_transfer_setup(NULL);
   server_transfer_setup(NULL);
+#endif /* LEAF */
 }
 }

+ 4 - 2
src/mod/transfer.mod/transfer.h

@@ -119,7 +119,9 @@ typedef struct zarrf {
 #define TRANSFER_STAT_MEMORY        "   Using %d bytes of memory\n"
 #define TRANSFER_STAT_MEMORY        "   Using %d bytes of memory\n"
 /* end of langauge addon */
 /* end of langauge addon */
 
 
-extern struct dcc_table 		DCC_SEND, DCC_GET, DCC_GET_PENDING, DCC_FORK_SEND;
-
+extern struct dcc_table 		DCC_SEND, DCC_FORK_SEND;
+#ifdef HUB
+extern struct dcc_table			DCC_GET, DCC_GET_PENDING;
+#endif /* HUB */
 
 
 #endif				/* _EGG_MOD_TRANSFER_TRANSFER_H */
 #endif				/* _EGG_MOD_TRANSFER_TRANSFER_H */

+ 2 - 0
src/mod/update.mod/update.c

@@ -411,6 +411,7 @@ void update_report(int idx, int details)
 	  if (!ok)
 	  if (!ok)
 	    dprintf(idx, "Download binary from %s (negotiating "
 	    dprintf(idx, "Download binary from %s (negotiating "
 		    "botentries)\n", dcc[i].nick);
 		    "botentries)\n", dcc[i].nick);
+#ifdef HUB
 	} else if (dcc[i].status & STAT_SENDINGU) {
 	} else if (dcc[i].status & STAT_SENDINGU) {
 	  for (j = 0; j < dcc_total; j++) {
 	  for (j = 0; j < dcc_total; j++) {
 	    if (((dcc[j].type->flags & (DCT_FILETRAN | DCT_FILESEND))
 	    if (((dcc[j].type->flags & (DCT_FILETRAN | DCT_FILESEND))
@@ -427,6 +428,7 @@ void update_report(int idx, int details)
 			dcc[i].nick);
 			dcc[i].nick);
 	    }
 	    }
 	  }
 	  }
+#endif /* HUB */
 	}
 	}
       }
       }
   }
   }

+ 1 - 1
src/tandem.h

@@ -13,7 +13,7 @@ typedef struct tand_t_struct {
   struct tand_t_struct *via;
   struct tand_t_struct *via;
   struct tand_t_struct *uplink;
   struct tand_t_struct *uplink;
   struct tand_t_struct *next;
   struct tand_t_struct *next;
-  char *version;
+  char version[121];
   time_t buildts;
   time_t buildts;
   int localhub;
   int localhub;
   char share;
   char share;