1 |
/* |
2 |
* ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). |
3 |
* |
4 |
* Copyright (C) 2002 by the past and present ircd coders, and others. |
5 |
* |
6 |
* This program is free software; you can redistribute it and/or modify |
7 |
* it under the terms of the GNU General Public License as published by |
8 |
* the Free Software Foundation; either version 2 of the License, or |
9 |
* (at your option) any later version. |
10 |
* |
11 |
* This program is distributed in the hope that it will be useful, |
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
* GNU General Public License for more details. |
15 |
* |
16 |
* You should have received a copy of the GNU General Public License |
17 |
* along with this program; if not, write to the Free Software |
18 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
19 |
* USA |
20 |
*/ |
21 |
|
22 |
/*! \file m_admin.c |
23 |
* \brief Includes required functions for processing the ADMIN command. |
24 |
* \version $Id$ |
25 |
*/ |
26 |
|
27 |
#include "stdinc.h" |
28 |
#include "client.h" |
29 |
#include "ircd.h" |
30 |
#include "numeric.h" |
31 |
#include "conf.h" |
32 |
#include "s_serv.h" |
33 |
#include "send.h" |
34 |
#include "parse.h" |
35 |
#include "modules.h" |
36 |
#include "irc_string.h" |
37 |
|
38 |
|
39 |
|
40 |
/*! \brief Sends administrative information about this server. |
41 |
* |
42 |
* \param source_p Pointer to client to report to |
43 |
*/ |
44 |
static void |
45 |
do_admin(struct Client *source_p) |
46 |
{ |
47 |
const char *me_name = ID_or_name(&me, source_p->from); |
48 |
const char *nick = ID_or_name(source_p, source_p->from); |
49 |
|
50 |
sendto_realops_flags(UMODE_SPY, L_ALL, SEND_NOTICE, |
51 |
"ADMIN requested by %s (%s@%s) [%s]", |
52 |
source_p->name, source_p->username, |
53 |
source_p->host, source_p->servptr->name); |
54 |
|
55 |
sendto_one(source_p, RPL_ADMINME, |
56 |
me_name, nick, me.name); |
57 |
|
58 |
if (AdminInfo.name != NULL) |
59 |
sendto_one(source_p, RPL_ADMINLOC1, |
60 |
me_name, nick, AdminInfo.name); |
61 |
if (AdminInfo.description != NULL) |
62 |
sendto_one(source_p, RPL_ADMINLOC2, |
63 |
me_name, nick, AdminInfo.description); |
64 |
if (AdminInfo.email != NULL) |
65 |
sendto_one(source_p, RPL_ADMINEMAIL, |
66 |
me_name, nick, AdminInfo.email); |
67 |
} |
68 |
|
69 |
/*! \brief NICK command handler (called by already registered, |
70 |
* locally connected clients) |
71 |
* |
72 |
* \param client_p Pointer to allocated Client struct with physical connection |
73 |
* to this server, i.e. with an open socket connected. |
74 |
* \param source_p Pointer to allocated Client struct from which the message |
75 |
* originally comes from. This can be a local or remote client. |
76 |
* \param parc Integer holding the number of supplied arguments. |
77 |
* \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL |
78 |
* pointers. |
79 |
* \note Valid arguments for this command are: |
80 |
* - parv[0] = sender prefix |
81 |
* - parv[1] = nickname/servername |
82 |
*/ |
83 |
static void |
84 |
m_admin(struct Client *client_p, struct Client *source_p, |
85 |
int parc, char *parv[]) |
86 |
{ |
87 |
static time_t last_used = 0; |
88 |
|
89 |
if ((last_used + ConfigFileEntry.pace_wait_simple) > CurrentTime) |
90 |
{ |
91 |
sendto_one(source_p, RPL_LOAD2HI, |
92 |
me.name, source_p->name); |
93 |
return; |
94 |
} |
95 |
|
96 |
last_used = CurrentTime; |
97 |
|
98 |
if (!ConfigFileEntry.disable_remote) |
99 |
if (hunt_server(client_p, source_p, ":%s ADMIN :%s", 1, |
100 |
parc, parv) != HUNTED_ISME) |
101 |
return; |
102 |
|
103 |
do_admin(source_p); |
104 |
} |
105 |
|
106 |
/*! \brief ADMIN command handler (called by operators and |
107 |
* remotely connected clients) |
108 |
* |
109 |
* \param client_p Pointer to allocated Client struct with physical connection |
110 |
* to this server, i.e. with an open socket connected. |
111 |
* \param source_p Pointer to allocated Client struct from which the message |
112 |
* originally comes from. This can be a local or remote client. |
113 |
* \param parc Integer holding the number of supplied arguments. |
114 |
* \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL |
115 |
* pointers. |
116 |
* \note Valid arguments for this command are: |
117 |
* - parv[0] = sender prefix |
118 |
* - parv[1] = nickname/servername |
119 |
*/ |
120 |
static void |
121 |
ms_admin(struct Client *client_p, struct Client *source_p, |
122 |
int parc, char *parv[]) |
123 |
{ |
124 |
if (hunt_server(client_p, source_p, ":%s ADMIN :%s", 1, |
125 |
parc, parv) != HUNTED_ISME) |
126 |
return; |
127 |
|
128 |
if (IsClient(source_p)) |
129 |
do_admin(source_p); |
130 |
} |
131 |
|
132 |
static struct Message admin_msgtab = { |
133 |
"ADMIN", 0, 0, 0, MAXPARA, MFLG_SLOW, 0, |
134 |
{ m_unregistered, m_admin, ms_admin, m_ignore, ms_admin, m_ignore } |
135 |
}; |
136 |
|
137 |
static void |
138 |
module_init(void) |
139 |
{ |
140 |
mod_add_cmd(&admin_msgtab); |
141 |
} |
142 |
|
143 |
static void |
144 |
module_exit(void) |
145 |
{ |
146 |
mod_del_cmd(&admin_msgtab); |
147 |
} |
148 |
|
149 |
struct module module_entry = { |
150 |
.node = { NULL, NULL, NULL }, |
151 |
.name = NULL, |
152 |
.version = "$Revision$", |
153 |
.handle = NULL, |
154 |
.modinit = module_init, |
155 |
.modexit = module_exit, |
156 |
.flags = 0 |
157 |
}; |