2007-01-25 07:40:21 +01:00
|
|
|
/*
|
|
|
|
* ircd-ratbox: A slightly useful ircd.
|
|
|
|
* m_whois.c: Shows who a user was.
|
|
|
|
*
|
|
|
|
* Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
|
|
|
|
* Copyright (C) 1996-2002 Hybrid Development Team
|
|
|
|
* Copyright (C) 2002-2005 ircd-ratbox development team
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
* USA
|
|
|
|
*
|
|
|
|
* $Id: m_whowas.c 1717 2006-07-04 14:41:11Z jilles $
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "stdinc.h"
|
|
|
|
#include "whowas.h"
|
|
|
|
#include "client.h"
|
|
|
|
#include "common.h"
|
|
|
|
#include "hash.h"
|
2008-04-20 07:47:38 +02:00
|
|
|
#include "match.h"
|
2007-01-25 07:40:21 +01:00
|
|
|
#include "ircd.h"
|
|
|
|
#include "ircd_defs.h"
|
|
|
|
#include "numeric.h"
|
|
|
|
#include "s_serv.h"
|
|
|
|
#include "s_user.h"
|
|
|
|
#include "send.h"
|
|
|
|
#include "s_conf.h"
|
|
|
|
#include "msg.h"
|
|
|
|
#include "parse.h"
|
|
|
|
#include "modules.h"
|
|
|
|
|
|
|
|
static int m_whowas(struct Client *, struct Client *, int, const char **);
|
|
|
|
|
|
|
|
struct Message whowas_msgtab = {
|
|
|
|
"WHOWAS", 0, 0, 0, MFLG_SLOW,
|
2013-09-13 22:29:26 +02:00
|
|
|
{mg_unreg, {m_whowas, 2}, {m_whowas, 4}, mg_ignore, mg_ignore, {m_whowas, 2}}
|
2007-01-25 07:40:21 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
mapi_clist_av1 whowas_clist[] = { &whowas_msgtab, NULL };
|
|
|
|
DECLARE_MODULE_AV1(whowas, NULL, NULL, whowas_clist, NULL, NULL, "$Revision: 1717 $");
|
|
|
|
|
|
|
|
/*
|
|
|
|
** m_whowas
|
|
|
|
** parv[1] = nickname queried
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
m_whowas(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
|
|
|
{
|
|
|
|
struct Whowas *temp;
|
|
|
|
int cur = 0;
|
|
|
|
int max = -1, found = 0;
|
|
|
|
char *p;
|
|
|
|
const char *nick;
|
2008-04-20 07:03:39 +02:00
|
|
|
char tbuf[26];
|
2013-02-02 00:50:03 +01:00
|
|
|
long sendq_limit;
|
2007-01-25 07:40:21 +01:00
|
|
|
|
|
|
|
static time_t last_used = 0L;
|
|
|
|
|
2013-09-13 22:29:26 +02:00
|
|
|
if(MyClient(source_p) && !IsOper(source_p))
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2013-09-13 22:29:26 +02:00
|
|
|
if(last_used + (parc > 3 ? ConfigFileEntry.pace_wait :
|
|
|
|
ConfigFileEntry.pace_wait_simple
|
|
|
|
) > rb_current_time())
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
|
|
|
sendto_one(source_p, form_str(RPL_LOAD2HI),
|
|
|
|
me.name, source_p->name, "WHOWAS");
|
|
|
|
sendto_one(source_p, form_str(RPL_ENDOFWHOWAS),
|
|
|
|
me.name, source_p->name, parv[1]);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else
|
2008-04-02 01:53:20 +02:00
|
|
|
last_used = rb_current_time();
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(parc > 2)
|
|
|
|
max = atoi(parv[2]);
|
|
|
|
|
|
|
|
if(parc > 3)
|
|
|
|
if(hunt_server(client_p, source_p, ":%s WHOWAS %s %s :%s", 3, parc, parv))
|
|
|
|
return 0;
|
2013-09-13 22:29:26 +02:00
|
|
|
|
|
|
|
if(!MyClient(source_p) && (max <= 0 || max > 20))
|
|
|
|
max = 20;
|
2007-01-25 07:40:21 +01:00
|
|
|
|
|
|
|
if((p = strchr(parv[1], ',')))
|
|
|
|
*p = '\0';
|
|
|
|
|
|
|
|
nick = parv[1];
|
|
|
|
|
2013-02-02 00:50:03 +01:00
|
|
|
sendq_limit = get_sendq(client_p) * 9 / 10;
|
|
|
|
|
2007-01-25 07:40:21 +01:00
|
|
|
temp = WHOWASHASH[hash_whowas_name(nick)];
|
|
|
|
found = 0;
|
|
|
|
for (; temp; temp = temp->next)
|
|
|
|
{
|
|
|
|
if(!irccmp(nick, temp->name))
|
|
|
|
{
|
2013-02-02 00:50:03 +01:00
|
|
|
if(cur > 0 && rb_linebuf_len(&client_p->localClient->buf_sendq) > sendq_limit)
|
|
|
|
{
|
|
|
|
sendto_one(source_p, form_str(ERR_TOOMANYMATCHES),
|
|
|
|
me.name, source_p->name, "WHOWAS");
|
|
|
|
break;
|
|
|
|
}
|
2007-01-25 07:40:21 +01:00
|
|
|
sendto_one(source_p, form_str(RPL_WHOWASUSER),
|
|
|
|
me.name, source_p->name, temp->name,
|
|
|
|
temp->username, temp->hostname, temp->realname);
|
|
|
|
if (MyOper(source_p) && !EmptyString(temp->sockhost))
|
|
|
|
#if 0
|
|
|
|
sendto_one(source_p, form_str(RPL_WHOWASREAL),
|
|
|
|
me.name, source_p->name, temp->name,
|
|
|
|
"<untracked>", temp->sockhost);
|
|
|
|
#else
|
|
|
|
sendto_one_numeric(source_p, RPL_WHOISACTUALLY,
|
|
|
|
form_str(RPL_WHOISACTUALLY),
|
|
|
|
temp->name, temp->sockhost);
|
|
|
|
#endif
|
2010-08-29 22:30:54 +02:00
|
|
|
if (!EmptyString(temp->suser))
|
|
|
|
sendto_one_numeric(source_p, RPL_WHOISLOGGEDIN,
|
|
|
|
"%s %s :was logged in as",
|
|
|
|
temp->name, temp->suser);
|
2007-01-25 07:40:21 +01:00
|
|
|
sendto_one_numeric(source_p, RPL_WHOISSERVER,
|
|
|
|
form_str(RPL_WHOISSERVER),
|
|
|
|
temp->name, temp->servername,
|
2008-04-20 07:03:39 +02:00
|
|
|
rb_ctime(temp->logoff, tbuf, sizeof(tbuf)));
|
2007-01-25 07:40:21 +01:00
|
|
|
cur++;
|
|
|
|
found++;
|
|
|
|
}
|
|
|
|
if(max > 0 && cur >= max)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!found)
|
|
|
|
sendto_one(source_p, form_str(ERR_WASNOSUCHNICK),
|
|
|
|
me.name, source_p->name, nick);
|
|
|
|
|
|
|
|
sendto_one(source_p, form_str(RPL_ENDOFWHOWAS),
|
|
|
|
me.name, source_p->name, parv[1]);
|
|
|
|
return 0;
|
|
|
|
}
|