1 |
/* |
2 |
* ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). |
3 |
* m_lusers.c: Sends user statistics. |
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 |
* $Id$ |
23 |
*/ |
24 |
|
25 |
#include "stdinc.h" |
26 |
#include "handlers.h" |
27 |
#include "client.h" |
28 |
#include "ircd.h" |
29 |
#include "numeric.h" |
30 |
#include "s_serv.h" /* hunt_server */ |
31 |
#include "s_user.h" /* show_lusers */ |
32 |
#include "send.h" |
33 |
#include "s_conf.h" |
34 |
#include "msg.h" |
35 |
#include "parse.h" |
36 |
#include "modules.h" |
37 |
|
38 |
/* XXX LazyLinks ? */ |
39 |
|
40 |
static void m_lusers(struct Client*, struct Client*, int, char**); |
41 |
static void ms_lusers(struct Client*, struct Client*, int, char**); |
42 |
|
43 |
struct Message lusers_msgtab = { |
44 |
"LUSERS", 0, 0, 0, 0, MFLG_SLOW, 0, |
45 |
{m_unregistered, m_lusers, ms_lusers, m_ignore, ms_lusers, m_ignore} |
46 |
}; |
47 |
#ifndef STATIC_MODULES |
48 |
|
49 |
void |
50 |
_modinit(void) |
51 |
{ |
52 |
mod_add_cmd(&lusers_msgtab); |
53 |
} |
54 |
|
55 |
void |
56 |
_moddeinit(void) |
57 |
{ |
58 |
mod_del_cmd(&lusers_msgtab); |
59 |
} |
60 |
|
61 |
const char *_version = "$Revision$"; |
62 |
#endif |
63 |
/* m_lusers - LUSERS message handler |
64 |
* parv[0] = sender |
65 |
* parv[1] = host/server mask. |
66 |
* parv[2] = server to query |
67 |
* |
68 |
* 199970918 JRL hacked to ignore parv[1] completely and require parc > 3 |
69 |
* to cause a force |
70 |
* |
71 |
* 2003 hacked parv[1] back in, by request of efnet admins/opers -Dianora |
72 |
*/ |
73 |
static void |
74 |
m_lusers(struct Client *client_p, struct Client *source_p, |
75 |
int parc, char *parv[]) |
76 |
{ |
77 |
static time_t last_used = 0; |
78 |
|
79 |
if ((last_used + ConfigFileEntry.pace_wait_simple) > CurrentTime) |
80 |
{ |
81 |
/* safe enough to give this on a local connect only */ |
82 |
if (MyClient(source_p)) |
83 |
sendto_one(source_p, form_str(RPL_LOAD2HI), me.name, parv[0]); |
84 |
return; |
85 |
} |
86 |
else |
87 |
last_used = CurrentTime; |
88 |
|
89 |
if (parc > 2 && !ConfigFileEntry.disable_remote) |
90 |
{ |
91 |
if (hunt_server(client_p, source_p, ":%s LUSERS %s :%s", 2, parc, parv) != HUNTED_ISME) |
92 |
return; |
93 |
} |
94 |
|
95 |
show_lusers(source_p); |
96 |
} |
97 |
|
98 |
/* ms_lusers - LUSERS message handler for servers and opers |
99 |
* parv[0] = sender |
100 |
* parv[1] = host/server mask. |
101 |
* parv[2] = server to query |
102 |
*/ |
103 |
static void |
104 |
ms_lusers(struct Client *client_p, struct Client *source_p, |
105 |
int parc, char *parv[]) |
106 |
{ |
107 |
if (parc > 2) |
108 |
{ |
109 |
if(hunt_server(client_p, source_p, ":%s LUSERS %s :%s", 2, parc, parv) |
110 |
!= HUNTED_ISME) |
111 |
return; |
112 |
} |
113 |
|
114 |
if (IsClient(source_p)) |
115 |
show_lusers(source_p); |
116 |
} |