]> jfr.im git - solanum.git/blobdiff - src/tgchange.c
Apply the same restrictions to ban forwarding as to +f.
[solanum.git] / src / tgchange.c
index 387b191750a637074d2be942c01161b3c9d6eae8..7059a287cf40d7d02a0294984fb1f2591569abe1 100644 (file)
@@ -30,6 +30,8 @@
 #include "hash.h"
 #include "s_newconf.h"
 
+static int add_hashed_target(struct Client *source_p, uint32_t hashv);
+
 struct Channel *
 find_allowing_channel(struct Client *source_p, struct Client *target_p)
 {
@@ -48,9 +50,7 @@ find_allowing_channel(struct Client *source_p, struct Client *target_p)
 int
 add_target(struct Client *source_p, struct Client *target_p)
 {
-       int i, j;
        uint32_t hashv;
-       uint32_t *targets;
 
        /* can msg themselves or services without using any target slots */
        if(source_p == target_p || IsService(target_p))
@@ -65,6 +65,24 @@ add_target(struct Client *source_p, struct Client *target_p)
                return 1;
 
        hashv = fnv_hash_upper((const unsigned char *)use_id(target_p), 32);
+       return add_hashed_target(source_p, hashv);
+}
+
+int
+add_channel_target(struct Client *source_p, struct Channel *chptr)
+{
+       uint32_t hashv;
+
+       hashv = fnv_hash_upper((const unsigned char *)chptr->chname, 32);
+       return add_hashed_target(source_p, hashv);
+}
+
+static int
+add_hashed_target(struct Client *source_p, uint32_t hashv)
+{
+       int i, j;
+       uint32_t *targets;
+
        targets = source_p->localClient->targets;
 
        /* check for existing target, and move it to the head */
@@ -104,6 +122,16 @@ add_target(struct Client *source_p, struct Client *target_p)
                {
                        ServerStats.is_tgch++;
                        add_tgchange(source_p->sockhost);
+
+                       if (!IsTGExcessive(source_p))
+                       {
+                               SetTGExcessive(source_p);
+                               sendto_realops_snomask(SNO_BOTS, L_NETWIDE,
+                                       "Excessive target change from %s (%s@%s)",
+                                       source_p->name, source_p->username,
+                                       source_p->orighost);
+                       }
+
                        return 0;
                }
        }