]> jfr.im git - solanum.git/blobdiff - modules/m_kline.c
Kill Travis
[solanum.git] / modules / m_kline.c
index 4456d1afb5915904f220e694205529468c021f81..e478f50dc65ddf29387002d64de8224f9e72fc3b 100644 (file)
@@ -26,7 +26,6 @@
 #include "channel.h"
 #include "class.h"
 #include "client.h"
-#include "common.h"
 #include "match.h"
 #include "ircd.h"
 #include "hostmask.h"
@@ -86,6 +85,7 @@ static void remove_permkline_match(struct Client *, struct ConfItem *);
 static bool remove_temp_kline(struct Client *, struct ConfItem *);
 static void remove_prop_kline(struct Client *, struct ConfItem *);
 
+
 /* mo_kline()
  *
  *   parv[1] - temp time or user@host
@@ -99,14 +99,14 @@ mo_kline(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source
 {
        char def[] = "No Reason";
        char user[USERLEN + 2];
-       char host[HOSTLEN + 2];
+       char host_buf[HOSTLEN + 3], *host = host_buf + 1;
        char *reason = def;
        char *oper_reason;
        const char *target_server = NULL;
        struct ConfItem *aconf;
        int tkline_time = 0;
        int loc = 1;
-       int propagated = ConfigFileEntry.use_propagated_bans;
+       bool propagated = ConfigFileEntry.use_propagated_bans;
 
        if(!IsOperK(source_p))
        {
@@ -123,6 +123,12 @@ mo_kline(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source
        if(find_user_host(source_p, parv[loc], user, host) == 0)
                return;
 
+       if (*host == ':')
+       {
+               host--;
+               *host = '0';
+       }
+
        loc++;
 
        if(parc >= loc + 2 && !irccmp(parv[loc], "ON"))
@@ -147,8 +153,25 @@ mo_kline(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source
 
        reason = LOCAL_COPY(parv[loc]);
 
+       if(parse_netmask_strict(host, NULL, NULL) == HM_ERROR)
+       {
+               sendto_one_notice(source_p,
+                               ":[%s@%s] looks like an ill-formed IP K-line, refusing to set it",
+                               user, host);
+               return;
+       }
+
        if(target_server != NULL)
        {
+               if (tkline_time)
+                       sendto_realops_snomask(SNO_GENERAL, L_NETWIDE,
+                                       "%s is adding a temporary %d min. K-Line for [%s@%s] on %s [%s]",
+                                       get_oper_name(source_p), tkline_time / 60, user, host, target_server, reason);
+               else
+                       sendto_realops_snomask(SNO_GENERAL, L_NETWIDE,
+                                       "%s is adding a K-Line for [%s@%s] on %s [%s]",
+                                       get_oper_name(source_p), user, host, target_server, reason);
+
                propagate_generic(source_p, "KLINE", target_server, CAP_KLN,
                                  "%d %s %s :%s", tkline_time, user, host, reason);
 
@@ -157,7 +180,7 @@ mo_kline(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source
                        return;
 
                /* Set as local-only. */
-               propagated = 0;
+               propagated = false;
        }
        /* if we have cluster servers, send it to them.. */
        else if(!propagated && rb_dlink_list_length(&cluster_conf_list) > 0)
@@ -216,17 +239,7 @@ mo_kline(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source
        else
                apply_kline(source_p, aconf, reason, oper_reason);
 
-       if(ConfigFileEntry.kline_delay)
-       {
-               if(kline_queued == 0)
-               {
-                       rb_event_addonce("check_klines", check_klines_event, NULL,
-                                        ConfigFileEntry.kline_delay);
-                       kline_queued = 1;
-               }
-       }
-       else
-               check_klines();
+       check_one_kline(aconf);
 }
 
 /* ms_kline()
@@ -279,11 +292,6 @@ handle_remote_kline(struct Client *source_p, int tkline_time,
        struct ConfItem *aconf = NULL;
        char *oper_reason;
 
-       if(!find_shared_conf(source_p->username, source_p->host,
-                            source_p->servptr->name,
-                            (tkline_time > 0) ? SHARED_TKLINE : SHARED_PKLINE))
-               return;
-
        if(!valid_user_host(source_p, user, host))
                return;
 
@@ -326,17 +334,7 @@ handle_remote_kline(struct Client *source_p, int tkline_time,
        else
                apply_kline(source_p, aconf, reason, oper_reason);
 
-       if(ConfigFileEntry.kline_delay)
-       {
-               if(kline_queued == 0)
-               {
-                       rb_event_addonce("check_klines", check_klines_event, NULL,
-                                        ConfigFileEntry.kline_delay);
-                       kline_queued = 1;
-               }
-       }
-       else
-               check_klines();
+       check_one_kline(aconf);
 }
 
 /* mo_unkline()
@@ -353,7 +351,7 @@ mo_unkline(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sour
        char splat[] = "*";
        char *h = LOCAL_COPY(parv[1]);
        struct ConfItem *aconf;
-       int propagated = 1;
+       bool propagated = true;
 
        if(!IsOperUnkline(source_p))
        {
@@ -401,12 +399,15 @@ mo_unkline(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sour
                        return;
                }
 
+               sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "%s is removing the K-Line for [%s@%s] on %s",
+                               get_oper_name(source_p), user, host, parv[3]);
+
                propagate_generic(source_p, "UNKLINE", parv[3], CAP_UNKLN, "%s %s", user, host);
 
                if(match(parv[3], me.name) == 0)
                        return;
 
-               propagated = 0;
+               propagated = false;
        }
 
        aconf = find_exact_conf_by_address(host, CONF_KILL, user);
@@ -475,10 +476,6 @@ handle_remote_unkline(struct Client *source_p, const char *user, const char *hos
 {
        struct ConfItem *aconf;
 
-       if(!find_shared_conf(source_p->username, source_p->host,
-                            source_p->servptr->name, SHARED_UNKLINE))
-               return;
-
        aconf = find_exact_conf_by_address(host, CONF_KILL, user);
        if(aconf == NULL)
        {
@@ -714,17 +711,12 @@ already_placed_kline(struct Client *source_p, const char *luser, const char *lho
        if(aconf == NULL && ConfigFileEntry.non_redundant_klines)
        {
                bits = 0;
-               if((t = parse_netmask(lhost, &iphost, &bits)) != HM_HOST)
-               {
-#ifdef RB_IPV6
-                       if(t == HM_IPV6)
-                               t = AF_INET6;
-                       else
-#endif
-                               t = AF_INET;
-
-                       piphost = &iphost;
-               }
+               t = parse_netmask_strict(lhost, &iphost, &bits);
+               piphost = &iphost;
+               if (t == HM_IPV4)
+                       t = AF_INET;
+               else if (t == HM_IPV6)
+                       t = AF_INET6;
                else
                        piphost = NULL;