Add new feature FEAT_HIS_WHOIS_LOCALCHAN.
[ircu2.10.12-pk.git] / ircd / m_whois.c
index ed0213ad2ee8d7a18d099d1e8ce45f06f8d4f6df..343ca82d7af9414ed91bcaa8574367e693e4b2bb 100644 (file)
@@ -152,13 +152,21 @@ static void do_whois(struct Client* sptr, struct Client *acptr, int parc)
     {
        chptr = chan->channel;
        
-       if (!ShowChannel(sptr, chptr))
+       if (!ShowChannel(sptr, chptr)
+           && !(IsOper(sptr) && IsLocalChannel(chptr->chname)))
           continue;
-          
+
        if (acptr != sptr && IsZombie(chan))
           continue;
-          
-       if (len+strlen(chptr->chname) + mlen > BUFSIZE - 5) 
+
+       /* Don't show local channels when HIS is defined, unless it's a
+       * remote WHOIS --ULtimaTe_
+       */
+       if (IsLocalChannel(chptr->chname) && (acptr != sptr) && (parc == 2)
+           && feature_bool(FEAT_HIS_WHOIS_LOCALCHAN) && !IsAnOper(sptr))
+         continue;
+
+       if (len+strlen(chptr->chname) + mlen > BUFSIZE - 5)
        {
           send_reply(sptr, SND_EXPLICIT | RPL_WHOISCHANNELS, "%s :%s", name, buf);
           *buf = '\0';
@@ -166,6 +174,8 @@ static void do_whois(struct Client* sptr, struct Client *acptr, int parc)
        }
        if (IsDeaf(acptr))
          *(buf + len++) = '-';
+       if (IsOper(sptr) && !ShowChannel(sptr, chptr))
+         *(buf + len++) = '*';
        if (IsDelayedJoin(chan) && (sptr != acptr))
          *(buf + len++) = '<';
        else if (IsChanOp(chan))
@@ -206,15 +216,15 @@ static void do_whois(struct Client* sptr, struct Client *acptr, int parc)
 
     if (HasHiddenHost(acptr) && (IsAnOper(sptr) || acptr == sptr))
       send_reply(sptr, RPL_WHOISACTUALLY, name, user->username,
-                 user->realhost, ircd_ntoa((const char*) &(cli_ip(acptr))));
-    
+                 user->realhost, ircd_ntoa(&cli_ip(acptr)));
+
     /* Hint: if your looking to add more flags to a user, eg +h, here's
      *       probably a good place to add them :)
      */
-     
+
     if (MyConnect(acptr) && (!feature_bool(FEAT_HIS_WHOIS_IDLETIME) ||
                              (sptr == acptr || IsAnOper(sptr) || parc >= 3)))
-       send_reply(sptr, RPL_WHOISIDLE, name, CurrentTime - user->last, 
+       send_reply(sptr, RPL_WHOISIDLE, name, CurrentTime - user->last,
                   cli_firsttime(acptr));
   }
 }
@@ -345,6 +355,7 @@ int m_whois(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
   char*           p = 0;
   int             found = 0;
   int            total = 0;
+  int             wildscount = 0;
 
   if (parc < 2)
   {
@@ -401,7 +412,13 @@ int m_whois(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
       }
     }
     else /* wilds */
-       found=do_wilds(sptr, nick, total, parc);
+    {
+      if (++wildscount > 3) {
+        send_reply(sptr, ERR_QUERYTOOLONG, parv[1]);
+        break;
+      }
+      found=do_wilds(sptr, nick, total, parc);
+    }
 
     if (!found)
       send_reply(sptr, ERR_NOSUCHNICK, nick);