Przeglądaj źródła

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

Bryan Drewery 5 miesięcy temu
rodzic
commit
25e95fbfe4
4 zmienionych plików z 22 dodań i 4 usunięć
  1. 13 2
      src/adns.cc
  2. 2 0
      src/adns.h
  3. 6 2
      src/dcc.cc
  4. 1 0
      src/dcc.h

+ 13 - 2
src/adns.cc

@@ -246,13 +246,24 @@ static void display_dcc_dnswait(int idx, char *buf, size_t bufsiz)
 	simple_snprintf(buf, bufsiz, "dns   waited %ds", (int) (now - dcc[idx].timeval));
 }
 
+void free_dns_info(struct dns_info *p)
+{
+	if (p->caller_data != NULL) {
+		free(p->caller_data);
+		p->caller_data = NULL;
+	}
+	if (p->ips != NULL) {
+		delete p->ips;
+		p->ips = NULL;
+	}
+}
+
 void kill_dcc_dnswait(int idx, void *x)
 {
 	struct dns_info *p = (struct dns_info *) x;
 
 	if (p) {
-		free(p->caller_data);
-		delete p->ips;
+		free_dns_info(p);
 		// free(p) is same thing here.
 		assert(p == dcc[idx].u.other);
 		free(dcc[idx].u.other);

+ 2 - 0
src/adns.h

@@ -59,6 +59,8 @@ void dns_cache_flush();
 bool valid_dns_id(int, int);
 int reverse_ip(const char *host, char *reverse);
 ssize_t dns_find_ip(const bd::Array<bd::String>& ips, int af_type, ssize_t = -1);
+void kill_dcc_dnswait(int idx, void *x);
+void free_dns_info(struct dns_info *p);
 
 extern int		dns_sock, dns_idx;
 extern const char	*dns_ip;

+ 6 - 2
src/dcc.cc

@@ -473,13 +473,18 @@ display_dcc_bot_new(int idx, char *buf, size_t bufsiz)
 static void
 free_dcc_bot_(int n, void *x)
 {
+  struct bot_info *bi = (struct bot_info *)x;
   if (dcc[n].type == &DCC_BOT) {
     unvia(n, findbot(dcc[n].nick));
     /* Stop sharing with this bot in case rembot->laston is shared out. */
     dcc[n].status &= ~STAT_SHARE;
     rembot(dcc[n].nick);
   }
-  free(x);
+  if (bi->di != NULL) {
+    free_dns_info(bi->di);
+    bi->di = NULL;
+  }
+  free(bi);
 }
 
 struct dcc_table DCC_BOT_NEW = {
@@ -605,7 +610,6 @@ dcc_bot_connwait_display(int idx, char *buf, size_t bufsiz)
   simple_snprintf(buf, bufsiz, "conn  bot");
 }
 
-void kill_dcc_dnswait(int idx, void *x);
 static void
 dcc_bot_connwait_free(int idx, void *x)
 {

+ 1 - 0
src/dcc.h

@@ -124,6 +124,7 @@ struct bot_info {
   char linker[NOTENAMELEN + 1]; /* who requested this link              */
   char sysname[121];
   char version[121];            /* channel/version info                 */
+  struct dns_info *di;
 };
 
 struct relay_info {