/[svn]/ircd-hybrid-8/modules/m_whowas.c
ViewVC logotype

Annotation of /ircd-hybrid-8/modules/m_whowas.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 269 - (hide annotations)
Mon Nov 14 19:39:09 2005 UTC (14 years, 1 month ago) by adx
Original Path: ircd-hybrid-7.2/modules/m_whowas.c
File MIME type: text/x-chdr
File size: 4373 byte(s)
+ more rate limiting fixes
+ update RELNOTES

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     #include "whowas.h"
27     #include "handlers.h"
28     #include "client.h"
29     #include "common.h"
30     #include "hash.h"
31     #include "irc_string.h"
32     #include "ircd.h"
33     #include "ircd_defs.h"
34     #include "numeric.h"
35     #include "s_serv.h"
36     #include "s_user.h"
37     #include "send.h"
38     #include "s_conf.h"
39     #include "msg.h"
40     #include "parse.h"
41     #include "modules.h"
42    
43    
44     static void m_whowas(struct Client *, struct Client *, int, char *[]);
45     static void mo_whowas(struct Client *, struct Client *, int, char *[]);
46     static void whowas_do(struct Client *, struct Client *, int, char *[]);
47    
48     struct Message whowas_msgtab = {
49     "WHOWAS", 0, 0, 0, 0, MFLG_SLOW, 0,
50 michael 143 { m_unregistered, m_whowas, mo_whowas, m_ignore, mo_whowas, m_ignore }
51 adx 30 };
52    
53     #ifndef STATIC_MODULES
54     void
55     _modinit(void)
56     {
57     mod_add_cmd(&whowas_msgtab);
58     }
59    
60     void
61     _moddeinit(void)
62     {
63     mod_del_cmd(&whowas_msgtab);
64     }
65    
66 knight 31 const char *_version = "$Revision$";
67 adx 30 #endif
68    
69     /*
70     ** m_whowas
71     ** parv[0] = sender prefix
72     ** parv[1] = nickname queried
73     */
74     static void
75     m_whowas(struct Client *client_p, struct Client *source_p,
76     int parc, char *parv[])
77     {
78     static time_t last_used = 0;
79    
80     if (parc < 2 || *parv[1] == '\0')
81     {
82     sendto_one(source_p, form_str(ERR_NONICKNAMEGIVEN),
83     me.name, source_p->name);
84     return;
85     }
86    
87 adx 269 if ((last_used + ConfigFileEntry.pace_wait) > CurrentTime)
88 adx 30 {
89     sendto_one(source_p,form_str(RPL_LOAD2HI),
90     me.name, source_p->name);
91     return;
92     }
93     else
94     last_used = CurrentTime;
95    
96     whowas_do(client_p, source_p, parc, parv);
97     }
98    
99     static void
100     mo_whowas(struct Client *client_p, struct Client *source_p,
101     int parc, char *parv[])
102     {
103     if (parc < 2 || *parv[1] == '\0')
104     {
105     sendto_one(source_p, form_str(ERR_NONICKNAMEGIVEN),
106     me.name, source_p->name);
107     return;
108     }
109    
110     whowas_do(client_p, source_p, parc, parv);
111     }
112    
113     static void
114     whowas_do(struct Client *client_p, struct Client *source_p,
115     int parc, char *parv[])
116     {
117     struct Whowas *temp = NULL;
118     int cur = 0;
119     int max = -1;
120 michael 143 char *p = NULL, *nick = NULL;
121 adx 30
122     if (parc > 2)
123 michael 145 {
124 adx 30 max = atoi(parv[2]);
125 michael 143
126 michael 145 if (!MyConnect(source_p) && max > 20)
127     max = 20;
128     }
129    
130 adx 30 if (parc > 3)
131 michael 143 if (hunt_server(client_p, source_p, ":%s WHOWAS %s %s :%s", 3,
132     parc, parv) != HUNTED_ISME)
133 adx 30 return;
134    
135     nick = parv[1];
136     while (*nick == ',')
137     nick++;
138     if ((p = strchr(nick,',')) != NULL)
139     *p = '\0';
140     if (*nick == '\0')
141     return;
142    
143     temp = WHOWASHASH[strhash(nick)];
144    
145     for (; temp; temp = temp->next)
146     {
147     if (irccmp(nick, temp->name) == 0)
148     {
149     sendto_one(source_p, form_str(RPL_WHOWASUSER),
150     me.name, source_p->name, temp->name,
151     temp->username, temp->hostname,
152     temp->realname);
153    
154     if (ConfigServerHide.hide_servers && !IsOper(source_p))
155     sendto_one(source_p, form_str(RPL_WHOISSERVER),
156     me.name, source_p->name, temp->name,
157     ServerInfo.network_name, myctime(temp->logoff));
158     else
159     sendto_one(source_p, form_str(RPL_WHOISSERVER),
160     me.name, source_p->name, temp->name,
161     temp->servername, myctime(temp->logoff));
162     cur++;
163     }
164    
165     if (max > 0 && cur >= max)
166     break;
167     }
168    
169     if (!cur)
170     sendto_one(source_p, form_str(ERR_WASNOSUCHNICK),
171     me.name, source_p->name, nick);
172    
173     sendto_one(source_p, form_str(RPL_ENDOFWHOWAS),
174     me.name, source_p->name, parv[1]);
175     }

Properties

Name Value
svn:eol-style native
svn:keywords Id Revision

svnadmin@ircd-hybrid.org
ViewVC Help
Powered by ViewVC 1.1.26