]> jfr.im git - solanum.git/blobdiff - modules/m_xline.c
ircd/packet.c: make function definition consistent with declaration (#301)
[solanum.git] / modules / m_xline.c
index 8f8861e1c99636f9aca8205238662c23507536da..597f7618c244241873eccb7f0c6a46eb6838a5c9 100644 (file)
@@ -32,8 +32,7 @@
 #include "send.h"
 #include "channel.h"
 #include "client.h"
-#include "common.h"
-#include "config.h"
+#include "defaults.h"
 #include "class.h"
 #include "ircd.h"
 #include "numeric.h"
@@ -66,7 +65,7 @@ static void me_unxline(struct MsgBuf *msgbuf_p, struct Client *client_p, struct
 
 static bool valid_xline(struct Client *, const char *, const char *);
 static void apply_xline(struct Client *client_p, const char *name,
-                       const char *reason, int temp_time, int propagated);
+                       const char *reason, int temp_time, bool propagated);
 static void propagate_xline(struct Client *source_p, const char *target,
                            int temp_time, const char *name, const char *type, const char *reason);
 static void cluster_xline(struct Client *source_p, int temp_time,
@@ -76,7 +75,7 @@ static void handle_remote_xline(struct Client *source_p, int temp_time,
                                const char *name, const char *reason);
 static void handle_remote_unxline(struct Client *source_p, const char *name);
 static void remove_xline(struct Client *source_p, const char *name,
-                        int propagated);
+                        bool propagated);
 
 struct Message xline_msgtab = {
        "XLINE", 0, 0, 0, 0,
@@ -107,7 +106,7 @@ mo_xline(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source
        const char *target_server = NULL;
        int temp_time;
        int loc = 1;
-       int propagated = ConfigFileEntry.use_propagated_bans;
+       bool propagated = ConfigFileEntry.use_propagated_bans;
 
        if(!IsOperXline(source_p))
        {
@@ -149,13 +148,20 @@ mo_xline(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source
 
        if(target_server != NULL)
        {
+               if (temp_time)
+                       sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "%s is adding a temporary %d min. X-Line for [%s] on %s [%s]",
+                                       get_oper_name(source_p), temp_time / 60, name, target_server, reason);
+               else
+                       sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "%s is adding a permanent X-Line for [%s] on %s [%s]",
+                                       get_oper_name(source_p), name, target_server, reason);
+
                propagate_xline(source_p, target_server, temp_time, name, "2", reason);
 
                if(!match(target_server, me.name))
                        return;
 
                /* Set as local-only. */
-               propagated = 0;
+               propagated = false;
        }
        else if(!propagated && rb_dlink_list_length(&cluster_conf_list) > 0)
                cluster_xline(source_p, temp_time, name, reason);
@@ -216,11 +222,6 @@ handle_remote_xline(struct Client *source_p, int temp_time, const char *name, co
 {
        struct ConfItem *aconf;
 
-       if(!find_shared_conf(source_p->username, source_p->host,
-                            source_p->servptr->name,
-                            (temp_time > 0) ? SHARED_TXLINE : SHARED_PXLINE))
-               return;
-
        if(!valid_xline(source_p, name, reason))
                return;
 
@@ -232,7 +233,7 @@ handle_remote_xline(struct Client *source_p, int temp_time, const char *name, co
                return;
        }
 
-       apply_xline(source_p, name, reason, temp_time, 0);
+       apply_xline(source_p, name, reason, temp_time, false);
 }
 
 /* valid_xline()
@@ -264,7 +265,7 @@ valid_xline(struct Client *source_p, const char *gecos, const char *reason)
 }
 
 void
-apply_xline(struct Client *source_p, const char *name, const char *reason, int temp_time, int propagated)
+apply_xline(struct Client *source_p, const char *name, const char *reason, int temp_time, bool propagated)
 {
        struct ConfItem *aconf;
 
@@ -284,7 +285,7 @@ apply_xline(struct Client *source_p, const char *name, const char *reason, int t
                aconf->lifetime = aconf->hold;
 
                replace_old_ban(aconf);
-               rb_dlinkAddAlloc(aconf, &prop_bans);
+               add_prop_ban(aconf);
 
                sendto_realops_snomask(SNO_GENERAL, L_ALL,
                                       "%s added global %d min. X-Line for [%s] [%s]",
@@ -385,7 +386,7 @@ cluster_xline(struct Client *source_p, int temp_time, const char *name, const ch
 static void
 mo_unxline(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
 {
-       int propagated = 1;
+       bool propagated = true;
 
        if(!IsOperXline(source_p))
        {
@@ -402,12 +403,15 @@ mo_unxline(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sour
                        return;
                }
 
+               sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "%s is removing the X-Line for [%s] on %s.",
+                               get_oper_name(source_p), parv[1], parv[3]);
+
                propagate_generic(source_p, "UNXLINE", parv[3], CAP_CLUSTER, "%s", parv[1]);
 
                if(match(parv[3], me.name) == 0)
                        return;
 
-               propagated = 0;
+               propagated = false;
        }
        /* cluster{} moved to remove_xline */
 
@@ -448,15 +452,11 @@ me_unxline(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sour
 static void
 handle_remote_unxline(struct Client *source_p, const char *name)
 {
-       if(!find_shared_conf(source_p->username, source_p->host,
-                            source_p->servptr->name, SHARED_UNXLINE))
-               return;
-
-       remove_xline(source_p, name, 0);
+       remove_xline(source_p, name, false);
 }
 
 static void
-remove_xline(struct Client *source_p, const char *name, int propagated)
+remove_xline(struct Client *source_p, const char *name, bool propagated)
 {
        struct ConfItem *aconf;
        rb_dlink_node *ptr;
@@ -475,8 +475,7 @@ remove_xline(struct Client *source_p, const char *name, int propagated)
                                        sendto_one_notice(source_p, ":Cannot remove global X-Line %s on specific servers", name);
                                        return;
                                }
-                               ptr = rb_dlinkFind(aconf, &prop_bans);
-                               if(ptr == NULL)
+                               if (!lookup_prop_ban(aconf))
                                        return;
                                sendto_one_notice(source_p, ":X-Line for [%s] is removed", name);
                                sendto_realops_snomask(SNO_GENERAL, L_ALL,
@@ -499,7 +498,7 @@ remove_xline(struct Client *source_p, const char *name, int propagated)
                                                0,
                                                (int)(aconf->lifetime - aconf->created));
                                remove_reject_mask(aconf->host, NULL);
-                               deactivate_conf(aconf, ptr, now);
+                               deactivate_conf(aconf, now);
                                return;
                        }
                        else if(propagated && rb_dlink_list_length(&cluster_conf_list))