| 1 |
adx |
30 |
/* |
| 2 |
|
|
* ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). |
| 3 |
|
|
* m_whois.c: Shows who a user was. |
| 4 |
|
|
* |
| 5 |
|
|
* Copyright (C) 2002 by the past and present ircd coders, and others. |
| 6 |
|
|
* |
| 7 |
|
|
* This program is free software; you can redistribute it and/or modify |
| 8 |
|
|
* it under the terms of the GNU General Public License as published by |
| 9 |
|
|
* the Free Software Foundation; either version 2 of the License, or |
| 10 |
|
|
* (at your option) any later version. |
| 11 |
|
|
* |
| 12 |
|
|
* This program is distributed in the hope that it will be useful, |
| 13 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
|
|
* GNU General Public License for more details. |
| 16 |
|
|
* |
| 17 |
|
|
* You should have received a copy of the GNU General Public License |
| 18 |
|
|
* along with this program; if not, write to the Free Software |
| 19 |
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
| 20 |
|
|
* USA |
| 21 |
|
|
* |
| 22 |
knight |
31 |
* $Id$ |
| 23 |
adx |
30 |
*/ |
| 24 |
|
|
|
| 25 |
|
|
#include "stdinc.h" |
| 26 |
michael |
1358 |
#include "list.h" |
| 27 |
adx |
30 |
#include "whowas.h" |
| 28 |
|
|
#include "client.h" |
| 29 |
|
|
#include "hash.h" |
| 30 |
|
|
#include "irc_string.h" |
| 31 |
|
|
#include "ircd.h" |
| 32 |
|
|
#include "ircd_defs.h" |
| 33 |
|
|
#include "numeric.h" |
| 34 |
|
|
#include "s_serv.h" |
| 35 |
|
|
#include "s_user.h" |
| 36 |
|
|
#include "send.h" |
| 37 |
michael |
1309 |
#include "conf.h" |
| 38 |
adx |
30 |
#include "parse.h" |
| 39 |
|
|
#include "modules.h" |
| 40 |
|
|
|
| 41 |
|
|
|
| 42 |
|
|
static void |
| 43 |
|
|
whowas_do(struct Client *client_p, struct Client *source_p, |
| 44 |
michael |
1857 |
const int parc, char *parv[]) |
| 45 |
adx |
30 |
{ |
| 46 |
|
|
int cur = 0; |
| 47 |
|
|
int max = -1; |
| 48 |
michael |
1358 |
const dlink_node *ptr = NULL; |
| 49 |
adx |
30 |
|
| 50 |
michael |
2076 |
if (parc > 3 && !EmptyString(parv[3])) |
| 51 |
michael |
143 |
if (hunt_server(client_p, source_p, ":%s WHOWAS %s %s :%s", 3, |
| 52 |
|
|
parc, parv) != HUNTED_ISME) |
| 53 |
adx |
30 |
return; |
| 54 |
|
|
|
| 55 |
michael |
2076 |
if (parc > 2 && !EmptyString(parv[2])) |
| 56 |
|
|
if ((max = atoi(parv[2])) > 20 && !MyConnect(source_p)) |
| 57 |
|
|
max = 20; |
| 58 |
adx |
30 |
|
| 59 |
michael |
2076 |
DLINK_FOREACH(ptr, WHOWASHASH[strhash(parv[1])].head) |
| 60 |
michael |
1358 |
{ |
| 61 |
|
|
const struct Whowas *temp = ptr->data; |
| 62 |
adx |
30 |
|
| 63 |
michael |
2076 |
if (!irccmp(parv[1], temp->name)) |
| 64 |
adx |
30 |
{ |
| 65 |
michael |
1834 |
sendto_one(source_p, form_str(RPL_WHOWASUSER), |
| 66 |
adx |
30 |
me.name, source_p->name, temp->name, |
| 67 |
|
|
temp->username, temp->hostname, |
| 68 |
|
|
temp->realname); |
| 69 |
|
|
|
| 70 |
michael |
1219 |
if (ConfigServerHide.hide_servers && !HasUMode(source_p, UMODE_OPER)) |
| 71 |
michael |
2076 |
sendto_one(source_p, form_str(RPL_WHOISSERVER), me.name, |
| 72 |
|
|
source_p->name, temp->name, |
| 73 |
adx |
30 |
ServerInfo.network_name, myctime(temp->logoff)); |
| 74 |
|
|
else |
| 75 |
michael |
2076 |
sendto_one(source_p, form_str(RPL_WHOISSERVER), me.name, |
| 76 |
|
|
source_p->name, temp->name, |
| 77 |
adx |
30 |
temp->servername, myctime(temp->logoff)); |
| 78 |
michael |
1358 |
++cur; |
| 79 |
adx |
30 |
} |
| 80 |
|
|
|
| 81 |
|
|
if (max > 0 && cur >= max) |
| 82 |
|
|
break; |
| 83 |
|
|
} |
| 84 |
|
|
|
| 85 |
|
|
if (!cur) |
| 86 |
michael |
1834 |
sendto_one(source_p, form_str(ERR_WASNOSUCHNICK), |
| 87 |
michael |
2076 |
me.name, source_p->name, parv[1]); |
| 88 |
adx |
30 |
|
| 89 |
michael |
1834 |
sendto_one(source_p, form_str(RPL_ENDOFWHOWAS), |
| 90 |
adx |
30 |
me.name, source_p->name, parv[1]); |
| 91 |
|
|
} |
| 92 |
michael |
1230 |
|
| 93 |
|
|
/* |
| 94 |
|
|
** m_whowas |
| 95 |
|
|
** parv[0] = sender prefix |
| 96 |
|
|
** parv[1] = nickname queried |
| 97 |
|
|
*/ |
| 98 |
|
|
static void |
| 99 |
|
|
m_whowas(struct Client *client_p, struct Client *source_p, |
| 100 |
|
|
int parc, char *parv[]) |
| 101 |
|
|
{ |
| 102 |
|
|
static time_t last_used = 0; |
| 103 |
|
|
|
| 104 |
|
|
if (parc < 2 || EmptyString(parv[1])) |
| 105 |
|
|
{ |
| 106 |
michael |
1834 |
sendto_one(source_p, form_str(ERR_NONICKNAMEGIVEN), |
| 107 |
michael |
1230 |
me.name, source_p->name); |
| 108 |
|
|
return; |
| 109 |
|
|
} |
| 110 |
|
|
|
| 111 |
|
|
if ((last_used + ConfigFileEntry.pace_wait) > CurrentTime) |
| 112 |
|
|
{ |
| 113 |
michael |
1834 |
sendto_one(source_p,form_str(RPL_LOAD2HI), |
| 114 |
michael |
1230 |
me.name, source_p->name); |
| 115 |
|
|
return; |
| 116 |
|
|
} |
| 117 |
|
|
|
| 118 |
|
|
last_used = CurrentTime; |
| 119 |
|
|
|
| 120 |
|
|
whowas_do(client_p, source_p, parc, parv); |
| 121 |
|
|
} |
| 122 |
|
|
|
| 123 |
|
|
static void |
| 124 |
|
|
mo_whowas(struct Client *client_p, struct Client *source_p, |
| 125 |
|
|
int parc, char *parv[]) |
| 126 |
|
|
{ |
| 127 |
|
|
if (parc < 2 || EmptyString(parv[1])) |
| 128 |
|
|
{ |
| 129 |
michael |
1834 |
sendto_one(source_p, form_str(ERR_NONICKNAMEGIVEN), |
| 130 |
michael |
1230 |
me.name, source_p->name); |
| 131 |
|
|
return; |
| 132 |
|
|
} |
| 133 |
|
|
|
| 134 |
|
|
whowas_do(client_p, source_p, parc, parv); |
| 135 |
|
|
} |
| 136 |
|
|
|
| 137 |
|
|
static struct Message whowas_msgtab = { |
| 138 |
|
|
"WHOWAS", 0, 0, 0, MAXPARA, MFLG_SLOW, 0, |
| 139 |
|
|
{ m_unregistered, m_whowas, mo_whowas, m_ignore, mo_whowas, m_ignore } |
| 140 |
|
|
}; |
| 141 |
|
|
|
| 142 |
|
|
static void |
| 143 |
|
|
module_init(void) |
| 144 |
|
|
{ |
| 145 |
|
|
mod_add_cmd(&whowas_msgtab); |
| 146 |
|
|
} |
| 147 |
|
|
|
| 148 |
|
|
static void |
| 149 |
|
|
module_exit(void) |
| 150 |
|
|
{ |
| 151 |
|
|
mod_del_cmd(&whowas_msgtab); |
| 152 |
|
|
} |
| 153 |
|
|
|
| 154 |
|
|
struct module module_entry = { |
| 155 |
|
|
.node = { NULL, NULL, NULL }, |
| 156 |
|
|
.name = NULL, |
| 157 |
|
|
.version = "$Revision$", |
| 158 |
|
|
.handle = NULL, |
| 159 |
|
|
.modinit = module_init, |
| 160 |
|
|
.modexit = module_exit, |
| 161 |
|
|
.flags = 0 |
| 162 |
|
|
}; |