[cvslog] [CVS] Module eggdrop1.6: Change committed

cvs at eggheads.org cvs at eggheads.org
Thu May 7 16:01:52 CST 2009


Committer  : cvs
CVSROOT    : /usr/local/cvsroot
Module     : eggdrop1.6
Commit time: 2009-05-07 22:01:52 UTC

Modified files:
     eggdrop.conf doc/Changes1.6 doc/tcl-commands.doc
     doc/html/mod-channels.html doc/html/tcl-commands.html
     doc/settings/mod.channels src/chan.h src/misc.c src/modules.c
     src/patch.h src/proto.h src/mod/module.h
     src/mod/channels.mod/channels.c src/mod/channels.mod/cmdschan.c
     src/mod/channels.mod/tclchan.c
     src/mod/channels.mod/help/chaninfo.help src/mod/irc.mod/chan.c
     src/mod/irc.mod/irc.c src/mod/irc.mod/tclirc.c

Log message:

Added masktype selection to tcl_maskhost and ban-type configuration setting to set default banmask type for each channel.

Patch by: pseudo

---------------------- diff included ----------------------
Index: eggdrop1.6/doc/Changes1.6
diff -u eggdrop1.6/doc/Changes1.6:1.22 eggdrop1.6/doc/Changes1.6:1.23
--- eggdrop1.6/doc/Changes1.6:1.22	Wed May  6 19:18:48 2009
+++ eggdrop1.6/doc/Changes1.6	Thu May  7 16:01:41 2009
@@ -1,4 +1,4 @@
-$Id: Changes1.6,v 1.22 2009/05/07 01:18:48 tothwolf Exp $
+$Id: Changes1.6,v 1.23 2009/05/07 22:01:41 tothwolf Exp $
 
 Eggdrop Changes (since version 1.6.0)
 
@@ -6,6 +6,10 @@
 
 1.6.20 (CVS):
 
+  - Added masktype selection to tcl_maskhost and ban-type configuration
+    setting to set default banmask type for each channel.
+    Patch by: pseudo
+
   - Added AUTHORS file that documents the developers, major contributors,
     and groups who've developed and maintained Eggdrop.
   - Added THANKS file that contains a full list of Eggdrop contributors.
Index: eggdrop1.6/doc/html/mod-channels.html
diff -u eggdrop1.6/doc/html/mod-channels.html:1.26 eggdrop1.6/doc/html/mod-channels.html:1.27
--- eggdrop1.6/doc/html/mod-channels.html:1.26	Sat Feb 16 15:40:58 2008
+++ eggdrop1.6/doc/html/mod-channels.html	Thu May  7 16:01:41 2009
@@ -1,5 +1,5 @@
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<!-- $Id: mod-channels.html,v 1.26 2008/02/16 21:40:58 guppy Exp $ -->
+<!-- $Id: mod-channels.html,v 1.27 2009/05/07 22:01:41 tothwolf Exp $ -->
 
 <html>
   <head>
@@ -180,6 +180,83 @@
                 </table>
               </dd>
 
+
+              <dt><strong>ban-type 3</strong></dt>
+
+	      <dd>
+	      	<p> This setting defines what type of bans should eggdrop
+	      	place for +k users or when revenge-mode is 3.<br>
+	      	Available types are:</p>
+
+                <table border=0>
+                  <tr>
+                    <td>0</td>
+
+                    <td>*!user at host</td>
+                  </tr>
+
+                  <tr>
+                    <td>1</td>
+
+                    <td>*!*user at host</td>
+                  </tr>
+
+                  <tr>
+                    <td>2</td>
+
+                    <td>*!*@host</td>
+                  </tr>
+
+                  <tr>
+                    <td>3</td>
+
+                    <td>*!*user@*.host</td>
+                  </tr>
+
+                  <tr>
+                    <td>4</td>
+
+                    <td>*!*@*.host</td>
+                  </tr>
+
+                  <tr>
+                    <td>5</td>
+
+                    <td>nick!user at host</td>
+                  </tr>
+
+                  <tr>
+                    <td>6</td>
+
+                    <td>nick!*user at host</td>
+                  </tr>
+
+                  <tr>
+                    <td>7</td>
+
+                    <td>nick!*@host</td>
+                  </tr>
+
+                  <tr>
+                    <td>8</td>
+
+                    <td>nick!*user@*.host</td>
+                  </tr>
+
+                  <tr>
+                    <td>9</td>
+
+                    <td>nick!*@*.host</td>
+                  </tr>
+                </table>
+
+		<p>You can also specify types from 10 to 19 which correspond
+		to types 0 to 9, with the exception that numbers in hostnames
+		are replaced with the '?' wildcard, or 20 to 29, which works
+		like 10 to 19 but using '*' for numbers, instead of '?'.</p>
+
+	      </dd>
+
               <dt><strong>ban-time 120</strong></dt>
               
               <dd>
Index: eggdrop1.6/doc/html/tcl-commands.html
diff -u eggdrop1.6/doc/html/tcl-commands.html:1.56 eggdrop1.6/doc/html/tcl-commands.html:1.57
--- eggdrop1.6/doc/html/tcl-commands.html:1.56	Mon Jun 23 16:50:45 2008
+++ eggdrop1.6/doc/html/tcl-commands.html	Thu May  7 16:01:41 2009
@@ -1,5 +1,5 @@
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<!-- $Id: tcl-commands.html,v 1.56 2008/06/23 22:50:45 tothwolf Exp $ -->
+<!-- $Id: tcl-commands.html,v 1.57 2009/05/07 22:01:41 tothwolf Exp $ -->
 
 <html>
   <head>
@@ -2899,13 +2899,128 @@
           <p><strong>Module:</strong> core</p>
         </dd>
 
-        <dt><strong><a name="cmd_maskhost"></a>maskhost &lt;nick!user at host&gt;</strong></dt>
+        <dt><strong><a name="cmd_maskhost"></a>maskhost &lt;nick!user at host&gt;
+        [masktype]</strong></dt>
 
         <dd>
+          <p><strong>Description:</strong> masks the given irc hostmask, so
+          that it can match a wider set of nick/user/host combinations. The
+          masktypes supported are compatible with mIRC's standard types.</p>
+	  <p> Available types are: <br>
+          <blockquote>
+            <table>
+              <tr valign="top">
+                <td>
+                  <p><strong>0</strong></p>
+                </td>
+
+                <td>
+                  <p>*!user at host</p>
+
+                </td>
+              </tr>
+
+              <tr valign="top">
+                <td>
+                  <p><strong>1</strong></p>
+                </td>
+
+                <td>
+
+                  <p>*!*user at host</p>
+                </td>
+              </tr>
+
+              <tr valign="top">
+                <td>
+                  <p><strong>2</strong></p>
+                </td>
+
+                <td>
+                  <p>*!*@host</p>
+                </td>
+              </tr>
+
+              <tr valign="top">
+                <td>
+                  <p><strong>3</strong></p>
+
+                </td>
+
+                <td>
+                  <p>*!*user@*.host</p>
+                </td>
+              </tr>
+
+              <tr valign="top">
+                <td>
+                  <p><strong>4</strong></p>
+                </td>
+
+                <td>
+                  <p>*!*@*.host</p>
+                </td>
+              </tr>
+
+              <tr valign="top">
+                <td>
+                  <p><strong>5</strong></p>
+                </td>
+
+                <td>
+                  <p>nick!user at host</p>
+                </td>
+              </tr>
+
+              <tr valign="top">
+                <td>
+                  <p><strong>6</strong></p>
+                </td>
+
+                <td>
+                  <p>nick!*user at host</p>
+                </td>
+              </tr>
+
+              <tr valign="top">
+                <td>
+                  <p><strong>7</strong></p>
+                </td>
+
+                <td>
+                  <p>nick!*@host</p>
+                </td>
+              </tr>
+
+              <tr valign="top">
+                <td>
+                  <p><strong>8</strong></p>
+                </td>
+
+                <td>
+                  <p>nick!*user@*.host</p>
+                </td>
+              </tr>
+
+              <tr valign="top">
+                <td>
+                  <p><strong>9</strong></p>
+                </td>
+
+                <td>
+                  <p>nick!*@*.host</p>
+                </td>
+              </tr>
+            </table>
+          </blockquote>
+	  </p>
+	  <p> You can also specify types from 10 to 19 which correspond to types
+	  0 to 9, with the exception that numbers in hostnames are replaced with
+	  the '?' wildcard, or 20 to 29, which works like 10 to 19 but using '*'
+	  for numbers, instead of '?'.</p>
+
           <p><strong>Returns:</strong> masked hostmask for the string
-          given (&quot;n!u at 1.2.3.4&quot; -&gt; &quot;*!u at 1.2.3.*&quot;,
-          &quot;n!u at lame.com&quot; -&gt; &quot;*!u at lame.com&quot;,
-          &quot;n!u at a.b.edu&quot; -&gt; &quot;*!u@*.b.edu&quot;)</p>
+          given according to the masktype. </p>
 
           <p><strong>Module:</strong> core</p>
         </dd>
Index: eggdrop1.6/doc/settings/mod.channels
diff -u eggdrop1.6/doc/settings/mod.channels:1.21 eggdrop1.6/doc/settings/mod.channels:1.22
--- eggdrop1.6/doc/settings/mod.channels:1.21	Sat Feb 16 15:41:01 2008
+++ eggdrop1.6/doc/settings/mod.channels	Thu May  7 16:01:41 2009
@@ -1,4 +1,4 @@
-$Id: mod.channels,v 1.21 2008/02/16 21:41:01 guppy Exp $
+$Id: mod.channels,v 1.22 2009/05/07 22:01:41 tothwolf Exp $
 
 Channels Module
 Last revised: February 12, 2003
@@ -72,6 +72,24 @@
           2 Deop the user, give them the +d flag for the channel, and kick them.
           3 Deop the user, give them the +d flag for the channel, kick, and ban them.
 
+      ban-type 3
+	This setting defines what type of bans should eggdrop place for
+	+k users or when revenge-mode is 3. Available types are:
+	  0 *!user at host
+	  1 *!*user at host
+	  2 *!*@host
+	  3 *!*user@*.host
+	  4 *!*@*.host
+	  5 nick!user at host
+	  6 nick!*user at host
+	  7 nick!*@host
+	  8 nick!*user@*.host
+	  9 nick!*@*.host
+	You can also specify types from 10 to 19 which correspond to types
+	0 to 9, with the exception that numbers in hostnames are replaced with
+	the '?' wildcard, or 20 to 29, which works like 10 to 19 but using '*'
+	for numbers, instead of '?'.
+
       ban-time 120
         Set here how long temporary bans will last (in minutes). If you
         set this setting to 0, the bot will never remove them.
Index: eggdrop1.6/doc/tcl-commands.doc
diff -u eggdrop1.6/doc/tcl-commands.doc:1.122 eggdrop1.6/doc/tcl-commands.doc:1.123
--- eggdrop1.6/doc/tcl-commands.doc:1.122	Mon Mar 27 00:48:58 2006
+++ eggdrop1.6/doc/tcl-commands.doc	Thu May  7 16:01:41 2009
@@ -1,4 +1,4 @@
-$Id: tcl-commands.doc,v 1.122 2006/03/27 06:48:58 wcc Exp $
+$Id: tcl-commands.doc,v 1.123 2009/05/07 22:01:41 tothwolf Exp $
 
 Eggdrop Tcl Commands
 Last revised: August 02, 2004
@@ -1310,9 +1310,24 @@
       list of logfiles such as: {mco * eggdrop.log} {jp #lame lame.log}
     Module: core
 
-  maskhost <nick!user at host>
-    Returns: masked hostmask for the string given ("n!u at 1.2.3.4" -> "*!u at 1.2.3.*",
-      "n!u at lame.com" -> "*!u at lame.com", "n!u at a.b.edu" -> "*!u@*.b.edu")
+  maskhost <nick!user at host> [masktype]
+    Returns: masked hostmask for the string given according to the masktype
+      (the default is 3).
+      Available types are:
+	0: *!user at host
+	1: *!*user at host
+	2: *!*@host
+	3: *!*user@*.host
+	4: *!*@*.host
+	5: nick!user at host
+	6: nick!*user at host
+	7: nick!*@host
+	8: nick!*user@*.host
+	9: nick!*@*.host
+      You can also specify types from 10 to 19 which correspond to types
+      0 to 9, with the exception that numbers in hostnames are replaced with
+      the '?' wildcard, or 20 to 29, which works like 10 to 19 but using '*'
+      for numbers, instead of '?'.
     Module: core
 
   timer <minutes> <tcl-command>
Index: eggdrop1.6/eggdrop.conf
diff -u eggdrop1.6/eggdrop.conf:1.53 eggdrop1.6/eggdrop.conf:1.54
--- eggdrop1.6/eggdrop.conf:1.53	Wed Jan 21 21:12:45 2009
+++ eggdrop1.6/eggdrop.conf	Thu May  7 16:01:41 2009
@@ -1,7 +1,7 @@
 #! /path/to/executable/eggdrop
 # ^- This should contain a fully qualified path to your Eggdrop executable.
 #
-# $Id: eggdrop.conf,v 1.53 2009/01/22 03:12:45 tothwolf Exp $
+# $Id: eggdrop.conf,v 1.54 2009/05/07 22:01:41 tothwolf Exp $
 #
 # This is a sample Eggdrop configuration file which includes all possible
 # settings that can be used to configure your bot.
@@ -475,6 +475,7 @@
 set global-chanmode "nt"
 set global-stopnethack-mode 0
 set global-revenge-mode 0
+set global-ban-type 3
 set global-ban-time 120
 set global-exempt-time 60
 set global-invite-time 60
@@ -550,6 +551,25 @@
 #     2 Deop the user, give them the +d flag for the channel, and kick them.
 #     3 Deop the user, give them the +d flag for the channel, kick, and ban them.
 #
+# ban-type 3
+#   This setting defines what type of bans should eggdrop place for +k users or
+#   when revenge-mode is 3.
+#   Available types are:
+#     0 *!user at host
+#     1 *!*user at host
+#     2 *!*@host
+#     3 *!*user@*.host
+#     4 *!*@*.host
+#     5 nick!user at host
+#     6 nick!*user at host
+#     7 nick!*@host
+#     8 nick!*user@*.host
+#     9 nick!*@*.host
+#   You can also specify types from 10 to 19 which correspond to types 0 to 9,
+#   with the exception that numbers in hostnames are replaced with the '?'
+#   wildcard, or 20 to 29, which works like 10 to 19 but using '*' for numbers,
+#   instead of '?'.
+#
 # ban-time 120
 #   Set here how long temporary bans will last (in minutes). If you
 #   set this setting to 0, the bot will never remove them.
Index: eggdrop1.6/src/chan.h
diff -u eggdrop1.6/src/chan.h:1.46 eggdrop1.6/src/chan.h:1.47
--- eggdrop1.6/src/chan.h:1.46	Sat Nov  1 14:41:10 2008
+++ eggdrop1.6/src/chan.h	Thu May  7 16:01:41 2009
@@ -3,7 +3,7 @@
  *   stuff common to chan.c and mode.c
  *   users.h needs to be loaded too
  *
- * $Id: chan.h,v 1.46 2008/11/01 20:41:10 tothwolf Exp $
+ * $Id: chan.h,v 1.47 2009/05/07 22:01:41 tothwolf Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -181,6 +181,7 @@
   int idle_kick;
   int stopnethack_mode;
   int revenge_mode;
+  int ban_type;
   int ban_time;
   int invite_time;
   int exempt_time;
Index: eggdrop1.6/src/misc.c
diff -u eggdrop1.6/src/misc.c:1.79 eggdrop1.6/src/misc.c:1.80
--- eggdrop1.6/src/misc.c:1.79	Sat Feb 16 15:41:04 2008
+++ eggdrop1.6/src/misc.c	Thu May  7 16:01:41 2009
@@ -7,7 +7,7 @@
  *   help system
  *   motd display and %var substitution
  *
- * $Id: misc.c,v 1.79 2008/02/16 21:41:04 guppy Exp $
+ * $Id: misc.c,v 1.80 2009/05/07 22:01:41 tothwolf Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -289,106 +289,129 @@
   return r;
 }
 
-/* Convert "abc!user at a.b.host" into "*!user@*.b.host"
- * or "abc!user at 1.2.3.4" into "*!user at 1.2.3.*"
- * or "abc!user at 0:0:0:0:0:ffff:1.2.3.4" into "*!user at 0:0:0:0:0:ffff:1.2.3.*"
- * or "abc!user at 3ffe:604:2:b02e:6174:7265:6964:6573" into
- *    "*!user at 3ffe:604:2:b02e:6174:7265:6964:*"
- */
-void _maskhost(const char *s, char *nw, int host)
-{
-  register const char *p, *q, *e, *f;
-  int i;
-
-  *nw++ = '*';
-  *nw++ = '!';
-  p = (q = strchr(s, '!')) ? q + 1 : s;
-  /* Strip of any nick, if a username is found, use last 8 chars */
-  if ((q = strchr(p, '@'))) {
-    int fl = 0;
-
-    if ((q - p) > 9) {
-      nw[0] = '*';
-      p = q - 7;
-      i = 1;
-    } else
-      i = 0;
-    while (*p != '@') {
-      if (!fl && strchr("~+-^=", *p)) {
-        if (strict_host)
-          nw[i] = '?';
-        else if (!host)
-          nw[i] = '*';
-        else
-          i--;
-      } else
-        nw[i] = *p;
-      fl++;
-      p++;
-      i++;
-    }
-    nw[i++] = '@';
-    q++;
-  } else {
-    nw[0] = '*';
-    nw[1] = '@';
-    i = 2;
-    q = s;
-  }
-  nw += i;
-  e = NULL;
-  /* Now q points to the hostname, i point to where to put the mask */
-  if ((!(p = strchr(q, '.')) || !(e = strchr(p + 1, '.'))) && !strchr(q, ':'))
-    /* TLD or 2 part host */
-    strcpy(nw, q);
+/* maskhost(), modified to support custom mask types, as defined
+ * by mIRC.
+ * Does not require a proper hostmask in 's'. Accepts any strings,
+ * including empty ones and attempts to provide meaningful results.
+ *
+ * Strings containing no '@' character will be parsed as if the 
+ * whole string is a host.
+ * Strings containing no '!' character will be interpreted as if
+ * there is no nick.
+ * '!' as a nick/user separator must precede any '@' characters.
+ * Otherwise it will be considered a part of the host.
+ * Supported types are listed in tcl-commands.doc in the maskhost
+ * command section. Type 3 resembles the older maskhost() most closely.
+ * 
+ * Specific examples (with type=3):
+ * 
+ * "nick!user at is.the.lamest.bg"  -> *!*user@*.the.lamest.bg (ccTLD)
+ * "nick!user at is.the.lamest.com" -> *!*user@*.lamest.com (gTLD)
+ * "lamest.example"	         -> *!*@lamest.example
+ * "whatever at lamest.example"     -> *!*whatever at lamest.example
+ * "com.example at user!nick"       -> *!*com.example at user!nick
+ * "!"			         -> *!*@!
+ * "@"			         -> *!*@*
+ * ""				 -> *!*@*
+ * "abc!user at 2001:db8:618:5c0:263:15:dead:babe"
+ * -> *!*user at 2001:db8:618:5c0:263:15:dead:*
+ * "abc!user at 0:0:0:0:0:ffff:1.2.3.4"
+ * -> *!*user at 0:0:0:0:0:ffff:1.2.3.*
+ */
+void maskaddr(const char *s, char *nw, int type)
+{
+  int d = type % 5, num = 1;
+  register char *p, *u = 0, *h = 0, *ss;
+
+  /* Look for user and host.. */
+  ss = (char *)s;
+  u = strchr(s, '!');
+  if (u)
+    h = strchr(u, '@');
+  if (!h){
+    h = strchr(s, '@');
+    u = 0;
+  }
+
+  /* Print nick if required and available */
+  if (!u || (type % 10) < 5)
+    *nw++ = '*';
   else {
-    if (e == NULL) {            /* IPv6 address?                */
-      const char *mask_str;
-
-      f = strrchr(q, ':');
-      if (strchr(f, '.')) {     /* IPv4 wrapped in an IPv6?     */
-        f = strrchr(f, '.');
-        mask_str = ".*";
-      } else                      /* ... no, true IPv6.               */
-        mask_str = ":*";
-      strncpy(nw, q, f - q);
-      /* No need to nw[f-q] = 0 here, as the strcpy below will
-       * terminate the string for us.
-       */
-      nw += (f - q);
-      strcpy(nw, mask_str);
-    } else {
-      for (f = e; *f; f++);
-      f--;
-      if (*f >= '0' && *f <= '9') {     /* Numeric IP address */
-        while (*f != '.')
-          f--;
-        strncpy(nw, q, f - q);
-        /* No need to nw[f-q] = 0 here, as the strcpy below will
-         * terminate the string for us.
-         */
-        nw += (f - q);
-        strcpy(nw, ".*");
-      } else {                    /* Normal host >= 3 parts */
-        /*    a.b.c  -> *.b.c
-         *    a.b.c.d ->  *.b.c.d if tld is a country (2 chars)
-         *             OR   *.c.d if tld is com/edu/etc (3 chars)
-         *    a.b.c.d.e -> *.c.d.e   etc
-         */
-        const char *x = strchr(e + 1, '.');
+    strncpy(nw, s, u - s);
+    nw += u - s;
+  }
+  *nw++ = '!';
 
-        if (!x)
-          x = p;
-        else if (strchr(x + 1, '.'))
-          x = e;
-        else if (strlen(x) == 3)
-          x = p;
-        else
-          x = e;
-        sprintf(nw, "*%s", x);
+  /* Write user if required and available */
+  u = (u ? u + 1 : ss);
+  if (!h || (d == 2) || (d == 4))
+    *nw++ = '*';
+  else {
+    if (d) {
+      *nw++ = '*';
+      if (strchr("~+-^=", *u))
+        u++; /* trim leading crap */
+    }
+    strncpy(nw, u, h - u);
+    nw += h - u;
+  }
+  *nw++ = '@';
+
+  /* The rest is for the host */
+  h = (h ? h + 1 : ss);
+  for (p = h; *p; p++) /* hostname? */
+    if ((*p > '9' || *p < '0') && *p != '.') {
+      num = 0;
+      break;
+    }
+  p = strrchr(h, ':'); /* IPv6? */
+  /* Mask out after the last colon/dot */
+  if (p && d > 2) {
+    if ((u = strrchr(p, '.')))
+      p = u;
+    strncpy(nw, h, ++p - h);
+    nw += p - h;
+    strcpy(nw, "*");
+  } else if (!p && !num && type >= 10) {
+      /* we have a hostname and type
+       requires us to replace numbers */
+    num = 0;
+    for (p = h; *p; p++) {
+      if (*p < '0' || *p > '9') {
+        *nw++ = *p;
+        num = 0;
+      } else {
+        if (type < 20)
+          *nw++ = '?';
+        else if (!num) {
+          *nw++ = '*';
+          num = 1; /* place only one '*'
+                      per numeric sequence */
+        }
       }
     }
-  }
+    *nw = 0;
+  } else if (d > 2 && (p = strrchr(h, '.'))) {
+    if (num) { /* IPv4 */
+      strncpy(nw, h, p - h);
+      nw += p - h;
+      strcpy(nw, ".*");
+      return;
+    }
+    for (u = h, d = 0; (u = strchr(++u, '.')); d++);
+    if (d < 2) { /* types < 2 don't mask the host */
+      strcpy(nw, h);
+      return;
+    }
+    u = strchr(h, '.');
+    if (d > 3 || (d == 3 && strlen(p) > 3))
+      u = strchr(++u, '.'); /* ccTLD or not? Look above. */
+    sprintf(nw, "*%s", u);
+  } else if (!*h)
+      /* take care if the mask is empty or contains only '@' */
+      strcpy(nw, "*");
+    else
+      strcpy(nw, h);
 }
 
 /* Dump a potentially super-long string of text.
Index: eggdrop1.6/src/mod/channels.mod/channels.c
diff -u eggdrop1.6/src/mod/channels.mod/channels.c:1.97 eggdrop1.6/src/mod/channels.mod/channels.c:1.98
--- eggdrop1.6/src/mod/channels.mod/channels.c:1.97	Sat Nov  1 21:19:57 2008
+++ eggdrop1.6/src/mod/channels.mod/channels.c	Thu May  7 16:01:41 2009
@@ -2,7 +2,7 @@
  * channels.c -- part of channels.mod
  *   support for channels within the bot
  *
- * $Id: channels.c,v 1.97 2008/11/02 03:19:57 tothwolf Exp $
+ * $Id: channels.c,v 1.98 2009/05/07 22:01:41 tothwolf Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -39,7 +39,7 @@
 static int setstatic, use_info, chan_hack, quiet_save, global_revenge_mode,
            global_stopnethack_mode, global_idle_kick, global_aop_min,
            global_aop_max, global_ban_time, global_exempt_time,
-           global_invite_time;
+           global_invite_time, global_ban_type;
 
 /* Global channel settings (drummer/dw) */
 static char glob_chanset[512];
@@ -415,12 +415,12 @@
 "channel %s %s%schanmode %s idle-kick %d stopnethack-mode %d revenge-mode %d \
 need-op %s need-invite %s need-key %s need-unban %s need-limit %s \
 flood-chan %d:%d flood-ctcp %d:%d flood-join %d:%d flood-kick %d:%d \
-flood-deop %d:%d flood-nick %d:%d aop-delay %d:%d ban-time %d exempt-time %d \
-invite-time %d %cenforcebans %cdynamicbans %cuserbans %cautoop %cautohalfop \
-%cbitch %cgreet %cprotectops %cprotecthalfops %cprotectfriends %cdontkickops \
-%cstatuslog %crevenge %crevengebot %cautovoice %csecret %cshared %ccycle \
-%cseen %cinactive %cdynamicexempts %cuserexempts %cdynamicinvites \
-%cuserinvites %cnodesynch ",
+flood-deop %d:%d flood-nick %d:%d aop-delay %d:%d ban-type %d ban-time %d \
+exempt-time %d invite-time %d %cenforcebans %cdynamicbans %cuserbans %cautoop \
+%cautohalfop %cbitch %cgreet %cprotectops %cprotecthalfops %cprotectfriends \
+%cdontkickops %cstatuslog %crevenge %crevengebot %cautovoice %csecret \
+%cshared %ccycle %cseen %cinactive %cdynamicexempts %cuserexempts \
+%cdynamicinvites %cuserinvites %cnodesynch ",
             channel_static(chan) ? "set" : "add", name, channel_static(chan) ?
             " " : " { ", w2, chan->idle_kick, chan->stopnethack_mode,
             chan->revenge_mode, need1, need2, need3, need4, need5,
@@ -430,7 +430,7 @@
             chan->flood_kick_thr, chan->flood_kick_time,
             chan->flood_deop_thr, chan->flood_deop_time,
             chan->flood_nick_thr, chan->flood_nick_time,
-            chan->aop_min, chan->aop_max, chan->ban_time,
+            chan->aop_min, chan->aop_max, chan->ban_type, chan->ban_time,
             chan->exempt_time, chan->invite_time,
             PLSMNS(channel_enforcebans(chan)),
             PLSMNS(channel_dynamicbans(chan)),
@@ -724,6 +724,7 @@
       if (chan->revenge_mode)
         dprintf(idx, "      revenge-mode: %d\n", chan->revenge_mode);
 
+      dprintf(idx, "      ban-type: %d\n", chan->ban_type);
       dprintf(idx, "      Bans last %d minute%s.\n", chan->ban_time,
                (chan->ban_time == 1) ? "" : "s");
       dprintf(idx, "      Exemptions last %d minute%s.\n", chan->exempt_time,
@@ -828,6 +829,7 @@
   {"global-ban-time",         &global_ban_time,         0},
   {"global-exempt-time",      &global_exempt_time,      0},
   {"global-invite-time",      &global_invite_time,      0},
+  {"global-ban-type",         &global_ban_type,         0},
   /* keeping [ban|exempt|invite]-time for compatability <Wcc[07/20/02]> */
   {"ban-time",                &global_ban_time,         0},
   {"exempt-time",             &global_exempt_time,      0},
@@ -974,6 +976,7 @@
   udef = NULL;
   global_stopnethack_mode = 0;
   global_revenge_mode = 0;
+  global_ban_type = 3;
   global_ban_time = 120;
   global_exempt_time = 60;
   global_invite_time = 60;
Index: eggdrop1.6/src/mod/channels.mod/cmdschan.c
diff -u eggdrop1.6/src/mod/channels.mod/cmdschan.c:1.76 eggdrop1.6/src/mod/channels.mod/cmdschan.c:1.77
--- eggdrop1.6/src/mod/channels.mod/cmdschan.c:1.76	Thu Jul 10 04:06:54 2008
+++ eggdrop1.6/src/mod/channels.mod/cmdschan.c	Thu May  7 16:01:41 2009
@@ -2,7 +2,7 @@
  * cmdschan.c -- part of channels.mod
  *   commands from a user via dcc that cause server interaction
  *
- * $Id: cmdschan.c,v 1.76 2008/07/10 10:06:54 tothwolf Exp $
+ * $Id: cmdschan.c,v 1.77 2009/05/07 22:01:41 tothwolf Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -1282,6 +1282,7 @@
       dprintf(idx, "revenge-mode: %d\n", chan->revenge_mode);
     else
       dprintf(idx, "revenge-mode: 0\n");
+    dprintf(idx, "ban-type: %d\n", chan->ban_type);
     if (chan->ban_time)
       dprintf(idx, "ban-time: %d\n", chan->ban_time);
     else
Index: eggdrop1.6/src/mod/channels.mod/help/chaninfo.help
diff -u eggdrop1.6/src/mod/channels.mod/help/chaninfo.help:1.14 eggdrop1.6/src/mod/channels.mod/help/chaninfo.help:1.15
--- eggdrop1.6/src/mod/channels.mod/help/chaninfo.help:1.14	Sat Feb  1 22:20:44 2003
+++ eggdrop1.6/src/mod/channels.mod/help/chaninfo.help	Thu May  7 16:01:41 2009
@@ -43,6 +43,24 @@
                               channel, and kick them.
                             3 Deop the user, give them the +d flag for the
                               channel, kick, and ban them.
+        %bban-type%b          This setting defines what type of bans should
+                          eggdrop place for +k users or when revenge-mode is 3.
+                          Available types are:
+                            0 *!user at host
+                            1 *!*user at host
+                            2 *!*@host
+                            3 *!*user@*.host
+                            4 *!*@*.host
+                            5 nick!user at host
+                            6 nick!*user at host
+                            7 nick!*@host
+                            8 nick!*user@*.host
+                            9 nick!*@*.host
+                          You can also specify types from 10 to 19 which
+                          correspond to types 0 to 9, with the exception that
+                          numbers in hostnames are replaced with the '?'
+                          wildcard, or 20 to 29, which works like 10 to 19 but
+                          using '*' for numbers, instead of '?'.
         %bban-time%b          Set here how long temporary bans will last (in
                           minutes). If you set this setting to 0, the bot will
                           never remove them.
Index: eggdrop1.6/src/mod/channels.mod/tclchan.c
diff -u eggdrop1.6/src/mod/channels.mod/tclchan.c:1.99 eggdrop1.6/src/mod/channels.mod/tclchan.c:1.100
--- eggdrop1.6/src/mod/channels.mod/tclchan.c:1.99	Sat Nov  1 14:41:10 2008
+++ eggdrop1.6/src/mod/channels.mod/tclchan.c	Thu May  7 16:01:41 2009
@@ -1,7 +1,7 @@
 /*
  * tclchan.c -- part of channels.mod
  *
- * $Id: tclchan.c,v 1.99 2008/11/01 20:41:10 tothwolf Exp $
+ * $Id: tclchan.c,v 1.100 2009/05/07 22:01:41 tothwolf Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -786,6 +786,8 @@
   Tcl_AppendElement(irp, s);
   simple_sprintf(s, "%d:%d", chan->aop_min, chan->aop_max);
   Tcl_AppendElement(irp, s);
+  simple_sprintf(s, "%d", chan->ban_type);
+  Tcl_AppendElement(irp, s);
   simple_sprintf(s, "%d", chan->ban_time);
   Tcl_AppendElement(irp, s);
   simple_sprintf(s, "%d", chan->exempt_time);
@@ -959,6 +961,8 @@
     simple_sprintf(s, "%d", chan->stopnethack_mode);
   else if (!strcmp(setting, "revenge-mode"))
     simple_sprintf(s, "%d", chan->revenge_mode);
+  else if (!strcmp(setting, "ban-type"))
+    simple_sprintf(s, "%d", chan->ban_type);
   else if (!strcmp(setting, "ban-time"))
     simple_sprintf(s, "%d", chan->ban_time);
   else if (!strcmp(setting, "exempt-time"))
@@ -1199,6 +1203,14 @@
         return TCL_ERROR;
       }
       chan->revenge_mode = atoi(item[i]);
+    } else if (!strcmp(item[i], "ban-type")) {
+      i++;
+      if (i >= items) {
+        if (irp)
+          Tcl_AppendResult(irp, "channel ban-type needs argument", NULL);
+        return TCL_ERROR;
+      }
+      chan->ban_type = atoi(item[i]);
     } else if (!strcmp(item[i], "ban-time")) {
       i++;
       if (i >= items) {
@@ -1899,6 +1911,7 @@
     chan->flood_nick_time = gfld_nick_time;
     chan->stopnethack_mode = global_stopnethack_mode;
     chan->revenge_mode = global_revenge_mode;
+    chan->ban_type = global_ban_type;
     chan->ban_time = global_ban_time;
     chan->exempt_time = global_exempt_time;
     chan->invite_time = global_invite_time;
Index: eggdrop1.6/src/mod/irc.mod/chan.c
diff -u eggdrop1.6/src/mod/irc.mod/chan.c:1.128 eggdrop1.6/src/mod/irc.mod/chan.c:1.129
--- eggdrop1.6/src/mod/irc.mod/chan.c:1.128	Thu Jul 10 04:56:23 2008
+++ eggdrop1.6/src/mod/irc.mod/chan.c	Thu May  7 16:01:41 2009
@@ -6,7 +6,7 @@
  *   user kickban, kick, op, deop
  *   idle kicking
  *
- * $Id: chan.c,v 1.128 2008/07/10 10:56:23 tothwolf Exp $
+ * $Id: chan.c,v 1.129 2009/05/07 22:01:41 tothwolf Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -354,7 +354,7 @@
 {
   static char s1[512];
 
-  maskban(uhost, s1);
+  maskaddr(uhost, s1, chan->ban_type);
   do_mask(chan, chan->channel.ban, s1, 'b');
   return s1;
 }
Index: eggdrop1.6/src/mod/irc.mod/irc.c
diff -u eggdrop1.6/src/mod/irc.mod/irc.c:1.111 eggdrop1.6/src/mod/irc.mod/irc.c:1.112
--- eggdrop1.6/src/mod/irc.mod/irc.c:1.111	Mon Jun 30 18:20:04 2008
+++ eggdrop1.6/src/mod/irc.mod/irc.c	Thu May  7 16:01:42 2009
@@ -2,7 +2,7 @@
  * irc.c -- part of irc.mod
  *   support for channels within the bot
  *
- * $Id: irc.c,v 1.111 2008/07/01 00:20:04 tothwolf Exp $
+ * $Id: irc.c,v 1.112 2009/05/07 22:01:42 tothwolf Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -173,7 +173,7 @@
     /* ... or creating new user and setting that to deop */
     else {
       strcpy(s1, whobad);
-      maskban(s1, s);
+      maskaddr(s1, s, chan->ban_type);
       strcpy(s1, badnick);
       /* If that handle exists use "badX" (where X is an increasing number)
        * instead.
@@ -209,7 +209,7 @@
     char s[UHOSTLEN], s1[UHOSTLEN];
 
     splitnick(&whobad);
-    maskban(whobad, s1);
+    maskaddr(whobad, s1, chan->ban_type);
     simple_sprintf(s, "(%s) %s", ct, reason);
     u_addban(chan, s1, botnetnick, s, now + (60 * chan->ban_time), 0);
     if (!mevictim && HALFOP_CANDOMODE('b')) {
Index: eggdrop1.6/src/mod/irc.mod/tclirc.c
diff -u eggdrop1.6/src/mod/irc.mod/tclirc.c:1.53 eggdrop1.6/src/mod/irc.mod/tclirc.c:1.54
--- eggdrop1.6/src/mod/irc.mod/tclirc.c:1.53	Fri Jul 11 17:29:28 2008
+++ eggdrop1.6/src/mod/irc.mod/tclirc.c	Thu May  7 16:01:42 2009
@@ -1,7 +1,7 @@
 /*
  * tclirc.c -- part of irc.mod
  *
- * $Id: tclirc.c,v 1.53 2008/07/11 23:29:28 tothwolf Exp $
+ * $Id: tclirc.c,v 1.54 2009/05/07 22:01:42 tothwolf Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -497,11 +497,13 @@
 {
   char *new;
   
-  BADARGS(2, 2, " nick!user at host");
+  BADARGS(2, 3, " nick!user at host ?type?");
 
   new = nmalloc(strlen(argv[1]) + 5);
-
-  maskban(argv[1], new);
+  if (argc == 3)
+    maskaddr(argv[1], new, atoi(argv[2]));
+  else
+    maskban(argv[1], new);
   Tcl_AppendResult(irp, new, NULL);
   nfree(new);
   return TCL_OK;
Index: eggdrop1.6/src/mod/module.h
diff -u eggdrop1.6/src/mod/module.h:1.86 eggdrop1.6/src/mod/module.h:1.87
--- eggdrop1.6/src/mod/module.h:1.86	Thu Jul 10 04:06:54 2008
+++ eggdrop1.6/src/mod/module.h	Thu May  7 16:01:41 2009
@@ -1,7 +1,7 @@
 /*
  * module.h
  *
- * $Id: module.h,v 1.86 2008/07/10 10:06:54 tothwolf Exp $
+ * $Id: module.h,v 1.87 2009/05/07 22:01:41 tothwolf Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -288,7 +288,7 @@
 /* 152 - 155 */
 #define makepass ((void (*) (char *))global[152])
 #define wild_match ((int (*)(const char *, const char *))global[153])
-#define _maskhost ((void (*)(const char *, char *, int))global[154])
+#define maskaddr ((void (*)(const char *, char *, int))global[154])
 #define show_motd ((void(*)(int))global[155])
 /* 156 - 159 */
 #define tellhelp ((void(*)(int, char *, struct flag_record *, int))global[156])
@@ -480,8 +480,8 @@
 #define remove_crlf ((void (*)(char **))global[293])
 
 /* hostmasking */
-#define maskhost(a,b) _maskhost((a),(b),1)
-#define maskban(a,b) _maskhost((a),(b),0)
+#define maskhost(a,b) maskaddr((a),(b),3)
+#define maskban(a,b) maskaddr((a),(b),3)
 
 /* This is for blowfish module, couldnt be bothered making a whole new .h
  * file for it ;)
Index: eggdrop1.6/src/modules.c
diff -u eggdrop1.6/src/modules.c:1.99 eggdrop1.6/src/modules.c:1.100
--- eggdrop1.6/src/modules.c:1.99	Sat Feb 16 15:41:04 2008
+++ eggdrop1.6/src/modules.c	Thu May  7 16:01:41 2009
@@ -4,7 +4,7 @@
  *
  * by Darrin Smith (beldin at light.iinet.net.au)
  *
- * $Id: modules.c,v 1.99 2008/02/16 21:41:04 guppy Exp $
+ * $Id: modules.c,v 1.100 2009/05/07 22:01:41 tothwolf Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -388,7 +388,7 @@
   /* 152 - 155 */
   (Function) makepass,
   (Function) _wild_match,
-  (Function) _maskhost,
+  (Function) maskaddr,
   (Function) show_motd,
   /* 156 - 159 */
   (Function) tellhelp,
Index: eggdrop1.6/src/patch.h
diff -u eggdrop1.6/src/patch.h:1.1201 eggdrop1.6/src/patch.h:1.1202
--- eggdrop1.6/src/patch.h:1.1201	Wed May  6 13:17:51 2009
+++ eggdrop1.6/src/patch.h	Thu May  7 16:01:41 2009
@@ -10,7 +10,7 @@
  * statement, leave the rest of the file alone, this allows better
  * overlapping patches.
  *
- * $Id: patch.h,v 1.1201 2009/05/06 19:17:51 tothwolf Exp $
+ * $Id: patch.h,v 1.1202 2009/05/07 22:01:41 tothwolf Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -41,12 +41,12 @@
  *
  *
  */
-patch("1241636525");            /* current unixtime */
+patch("1241732502");            /* current unixtime */
 /*
  *
  *
  */
-patch("ctcpfix2");
+patch("masktype");
 /*
  *
  *
Index: eggdrop1.6/src/proto.h
diff -u eggdrop1.6/src/proto.h:1.73 eggdrop1.6/src/proto.h:1.74
--- eggdrop1.6/src/proto.h:1.73	Thu Jul 10 04:06:53 2008
+++ eggdrop1.6/src/proto.h	Thu May  7 16:01:41 2009
@@ -7,7 +7,7 @@
  * because they use structures in those
  * (saves including those .h files EVERY time) - Beldin
  *
- * $Id: proto.h,v 1.73 2008/07/10 10:06:53 tothwolf Exp $
+ * $Id: proto.h,v 1.74 2009/05/07 22:01:41 tothwolf Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -235,9 +235,9 @@
 int str_isdigit(const char *);
 void kill_bot(char *, char *);
 
-void _maskhost(const char *, char *, int);
-#define maskhost(a,b) _maskhost((a),(b),1)
-#define maskban(a,b)  _maskhost((a),(b),0)
+void maskaddr(const char *, char *, int);
+#define maskhost(a,b) maskaddr((a),(b),3)
+#define maskban(a,b)  maskaddr((a),(b),3)
 
 /* net.c */
 IP my_atoul(char *);
----------------------- End of diff -----------------------



More information about the Changes mailing list