#include "client.h"
#include "hash.h"
#include "ircd.h"
-#include "ircd_policy.h"
+#include "ircd_features.h"
+#include "ircd_log.h"
#include "ircd_reply.h"
#include "ircd_string.h"
#include "match.h"
#include "send.h"
#include "whocmds.h"
-#include <assert.h>
+/* #include <assert.h> -- Now using assert in ircd_log.h */
#include <string.h>
/*
{
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';
}
if (IsDeaf(acptr))
*(buf + len++) = '-';
- if (is_chan_op(acptr, chptr))
+ if (IsOper(sptr) && !ShowChannel(sptr, chptr))
+ *(buf + len++) = '*';
+ if (IsDelayedJoin(chan) && (sptr != acptr))
+ *(buf + len++) = '<';
+ else if (IsChanOp(chan))
*(buf + len++) = '@';
- else if (has_voice(acptr, chptr))
+ else if (HasVoice(chan))
*(buf + len++) = '+';
else if (IsZombie(chan))
*(buf + len++) = '!';
send_reply(sptr, RPL_WHOISCHANNELS, name, buf);
}
-#ifdef HEAD_IN_SAND_WHOIS_SERVERNAME
- if (!IsAnOper(sptr) && sptr != acptr)
- send_reply(sptr, RPL_WHOISSERVER, name, HEAD_IN_SAND_SERVERNAME,
- HEAD_IN_SAND_SERVERINFO);
+ if (feature_bool(FEAT_HIS_WHOIS_SERVERNAME) && !IsAnOper(sptr) &&
+ sptr != acptr)
+ send_reply(sptr, RPL_WHOISSERVER, name, feature_str(FEAT_HIS_SERVERNAME),
+ feature_str(FEAT_HIS_SERVERINFO));
else
-#endif
send_reply(sptr, RPL_WHOISSERVER, name, cli_name(a2cptr),
cli_info(a2cptr));
if (user->away)
send_reply(sptr, RPL_AWAY, name, user->away);
- if (IsAnOper(acptr) && (HasPriv(acptr, PRIV_DISPLAY) ||
- HasPriv(sptr, PRIV_SEE_OPERS)))
+ if (SeeOper(sptr,acptr))
send_reply(sptr, RPL_WHOISOPERATOR, name);
-
+
+ if (IsAccount(acptr))
+ send_reply(sptr, RPL_WHOISACCOUNT, name, user->account);
+
+ if (HasHiddenHost(acptr) && (IsAnOper(sptr) || acptr == sptr))
+ send_reply(sptr, RPL_WHOISACTUALLY, name, user->username,
+ 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)
-#ifdef HEAD_IN_SAND_WHOIS_IDLETIME
- && (sptr == acptr || IsAnOper(sptr) || parc >= 3)
-#endif
- )
- send_reply(sptr, RPL_WHOISIDLE, name, CurrentTime - user->last,
+
+ if (MyConnect(acptr) && (!feature_bool(FEAT_HIS_WHOIS_IDLETIME) ||
+ (sptr == acptr || IsAnOper(sptr) || parc >= 3)))
+ send_reply(sptr, RPL_WHOISIDLE, name, CurrentTime - user->last,
cli_firsttime(acptr));
}
}
{
struct Client *acptr; /* Current client we're concidering */
struct User *user; /* the user portion of the client */
- char *name; /* the name of this client */
+ const char *name; /* the name of this client */
struct Membership* chan;
int invis; /* does +i apply? */
int member; /* Is this user on any channels? */
char* p = 0;
int found = 0;
int total = 0;
+ int wildscount = 0;
if (parc < 2)
{
if (parc > 2)
{
- struct Client *acptr;
/* For convenience: Accept a nickname as first parameter, by replacing
* 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 (feature_int(FEAT_HIS_REMOTE))
+ {
+ /* If remote queries are disabled, then use the *second* parameter of
+ * of whois, so /whois nick nick still works.
+ */
+ if (!IsAnOper(sptr))
+ {
+ if (!FindUser(parv[2]))
+ {
+ send_reply(sptr, ERR_NOSUCHNICK, parv[2]);
+ send_reply(sptr, RPL_ENDOFWHOIS, parv[2]);
+ return 0;
+ }
+ parv[1] = parv[2];
+ }
+ }
+
if (hunt_server_cmd(sptr, CMD_WHOIS, cptr, 0, "%C :%s", 1, parc, parv) !=
- HUNTED_ISME)
- return 0;
+ HUNTED_ISME)
+ return 0;
+
parv[1] = parv[2];
}
}
}
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);
if (parc > 2)
{
- struct Client *acptr;
- /* For convenience: Accept a nickname as first parameter, by replacing
- * it with the correct servername - as is needed by hunt_server().
- * This is the secret behind the /whois nick nick trick.
- */
- acptr = FindUser(parv[1]);
- if (acptr)
- parv[1] = cli_name(cli_user(acptr)->server);
if (hunt_server_cmd(sptr, CMD_WHOIS, cptr, 0, "%C :%s", 1, parc, parv) !=
HUNTED_ISME)
return 0;
return 0;
}
+