Ver código fonte

Merge branch 'link-wrong-hub'

* link-wrong-hub:
  * Only check expected nick if provided
  * Fix bots linking to the wrong hub not giving a good reason why they failed in the log. (fixes #369)

Conflicts:

	doc/UPDATES
Bryan Drewery 17 anos atrás
pai
commit
fd14c83a00
2 arquivos alterados com 14 adições e 1 exclusões
  1. 1 0
      doc/UPDATES
  2. 13 1
      src/dcc.c

+ 1 - 0
doc/UPDATES

@@ -30,6 +30,7 @@
 * Added telnet 'tcl expect' script in scripts/telnet.exp. Can be used for easier hub management over telnet from shell.
 * Fix 'cmd_rehash' problems on hubs.
 * Fix 'HQ' user getting wiped in -t mode resulting in a crash. (fixes #298)
+* Fix bots linking to the wrong hub not giving a good reason why they failed in the log. (fixes #369)
 
 1.2.15.1
 * Fix leaf bots not updating behind other hubs (fixes #419)

+ 13 - 1
src/dcc.c

@@ -399,7 +399,7 @@ dcc_bot_new(int idx, char *buf, int x)
 
       sdprintf(STR("Choosing '%s' (%d/%d) for link"), enclink[i].name, enclink[i].type, i);
       link_hash(idx, rand);
-      dprintf(-dcc[idx].sock, STR("neg %s %d\n"), dcc[idx].shahash, enclink[i].type);
+      dprintf(-dcc[idx].sock, STR("neg %s %d %s\n"), dcc[idx].shahash, enclink[i].type, dcc[idx].nick);
       socklist[snum].enclink = i;
       link_link(idx, -1, i, TO);
     }
@@ -982,6 +982,18 @@ dcc_chat_pass(int idx, char *buf, int atr)
           lostdcc(idx);
           return;
         }
+
+        if (buf[0]) {
+          const char *expected_nick = newsplit(&buf);
+
+          if (egg_strcasecmp(expected_nick, conf.bot->nick)) {
+            putlog(LOG_WARN, "*", STR("%s failed encrypted link handshake (was expecting '%s' instead of me)"), dcc[idx].nick, expected_nick);
+            killsock(dcc[idx].sock);
+            lostdcc(idx);
+            return;
+          }
+        }
+
         socklist[snum].enclink = i;
 
         link_link(idx, -1, i, FROM);