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

* Port [3744] to 1.2.15
* Change default ip/host/ip6 to a * in the binary config
* Hide datadir if it is set to the default in the binary config
* Silently fix user mistake of giving hostname in ip field in binary config



svn: 3745

Bryan Drewery 18 лет назад
Родитель
Сommit
976f39d2df
4 измененных файлов с 39 добавлено и 24 удалено
  1. 3 0
      doc/UPDATES
  2. 2 2
      src/binary.c
  3. 1 1
      src/cmds.c
  4. 33 21
      src/conf.c

+ 3 - 0
doc/UPDATES

@@ -26,6 +26,9 @@
 * Fix case where binpath/datadir were not updated correctly when homedir changed. (fixes #169)
 * For security purposes the following commands are now hub-only: botnick, botserver, botversion, botmsg, netnick, netserver, netversion
 * Added cmd_nick to display leaf's current nick
+* Change default ip/host/ip6 to a * in the binary config
+* Hide datadir if it is set to the default in the binary config
+* Silently fix user mistake of giving hostname in ip field in binary config
 
 1.2.14 - http://wraith.botpack.net/milestone/1.2.14
 * Fix another bug in shell functions. (fixes #321)

+ 2 - 2
src/binary.c

@@ -548,9 +548,9 @@ void conf_to_bin(conf_t *in, bool move, int die)
                            settings.bots && settings.bots[0] ? settings.bots : "",
                            bot->disabled ? "/" : "",
                            bot->nick,
-                           bot->net.ip ? bot->net.ip : ".", 
+                           bot->net.ip ? bot->net.ip : "*", 
                            bot->net.host6 ? "+" : "", 
-                           bot->net.host ? bot->net.host : (bot->net.host6 ? bot->net.host6 : "."),
+                           bot->net.host ? bot->net.host : (bot->net.host6 ? bot->net.host6 : "*"),
                            bot->net.ip6 ? bot->net.ip6 : "");
     }
 

+ 1 - 1
src/cmds.c

@@ -3159,7 +3159,7 @@ static void cmd_newleaf(int idx, char *par)
       }
     }
     dprintf(idx, "Bot config line (prefix host with '+' if ipv6):\n");
-    dprintf(idx, "%s %s %s %s\n", handle, ip ? ip : ".", bhostname ? bhostname : ".", ip6 ? ip6 : "");
+    dprintf(idx, "%s %s %s %s\n", handle, ip ? ip : "*", bhostname ? bhostname : "*", ip6 ? ip6 : "");
     if (ip) free(ip);
     if (ip6) free(ip6);
     if (bhostname) free(bhostname);

+ 33 - 21
src/conf.c

@@ -470,7 +470,7 @@ conf_addbot(char *nick, char *ip, char *host, char *ip6)
   bot->pid_file = NULL;
   if (nick[0] == '/') {
     bot->disabled = 1;
-    nick++;
+    ++nick;
     sdprintf("%s is disabled.", nick);
   }
   bot->nick = strldup(nick, HANDLEN);
@@ -480,13 +480,13 @@ conf_addbot(char *nick, char *ip, char *host, char *ip6)
   bot->net.host6 = NULL;
 
   if (host && host[0] == '+') {
-    host++;
+    ++host;
     bot->net.host6 = strdup(host);
-  } else if (host && strcmp(host, ".")) {
+  } else if (host && !strchr(".*", host[0])) {
     bot->net.host = strdup(host);
   }
 
-  if (ip && strcmp(ip, ".")) {
+  if (ip && !strchr(".*", ip[0])) {
     int aftype = is_dotted_ip(ip);
 
     if (aftype == AF_INET)
@@ -495,9 +495,15 @@ conf_addbot(char *nick, char *ip, char *host, char *ip6)
     else if (aftype == AF_INET6)
       bot->net.ip6 = strdup(ip);
 #endif /* USE_IPV6 */
+    else if (aftype == 0) { /* The idiot used a hostname in place of ip */
+      if (bot->net.host)
+        free(bot->net.host);
+      bot->net.host = strdup(ip);
+    }
   }
+
 #ifdef USE_IPV6
-  if (ip6 && strcmp(ip6, ".") && is_dotted_ip(ip6) == AF_INET6)
+  if (ip6 && !strchr(".*", ip6[0]) && is_dotted_ip(ip6) == AF_INET6)
     bot->net.ip6 = strdup(ip6);
 
   if (bot->net.ip6 || bot->net.host6)
@@ -890,20 +896,23 @@ writeconf(char *filename, FILE * stream, int bits)
 
   comment("");
 
-  comment("# datadir should be set to a static directory that is writable");
-  if (homedir() && strstr(conf.datadir, homedir())) {
-    p = replace(conf.datadir, homedir(), "~");
-    my_write(f, "! datadir %s\n", p);
-  } else if (conf.homedir && strstr(conf.datadir, conf.homedir)) { /* Could be an older homedir */
-    p = replace(conf.datadir, conf.homedir, "~");
-    my_write(f, "! datadir %s\n", p);
-  } else
-    my_write(f, "! datadir %s\n", conf.datadir);
+  if (conf.datadir && strcmp(conf.datadir, "./...")) {
+    comment("# datadir should be set to a static directory that is writable");
 
-  comment("");
+    if (homedir() && strstr(conf.datadir, homedir())) {
+      p = replace(conf.datadir, homedir(), "~");
+      my_write(f, "! datadir %s\n", p);
+    } else if (conf.homedir && strstr(conf.datadir, conf.homedir)) { /* Could be an older homedir */
+      p = replace(conf.datadir, conf.homedir, "~");
+      my_write(f, "! datadir %s\n", p);
+    } else
+      my_write(f, "! datadir %s\n", conf.datadir);
+
+    comment("");
+  }
 
   if (conf.portmin || conf.portmax) {
-    comment("# portmin/max are for incoming connections (DCC) [0 for any]");
+    comment("# portmin/max are for incoming connections (DCC) [0 for any] (These only make sense for HUBS)");
     my_write(f, "! portmin %d\n", conf.portmin);
     my_write(f, "! portmax %d\n", conf.portmax);
 
@@ -918,7 +927,7 @@ writeconf(char *filename, FILE * stream, int bits)
     comment("");
   }
 
-  comment("# Automatically add the bot to crontab? (Disable if binname has funky chars that need escaping)");
+  comment("# Automatically add the bot to crontab?");
   my_write(f, "! autocron %d\n", conf.autocron);
 
   comment("");
@@ -940,17 +949,20 @@ writeconf(char *filename, FILE * stream, int bits)
   comment("# '|' means OR, [] means the enclosed is optional");
   comment("# A '+' in front of HOST means the HOST is ipv6");
   comment("# A '/' in front of BOT will disable that bot.");
-  comment("#[/]BOT IP|. [+]HOST|. [IPV6-IP]");
+  comment("#[/]BOT IP|* [+]HOST|* [IPV6-IP]");
   comment("#bot ip vhost");
-  comment("#bot2 ip vhost");
+  comment("#bot2 * vhost");
+  comment("#bot3 ip");
+  comment("#bot4 * +ipv6.vhost.com");
+  comment("#bot5 * * ip:v6:ip:goes:here::");
   comment("### Hubs should have their own binary ###");
 
 #endif /* CYGWIN_HACKS */
   for (bot = conf.bots; bot && bot->nick; bot = bot->next) {
     my_write(f, "%s%s %s %s%s %s\n", 
              bot->disabled ? "/" : "", bot->nick,
-             bot->net.ip ? bot->net.ip : ".", bot->net.host6 ? "+" : "",
-             bot->net.host ? bot->net.host : (bot->net.host6 ? bot->net.host6 : "."), bot->net.ip6 ? bot->net.ip6 : "");
+             bot->net.ip ? bot->net.ip : "*", bot->net.host6 ? "+" : "",
+             bot->net.host ? bot->net.host : (bot->net.host6 ? bot->net.host6 : "*"), bot->net.ip6 ? bot->net.ip6 : "");
   }
 
   fflush(f);