]> jfr.im git - irc/rqf/shadowircd.git/blobdiff - modules/m_gline.c
Remove silly a2client_p, entirely pointless since User.server removal.
[irc/rqf/shadowircd.git] / modules / m_gline.c
index d644bcad1eca7848078bca10c014910d2b8dfa23..f2d08705de0169a1f018f399bb1f87fb79d9f3be 100644 (file)
@@ -21,7 +21,7 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
  *  USA
  *
- *  $Id: m_gline.c 1146 2006-04-07 22:52:35Z jilles $
+ *  $Id: m_gline.c 3225 2007-03-04 23:42:55Z jilles $
  */
 
 #include "stdinc.h"
@@ -47,6 +47,7 @@
 #include "parse.h"
 #include "modules.h"
 #include "s_log.h"
+#include "reject.h"
 
 static int mo_gline(struct Client *, struct Client *, int, const char **);
 static int mc_gline(struct Client *, struct Client *, int, const char **);
@@ -63,7 +64,7 @@ struct Message ungline_msgtab = {
 };
 
 mapi_clist_av1 gline_clist[] = { &gline_msgtab, &ungline_msgtab, NULL };
-DECLARE_MODULE_AV1(gline, NULL, NULL, gline_clist, NULL, NULL, "$Revision: 1146 $");
+DECLARE_MODULE_AV1(gline, NULL, NULL, gline_clist, NULL, NULL, "$Revision: 3225 $");
 
 static int majority_gline(struct Client *source_p, const char *user,
                          const char *host, const char *reason);
@@ -93,8 +94,7 @@ mo_gline(struct Client *client_p, struct Client *source_p, int parc, const char
 
        if(!ConfigFileEntry.glines)
        {
-               sendto_one(source_p, ":%s NOTICE %s :GLINE disabled, perhaps you want a clustered or remote KLINE?",
-                          me.name, source_p->name);
+               sendto_one_notice(source_p, ":GLINE disabled, perhaps you want a clustered or remote KLINE?");
                return 0;
        }
 
@@ -123,9 +123,7 @@ mo_gline(struct Client *client_p, struct Client *source_p, int parc, const char
                /* ok, its not a host.. abort */
                if(strchr(parv[1], '.') == NULL)
                {
-                       sendto_one(source_p,
-                                  ":%s NOTICE %s :Invalid parameters",
-                                  me.name, source_p->name);
+                       sendto_one_notice(source_p, ":Invalid parameters");
                        return 0;
                }
 
@@ -142,10 +140,8 @@ mo_gline(struct Client *client_p, struct Client *source_p, int parc, const char
        if(check_wild_gline(user, host))
        {
                if(MyClient(source_p))
-                       sendto_one(source_p,
-                                  ":%s NOTICE %s :Please include at least %d non-wildcard "
-                                  "characters with the user@host",
-                                  me.name, source_p->name, 
+                       sendto_one_notice(source_p,
+                                  ":Please include at least %d non-wildcard characters with the user@host",
                                   ConfigFileEntry.min_nonwildcard);
                return 0;
        }
@@ -160,8 +156,7 @@ mo_gline(struct Client *client_p, struct Client *source_p, int parc, const char
                {
                        if(bitlen < ConfigFileEntry.gline_min_cidr)
                        {
-                               sendto_one(source_p, ":%s NOTICE %s :Cannot set G-Lines with cidr length < %d",
-                                          me.name, source_p->name,
+                               sendto_one_notice(source_p, ":Cannot set G-Lines with cidr length < %d",
                                           ConfigFileEntry.gline_min_cidr);
                                return 0;
                        }
@@ -169,8 +164,7 @@ mo_gline(struct Client *client_p, struct Client *source_p, int parc, const char
                /* ipv6 */
                else if(bitlen < ConfigFileEntry.gline_min_cidr6)
                {
-                       sendto_one(source_p, ":%s NOTICE %s :Cannot set G-Lines with cidr length < %d",
-                                  me.name, source_p->name, 
+                       sendto_one_notice(source_p, ":Cannot set G-Lines with cidr length < %d",
                                   ConfigFileEntry.gline_min_cidr6);
                        return 0;
                }
@@ -185,7 +179,7 @@ mo_gline(struct Client *client_p, struct Client *source_p, int parc, const char
                        source_p->host, me.name, user, host, reason);
        ilog(L_GLINE, "R %s %s %s %s %s %s %s",
             source_p->name, source_p->username, source_p->host, 
-            source_p->user->server, user, host, reason);
+            source_p->servptr->name, user, host, reason);
 
        /* If at least 3 opers agree this user should be G lined then do it */
        majority_gline(source_p, user, host, reason);
@@ -202,7 +196,7 @@ mo_gline(struct Client *client_p, struct Client *source_p, int parc, const char
        sendto_server(NULL, NULL, NOCAPS, CAP_GLN,
                        ":%s GLINE %s %s %s %s %s %s :%s",
                        me.name, source_p->name, source_p->username,
-                       source_p->host, source_p->user->server
+                       source_p->host, source_p->servptr->name
                        user, host, reason);
        return 0;
 }
@@ -240,9 +234,9 @@ mc_gline(struct Client *client_p, struct Client *source_p,
                      acptr->name, user, host, reason);
        sendto_server(client_p, NULL, NOCAPS, CAP_GLN,
                      ":%s GLINE %s %s %s %s %s %s :%s",
-                     acptr->user->server, acptr->name, 
+                     acptr->servptr->name, acptr->name, 
                      acptr->username, acptr->host,
-                     acptr->user->server, user, host, reason);
+                     acptr->servptr->name, user, host, reason);
 
        if(!ConfigFileEntry.glines)
                return 0;
@@ -254,7 +248,7 @@ mc_gline(struct Client *client_p, struct Client *source_p,
                                "%s!%s@%s on %s is requesting a gline without "
                                "%d non-wildcard characters for [%s@%s] [%s]",
                                acptr->name, acptr->username, 
-                               acptr->host, acptr->user->server,
+                               acptr->host, acptr->servptr->name,
                                ConfigFileEntry.min_nonwildcard,
                                user, host, reason);
                return 0;
@@ -273,7 +267,7 @@ mc_gline(struct Client *client_p, struct Client *source_p,
                                sendto_realops_snomask(SNO_GENERAL, L_ALL, "%s!%s@%s on %s is requesting a "
                                                     "gline with a cidr mask < %d for [%s@%s] [%s]",
                                                     acptr->name, acptr->username, acptr->host,
-                                                    acptr->user->server,
+                                                    acptr->servptr->name,
                                                     ConfigFileEntry.gline_min_cidr, 
                                                     user, host, reason);
                                return 0;
@@ -285,7 +279,7 @@ mc_gline(struct Client *client_p, struct Client *source_p,
                        sendto_realops_snomask(SNO_GENERAL, L_ALL, "%s!%s@%s on %s is requesting a "
                                             "gline with a cidr mask < %d for [%s@%s] [%s]",
                                             acptr->name, acptr->username, acptr->host,
-                                            acptr->user->server,
+                                            acptr->servptr->name,
                                             ConfigFileEntry.gline_min_cidr6,
                                             user, host, reason);
                        return 0;
@@ -296,11 +290,11 @@ mc_gline(struct Client *client_p, struct Client *source_p,
        sendto_realops_snomask(SNO_GENERAL, L_ALL,
                        "%s!%s@%s on %s is requesting gline for [%s@%s] [%s]",
                        acptr->name, acptr->username, acptr->host,
-                       acptr->user->server, user, host, reason);
+                       acptr->servptr->name, user, host, reason);
 
        ilog(L_GLINE, "R %s %s %s %s %s %s %s",
             source_p->name, source_p->username, source_p->host, 
-            source_p->user->server, user, host, reason);
+            source_p->servptr->name, user, host, reason);
 
        /* If at least 3 opers agree this user should be G lined then do it */
        majority_gline(acptr, user, host, reason);
@@ -352,9 +346,9 @@ ms_gline(struct Client *client_p, struct Client *source_p, int parc, const char
                      acptr->name, user, host, reason);
        sendto_server(client_p, NULL, NOCAPS, CAP_GLN,
                      ":%s GLINE %s %s %s %s %s %s :%s",
-                     acptr->user->server, acptr->name, 
+                     acptr->servptr->name, acptr->name, 
                      acptr->username, acptr->host,
-                     acptr->user->server, user, host, reason);
+                     acptr->servptr->name, user, host, reason);
 
        if(!ConfigFileEntry.glines)
                return 0;
@@ -366,7 +360,7 @@ ms_gline(struct Client *client_p, struct Client *source_p, int parc, const char
                                "%s!%s@%s on %s is requesting a gline without "
                                "%d non-wildcard characters for [%s@%s] [%s]",
                                acptr->name, acptr->username, 
-                               acptr->host, acptr->user->server,
+                               acptr->host, acptr->servptr->name,
                                ConfigFileEntry.min_nonwildcard,
                                user, host, reason);
                return 0;
@@ -375,11 +369,11 @@ ms_gline(struct Client *client_p, struct Client *source_p, int parc, const char
        sendto_realops_snomask(SNO_GENERAL, L_ALL,
                        "%s!%s@%s on %s is requesting gline for [%s@%s] [%s]",
                        acptr->name, acptr->username, acptr->host,
-                       acptr->user->server, user, host, reason);
+                       acptr->servptr->name, user, host, reason);
 
        ilog(L_GLINE, "R %s %s %s %s %s %s %s",
             acptr->name, acptr->username, acptr->host, 
-            acptr->user->server, user, host, reason);
+            acptr->servptr->name, user, host, reason);
 
        /* If at least 3 opers agree this user should be G lined then do it */
        majority_gline(acptr, user, host, reason);
@@ -402,7 +396,7 @@ mo_ungline(struct Client *client_p, struct Client *source_p, int parc, const cha
 
        if(!ConfigFileEntry.glines)
        {
-               sendto_one(source_p, ":%s NOTICE %s :UNGLINE disabled, perhaps you want UNKLINE?", me.name, parv[0]);
+               sendto_one_notice(source_p, ":UNGLINE disabled, perhaps you want UNKLINE?");
                return 0;
        }
 
@@ -438,25 +432,23 @@ mo_ungline(struct Client *client_p, struct Client *source_p, int parc, const cha
        }
        else
        {
-               sendto_one(source_p, ":%s NOTICE %s :Invalid parameters", me.name, parv[0]);
+               sendto_one_notice(source_p, ":Invalid parameters");
                return 0;
        }
 
        if(remove_temp_gline(user, host))
        {
-               sendto_one(source_p, ":%s NOTICE %s :Un-glined [%s@%s]",
-                          me.name, parv[0], user, host);
+               sendto_one_notice(source_p, ":Un-glined [%s@%s]", user, host);
                sendto_realops_snomask(SNO_GENERAL, L_ALL,
                                     "%s has removed the G-Line for: [%s@%s]",
                                     get_oper_name(source_p), user, host);
                ilog(L_GLINE, "U %s %s %s %s %s %s",
                     source_p->name, source_p->username, source_p->host, 
-                    source_p->user->server, user, host);
+                    source_p->servptr->name, user, host);
        }
        else
        {
-               sendto_one(source_p, ":%s NOTICE %s :No G-Line for %s@%s",
-                          me.name, parv[0], user, host);
+               sendto_one_notice(source_p, ":No G-Line for %s@%s", user, host);
        }
 
        return 0;
@@ -519,13 +511,12 @@ invalid_gline(struct Client *source_p, const char *luser,
 {
        if(strchr(luser, '!'))
        {
-               sendto_one(source_p, ":%s NOTICE %s :Invalid character '!' in gline",
-                          me.name, source_p->name);
+               sendto_one_notice(source_p, ":Invalid character '!' in gline");
                return 1;
        }
 
-       if(strlen(lreason) > REASONLEN)
-               lreason[REASONLEN] = '\0';
+       if(strlen(lreason) > BANREASONLEN)
+               lreason[BANREASONLEN] = '\0';
 
        return 0;
 }
@@ -556,8 +547,8 @@ set_local_gline(struct Client *source_p, const char *user,
        aconf->status = CONF_GLINE;
        aconf->flags |= CONF_FLAGS_TEMPORARY;
 
-       if(strlen(my_reason) > REASONLEN)
-               my_reason[REASONLEN-1] = '\0';
+       if(strlen(my_reason) > BANREASONLEN)
+               my_reason[BANREASONLEN-1] = '\0';
 
        if((oper_reason = strchr(my_reason, '|')) != NULL)
        {
@@ -579,11 +570,11 @@ set_local_gline(struct Client *source_p, const char *user,
        sendto_realops_snomask(SNO_GENERAL, L_ALL,
                             "%s!%s@%s on %s has triggered gline for [%s@%s] [%s]",
                             source_p->name, source_p->username,
-                            source_p->host, source_p->user->server,
+                            source_p->host, source_p->servptr->name,
                             user, host, reason);
        ilog(L_GLINE, "T %s %s %s %s %s %s %s",
             source_p->name, source_p->username, source_p->host, 
-            source_p->user->server, user, host, reason);
+            source_p->servptr->name, user, host, reason);
 
        check_glines();
 }
@@ -622,7 +613,7 @@ majority_gline(struct Client *source_p, const char *user,
                                sendto_realops_snomask(SNO_GENERAL, L_ALL, "oper has already voted");
                                return NO;
                        }
-                       else if(irccmp(pending->oper_server1, source_p->user->server) == 0)
+                       else if(irccmp(pending->oper_server1, source_p->servptr->name) == 0)
                        {
                                sendto_realops_snomask(SNO_GENERAL, L_ALL, "server has already voted");
                                return NO;
@@ -638,7 +629,7 @@ majority_gline(struct Client *source_p, const char *user,
                                                             "oper has already voted");
                                        return NO;
                                }
-                               else if(irccmp(pending->oper_server2, source_p->user->server) == 0)
+                               else if(irccmp(pending->oper_server2, source_p->servptr->name) == 0)
                                {
                                        sendto_realops_snomask(SNO_GENERAL, L_ALL,
                                                             "server has already voted");
@@ -661,7 +652,7 @@ majority_gline(struct Client *source_p, const char *user,
                                strlcpy(pending->oper_host2, source_p->host,
                                        sizeof(pending->oper_host2));
                                DupString(pending->reason2, reason);
-                               pending->oper_server2 = find_or_add(source_p->user->server);
+                               pending->oper_server2 = scache_get_name(source_p->servptr->serv->nameinfo);
                                pending->last_gline_time = CurrentTime;
                                pending->time_request2 = CurrentTime;
                                return NO;
@@ -680,7 +671,7 @@ majority_gline(struct Client *source_p, const char *user,
        strlcpy(pending->oper_host1, source_p->host,
                sizeof(pending->oper_host1));
 
-       pending->oper_server1 = find_or_add(source_p->user->server);
+       pending->oper_server1 = scache_get_name(source_p->servptr->serv->nameinfo);
 
        strlcpy(pending->user, user, sizeof(pending->user));
        strlcpy(pending->host, host, sizeof(pending->host));
@@ -732,6 +723,7 @@ remove_temp_gline(const char *user, const char *host)
                        continue;
 
                dlinkDestroy(ptr, &glines);
+               remove_reject_mask(aconf->user, aconf->host);
                delete_one_address_conf(aconf->host, aconf);
                return YES;
        }