Pārlūkot izejas kodu

* Port [3172] to 1.2.13
* Fix many instances of hub nicks leaking to leaf bots. (fixes #326)



svn: 3173

Bryan Drewery 19 gadi atpakaļ
vecāks
revīzija
a724eedbd4
4 mainītis faili ar 23 papildinājumiem un 13 dzēšanām
  1. 1 0
      doc/UPDATES
  2. 18 9
      src/botcmd.c
  3. 1 1
      src/botmsg.c
  4. 3 3
      src/mod/share.mod/share.c

+ 1 - 0
doc/UPDATES

@@ -22,6 +22,7 @@ Lines prefixed with '-' were disabled before release and are not finished, or ar
 * -user on a bot now works on linked bots. (fixes #200)
 * Fix cmd_link being used to link to non-hubs. (fixes #329)
 * Fix cmd_mns_chan not sharing console changes. (fixes #328)
+* Fix many instances of hub nicks leaking to leaf bots. (fixes #326)
 
 1.2.12 - http://wraith.shatow.net/milestone/1.2.12
 * Clearing a variable via 'set var -' now resets that variable to default settings. (implements #111)

+ 18 - 9
src/botcmd.c

@@ -164,6 +164,7 @@ void bot_remotereply(int idx, char *par) {
 
 /* chat <from> <notice>  -- only from bots
  */
+/* this is only sent to hub bots */
 static void bot_chat(int idx, char *par)
 {
   char *from = NULL;
@@ -220,7 +221,15 @@ static void bot_actchan(int idx, char *par)
     else
       p++;
   }
-  chanout_but(-1, chan, "* %s %s\n", from, par);
+  if (!conf.bot->hub) { /* Need to strip out the hub nick */
+    char *q = NULL, newfrom[HANDLEN + 9 + 1]; /* HANDLEN@[botnet] */
+ 
+    strlcpy(newfrom, from, sizeof(newfrom));
+    q = strchr(newfrom, '@');
+    *q = 0;
+    chanout_but(-1, chan, "* %s@[botnet] %s\n", newfrom, par);
+  } else
+    chanout_but(-1, chan, "* %s %s\n", from, par);
   botnet_send_act(idx, from, NULL, chan, par);
 }
 
@@ -291,7 +300,7 @@ static void bot_bye(int idx, char *par)
   bots = bots_in_subtree(findbot(dcc[idx].nick));
   users = users_in_subtree(findbot(dcc[idx].nick));
   simple_sprintf(s, "%s %s. %s (lost %d bot%s and %d user%s)",
-		 BOT_DISCONNECTED, dcc[idx].nick, par[0] ?
+		 BOT_DISCONNECTED, conf.bot->hub ? dcc[idx].nick : "botnet", par[0] ?
 		 par : "No reason", bots, (bots != 1) ?
 		 "s" : "", users, (users != 1) ? "s" : "");
   putlog(LOG_BOTS, "*", "%s", s);
@@ -931,7 +940,7 @@ static void bot_nickchange(int idx, char *par)
     return;
   }
   chanout_but(-1, party[i].chan, "*** (%s) Nick change: %s -> %s\n",
-	      bot, newnick, party[i].nick);
+	      conf.bot->hub ? bot : "[botnet]", newnick, party[i].nick);
   botnet_send_nkch_part(idx, i, newnick);
 }
 
@@ -979,10 +988,10 @@ static void bot_join(int idx, char *par)
   botnet_send_join_party(idx, linking, i2);
   if (i != chan) {
     if (i >= 0) {
-      chanout_but(-1, i, "*** (%s) %s %s %s.\n", bot, nick, NET_LEFTTHE, i ? "channel" : "party line");
+      chanout_but(-1, i, "*** (%s) %s %s %s.\n", conf.bot->hub ? bot : "[botnet]", nick, NET_LEFTTHE, i ? "channel" : "party line");
     }
     if (!linking)
-    chanout_but(-1, chan, "*** (%s) %s %s %s.\n", bot, nick, NET_JOINEDTHE, chan ? "channel" : "party line");
+    chanout_but(-1, chan, "*** (%s) %s %s %s.\n", conf.bot->hub ? bot : "[botnet]", nick, NET_JOINEDTHE, chan ? "channel" : "party line");
   }
 }
 
@@ -1014,11 +1023,11 @@ static void bot_part(int idx, char *par)
       register int chan = party[partyidx].chan;
 
       if (par[0])
-	chanout_but(-1, chan, "*** (%s) %s %s %s (%s).\n", bot, nick,
+	chanout_but(-1, chan, "*** (%s) %s %s %s (%s).\n", conf.bot->hub ? bot : "[botnet]", nick,
 		    NET_LEFTTHE,
 		    chan ? "channel" : "party line", par);
       else
-	chanout_but(-1, chan, "*** (%s) %s %s %s.\n", bot, nick,
+	chanout_but(-1, chan, "*** (%s) %s %s %s.\n", conf.bot->hub ? bot : "[botnet]", nick,
 		    NET_LEFTTHE,
 		    chan ? "channel" : "party line");
     }
@@ -1069,11 +1078,11 @@ static void bot_away(int idx, char *par)
   if (!linking) {
     if (par[0])
       chanout_but(-1, party[partyidx].chan,
-		  "*** (%s) %s %s: %s.\n", bot,
+		  "*** (%s) %s %s: %s.\n", conf.bot->hub ? bot : "[botnet]",
 		  party[partyidx].nick, NET_AWAY, par);
     else
       chanout_but(-1, party[partyidx].chan,
-		  "*** (%s) %s %s.\n", bot,
+		  "*** (%s) %s %s.\n", conf.bot->hub ? bot : "[botnet]",
 		  party[partyidx].nick, NET_UNAWAY);
   }
   botnet_send_away(idx, bot, sock, par, linking);

+ 1 - 1
src/botmsg.c

@@ -160,7 +160,7 @@ void botnet_send_chat(int idx, char *botnick, char *data)
   if (tands > 0) {
     size_t len = simple_snprintf(OBUF, sizeof(OBUF), "ct %s %s\n", botnick, data);
 
-    send_tand_but(idx, OBUF, len);
+    send_hubs_but(idx, OBUF, len);
   }
 }
 

+ 3 - 3
src/mod/share.mod/share.c

@@ -1467,12 +1467,12 @@ share_report(int idx, int details)
             if (dcc[j].type && ((dcc[j].type->flags & (DCT_FILETRAN | DCT_FILESEND))
                  == (DCT_FILETRAN | DCT_FILESEND)) && !egg_strcasecmp(dcc[j].host, dcc[i].nick)) {
               dprintf(idx, "Downloading userlist from %s (%d%% done)\n",
-                      dcc[i].nick, (int) (100.0 * ((float) dcc[j].status) / ((float) dcc[j].u.xfer->length)));
+                      conf.bot->hub ? dcc[i].nick : "[botnet]", (int) (100.0 * ((float) dcc[j].status) / ((float) dcc[j].u.xfer->length)));
               ok = 1;
               break;
             }
           if (!ok)
-            dprintf(idx, "Download userlist from %s (negotiating " "botentries)\n", dcc[i].nick);
+            dprintf(idx, "Download userlist from %s (negotiating " "botentries)\n", conf.bot->hub ? dcc[i].nick : "[botnet]");
         } else if (dcc[i].status & STAT_SENDING) {
           for (j = 0; j < dcc_total; j++) {
             if (dcc[j].type && ((dcc[j].type->flags & (DCT_FILETRAN | DCT_FILESEND))
@@ -1487,7 +1487,7 @@ share_report(int idx, int details)
             }
           }
         } else if (dcc[i].status & STAT_AGGRESSIVE) {
-          dprintf(idx, "    Passively sharing with %s.\n", dcc[i].nick);
+          dprintf(idx, "    Passively sharing with %s.\n", conf.bot->hub ? dcc[i].nick : "[botnet]");
         } else if (dcc[i].status & STAT_SHARE) {
           dprintf(idx, "    Aggressively sharing with %s.\n", dcc[i].nick);
         }