Author: Kev <klmitch@mit.edu>
[ircu2.10.12-pk.git] / ircd / m_whois.c
index 4d9f5205a66b4dcc68a9f90408f2c91934b64ab2..45ac83bf6367142c9cc12b6b1f08a1cb8c8d85c6 100644 (file)
  *            note:   it is guaranteed that parv[0]..parv[parc-1] are all
  *                    non-NULL pointers.
  */
-#if 0
-/*
- * No need to include handlers.h here the signatures must match
- * and we don't need to force a rebuild of all the handlers everytime
- * we add a new one to the list. --Bleep
- */
-#include "handlers.h"
-#endif /* 0 */
+#include "config.h"
+
 #include "channel.h"
 #include "client.h"
 #include "hash.h"
 #include "ircd.h"
+#include "ircd_policy.h"
 #include "ircd_reply.h"
 #include "ircd_string.h"
 #include "match.h"
 /*
  * Send whois information for acptr to sptr
  */
-static void do_whois(struct Client* sptr, struct Client *acptr)
+static void do_whois(struct Client* sptr, struct Client *acptr, int parc)
 {
   struct Client *a2cptr=0;
   struct Channel *chptr=0;
@@ -187,7 +182,15 @@ static void do_whois(struct Client* sptr, struct Client *acptr)
      if (buf[0] != '\0')
         send_reply(sptr, RPL_WHOISCHANNELS, name, buf);
   }
-  send_reply(sptr, RPL_WHOISSERVER, name, cli_name(a2cptr), cli_info(a2cptr));
+
+#ifdef HEAD_IN_SAND_WHOIS_SERVERNAME
+  if (!IsAnOper(sptr) && sptr != acptr)
+    send_reply(sptr, RPL_WHOISSERVER, name, "*.undernet.org",
+              "The Undernet Underworld");
+  else
+#endif
+    send_reply(sptr, RPL_WHOISSERVER, name, cli_name(a2cptr),
+              cli_info(a2cptr));
 
   if (user)
   {
@@ -202,7 +205,11 @@ static void do_whois(struct Client* sptr, struct Client *acptr)
      *       probably a good place to add them :)
      */
      
-    if (MyConnect(acptr))
+    if (MyConnect(acptr)
+#ifdef HEAD_IN_SAND_WHOIS_IDLETIME
+       && (sptr == acptr || IsAnOper(sptr) || parc >= 3)
+#endif
+       )
        send_reply(sptr, RPL_WHOISIDLE, name, CurrentTime - user->last, 
                   cli_firsttime(acptr));
   }
@@ -213,7 +220,7 @@ static void do_whois(struct Client* sptr, struct Client *acptr)
  * returns the number of people found (or, obviously, 0, if none where
  * found).
  */
-static int do_wilds(struct Client* sptr,char *nick,int count)
+static int do_wilds(struct Client* sptr, char *nick, int count, int parc)
 {
   struct Client *acptr; /* Current client we're concidering */
   struct User *user;   /* the user portion of the client */
@@ -265,7 +272,7 @@ static int do_wilds(struct Client* sptr,char *nick,int count)
     /* Should we show this person now? */
     if (showperson) {
        found++;
-       do_whois(sptr,acptr);
+       do_whois(sptr, acptr, parc);
        if (count+found>MAX_WHOIS_LINES)
          return found;
        continue;
@@ -307,7 +314,7 @@ static int do_wilds(struct Client* sptr,char *nick,int count)
     if (!showperson)
       continue;
       
-    do_whois(sptr,acptr);
+    do_whois(sptr, acptr, parc);
     found++;
     if (count+found>MAX_WHOIS_LINES)
        return found;  
@@ -348,7 +355,14 @@ int m_whois(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
      * it with the correct servername - as is needed by hunt_server().
      * This is the secret behind the /whois nick nick trick.
      */
+#if HEAD_IN_SAND_REMOTE
+    /* If remote queries are disabled, then use the *second* parameter of
+     * of whois, so /whois nick nick still works.
+     */
+    acptr = FindUser(parv[2]);
+#else
     acptr = FindUser(parv[1]);
+#endif
     if (acptr)
       parv[1] = cli_name(cli_user(acptr)->server);
     if (hunt_server_cmd(sptr, CMD_WHOIS, cptr, 0, "%C :%s", 1, parc, parv) !=
@@ -371,12 +385,12 @@ int m_whois(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
       /* No wildcards */
       acptr = FindUser(nick);
       if (acptr && !IsServer(acptr)) {
-        do_whois(sptr,acptr);
+        do_whois(sptr, acptr, parc);
         found = 1;
       }
     }
     else /* wilds */
-       found=do_wilds(sptr,nick,total);
+       found=do_wilds(sptr, nick, total, parc);
 
     if (!found)
       send_reply(sptr, ERR_NOSUCHNICK, nick);
@@ -448,7 +462,7 @@ int ms_whois(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
     acptr = FindUser(nick);
     if (acptr && !IsServer(acptr)) {
       found++;
-      do_whois(sptr,acptr);
+      do_whois(sptr, acptr, parc);
     }
 
     if (!found)