]> jfr.im git - irc/ircd-hybrid/ircd-hybrid-8-cvs.git/commitdiff
- Formatting changes to the protocol structures.
authora1kmm <a1kmm>
Fri, 19 Apr 2002 10:56:14 +0000 (10:56 +0000)
committera1kmm <a1kmm>
Fri, 19 Apr 2002 10:56:14 +0000 (10:56 +0000)
- Made G-lines be saved in a config file & go into the host hashtable,
  sharing code with K-lines.

13 files changed:
include/config.h
include/hostmask.h
include/s_conf.h
modules/m_gline.c
modules/m_kline.c
modules/m_testline.c
src/balloc.c
src/client.c
src/hostmask.c
src/ircd.c
src/p_irc.c
src/p_ts.c
src/s_conf.c

index 40d7d488cf4b48b7c1ca234852fa4a9c92a0253a..f00952d20e615b0111860e8412f7ca0e07493570 100644 (file)
@@ -14,7 +14,7 @@
  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  *  GNU General Public License for more details.
  *
- * $Id: config.h,v 1.3 2002/01/13 07:15:10 a1kmm Exp $
+ * $Id: config.h,v 1.4 2002/04/19 10:56:14 a1kmm Exp $
  */
 
 #ifndef INCLUDED_config_h
@@ -99,6 +99,7 @@
 #define SLPATH  BINPATH "]SERVLINK.EXE"          /* servlink executable */
 #define CPATH   ETCPATH "]IRCD.CONF"             /* config file */
 #define KPATH   ETCPATH "]KLINE.CONF"            /* kline file */
+#define GCPATH  ETCPATH "]GLINE.CONF"            /* gline file */
 #define DLPATH  ETCPATH "]DLINE.CONF"            /* dline file */
 #define GPATH   LOGPATH "]GLINE.LOG"             /* gline logfile */
 #define RPATH   ETCPATH "]IRCD.RSA"              /* RSA private key file */
 #define SLPATH  BINPATH "/servlink"             /* servlink executable */
 #define CPATH   ETCPATH "/ircd.conf"            /* ircd.conf file */
 #define KPATH   ETCPATH "/kline.conf"           /* kline file */
+#define GCPATH  ETCPATH "/gline.conf"           /* gline file */
 #define DLPATH  ETCPATH "/dline.conf"           /* dline file */
 #define GPATH   LOGPATH "/gline.log"            /* gline logfile */
 #define RPATH   ETCPATH "/ircd.rsa"             /* ircd rsa private keyfile */
index ddec2a0e42ed57f636d7df895a9d37a629397ff5..10ce22cf776aa3a6bbe3ed7dac80baab728f2a9f 100644 (file)
@@ -17,7 +17,7 @@
  *  You should have received a copy of the GNU General Public License
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- * $Id: hostmask.h,v 1.2 2002/01/06 07:18:12 a1kmm Exp $ 
+ * $Id: hostmask.h,v 1.3 2002/04/19 10:56:14 a1kmm Exp $ 
  */
 
 enum
@@ -53,6 +53,7 @@ struct ConfItem* find_dline(struct irc_inaddr *, int);
 
 void report_Klines(struct Client*, int temp, int mask);
 void report_auth(struct Client*);
+const char *format_netmask(struct irc_inaddr *in, int bits, int type);
 #ifdef IPV6
 int match_ipv6(struct irc_inaddr*, struct irc_inaddr*, int);
 #endif
index c08103dc22dd48df06d4357b06fb59697aa16aff..47c20086cef38595e25405196d54933af0407676 100644 (file)
@@ -19,7 +19,7 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
  *  USA
  *
- * $Id: s_conf.h,v 1.3 2002/01/06 07:18:13 a1kmm Exp $
+ * $Id: s_conf.h,v 1.4 2002/04/19 10:56:14 a1kmm Exp $
  */
 
 #ifndef INCLUDED_s_conf_h
@@ -134,8 +134,12 @@ struct ConfItem
 #define CONF_FLAGS_LAZY_LINK            0x00010000
 #define CONF_FLAGS_ENCRYPTED            0x00020000
 #define CONF_FLAGS_COMPRESSED           0x00040000
-#define CONF_FLAGS_TEMPORARY            0x00080000
-#define CONF_FLAGS_CRYPTLINK            0x00100000
+#define CONF_FLAGS_CRYPTLINK            0x00080000
+
+/* ban conf flags... */
+#define BAN_FLAGS_TEMPORARY             0x00000001
+#define BAN_FLAGS_GLINE                 0x00000002
+
 /* Macros for struct ConfItem */
 
 #define IsLimitIp(x)            ((x)->flags & CONF_FLAGS_LIMIT_IP)
@@ -174,6 +178,7 @@ struct config_file_entry
   char *configfile;
   char *klinefile;
   char *dlinefile;
+  char *glineconffile;
 
   char *glinefile;
 
@@ -381,17 +386,17 @@ extern int conf_fbgets(char *, int, FBFILE *);
 typedef enum {
   CONF_TYPE,
   KLINE_TYPE,
-  DLINE_TYPE
+  DLINE_TYPE,
+  GLINE_TYPE
 } KlineType;
 
-extern void WriteKlineOrDline( KlineType, struct Client *,
-                              char *user, char *host, const char *reason,
-                              const char *oper_reason,
-                              const char *current_date, time_t cur_time );
-extern  void    add_temp_kline(struct ConfItem *);
-extern  void    report_temp_klines(struct Client *);
-extern  void    show_temp_klines(struct Client *, dlink_list *);
-extern  void    cleanup_tklines(void *notused);
+extern void write_ban(KlineType, struct Client *, char *user, char *host,
+                      const char *reason, const char *oper_reason,
+                      const char *current_date, time_t cur_time);
+extern void add_temp_kline(struct ConfItem *);
+extern void report_temp_klines(struct Client *);
+extern void show_temp_klines(struct Client *, dlink_list *);
+extern void cleanup_tklines(void *notused);
 
 extern  const   char *get_conf_name(KlineType);
 extern  int     rehash (int);
index 324081147a4aa5bcaf9852981368e7d43bc98fde..798cb76f03c3f8a4d46cb3b8ce2fe5e5266f1191 100644 (file)
@@ -19,7 +19,7 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
  *  USA
  *
- *  $Id: m_gline.c,v 1.5 2002/02/26 04:55:46 a1kmm Exp $
+ *  $Id: m_gline.c,v 1.6 2002/04/19 10:56:16 a1kmm Exp $
  */
 
 #include <assert.h>
 #include "list.h"
 
 /* internal functions */
-static void set_local_gline(const char *oper_nick,
-                            const char *oper_user,
-                            const char *oper_host,
-                            const char *oper_server,
-                            const char *user,
+static void set_local_gline(struct Client *oper, const char *user,
                             const char *host, const char *reason);
 
 static void log_gline_request(const char *, const char *, const char *,
@@ -75,10 +71,7 @@ static void log_gline(struct Client *, struct gline_pending *,
 
 
 static void check_majority_gline(struct Client *source_p,
-                                 const char *oper_nick,
-                                 const char *oper_user,
-                                 const char *oper_host,
-                                 const char *oper_server,
+                                 struct Client *oper,
                                  const char *user, const char *host,
                                  const char *reason);
 
@@ -123,7 +116,7 @@ _moddeinit(void)
   mod_del_cmd(gline_msgtab);
 }
 
-char *_version = "$Revision: 1.5 $";
+char *_version = "$Revision: 1.6 $";
 #endif
 /*
  * mo_gline()
@@ -168,19 +161,22 @@ mo_gline(struct Client *client_p,
         user = parv[1];         /* here is user part */
         *(host++) = '\0';       /* and now here is host */
       }
+      else if (strchr(parv[1], '.') == NULL)
+      {
+        /* no ., no @, its a username... */
+        host = "*";
+        user = parv[1];
+      }
       else
       {
-        user = "*";             /* no @ found, assume its *@somehost */
+        /* No @ but we have a . so its a host. */
+        user = "*";
         host = parv[1];
       }
 
-      if (!*host)               /* duh. no host found, assume its '*' host */
-        host = "*";
-
-      strncpy_irc(tempuser, user, USERLEN + 1); /* allow for '*' */
-      tempuser[USERLEN + 1] = '\0';
-      strncpy_irc(temphost, host, HOSTLEN);
-      temphost[HOSTLEN] = '\0';
+      /* USERLEN + 1 to allow for '*' + full length username. */
+      strlcpy(tempuser, user, sizeof(tempuser));
+      strlcpy(temphost, host, sizeof(temphost));
       user = tempuser;
       host = temphost;
     }
@@ -208,10 +204,7 @@ mo_gline(struct Client *client_p,
 
     /* If at least 3 opers agree this user should be G lined then do it */
 
-    check_majority_gline(source_p,
-                         source_p->name,
-                         (const char *)source_p->username,
-                         source_p->host, me.name, user, host, reason);
+    check_majority_gline(source_p, source_p, user, host, reason);
 
     /* 4 param version for hyb-7 servers */
     sendto_server(NULL, source_p, NULL, CAP_GLN | CAP_UID, NOCAPS,
@@ -307,26 +300,14 @@ ms_gline(struct Client *client_p,
    * and its faked, as the oper isnt sending the gline..
    * check they're real --fl_ */
   /* we need acptr for LL introduction anyway -davidt */
-  if ((acptr = find_server(oper_server)))
-  {
-    if ((acptr = find_client(oper_nick)) == NULL)
-      return;
-  }
-  else
+  if ((acptr = find_server(oper_server)) == NULL ||
+      (acptr = find_client(oper_nick)) == NULL ||
+      strcasecmp(oper_server, acptr->servptr->name))
     return;
 
   if (invalid_gline(acptr, user, host, (char *)reason))
     return;
 
-  /* send in hyb-7 to compatable servers */
-  sendto_server(client_p, acptr, NULL, CAP_GLN, NOCAPS, LL_ICLIENT,
-                ":%s GLINE %s %s :%s", oper_nick, user, host, reason);
-  /* hyb-6 version to the rest */
-  sendto_server(client_p, NULL, NULL, NOCAPS, CAP_GLN, NOFLAGS,
-                ":%s GLINE %s %s %s %s %s %s :%s",
-                oper_server, oper_nick, oper_user, oper_host,
-                oper_server, user, host, reason);
-
   if (ConfigFileEntry.glines)
   {
     /* I dont like the idea of checking for x non-wildcard chars in a
@@ -335,10 +316,16 @@ ms_gline(struct Client *client_p,
     if (check_wild_gline(user, host))
     {
       sendto_realops_flags(FLAGS_ALL, L_ALL,
-                           "%s!%s@%s on %s is requesting a gline without %d non-wildcard characters for [%s@%s] [%s]",
+                           "%s!%s@%s on %s is requesting a gline without %u "
+                           "non-wildcard characters for [%s@%s] [%s]",
                            oper_nick, oper_user, oper_host, oper_server,
                            ConfigFileEntry.min_nonwildcard, user, host,
                            reason);
+      sendto_one(client_p, ":%s NOTICE %s :Your GLINE of %s@%s[%s] does not "
+                 "have %u non-wildcard characters. It will not take effect "
+                 "behind %s. Please repeat with a more specific GLINE if "
+                 "abuse continues.", me.name, oper_nick, user, host,
+                 reason, ConfigFileEntry.min_nonwildcard, me.name);
       return;
     }
 
@@ -352,11 +339,16 @@ ms_gline(struct Client *client_p,
                          oper_host, oper_server, user, host, reason);
 
     /* If at least 3 opers agree this user should be G lined then do it */
-    check_majority_gline(source_p,
-                         oper_nick,
-                         oper_user,
-                         oper_host, oper_server, user, host, reason);
+    check_majority_gline(source_p, acptr, user, host, reason);
   }
+  /* send in hyb-7 to compatable servers */
+  sendto_server(client_p, acptr, NULL, CAP_GLN, NOCAPS, LL_ICLIENT,
+                ":%s GLINE %s %s :%s", oper_nick, user, host, reason);
+  /* hyb-6 version to the rest */
+  sendto_server(client_p, NULL, NULL, NOCAPS, CAP_GLN, NOFLAGS,
+                ":%s GLINE %s %s %s %s %s %s :%s",
+                oper_server, oper_nick, oper_user, oper_host,
+                oper_server, user, host, reason);
 }
 
 /*
@@ -442,17 +434,13 @@ invalid_gline(struct Client *source_p, char *luser, char *lhost,
  */
 static void
 check_majority_gline(struct Client *source_p,
-                     const char *oper_nick,
-                     const char *oper_user,
-                     const char *oper_host,
-                     const char *oper_server,
+                     struct Client *oper,
                      const char *user, const char *host, const char *reason)
 {
-  if (majority_gline(source_p, oper_nick, oper_user, oper_host,
-                     oper_server, user, host, reason))
+  if (majority_gline(source_p, oper->name, oper->username, oper->host,
+                     oper->servptr->name, user, host, reason))
   {
-    set_local_gline(oper_nick, oper_user, oper_host, oper_server,
-                    user, host, reason);
+    set_local_gline(oper, user, host, reason);
     cleanup_glines();
   }
 }
@@ -471,10 +459,7 @@ check_majority_gline(struct Client *source_p,
  * side effects        -
  */
 static void
-set_local_gline(const char *oper_nick,
-                const char *oper_user,
-                const char *oper_host,
-                const char *oper_server,
+set_local_gline(struct Client *oper,
                 const char *user, const char *host, const char *reason)
 {
   char buffer[IRCD_BUFSIZE];
@@ -490,15 +475,17 @@ set_local_gline(const char *oper_nick,
   ircsprintf(buffer, "%s (%s)", reason, current_date);
 
   DupString(aconf->passwd, buffer);
-  DupString(aconf->name, (char *)user);
-  DupString(aconf->host, (char *)host);
+  DupString(aconf->user, user);
+  DupString(aconf->host, host);
   aconf->hold = CurrentTime + ConfigFileEntry.gline_time;
-  add_gline(aconf);
-
-  sendto_realops_flags(FLAGS_ALL, L_ALL,
-                       "%s!%s@%s on %s has triggered gline for [%s@%s] [%s]",
-                       oper_nick,
-                       oper_user, oper_host, oper_server, user, host, reason);
+  add_conf_by_address(aconf->host, CONF_KILL, aconf->user, aconf);
+  write_ban(GLINE_TYPE, oper, aconf->user, aconf->host, aconf->passwd, "",
+            current_date, CurrentTime);
+
+  sendto_realops_flags(FLAGS_ALL, L_ALL, "%s!%s@%s{%s} on %s has triggered "
+                       "gline for [%s@%s] [%s]", oper->name, oper->username,
+                       oper->host, get_oper_name(oper), oper->servptr->name,
+                       user, host, reason);
   check_klines();
 }
 
index 921a250670506e6ac21967f03cfbaf756aef1908..58154acfb39d249425d190cbfd6392707ea6a6dd 100644 (file)
@@ -19,7 +19,7 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
  *  USA
  *
- *   $Id: m_kline.c,v 1.5 2002/02/26 04:55:46 a1kmm Exp $
+ *   $Id: m_kline.c,v 1.6 2002/04/19 10:56:16 a1kmm Exp $
  */
 
 #include "tools.h"
@@ -84,7 +84,7 @@ _moddeinit(void)
   mod_del_cmd(kline_msgtab);
 }
 
-char *_version = "$Revision: 1.5 $";
+char *_version = "$Revision: 1.6 $";
 #endif
 
 /* Local function prototypes */
@@ -369,8 +369,8 @@ apply_kline(struct Client *source_p, struct ConfItem *aconf,
             const char *current_date, time_t cur_time)
 {
   add_conf_by_address(aconf->host, CONF_KILL, aconf->user, aconf);
-  WriteKlineOrDline(KLINE_TYPE, source_p, aconf->user, aconf->host,
-                    reason, oper_reason, current_date, cur_time);
+  write_ban(KLINE_TYPE, source_p, aconf->user, aconf->host,
+            reason, oper_reason, current_date, cur_time);
   /* Now, activate kline against current online clients */
   check_klines();
 }
@@ -582,7 +582,6 @@ mo_dline(struct Client *client_p, struct Client *source_p,
   struct Client *target_p;
 #endif
   struct irc_inaddr daddr;
-  char cidr_form_host[HOSTLEN + 1];
   struct ConfItem *aconf;
   int bits, t;
   char dlbuffer[1024];
@@ -597,22 +596,13 @@ mo_dline(struct Client *client_p, struct Client *source_p,
   }
 
   dlhost = parv[1];
-  strncpy_irc(cidr_form_host, dlhost, HOSTLEN);
-  cidr_form_host[HOSTLEN] = '\0';
 
   if ((t = parse_netmask(dlhost, NULL, &bits)) == HM_HOST)
   {
-#ifdef IPV6
-    sendto_one(source_p, ":%s NOTICE %s :Sorry, please supply an address.",
-               me.name, parv[0]);
-    return;
-#else
     if (!(target_p = find_chasing(source_p, parv[1], NULL)))
       return;
-
     if (!target_p->user)
       return;
-    t = HM_IPV4;
     if (IsServer(target_p))
     {
       sendto_one(source_p,
@@ -632,45 +622,25 @@ mo_dline(struct Client *client_p, struct Client *source_p,
     if (IsExemptKline(target_p))
     {
       sendto_one(source_p,
-                 ":%s NOTICE %s :%s is E-lined", me.name, parv[0],
+                 ":%s NOTICE %s :%s is exempt from K-lines", me.name, parv[0],
                  target_p->name);
       return;
     }
-
-    /*
-     * XXX - this is always a fixed length output, we can get away
-     * with strcpy here
-     *
-     * strncpy_irc(cidr_form_host, inetntoa((char *)&target_p->ip), 32);
-     * cidr_form_host[32] = '\0';
+#ifdef IPV6
+    t = (target_p->aftype == AF_INET6) ? HM_IPV6 : HM_IPV4;
+    /* There has been some discussion amongst the coders on how wide the
+     * IPv6 mask should be, but the problem we came up with is that
+     * although many individuals have a personal /64, this could also
+     * serve several ISPs, and could hold thousands of billions of 
+     * users. So I am following the v4 convention of being 8 bits less
+     * than full mask(i.e. /120)
      */
-    strcpy(cidr_form_host, inetntoa((char *)&target_p->localClient->ip));
-
-    if ((p = strchr(cidr_form_host, '.')) == NULL)
-      return;
-    /* 192. <- p */
-
-    p++;
-    if ((p = strchr(p, '.')) == NULL)
-      return;
-    /* 192.168. <- p */
-
-    p++;
-    if ((p = strchr(p, '.')) == NULL)
-      return;
-    /* 192.168.0. <- p */
-
-    p++;
-    *p++ = '0';
-    *p++ = '/';
-    *p++ = '2';
-    *p++ = '4';
-    *p++ = '\0';
-    dlhost = cidr_form_host;
-
-    bits = 0xFFFFFF00L;
-/* XXX: Fix me for IPV6 */
+    bits = (t == HM_IPV6) ? 120 : 24;
+#else
+    t = HM_IPV4;
+    bits = 24;
 #endif
+    dlhost = format_netmask(&target_p->localClient->ip, bits, t);
   }
 
 
@@ -700,7 +670,11 @@ mo_dline(struct Client *client_p, struct Client *source_p,
   }
   else
   {
+#ifdef IPV6
+    if (bits < (t == HM_IPV6) ? 64 : 24)
+#else
     if (bits < 24)
+#endif
     {
       sendto_one(source_p,
                  ":%s NOTICE %s :Dline bitmasks less than 24 are for admins only.",
@@ -749,8 +723,8 @@ mo_dline(struct Client *client_p, struct Client *source_p,
   /*
    * Write dline to configuration file
    */
-  WriteKlineOrDline(DLINE_TYPE, source_p, NULL, dlhost, reason,
-                    oper_reason, current_date, cur_time);
+  write_ban(DLINE_TYPE, source_p, NULL, dlhost, reason,
+            oper_reason, current_date, cur_time);
   check_klines();
 }                               /* m_dline() */
 
index 50d53b5db3ba2e07c91f29dada752b0e92d4b5f0..c626e8274a488dd60015753ccc8d6771ac2abe7a 100644 (file)
@@ -14,7 +14,7 @@
  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  *  GNU General Public License for more details.
  *
- *   $Id: m_testline.c,v 1.4 2002/01/13 07:15:19 a1kmm Exp $
+ *   $Id: m_testline.c,v 1.5 2002/04/19 10:56:17 a1kmm Exp $
  */
 
 #include "handlers.h"
@@ -56,7 +56,7 @@ _moddeinit(void)
   mod_del_cmd(testline_msgtab);
 }
 
-char *_version = "$Revision: 1.4 $";
+char *_version = "$Revision: 1.5 $";
 #endif
 /*
  * mo_testline
@@ -149,7 +149,7 @@ mo_testline(struct Client *client_p, struct Client *source_p,
         sendto_one(source_p,
                    ":%s NOTICE %s :%c-line name [%s] host [%s] pass [%s]",
                    me.name, parv[0],
-                   (aconf->flags & CONF_FLAGS_TEMPORARY) ? 'k' : 'K',
+                   (aconf->flags & BAN_FLAGS_TEMPORARY) ? 'k' : 'K',
                    user, host, pass);
       }
       else if (aconf->status & CONF_CLIENT)
index 3d51d1840d643a94040524690110ef7c7c124f51..52278e098ed003f1558ab7942637585db0b21d2a 100644 (file)
@@ -19,7 +19,7 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
  *  USA
  *
- *   $Id: balloc.c,v 1.5 2002/01/06 09:20:35 a1kmm Exp $
+ *   $Id: balloc.c,v 1.6 2002/04/19 10:56:19 a1kmm Exp $
  */
 
 /* A note on the algorithm:
@@ -103,6 +103,10 @@ static INLINE void* get_block(size_t size);
 #ifdef HAVE_MMAP /* We've got mmap() that is good */
 #include <sys/mman.h>
 
+#if defined(MMAP_ANONYMOUS) && !defined(MMAP_ANON)
+#define MMAP_ANON MMAP_ANONYMOUS
+#endif
+
 /*
  * static inline void free_block(void *ptr, size_t size)
  *
index cb29601c93414ae6cd2893ad623fc26e61ad2083..c813838d15805f647237e73f92d8d97a26d0386f 100644 (file)
@@ -19,7 +19,7 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
  *  USA
  *
- *  $Id: client.c,v 1.5 2002/02/26 04:55:54 a1kmm Exp $
+ *  $Id: client.c,v 1.6 2002/04/19 10:56:20 a1kmm Exp $
  */
 
 #include "tools.h"
@@ -461,67 +461,26 @@ check_klines(void)
 
     if (IsPerson(client_p))
     {
-      if (ConfigFileEntry.glines &&
-          (aconf = find_gkill(client_p, client_p->username)))
+      if ((aconf = find_kill(client_p)))
       {
-        if (IsExemptKline(client_p))
-        {
-          sendto_realops_flags(FLAGS_ALL, L_ALL,
-                               "GLINE over-ruled for %s, client is kline_exempt",
-                               get_client_name(client_p, HIDE_IP));
-          continue;
-        }
-
-        if (IsExemptGline(client_p))
-        {
-          sendto_realops_flags(FLAGS_ALL, L_ALL,
-                               "GLINE over-ruled for %s, client is gline_exempt",
-                               get_client_name(client_p, HIDE_IP));
-          continue;
-        }
-
-        sendto_realops_flags(FLAGS_ALL, L_ALL, "GLINE active for %s",
-                             get_client_name(client_p, HIDE_IP));
-
-        if (ConfigFileEntry.kline_with_connection_closed &&
-            ConfigFileEntry.kline_with_reason)
-        {
-          reason = "Connection closed";
-
-          sendto_one(client_p, form_str(ERR_YOUREBANNEDCREEP),
-                     me.name, client_p->name,
-                     aconf->passwd ? aconf->passwd : "G-lined");
-        }
+        char *type;
+        if (aconf->flags & BAN_FLAGS_GLINE)
+          type = "GLINE";
+        else if (aconf->flags & BAN_FLAGS_TEMPORARY)
+          type = "TKLINE";
         else
-        {
-          if (ConfigFileEntry.kline_with_connection_closed)
-            reason = "Connection closed";
-          else if (ConfigFileEntry.kline_with_reason && aconf->passwd)
-            reason = aconf->passwd;
-          else
-            reason = "G-lined";
-
-          sendto_one(client_p, form_str(ERR_YOUREBANNEDCREEP),
-                     me.name, client_p->name, reason);
-        }
-
-        (void)exit_client(client_p, client_p, &me, reason);
-        /* and go examine next fd/client_p */
-        continue;
-      }
-      else if ((aconf = find_kill(client_p)))
-      {
+          type = "KLINE";
         /* if there is a returned struct ConfItem.. then kill it */
         if (IsExemptKline(client_p))
         {
           sendto_realops_flags(FLAGS_ALL, L_ALL,
-                               "KLINE over-ruled for %s, client is kline_exempt",
-                               get_client_name(client_p, HIDE_IP));
+                               "%s over-ruled for %s, client is kline_exempt",
+                               type, get_client_name(client_p, HIDE_IP));
           continue;
         }
 
-        sendto_realops_flags(FLAGS_ALL, L_ALL, "KLINE active for %s",
-                             get_client_name(client_p, HIDE_IP));
+        sendto_realops_flags(FLAGS_ALL, L_ALL, "%s active for %s",
+                             type, get_client_name(client_p, HIDE_IP));
 
         if (ConfigFileEntry.kline_with_connection_closed &&
             ConfigFileEntry.kline_with_reason)
@@ -530,7 +489,7 @@ check_klines(void)
 
           sendto_one(client_p, form_str(ERR_YOUREBANNEDCREEP),
                      me.name, client_p->name,
-                     aconf->passwd ? aconf->passwd : "K-lined");
+                     aconf->passwd ? aconf->passwd : type);
         }
         else
         {
@@ -539,7 +498,7 @@ check_klines(void)
           else if (ConfigFileEntry.kline_with_reason && aconf->passwd)
             reason = aconf->passwd;
           else
-            reason = "K-lined";
+            reason = "Banned";
 
           sendto_one(client_p, form_str(ERR_YOUREBANNEDCREEP),
                      me.name, client_p->name, reason);
index ab7598e4c14cb20a085a3e94a597d64c0d8e1beb..4d4f53840ba87e4a36fa04db33bb834484159165 100644 (file)
@@ -17,7 +17,7 @@
  *  You should have received a copy of the GNU General Public License
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- * $Id: hostmask.c,v 1.3 2002/01/06 07:18:48 a1kmm Exp $ 
+ * $Id: hostmask.c,v 1.4 2002/04/19 10:56:20 a1kmm Exp $ 
  */
 
 #include <stdlib.h>
@@ -238,6 +238,122 @@ parse_netmask(const char *text, struct irc_inaddr *addr, int *b)
   return HM_HOST;
 }
 
+#define RecordHex(ptr,num)\
+{\
+  int p1 = (num & 0xF0) >> 4, p2 = num & 0xF;\
+  *ptr++ = p1 >= 0xA ? (p1 + 'A' - 0xA) : (p1 + '0')\
+  *ptr++ = p2 >= 0xA ? (p2 + 'A' - 0xA) : (p2 + '0')\
+}
+
+#define RecordDec(ptr,num)\
+{\
+  int d1 = num / 100, d2 = num / 10 % 10, d3 = num % 10;\
+  if (d1 > 0)\
+    *ptr++ = d1 + '0';\
+  if (d2 > 0)\
+    *ptr++ = d2 + '0';\
+  if (d3 > 0)\
+    *ptr++ = d3 + '0';\
+}
+
+/* Lets us display an address as CIDR. */
+/* Input: addr    - an IPV4/6 address.
+ *        bits    - number of bits in the mask.
+ *        type    - HM_IPV4 or HM_IPV6
+ * Output: A pointer to a static buffer containing the formated string.
+ * Side-effects: Clobbers the pointer returned by previous calls to
+ *               this function.
+ */
+const char*
+format_netmask(struct irc_inaddr *addr, int bits, int type)
+{
+  static char buffer[3 * 7 + 2 + 1 + 3 + 1];
+  char *p = buffer;
+#ifdef IPV6
+  if (type == HM_IPV6)
+  {
+    int bl = bits, i = 0;
+    if (bits > 128 || bits < 0)
+    {
+      bits = 128;
+      bl = 128;
+    }
+    while (bl >= 16)
+    {
+      RecordHex(p, addr->sins.sin6.s6_addr16[i++]);
+      if (i < 8)
+        *p++ = ':';
+    }
+    if (i < 8 && bl != 0)
+    {
+      /* Mask off the remaining bits... */
+      unsigned long n = addr->sins.sin6.s6_addr16[i++];
+      n &= ~ (1 << bl) - 1;
+      RecordHex(p, n);
+      if (i < 8)
+        *p++ = ':';
+    }
+    /* Fill in the remainder with zeros... */
+    while (i < 8)
+    {
+      *p++ = '0';
+      *p++ = '0';
+      if (++i < 8)
+        *p++ = ':';
+    }
+    if (bits < 128)
+    {
+      *p++ = '/';
+      RecordDec(p, bits);
+    }
+    *p++ = 0;
+    return buffer;
+  }
+  else
+  {
+#endif
+    int bl = bits, i = 0;
+    if (bits > 32 || bits < 0)
+    {
+      bits = 32;
+      bl = 32;
+    }
+    while (bl >= 8)
+    {
+      RecordDec(p, (addr->sins.sin.s_addr & (3<<i)) << 8 >> i++);
+      if (i < 4)
+        *p++ = '.';
+    }
+    if (i < 8 && bl != 0)
+    {
+      /* Mask off the remaining bits... */
+      unsigned long n = (addr->sins.sin.s_addr & (3<<i)) << 8 >> i++;
+      n &= ~ (1 << bl) - 1;
+      RecordDec(p, n);
+      if (i < 4)
+        *p++ = '.';
+    }
+    /* Fill in the remainder with zeros... */
+    while (i < 4)
+    {
+      *p++ = '0';
+      if (++i < 8)
+        *p++ = '.';
+    }
+    if (bits < 128)
+    {
+      *p++ = '/';
+      RecordDec(p, bits);
+    }
+    *p++ = 0;
+    return buffer;
+#ifdef IPV6
+  }
+  /* Not reached. */
+  return NULL;
+#endif
+}
+
 /* The address matching stuff... */
 /* int match_ipv6(struct irc_inaddr *, struct irc_inaddr *, int)
  * Input: An IP address, an IP mask, the number of bits in the mask.
@@ -628,14 +744,14 @@ clear_out_address_conf(void)
       arecn = arec->next;
       /* We keep the temporary K-lines and destroy the
        * permanent ones, just to be confusing :) -A1kmm */
-      if (arec->aconf->flags & CONF_FLAGS_TEMPORARY)
+      if (arec->aconf->flags & BAN_FLAGS_TEMPORARY)
       {
         *store_next = arec;
         store_next = &arec->next;
       }
       else
       {
-        arec->aconf->flags |= CONF_ILLEGAL;
+        arec->aconf->status |= CONF_ILLEGAL;
         if (!arec->aconf->clients)
           free_conf(arec->aconf);
         MyFree(arec);
@@ -757,9 +873,9 @@ report_Klines(struct Client *client_p, int tkline, int mask)
     for (arec = atable[i]; arec; arec = arec->next)
       if (arec->type == CONF_KILL)
       {
-        if ((tkline && !((aconf = arec->aconf)->flags & CONF_FLAGS_TEMPORARY))
+        if ((tkline && !((aconf = arec->aconf)->flags & BAN_FLAGS_TEMPORARY))
             || (!tkline
-                && ((aconf = arec->aconf)->flags & CONF_FLAGS_TEMPORARY)))
+                && ((aconf = arec->aconf)->flags & BAN_FLAGS_TEMPORARY)))
           continue;
         get_printable_conf(aconf, &name, &host, &pass, &user, &port,
                            &classname);
index 8d33f424cce3f207724dc0db252402f3763e51e9..3d51da786d1a27dbc8cccfbd43c88d4bb9e1117d 100644 (file)
@@ -14,7 +14,7 @@
  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  *  GNU General Public License for more details.
  *
- * $Id: ircd.c,v 1.6 2002/02/26 04:55:55 a1kmm Exp $
+ * $Id: ircd.c,v 1.7 2002/04/19 10:56:20 a1kmm Exp $
  */
 
 #include <sys/types.h>
@@ -612,6 +612,7 @@ ircd_main(int argc, char *argv[])
     ConfigFileEntry.configfile = CPATH; /* Server configuration file */
     ConfigFileEntry.klinefile = KPATH;  /* Server kline file */
     ConfigFileEntry.dlinefile = DLPATH; /* dline file */
+    ConfigFileEntry.glineconffile = GCPATH; /* gline conf file */
     ConfigFileEntry.glinefile = GPATH;  /* gline log file */
 
     myargv = argv;
index 10db0cadbd7d805bc3d0028c51f9b41e569ef52b..fe2ab03cd4e0e0d8115bdb8c5038a1d86df0a2a2 100644 (file)
@@ -19,7 +19,7 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
  *  USA
  *
- *   $Id: p_irc.c,v 1.2 2002/02/26 04:55:55 a1kmm Exp $
+ *   $Id: p_irc.c,v 1.3 2002/04/19 10:56:20 a1kmm Exp $
  */
 
 #include "client.h"
@@ -126,36 +126,26 @@ usr_burst_channel(struct Client *client_p, struct Channel *chptr,
 /* Some special protocols are declared here... */
 struct Protocol p_unregistered =
 {
-  NULL,                /* Parent. */
-  &irc_unregistered,   /* Outgoing: Unregistered. */
-  NULL,                /* Outgoing: Registered. */
-  &irc_not_oper,       /* Outgoing: Not an IRC operator. */
-  &irc_error,          /* Incoming/Outgoing: error. */
-  NULL,                /* Outgoing: No such command. */
-  &irc_toofew_params,  /* Outgoing: Too few parameters. */
-  NULL,                /* Outgoing: Burst channel. */
+  m_unregistered: &irc_unregistered,
+  m_not_oper: &irc_not_oper,
+  m_error: &irc_error,
+  toofew_params: &irc_toofew_params
 };
 
 struct Protocol p_user =
 {
-  NULL,                /* Parent. */
-  NULL,                /* Outgoing: Unregistered. */
-  &irc_registered,     /* Outgoing: Registered. */
-  &irc_not_oper,       /* Outgoing: Not an IRC operator. */
-  NULL,                /* Incoming/Outgoing: error. */
-  &irc_illegal_command,/* Outgoing: No such command. */
-  &irc_toofew_params,  /* Outgoing: Too few parameters. */
-  &usr_burst_channel,  /* Outgoing: Burst channel. */
+  m_registered: &irc_registered,
+  m_not_oper: &irc_not_oper,
+  illegal_command: &irc_illegal_command,
+  toofew_params: &irc_toofew_params,
+  burst_channel: &usr_burst_channel
 };
 
 struct Protocol p_operuser =
 {
-  &p_user,             /* Parent. */
-  NULL,                /* Outgoing: Unregistered. */
-  &irc_registered,     /* Outgoing: Registered. */
-  NULL,                /* Outgoing: Not an IRC operator. */
-  NULL,                /* Incoming/Outgoing: error. */
-  &irc_illegal_command,/* Outgoing: No such command. */
-  &irc_toofew_params,  /* Outgoing: Too few parameters. */
-  &usr_burst_channel,  /* Outgoing: Burst channel. */
+  parent: &p_user,
+  m_registered: &irc_registered,
+  illegal_command: &irc_illegal_command,
+  toofew_params: &irc_toofew_params,
+  burst_channel: &usr_burst_channel
 };
index 5d7787765d352c9198cb8a49b4aecd01a0caf863..3c7a6d1aa28b7ef4d35874ee2d404cd368296379 100644 (file)
@@ -19,7 +19,7 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
  *  USA
  *
- *   $Id: p_ts.c,v 1.1 2002/01/13 07:15:39 a1kmm Exp $
+ *   $Id: p_ts.c,v 1.2 2002/04/19 10:56:20 a1kmm Exp $
  */
 
 #include "s_protocol.h"
@@ -54,13 +54,8 @@ tsm_error(struct Client *client_p, struct Client *source_p,
 
 struct Protocol p_ts5 =
 {
-  NULL, /* parent */
-  NULL, /* Unregistered. */
-  NULL, /* Registered. */
-  NULL, /* Not operator. */
-  tsm_error, /* Error. */
-  NULL, /* No such command. */
-  NULL /* Not enough parameters. */
+  m_error: tsm_error,
+  /* burst_channel: ts_burst_channel */
 };
 
 #endif
index 1543a84d982c7ed29adf2ab7a0de7362049cce3b..7c720a6a6f12680f231b53bf96c87250f953f9cd 100644 (file)
@@ -19,7 +19,7 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
  *  USA
  *
- *  $Id: s_conf.c,v 1.5 2002/02/26 04:55:55 a1kmm Exp $
+ *  $Id: s_conf.c,v 1.6 2002/04/19 10:56:20 a1kmm Exp $
  */
 
 #include <sys/types.h>
@@ -1794,7 +1794,7 @@ add_temp_kline(struct ConfItem *aconf)
   dlink_node *kill_node;
   kill_node = make_dlink_node();
   dlinkAdd(aconf, kill_node, &temporary_klines);
-  aconf->flags |= CONF_FLAGS_TEMPORARY;
+  aconf->flags |= BAN_FLAGS_TEMPORARY;
   add_conf_by_address(aconf->host, CONF_KILL, aconf->user, aconf);
 }
 
@@ -1833,8 +1833,9 @@ expire_tklines(dlink_list * tklist)
     if (kill_ptr->hold <= CurrentTime)
     {
       /* Alert opers that a TKline expired - Hwy */
-      sendto_realops_flags(FLAGS_ALL, L_ALL,
-                           "Temporary K-line for [%s@%s] expired",
+      sendto_realops_flags(FLAGS_ALL, L_ALL, "%s-line for [%s@%s] expired",
+                           (kill_ptr->flags & BAN_FLAGS_GLINE) ? "G"
+                             : "Temporary K",
                            (kill_ptr->user) ? kill_ptr->user : "*",
                            (kill_ptr->host) ? kill_ptr->host : "*");
 
@@ -2298,31 +2299,31 @@ flush_deleted_I_P(void)
 }
 
 /*
- * WriteKlineOrDline
+ * write_ban
  *
- * inputs       - kline or dline type flag
- *              - client pointer to report to
- *              - user name of target
- *              - host name of target
- *              - reason for target
- *              - time_t cur_time
- * output       - NONE
- * side effects - This function takes care of
- *                finding right kline or dline conf file, writing
- *                the right lines to this file, 
- *                notifying the oper that their kline/dline is in place
- *                notifying the opers on the server about the k/d line
- *                forwarding the kline onto the next U lined server
- *                
+ * inputs: type       - type of ban
+ *         source_p   - client pointer to report to
+ *         user       - user name of target
+ *         host       - host name of target
+ *         reason     - reason for target
+ *         oper_reason- reason only admins can see
+ *         cur_time   - time ban was placed
+ * output: none
+ * side effects: This function takes care of
+ *               finding right kline or dline conf file, writing
+ *               the right lines to this file, 
+ *               notifying the oper that their kline/dline is in place
+ *               notifying the opers on the server about the k/d line
+ *               forwarding the kline onto the next U lined server
  */
 void
-WriteKlineOrDline(KlineType type,
-                  struct Client *source_p,
-                  char *user,
-                  char *host,
-                  const char *reason,
-                  const char *oper_reason,
-                  const char *current_date, time_t cur_time)
+write_ban(KlineType type,
+          struct Client *source_p,
+          char *user,
+          char *host,
+          const char *reason,
+          const char *oper_reason,
+          const char *current_date, time_t cur_time)
 {
   char buffer[1024];
   FBFILE *out;
@@ -2330,49 +2331,40 @@ WriteKlineOrDline(KlineType type,
 
   filename = get_conf_name(type);
 
-  if (type == DLINE_TYPE)
-  {
-    sendto_realops_flags(FLAGS_ALL, L_ALL,
-                         "%s added D-Line for [%s] [%s]",
-                         get_oper_name(source_p), host, reason);
-    sendto_one(source_p, ":%s NOTICE %s :Added D-Line [%s] to %s",
-               me.name, source_p->name, host, filename);
-
-  }
-  else
+  if (oper_reason == NULL)
+    oper_reason = "";
+  switch (type)
   {
-    sendto_realops_flags(FLAGS_ALL, L_ALL,
-                         "%s added K-Line for [%s@%s] [%s]",
-                         get_oper_name(source_p), user, host, reason);
-    sendto_one(source_p, ":%s NOTICE %s :Added K-Line [%s@%s]",
-               me.name, source_p->name, user, host);
+    case DLINE_TYPE:
+      sendto_realops_flags(FLAGS_ALL, L_ALL,
+                           "%s added D-Line for [%s] [%s]",
+                           get_oper_name(source_p), host, reason);
+      sendto_one(source_p, ":%s NOTICE %s :Added D-Line [%s] to %s",
+                 me.name, source_p->name, host, filename);
+      ircsprintf(buffer, "\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",%ld\n",
+                 user, host, reason, oper_reason, current_date,
+                 get_oper_name(source_p), (long)cur_time);
+      break;
+    case KLINE_TYPE:
+      sendto_realops_flags(FLAGS_ALL, L_ALL,
+                           "%s added K-Line for [%s@%s] [%s]",
+                           get_oper_name(source_p), user, host, reason);
+      sendto_one(source_p, ":%s NOTICE %s :Added K-Line [%s@%s]",
+                 me.name, source_p->name, user, host);
+    default:
+      ircsprintf(buffer, "\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",%ld\n", host,
+                 reason, oper_reason, current_date, get_oper_name(source_p),
+                 (long)cur_time);
+      break;
   }
 
+  /* Now actually write it... */
   if ((out = fbopen(filename, "a")) == NULL)
   {
     sendto_realops_flags(FLAGS_ALL, L_ALL,
                          "*** Problem opening %s ", filename);
     return;
   }
-
-  if (oper_reason == NULL)
-    oper_reason = "";
-
-  if (type == KLINE_TYPE)
-    ircsprintf(buffer, "\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",%ld\n",
-               user,
-               host,
-               reason,
-               oper_reason,
-               current_date, get_oper_name(source_p), (long)cur_time);
-  else
-    ircsprintf(buffer, "\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",%ld\n",
-               host,
-               reason,
-               oper_reason,
-               current_date, get_oper_name(source_p), (long)cur_time);
-
-
   if (fbputs(buffer, out) == -1)
   {
     sendto_realops_flags(FLAGS_ALL, L_ALL,
@@ -2380,15 +2372,15 @@ WriteKlineOrDline(KlineType type,
     fbclose(out);
     return;
   }
-
   fbclose(out);
 
   if (type == KLINE_TYPE)
     ilog(L_TRACE, "%s added K-Line for [%s@%s] [%s]",
          source_p->name, user, host, reason);
-  else
+  else if (type == DLINE_TYPE)
     ilog(L_TRACE, "%s added D-Line for [%s] [%s]",
          get_oper_name(source_p), host, reason);
+  /* glines have their own logging. */
 }
 
 /* get_conf_name
@@ -2401,15 +2393,12 @@ const char *
 get_conf_name(KlineType type)
 {
   if (type == CONF_TYPE)
-  {
-    return (ConfigFileEntry.configfile);
-  }
+    return ConfigFileEntry.configfile;
   else if (type == KLINE_TYPE)
-  {
-    return (ConfigFileEntry.klinefile);
-  }
-
-  return (ConfigFileEntry.dlinefile);
+    return ConfigFileEntry.klinefile;
+  else if (type == GLINE_TYPE)
+    return ConfigFileEntry.glineconffile;
+  return ConfigFileEntry.dlinefile;
 }
 
 /*