Pārlūkot izejas kodu

fixup! Bot linking: Try each IP returned from DNS.

Bryan Drewery 5 mēneši atpakaļ
vecāks
revīzija
ccd20c84c0
3 mainītis faili ar 18 papildinājumiem un 3 dzēšanām
  1. 1 2
      src/botnet.cc
  2. 1 0
      src/botnet.h
  3. 16 1
      src/dcc.cc

+ 1 - 2
src/botnet.cc

@@ -1111,7 +1111,6 @@ int botlink(const char *linker, int idx, char *nick)
   return 0;
 }
 
-static void botlink_next_ip(int);
 static void botlink_dns_callback(int id, void *client_data, const char *host,
     const bd::Array<bd::String>& ips)
 {
@@ -1159,10 +1158,10 @@ botlink_next_ip(int i)
   assert(dcc[i].type == &DCC_BOT_CONNWAIT ||
       dcc[i].type == &DCC_FORK_BOT);
   struct dns_info *di = dcc[i].u.dns;
+  assert(di->ips->size() > 0);
   if (di->ip_from_dns_idx == -1 && di->no_more_ipv6 == true) {
     goto retries_exhausted;
   }
-  assert(di->ips->size() > 0);
 
 #ifdef USE_IPV6
   /* If IPv6 is available use it, otherwise fall back on IPv4 */

+ 1 - 0
src/botnet.h

@@ -26,6 +26,7 @@ void tell_bots(int, int, const char *);
 void tell_bottree(int);
 void dump_links(int);
 int botlink(const char *, int, char *);
+void botlink_next_ip(int);
 int botunlink(int, const char *, const char *);
 void addbot(char *, char *, char *, char, int, time_t, char *, char *, int);
 void updatebot(int, char *, char, int, time_t, char *, char *, int);

+ 16 - 1
src/dcc.cc

@@ -634,10 +634,25 @@ struct dcc_table DCC_BOT_CONNWAIT = {
   NULL
 };
 
+static void
+fork_bot_eof(int i)
+{
+  struct dns_info *di = dcc[i].u.dns;
+  /* unix socket won't have ips set, but otherwise wait until exhaustion. */
+  if (di->ips == NULL ||
+      (di->ip_from_dns_idx == -1 && di->no_more_ipv6 == true)) {
+    failed_link(i);
+    return;
+  }
+  if (di->ips != NULL) {
+    botlink_next_ip(i);
+  }
+}
+
 struct dcc_table DCC_FORK_BOT = {
   "FORK_BOT",
   0,
-  failed_link,
+  fork_bot_eof,
   cont_link,
   &connect_timeout,
   failed_link,