Committer  : entrope
CVSROOT    : /cvsroot/undernet-ircu
Module     : ircu2.10
Commit time: 2006-07-27 01:52:48 UTC

Modified files:
     ChangeLog ircd/send.c

Log message:

Allow IP-matching targets like PRIVMSG/NOTICE [EMAIL PROTECTED]/8.

---------------------- diff included ----------------------
Index: ircu2.10/ChangeLog
diff -u ircu2.10/ChangeLog:1.813 ircu2.10/ChangeLog:1.814
--- ircu2.10/ChangeLog:1.813    Wed Jul 26 18:25:51 2006
+++ ircu2.10/ChangeLog  Wed Jul 26 18:52:38 2006
@@ -1,5 +1,11 @@
 2006-07-26  Michael Poole <[EMAIL PROTECTED]>
 
+       * ircd/send.c (match_it): Add parameters to allow IP matching.
+       (sendcmdto_match): Try to parse 'to' to get an IP mask.  Move the
+       cli_sentalong() test  first (avoiding most match_it() calls).
+
+2006-07-26  Michael Poole <[EMAIL PROTECTED]>
+
        * ircd/ircd.c (check_pings): Send AsLL pings as high priority.
 
        * ircd/m_ping.c (mo_ping): Forward PINGs with high priority.
Index: ircu2.10/ircd/send.c
diff -u ircu2.10/ircd/send.c:1.59 ircu2.10/ircd/send.c:1.60
--- ircu2.10/ircd/send.c:1.59   Sun Jul 23 19:00:28 2006
+++ ircu2.10/ircd/send.c        Wed Jul 26 18:52:38 2006
@@ -19,7 +19,7 @@
  */
 /** @file
  * @brief Send messages to certain targets.
- * @version $Id: send.c,v 1.59 2006/07/24 02:00:28 entrope Exp $
+ * @version $Id: send.c,v 1.60 2006/07/27 01:52:38 entrope Exp $
  */
 #include "config.h"
 
@@ -273,15 +273,19 @@
  * @param[in] from Client trying to send a message (ignored).
  * @param[in] one Client being considered as a target.
  * @param[in] mask Mask for matching against.
+ * @param[in] addr IP address prefix to match against.
+ * @param[in] nbits Number of bits in \a addr (> 128 if none valid).
  * @param[in] what Type of match (either MATCH_HOST or MATCH_SERVER).
  * @return Non-zero if \a one matches, zero if not.
  */
-static int match_it(struct Client *from, struct Client *one, const char *mask, 
int what)
+static int match_it(struct Client *from, struct Client *one, const char *mask,
+                    struct irc_in_addr *addr, unsigned char nbits, int what)
 {
   switch (what)
   {
     case MATCH_HOST:
-      return (match(mask, cli_user(one)->host) == 0 ||
+      return ((nbits <= 128 && ipmask_check(&cli_ip(one), addr, nbits)) ||
+        match(mask, cli_user(one)->host) == 0 ||
         (HasHiddenHost(one) && match(mask, cli_user(one)->realhost) == 0));
     case MATCH_SERVER:
     default:
@@ -670,12 +674,18 @@
                      const char *pattern, ...)
 {
   struct VarData vd;
+  struct irc_in_addr addr;
   struct Client *cptr;
   struct MsgBuf *user_mb;
   struct MsgBuf *serv_mb;
+  unsigned char nbits;
 
   vd.vd_format = pattern;
 
+  /* See if destination looks like an IP mask. */
+  if (!ipmask_parse(to, &addr, &nbits))
+    nbits = 255;
+
   /* Build buffer to send to users */
   va_start(vd.vd_args, pattern);
   user_mb = msgq_make(0, "%:#C %s %v", from, cmd, &vd);
@@ -689,11 +699,11 @@
   /* send buffer along */
   bump_sentalong(one);
   for (cptr = GlobalClientList; cptr; cptr = cli_next(cptr)) {
-    if (!IsRegistered(cptr) ||
+    if (cli_sentalong(cptr) == sentalong_marker ||
+        !IsRegistered(cptr) ||
         IsServer(cptr) ||
-       !match_it(from, cptr, to, who) ||
-        cli_fd(cli_from(cptr)) < 0 ||
-       cli_sentalong(cptr) == sentalong_marker)
+       !match_it(from, cptr, to, &addr, nbits, who) ||
+        cli_fd(cli_from(cptr)) < 0)
       continue; /* skip it */
     cli_sentalong(cptr) = sentalong_marker;
 
----------------------- End of diff -----------------------
_______________________________________________
Patches mailing list
[email protected]
http://undernet.sbg.org/mailman/listinfo/patches

Reply via email to