]> jfr.im git - irc/rqf/shadowircd.git/blobdiff - modules/m_gline.c
m_away.c derived from ratbox3 - looks much better and do not use deprecated DupString.
[irc/rqf/shadowircd.git] / modules / m_gline.c
index 5c315539edae5f3934a4e3d0d5dc8296bc3a93d5..4f39befc142359d6f01368db73e957f1f0b01dc7 100644 (file)
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
  *  USA
  *
- *  $Id: m_gline.c 3161 2007-01-25 07:23:01Z nenolod $
+ *  $Id: m_gline.c 3225 2007-03-04 23:42:55Z jilles $
  */
 
 #include "stdinc.h"
-#include "tools.h"
 #include "s_gline.h"
 #include "channel.h"
 #include "client.h"
@@ -36,7 +35,6 @@
 #include "ircd.h"
 #include "hostmask.h"
 #include "numeric.h"
-#include "commio.h"
 #include "s_conf.h"
 #include "s_newconf.h"
 #include "scache.h"
@@ -47,6 +45,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 +62,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: 3161 $");
+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);
@@ -178,7 +177,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);
@@ -195,7 +194,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;
 }
@@ -233,9 +232,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;
@@ -247,7 +246,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;
@@ -266,7 +265,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;
@@ -278,7 +277,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;
@@ -289,11 +288,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);
@@ -345,9 +344,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;
@@ -359,7 +358,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;
@@ -368,11 +367,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);
@@ -443,7 +442,7 @@ mo_ungline(struct Client *client_p, struct Client *source_p, int parc, const cha
                                     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
        {
@@ -514,8 +513,8 @@ invalid_gline(struct Client *source_p, const char *luser,
                return 1;
        }
 
-       if(strlen(lreason) > REASONLEN)
-               lreason[REASONLEN] = '\0';
+       if(strlen(lreason) > BANREASONLEN)
+               lreason[BANREASONLEN] = '\0';
 
        return 0;
 }
@@ -546,8 +545,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)
        {
@@ -558,7 +557,7 @@ set_local_gline(struct Client *source_p, const char *user,
                        DupString(aconf->spasswd, oper_reason);
        }
 
-       ircsnprintf(buffer, sizeof(buffer), "%s (%s)", reason, current_date);
+       rb_snprintf(buffer, sizeof(buffer), "%s (%s)", reason, current_date);
 
        DupString(aconf->passwd, buffer);
        DupString(aconf->user, user);
@@ -569,11 +568,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();
 }
@@ -588,7 +587,7 @@ static int
 majority_gline(struct Client *source_p, const char *user,
               const char *host, const char *reason)
 {
-       dlink_node *pending_node;
+       rb_dlink_node *pending_node;
        struct gline_pending *pending;
 
        /* to avoid desync.. --fl */
@@ -598,7 +597,7 @@ majority_gline(struct Client *source_p, const char *user,
        if(find_is_glined(host, user))
                return NO;
 
-       DLINK_FOREACH(pending_node, pending_glines.head)
+       RB_DLINK_FOREACH(pending_node, pending_glines.head)
        {
                pending = pending_node->data;
 
@@ -612,7 +611,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;
@@ -628,7 +627,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");
@@ -651,7 +650,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;
@@ -670,7 +669,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));
@@ -680,7 +679,7 @@ majority_gline(struct Client *source_p, const char *user,
        pending->last_gline_time = CurrentTime;
        pending->time_request1 = CurrentTime;
 
-       dlinkAddAlloc(pending, &pending_glines);
+       rb_dlinkAddAlloc(pending, &pending_glines);
 
        return NO;
 }
@@ -695,14 +694,14 @@ static int
 remove_temp_gline(const char *user, const char *host)
 {
        struct ConfItem *aconf;
-       dlink_node *ptr;
+       rb_dlink_node *ptr;
        struct irc_sockaddr_storage addr, caddr;
        int bits, cbits;
        int mtype, gtype;
 
        mtype = parse_netmask(host, (struct sockaddr *)&addr, &bits);
 
-       DLINK_FOREACH(ptr, glines.head)
+       RB_DLINK_FOREACH(ptr, glines.head)
        {
                aconf = ptr->data;
 
@@ -721,7 +720,8 @@ remove_temp_gline(const char *user, const char *host)
                                                (struct sockaddr *)&caddr, bits))
                        continue;
 
-               dlinkDestroy(ptr, &glines);
+               rb_dlinkDestroy(ptr, &glines);
+               remove_reject_mask(aconf->user, aconf->host);
                delete_one_address_conf(aconf->host, aconf);
                return YES;
        }