]> jfr.im git - irc/rqf/shadowircd.git/blobdiff - modules/m_kline.c
Merge links_cache into scache and rework scache.
[irc/rqf/shadowircd.git] / modules / m_kline.c
index 0db2683827a07e3bf92c9f9ceffe16355f740882..ff1eaeddd2f547e14dd039f2cb4b8e4bbf939259 100644 (file)
@@ -21,7 +21,7 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
  *  USA
  *
- *  $Id: m_kline.c 3464 2007-05-19 22:21:10Z jilles $
+ *  $Id: m_kline.c 3466 2007-05-19 23:36:51Z jilles $
  */
 
 #include "stdinc.h"
@@ -65,7 +65,7 @@ struct Message unkline_msgtab = {
 };
 
 mapi_clist_av1 kline_clist[] = { &kline_msgtab, &unkline_msgtab, NULL };
-DECLARE_MODULE_AV1(kline, NULL, NULL, kline_clist, NULL, NULL, "$Revision: 3464 $");
+DECLARE_MODULE_AV1(kline, NULL, NULL, kline_clist, NULL, NULL, "$Revision: 3466 $");
 
 /* Local function prototypes */
 static int find_user_host(struct Client *source_p, const char *userhost, char *user, char *host);
@@ -280,7 +280,7 @@ handle_remote_kline(struct Client *source_p, int tkline_time,
        char *oper_reason;
 
        if(!find_shared_conf(source_p->username, source_p->host,
-                               source_p->user->server
+                               source_p->servptr->name
                                (tkline_time > 0) ? SHARED_TKLINE : SHARED_PKLINE))
                return;
 
@@ -466,7 +466,7 @@ static void
 handle_remote_unkline(struct Client *source_p, const char *user, const char *host)
 {
        if(!find_shared_conf(source_p->username, source_p->host,
-                               source_p->user->server, SHARED_UNKLINE))
+                               source_p->servptr->name, SHARED_UNKLINE))
                return;
 
        if(remove_temp_kline(user, host))
@@ -614,6 +614,7 @@ valid_wild_card(struct Client *source_p, const char *luser, const char *lhost)
        const char *p;
        char tmpch;
        int nonwild = 0;
+       int bitlen;
 
        /* user has no wildcards, always accept -- jilles */
        if (!strchr(luser, '?') && !strchr(luser, '*'))
@@ -632,12 +633,23 @@ valid_wild_card(struct Client *source_p, const char *luser, const char *lhost)
        }
 
        /* try host, as user didnt contain enough */
-       p = lhost;
-       while ((tmpch = *p++))
+       /* special case for cidr masks -- jilles */
+       if ((p = strrchr(lhost, '/')) != NULL && IsDigit(p[1]))
        {
-               if(!IsKWildChar(tmpch))
-                       if(++nonwild >= ConfigFileEntry.min_nonwildcard)
-                               return 1;
+               bitlen = atoi(p + 1);
+               /* much like non-cidr for ipv6, rather arbitrary for ipv4 */
+               if (bitlen > 0 && bitlen >= (strchr(lhost, ':') ? 4 * (ConfigFileEntry.min_nonwildcard - nonwild) : 6 - 2 * nonwild))
+                       return 1;
+       }
+       else
+       {
+               p = lhost;
+               while ((tmpch = *p++))
+               {
+                       if(!IsKWildChar(tmpch))
+                               if(++nonwild >= ConfigFileEntry.min_nonwildcard)
+                                       return 1;
+               }
        }
 
        sendto_one_notice(source_p,