Selaa lähdekoodia

* Fixed a long outstanding bug in cache_my_ip()

svn: 700
Bryan Drewery 22 vuotta sitten
vanhempi
commit
6072e65ecc
2 muutettua tiedostoa jossa 5 lisäystä ja 4 poistoa
  1. 2 2
      src/chanprog.c
  2. 3 2
      src/net.c

+ 2 - 2
src/chanprog.c

@@ -565,8 +565,8 @@ void chanprog()
     userlist = adduser(userlist, conf.bot->nick, "none", "-", USER_BOT | USER_OP );
     conf.bot->u = get_user_by_handle(userlist, conf.bot->nick);
     bi = calloc(1, sizeof(struct bot_addr));
-
-    bi->address = strdup(conf.bot->ip);
+    if (conf.bot->ip)
+      bi->address = strdup(conf.bot->ip);
     /* bi->telnet_port = atoi(buf) ? atoi(buf) : 3333; */
     bi->telnet_port = bi->relay_port = 3333;
 #ifdef HUB

+ 3 - 2
src/net.c

@@ -318,9 +318,10 @@ void cache_my_ip()
     if (get_ip(conf.bot->host, &cached_myip4_so))
       error = 2;
   } else {
-    gethostname(s, 120);
-    if (get_ip(conf.bot->host, &cached_myip4_so)) {
+    gethostname(s, sizeof(s));
+    if (get_ip(s, &cached_myip4_so)) {
       /* error = 3; */
+      sdprintf("IPV4 addr_any is set.");
       cached_myip4_so.sin.sin_family = AF_INET;
       cached_myip4_so.sin.sin_addr.s_addr = INADDR_ANY;
     }