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

* Added binary config botline output to cmd_newleaf. (#135)

svn: 2291
Bryan Drewery 21 лет назад
Родитель
Сommit
529c334ca0
3 измененных файлов с 19 добавлено и 1 удалено
  1. 1 0
      doc/UPDATES
  2. 4 0
      misc/help.txt
  3. 14 1
      src/cmds.c

+ 1 - 0
doc/UPDATES

@@ -41,6 +41,7 @@ Lines prefixed with '-' were disabled before release and are not finished, or ar
 * cmd_chpass now uses the whois_access() function. (#122)
 * cmd_chpass now uses the whois_access() function. (#122)
 * Updated CREDITS/cmd_about (#119)
 * Updated CREDITS/cmd_about (#119)
 * Fixed wrong notice on partyline when a user with no access attempts to telnet in.
 * Fixed wrong notice on partyline when a user with no access attempts to telnet in.
+* Added binary config botline output to cmd_newleaf. (#135)
 
 
 1.2.4
 1.2.4
 * Fixed cmd_botset not displaying botnick.
 * Fixed cmd_botset not displaying botnick.

+ 4 - 0
misc/help.txt

@@ -1326,6 +1326,10 @@ See also: w
    Adds a new leaf to the botnet with the specified handle and hostname.
    Adds a new leaf to the botnet with the specified handle and hostname.
    Any number of hosts can be specified in the cmd. You will need to
    Any number of hosts can be specified in the cmd. You will need to
    add a hostmask for the bot's ip for it to connect over DCC.
    add a hostmask for the bot's ip for it to connect over DCC.
+
+   The binary config botline will also be outputted, but should be
+   checked for correctness.
+
 ::newpass
 ::newpass
 ###  $bnewpass$b <password|rand>
 ###  $bnewpass$b <password|rand>
    Changes your password on the bot. This is similar to the '/msg <bot> pass'
    Changes your password on the bot. This is similar to the '/msg <bot> pass'

+ 14 - 1
src/cmds.c

@@ -3029,7 +3029,8 @@ static void cmd_newleaf(int idx, char *par)
   else {
   else {
     struct userrec *u1 = NULL;
     struct userrec *u1 = NULL;
     struct bot_addr *bi = NULL;
     struct bot_addr *bi = NULL;
-    char tmp[81] = "", *host = NULL;
+    char tmp[81] = "", *host = NULL, *p = NULL, *hostname = NULL, *ip = NULL, *ip6 = NULL, *bhostname = NULL;
+    int af_type = 0;
 
 
     userlist = adduser(userlist, handle, "none", "-", USER_OP, 1);
     userlist = adduser(userlist, handle, "none", "-", USER_OP, 1);
     u1 = get_user_by_handle(userlist, handle);
     u1 = get_user_by_handle(userlist, handle);
@@ -3052,7 +3053,19 @@ static void cmd_newleaf(int idx, char *par)
       host = newsplit(&par);
       host = newsplit(&par);
       addhost_by_handle(handle, host);
       addhost_by_handle(handle, host);
       dprintf(idx, "Added host '%s' to leaf: %s\n", host, handle);
       dprintf(idx, "Added host '%s' to leaf: %s\n", host, handle);
+      if ((p = strchr(host, '@'))) {
+        hostname = ++p;
+        af_type = is_dotted_ip(hostname);
+        if (af_type == AF_INET)
+          ip = strdup(hostname);
+        else if (af_type == AF_INET6)
+          ip6 = strdup(hostname);
+        else if (!strchr(hostname, '*') && !strchr(hostname, '?'))
+          bhostname = strdup(hostname);
+      }
     }
     }
+    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 : "");
     write_userfile(idx);
     write_userfile(idx);
   }
   }
 }
 }