Просмотр исходного кода

* Fixed ipv6 bots connecting over ipv4

svn: 1635
Bryan Drewery 21 лет назад
Родитель
Сommit
ec65bde143
4 измененных файлов с 35 добавлено и 6 удалено
  1. 1 0
      doc/UPDATES
  2. 12 4
      src/conf.c
  3. 1 1
      src/conf.h
  4. 21 1
      src/mod/server.mod/servmsg.c

+ 1 - 0
doc/UPDATES

@@ -23,6 +23,7 @@ This is a summary of ChangeLog basically.
 * Fixed display bug when bot is msgd with (op|pass|ident|invite) while the respective .config msg option is set to something else.
 * Fixed dns queries returning invalid (compressed) results for reverses.
 * Fixed some other relay segfaults and stack smashings (one from eggdrop).
+* Fixed ipv6 bots connecting over ipv4.
 
 1.2
 * No longer displaying SALTS on ./bin -v

+ 12 - 4
src/conf.c

@@ -48,17 +48,21 @@ tellconf(conf_t * inconf)
   sdprintf("bots:\n");
   for (bot = inconf->bots; bot && bot->nick; bot = bot->next) {
     i++;
-    sdprintf("%d: %s IP: %s HOST: %s IP6: %s HOST6: %s PID: %d\n", i,
+    sdprintf("%d: %s IP: %s HOST: %s IP6: %s HOST6: %s v6: %d PID: %d\n", i,
              bot->nick,
              bot->net.ip ? bot->net.ip : "",
-             bot->net.host ? bot->net.host : "", bot->net.ip6 ? bot->net.ip6 : "", bot->net.host6 ? bot->net.host6 : "", bot->pid);
+             bot->net.host ? bot->net.host : "", bot->net.ip6 ? bot->net.ip6 : "", bot->net.host6 ? bot->net.host6 : "", 
+             bot->net.v6,
+             bot->pid);
   }
   sdprintf("bot:\n");
   if (inconf->bot && ((bot = inconf->bot)))
-    sdprintf("%s IP: %s HOST: %s IP6: %s HOST6: %s PID: %d\n",
+    sdprintf("%s IP: %s HOST: %s IP6: %s HOST6: %s v6: %d PID: %d\n",
              bot->nick,
              bot->net.ip ? bot->net.ip : "",
-             bot->net.host ? bot->net.host : "", bot->net.ip6 ? bot->net.ip6 : "", bot->net.host6 ? bot->net.host6 : "", bot->pid);
+             bot->net.host ? bot->net.host : "", bot->net.ip6 ? bot->net.ip6 : "", bot->net.host6 ? bot->net.host6 : "", 
+             bot->net.v6,
+             bot->pid);
 }
 
 #ifdef LEAF
@@ -375,6 +379,9 @@ conf_addbot(char *nick, char *ip, char *host, char *ip6)
   if (ip6 && strcmp(ip6, ".") && is_dotted_ip(ip) == AF_INET6)
     bot->net.ip6 = strdup(ip6);
 
+  if (bot->net.ip6 || bot->net.host6)
+    bot->net.v6 = 1;
+
   bot->u = NULL;
   bot->pid = checkpid(nick, bot);
 }
@@ -752,6 +759,7 @@ conf_bot_dup(conf_bot * dest, conf_bot * src)
   dest->net.host = src->net.host ? strdup(src->net.host) : NULL;
   dest->net.ip6 = src->net.ip6 ? strdup(src->net.ip6) : NULL;
   dest->net.host6 = src->net.host6 ? strdup(src->net.host6) : NULL;
+  dest->net.v6 = src->net.v6;
   dest->u = src->u ? src->u : NULL;
   dest->pid = src->pid;
 #ifdef LEAF

+ 1 - 1
src/conf.h

@@ -12,7 +12,7 @@ typedef struct conf_net_b {
   char *host6;
   char *ip;
   char *ip6;
-  int family;
+  bool v6;
 } conf_net;  
 
 typedef struct conf_bot_b {

+ 21 - 1
src/mod/server.mod/servmsg.c

@@ -1413,8 +1413,28 @@ static void server_dns_callback(int id, void *client_data, const char *host, cha
   }
 
   addr_t addr;
+  char *ip = NULL;
 
-  get_addr(ips[0], &addr);
+
+  /* FIXME: this is a temporary hack to stop bots from connecting over ipv4 when they should be on ipv6
+   * eventually will handle this in open_telnet(ips);
+   */
+  if (conf.bot->net.v6) {
+    int i = 0;
+    for (i = 0; ips[i]; i++) {
+      if (is_dotted_ip(ips[i]) == AF_INET6) {
+        ip = ips[i];
+        break;
+      }
+    }
+    if (!ip) {
+      putlog(LOG_SERV, "*", "Failed connect to %s (Could not DNS as IPV6)", host);
+      return;
+    }
+  } else
+    ip = ips[0];
+
+  get_addr(ip, &addr);
  
   if (addr.family == AF_INET)
     dcc[idx].addr = htonl(addr.u.addr.s_addr);