]> jfr.im git - irc/rqf/shadowircd.git/blobdiff - src/send.c
Note that blacklist{} only accepts host/reason pairs, no host+host+reason.
[irc/rqf/shadowircd.git] / src / send.c
index b12b92e0f7a4d9ad77c71426e8550c895343b741..57e9df84e430f4effbf73d381b28b6cb4101e347 100644 (file)
@@ -49,6 +49,8 @@ static void send_queued_write(rb_fde_t *F, void *data);
 
 unsigned long current_serial = 0L;
 
+struct Client *remote_rehash_oper_p;
+
 /* send_linebuf()
  *
  * inputs      - client to send to, linebuf to attach
@@ -73,7 +75,7 @@ _send_linebuf(struct Client *to, buf_head_t *linebuf)
                {
                        sendto_realops_snomask(SNO_GENERAL, L_ALL,
                                             "Max SendQ limit exceeded for %s: %u > %lu",
-                                            get_server_name(to, HIDE_IP),
+                                            to->name,
                                             rb_linebuf_len(&to->localClient->buf_sendq), 
                                             get_sendq(to));
 
@@ -467,7 +469,6 @@ sendto_channel_flags(struct Client *one, int type, struct Client *source_p,
        static char buf[BUFSIZE];
        va_list args;
        buf_head_t rb_linebuf_local;
-       buf_head_t rb_linebuf_name;
        buf_head_t rb_linebuf_id;
        struct Client *target_p;
        struct membership *msptr;
@@ -475,7 +476,6 @@ sendto_channel_flags(struct Client *one, int type, struct Client *source_p,
        rb_dlink_node *next_ptr;
 
        rb_linebuf_newbuf(&rb_linebuf_local);
-       rb_linebuf_newbuf(&rb_linebuf_name);
        rb_linebuf_newbuf(&rb_linebuf_id);
 
        current_serial++;
@@ -493,7 +493,6 @@ sendto_channel_flags(struct Client *one, int type, struct Client *source_p,
                               source_p->name, source_p->username, 
                               source_p->host, buf);
 
-       rb_linebuf_putmsg(&rb_linebuf_name, NULL, NULL, ":%s %s", source_p->name, buf);
        rb_linebuf_putmsg(&rb_linebuf_id, NULL, NULL, ":%s %s", use_id(source_p), buf);
 
        RB_DLINK_FOREACH_SAFE(ptr, next_ptr, chptr->members.head)
@@ -520,11 +519,7 @@ sendto_channel_flags(struct Client *one, int type, struct Client *source_p,
 
                        if(target_p->from->serial != current_serial)
                        {
-                               if(has_id(target_p->from))
-                                       send_linebuf_remote(target_p, source_p, &rb_linebuf_id);
-                               else
-                                       send_linebuf_remote(target_p, source_p, &rb_linebuf_name);
-
+                               send_linebuf_remote(target_p, source_p, &rb_linebuf_id);
                                target_p->from->serial = current_serial;
                        }
                }
@@ -533,10 +528,96 @@ sendto_channel_flags(struct Client *one, int type, struct Client *source_p,
        }
 
        rb_linebuf_donebuf(&rb_linebuf_local);
-       rb_linebuf_donebuf(&rb_linebuf_name);
        rb_linebuf_donebuf(&rb_linebuf_id);
 }
 
+/* sendto_channel_flags()
+ *
+ * inputs      - server not to send to, flags needed, source, channel, va_args
+ * outputs     - message is sent to channel members
+ * side effects -
+ */
+void
+sendto_channel_opmod(struct Client *one, struct Client *source_p,
+                    struct Channel *chptr, const char *command,
+                    const char *text)
+{
+       buf_head_t rb_linebuf_local;
+       buf_head_t rb_linebuf_old;
+       buf_head_t rb_linebuf_new;
+       struct Client *target_p;
+       struct membership *msptr;
+       rb_dlink_node *ptr;
+       rb_dlink_node *next_ptr;
+
+       rb_linebuf_newbuf(&rb_linebuf_local);
+       rb_linebuf_newbuf(&rb_linebuf_old);
+       rb_linebuf_newbuf(&rb_linebuf_new);
+
+       current_serial++;
+
+       if(IsServer(source_p))
+               rb_linebuf_putmsg(&rb_linebuf_local, NULL, NULL,
+                              ":%s %s %s :%s",
+                              source_p->name, command, chptr->chname, text);
+       else
+               rb_linebuf_putmsg(&rb_linebuf_local, NULL, NULL,
+                              ":%s!%s@%s %s %s :%s",
+                              source_p->name, source_p->username, 
+                              source_p->host, command, chptr->chname, text);
+
+       if (chptr->mode.mode & MODE_MODERATED)
+               rb_linebuf_putmsg(&rb_linebuf_old, NULL, NULL,
+                              ":%s %s %s :%s",
+                              use_id(source_p), command, chptr->chname, text);
+       else
+               rb_linebuf_putmsg(&rb_linebuf_old, NULL, NULL,
+                              ":%s NOTICE @%s :<%s:%s> %s",
+                              use_id(source_p->servptr), chptr->chname,
+                              source_p->name, chptr->chname, text);
+       rb_linebuf_putmsg(&rb_linebuf_new, NULL, NULL,
+                      ":%s %s =%s :%s",
+                      use_id(source_p), command, chptr->chname, text);
+
+       RB_DLINK_FOREACH_SAFE(ptr, next_ptr, chptr->members.head)
+       {
+               msptr = ptr->data;
+               target_p = msptr->client_p;
+
+               if(IsIOError(target_p->from) || target_p->from == one)
+                       continue;
+
+               if((msptr->flags & CHFL_CHANOP) == 0)
+                       continue;
+
+               if(IsDeaf(target_p))
+                       continue;
+
+               if(!MyClient(target_p))
+               {
+                       /* if we've got a specific type, target must support
+                        * CHW.. --fl
+                        */
+                       if(NotCapable(target_p->from, CAP_CHW))
+                               continue;
+
+                       if(target_p->from->serial != current_serial)
+                       {
+                               if (IsCapable(target_p->from, CAP_EOPMOD))
+                                       send_linebuf_remote(target_p, source_p, &rb_linebuf_new);
+                               else
+                                       send_linebuf_remote(target_p, source_p, &rb_linebuf_old);
+                               target_p->from->serial = current_serial;
+                       }
+               }
+               else
+                       _send_linebuf(target_p, &rb_linebuf_local);
+       }
+
+       rb_linebuf_donebuf(&rb_linebuf_local);
+       rb_linebuf_donebuf(&rb_linebuf_old);
+       rb_linebuf_donebuf(&rb_linebuf_new);
+}
 
 /* sendto_channel_local()
  *
@@ -679,6 +760,69 @@ sendto_common_channels_local(struct Client *user, const char *pattern, ...)
        rb_linebuf_donebuf(&linebuf);
 }
 
+/*
+ * sendto_common_channels_local_with_capability()
+ *
+ * inputs      - pointer to client
+ *              - capability
+ *             - pattern to send
+ * output      - NONE
+ * side effects        - Sends a message to all people on local server who are
+ *               in same channel with user. 
+ *               used by m_nick.c and exit_one_client.
+ */
+void
+sendto_common_channels_local_with_capability(struct Client *user, int capability, const char *pattern, ...)
+{
+       va_list args;
+       rb_dlink_node *ptr;
+       rb_dlink_node *next_ptr;
+       rb_dlink_node *uptr;
+       rb_dlink_node *next_uptr;
+       struct Channel *chptr;
+       struct Client *target_p;
+       struct membership *msptr;
+       struct membership *mscptr;
+       buf_head_t linebuf;
+
+       rb_linebuf_newbuf(&linebuf);
+       va_start(args, pattern);
+       rb_linebuf_putmsg(&linebuf, pattern, &args, NULL);
+       va_end(args);
+
+       ++current_serial;
+
+       RB_DLINK_FOREACH_SAFE(ptr, next_ptr, user->user->channel.head)
+       {
+               mscptr = ptr->data;
+               chptr = mscptr->chptr;
+
+               RB_DLINK_FOREACH_SAFE(uptr, next_uptr, chptr->locmembers.head)
+               {
+                       msptr = uptr->data;
+                       target_p = msptr->client_p;
+
+                       if(!IsCapable(target_p, capability))
+                               continue;
+
+                       if(IsIOError(target_p) ||
+                          target_p->serial == current_serial)
+                               continue;
+
+                       target_p->serial = current_serial;
+                       send_linebuf(target_p, &linebuf);
+               }
+       }
+
+       /* this can happen when the user isnt in any channels, but we still
+        * need to send them the data, ie a nick change
+        */
+       if(MyConnect(user) && (user->serial != current_serial) && IsCapable(user, capability))
+               send_linebuf(user, &linebuf);
+
+       rb_linebuf_donebuf(&linebuf);
+}
+
 /*
  * sendto_common_channels_local_butone()
  *
@@ -733,6 +877,72 @@ sendto_common_channels_local_butone(struct Client *user, const char *pattern, ..
        rb_linebuf_donebuf(&linebuf);
 }
 
+/*
+ * sendto_common_channels_local_with_capability_butone()
+ *
+ * inputs      - pointer to client
+ *              - capability
+ *             - pattern to send
+ * output      - NONE
+ * side effects        - Sends a message to all people on local server who are
+ *               in same channel with user, except the user themselves.
+ *               used by m_nick.c and exit_one_client.
+ */
+void
+sendto_common_channels_local_with_capability_butone(struct Client *user, int capability, const char *pattern, ...)
+{
+       va_list args;
+       rb_dlink_node *ptr;
+       rb_dlink_node *next_ptr;
+       rb_dlink_node *uptr;
+       rb_dlink_node *next_uptr;
+       struct Channel *chptr;
+       struct Client *target_p;
+       struct membership *msptr;
+       struct membership *mscptr;
+       buf_head_t linebuf;
+
+       rb_linebuf_newbuf(&linebuf);
+       va_start(args, pattern);
+       rb_linebuf_putmsg(&linebuf, pattern, &args, NULL);
+       va_end(args);
+
+       ++current_serial;
+       /* Skip them -- jilles */
+       user->serial = current_serial;
+
+       RB_DLINK_FOREACH_SAFE(ptr, next_ptr, user->user->channel.head)
+       {
+               mscptr = ptr->data;
+               chptr = mscptr->chptr;
+
+               RB_DLINK_FOREACH_SAFE(uptr, next_uptr, chptr->locmembers.head)
+               {
+                       msptr = uptr->data;
+                       target_p = msptr->client_p;
+
+                       if(!IsCapable(target_p, capability))
+                               continue;
+
+                       if(IsIOError(target_p) ||
+                          target_p->serial == current_serial)
+                               continue;
+
+                       target_p->serial = current_serial;
+                       send_linebuf(target_p, &linebuf);
+               }
+       }
+
+       /* this can happen when the user isnt in any channels, but we still
+        * need to send them the data, ie a nick change
+        */
+       if(MyConnect(user) && (user->serial != current_serial) && IsCapable(user, capability))
+               send_linebuf(user, &linebuf);
+
+       rb_linebuf_donebuf(&linebuf);
+}
+
+
 /* sendto_match_butone()
  *
  * inputs      - server not to send to, source, mask, type of mask, va_args
@@ -749,11 +959,9 @@ sendto_match_butone(struct Client *one, struct Client *source_p,
        rb_dlink_node *ptr;
        rb_dlink_node *next_ptr;
        buf_head_t rb_linebuf_local;
-       buf_head_t rb_linebuf_name;
        buf_head_t rb_linebuf_id;
 
        rb_linebuf_newbuf(&rb_linebuf_local);
-       rb_linebuf_newbuf(&rb_linebuf_name);
        rb_linebuf_newbuf(&rb_linebuf_id);
 
        va_start(args, pattern);
@@ -769,7 +977,6 @@ sendto_match_butone(struct Client *one, struct Client *source_p,
                               source_p->name, source_p->username, 
                               source_p->host, buf);
 
-       rb_linebuf_putmsg(&rb_linebuf_name, NULL, NULL, ":%s %s", source_p->name, buf);
        rb_linebuf_putmsg(&rb_linebuf_id, NULL, NULL, ":%s %s", use_id(source_p), buf);
 
        if(what == MATCH_HOST)
@@ -799,15 +1006,11 @@ sendto_match_butone(struct Client *one, struct Client *source_p,
                if(target_p == one)
                        continue;
 
-               if(has_id(target_p))
-                       send_linebuf_remote(target_p, source_p, &rb_linebuf_id);
-               else
-                       send_linebuf_remote(target_p, source_p, &rb_linebuf_name);
+               send_linebuf_remote(target_p, source_p, &rb_linebuf_id);
        }
 
        rb_linebuf_donebuf(&rb_linebuf_local);
        rb_linebuf_donebuf(&rb_linebuf_id);
-       rb_linebuf_donebuf(&rb_linebuf_name);
 }
 
 /* sendto_match_servs()
@@ -825,13 +1028,11 @@ sendto_match_servs(struct Client *source_p, const char *mask, int cap,
        rb_dlink_node *ptr;
        struct Client *target_p;
        buf_head_t rb_linebuf_id;
-       buf_head_t rb_linebuf_name;
 
        if(EmptyString(mask))
                return;
 
        rb_linebuf_newbuf(&rb_linebuf_id);
-       rb_linebuf_newbuf(&rb_linebuf_name);
 
        va_start(args, pattern);
        rb_vsnprintf(buf, sizeof(buf), pattern, args);
@@ -839,8 +1040,6 @@ sendto_match_servs(struct Client *source_p, const char *mask, int cap,
 
        rb_linebuf_putmsg(&rb_linebuf_id, NULL, NULL, 
                        ":%s %s", use_id(source_p), buf);
-       rb_linebuf_putmsg(&rb_linebuf_name, NULL, NULL, 
-                       ":%s %s", source_p->name, buf);
 
        current_serial++;
 
@@ -868,15 +1067,11 @@ sendto_match_servs(struct Client *source_p, const char *mask, int cap,
                        if(nocap && !NotCapable(target_p->from, nocap))
                                continue;
 
-                       if(has_id(target_p->from))
-                               _send_linebuf(target_p->from, &rb_linebuf_id);
-                       else
-                               _send_linebuf(target_p->from, &rb_linebuf_name);
+                       _send_linebuf(target_p->from, &rb_linebuf_id);
                }
        }
 
        rb_linebuf_donebuf(&rb_linebuf_id);
-       rb_linebuf_donebuf(&rb_linebuf_name);
 }
 
 /* sendto_monitor()
@@ -992,6 +1187,16 @@ sendto_realops_snomask(int flags, int level, const char *pattern, ...)
                                        ":%s ENCAP * SNOTE %c :%s",
                                        me.id, snobuf[1], buf);
        }
+       else if (remote_rehash_oper_p != NULL)
+       {
+               /* rather a lot of copying around, oh well -- jilles */
+               va_start(args, pattern);
+               rb_vsnprintf(buf, sizeof(buf), pattern, args);
+               va_end(args);
+               rb_linebuf_putmsg(&linebuf, pattern, NULL, 
+                               ":%s NOTICE * :*** Notice -- %s", me.name, buf);
+               sendto_one_notice(remote_rehash_oper_p, ":*** Notice -- %s", buf);
+       }
        else
        {
                va_start(args, pattern);
@@ -1145,17 +1350,13 @@ kill_client_serv_butone(struct Client *one, struct Client *target_p, const char
        rb_dlink_node *ptr;
        rb_dlink_node *next_ptr;
        buf_head_t rb_linebuf_id;
-       buf_head_t rb_linebuf_name;
 
-       rb_linebuf_newbuf(&rb_linebuf_name);
        rb_linebuf_newbuf(&rb_linebuf_id);
        
        va_start(args, pattern);
        rb_vsnprintf(buf, sizeof(buf), pattern, args);
        va_end(args);
 
-       rb_linebuf_putmsg(&rb_linebuf_name, NULL, NULL, ":%s KILL %s :%s",
-                      me.name, target_p->name, buf);
        rb_linebuf_putmsg(&rb_linebuf_id, NULL, NULL, ":%s KILL %s :%s",
                       use_id(&me), use_id(target_p), buf);
 
@@ -1170,12 +1371,8 @@ kill_client_serv_butone(struct Client *one, struct Client *target_p, const char
                        (!has_id(client_p) || !has_id(target_p)))
                        continue;
 
-               if(has_id(client_p))
-                       _send_linebuf(client_p, &rb_linebuf_id);
-               else
-                       _send_linebuf(client_p, &rb_linebuf_name);
+               _send_linebuf(client_p, &rb_linebuf_id);
        }
 
        rb_linebuf_donebuf(&rb_linebuf_id);
-       rb_linebuf_donebuf(&rb_linebuf_name);
 }