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

Contents of /ircd-hybrid-8/modules/m_admin.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1178 - (show annotations)
Mon Aug 15 08:11:31 2011 UTC (8 years, 3 months ago) by michael
File MIME type: text/x-chdr
File size: 6093 byte(s)
- Cleanup and restore older parts of the irc-command parser.
  Gives back ability to specify maximum amount of parameters
  that are processed within a command.

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 "handlers.h"
29 #include "client.h"
30 #include "ircd.h"
31 #include "numeric.h"
32 #include "s_conf.h"
33 #include "s_serv.h"
34 #include "send.h"
35 #include "msg.h"
36 #include "parse.h"
37 #include "modules.h"
38 #include "irc_string.h"
39
40 static void m_admin(struct Client *, struct Client *, int, char *[]);
41 static void mr_admin(struct Client *, struct Client *, int, char *[]);
42 static void ms_admin(struct Client *, struct Client *, int, char *[]);
43 static void do_admin(struct Client *);
44
45 struct Message admin_msgtab = {
46 "ADMIN", 0, 0, 0, MAXPARA, MFLG_SLOW | MFLG_UNREG, 0,
47 {mr_admin, m_admin, ms_admin, m_ignore, ms_admin, m_ignore}
48 };
49
50 const char *_version = "$Revision$";
51
52 void
53 _modinit(void)
54 {
55 mod_add_cmd(&admin_msgtab);
56 }
57
58 void
59 _moddeinit(void)
60 {
61 mod_del_cmd(&admin_msgtab);
62 }
63
64 /*! \brief ADMIN command handler (called by unregistered,
65 * locally connected clients)
66 *
67 * \param client_p Pointer to allocated Client struct with physical connection
68 * to this server, i.e. with an open socket connected.
69 * \param source_p Pointer to allocated Client struct from which the message
70 * originally comes from. This can be a local or remote client.
71 * \param parc Integer holding the number of supplied arguments.
72 * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
73 * pointers.
74 * \note Valid arguments for this command are:
75 * - parv[0] = sender prefix
76 */
77 static void
78 mr_admin(struct Client *client_p, struct Client *source_p,
79 int parc, char *parv[])
80 {
81 static time_t last_used = 0;
82
83 ClearCap(client_p, CAP_TS6);
84
85 if ((last_used + ConfigFileEntry.pace_wait_simple) > CurrentTime)
86 {
87 sendto_one(source_p, form_str(RPL_LOAD2HI),
88 me.name, EmptyString(parv[0]) ? "*" : parv[0]);
89 return;
90 }
91
92 last_used = CurrentTime;
93
94 do_admin(source_p);
95 }
96
97 /*! \brief NICK command handler (called by already registered,
98 * locally connected clients)
99 *
100 * \param client_p Pointer to allocated Client struct with physical connection
101 * to this server, i.e. with an open socket connected.
102 * \param source_p Pointer to allocated Client struct from which the message
103 * originally comes from. This can be a local or remote client.
104 * \param parc Integer holding the number of supplied arguments.
105 * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
106 * pointers.
107 * \note Valid arguments for this command are:
108 * - parv[0] = sender prefix
109 * - parv[1] = nickname/servername
110 */
111 static void
112 m_admin(struct Client *client_p, struct Client *source_p,
113 int parc, char *parv[])
114 {
115 static time_t last_used = 0;
116
117 if ((last_used + ConfigFileEntry.pace_wait_simple) > CurrentTime)
118 {
119 sendto_one(source_p,form_str(RPL_LOAD2HI),
120 me.name, source_p->name);
121 return;
122 }
123
124 last_used = CurrentTime;
125
126 if (!ConfigFileEntry.disable_remote)
127 if (hunt_server(client_p, source_p, ":%s ADMIN :%s", 1,
128 parc, parv) != HUNTED_ISME)
129 return;
130
131 do_admin(source_p);
132 }
133
134 /*! \brief ADMIN command handler (called by operators and
135 * remotely connected clients)
136 *
137 * \param client_p Pointer to allocated Client struct with physical connection
138 * to this server, i.e. with an open socket connected.
139 * \param source_p Pointer to allocated Client struct from which the message
140 * originally comes from. This can be a local or remote client.
141 * \param parc Integer holding the number of supplied arguments.
142 * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
143 * pointers.
144 * \note Valid arguments for this command are:
145 * - parv[0] = sender prefix
146 * - parv[1] = nickname/servername
147 */
148 static void
149 ms_admin(struct Client *client_p, struct Client *source_p,
150 int parc, char *parv[])
151 {
152 if (hunt_server(client_p, source_p, ":%s ADMIN :%s", 1,
153 parc, parv) != HUNTED_ISME)
154 return;
155
156 if (IsClient(source_p))
157 do_admin(source_p);
158 }
159
160 /*! \brief Sends administrative information about this server.
161 *
162 * \param source_p Pointer to client to report to
163 */
164 static void
165 do_admin(struct Client *source_p)
166 {
167 const char *me_name;
168 const char *nick;
169
170 sendto_realops_flags(UMODE_SPY, L_ALL,
171 "ADMIN requested by %s (%s@%s) [%s]",
172 source_p->name, source_p->username,
173 source_p->host, source_p->servptr->name);
174
175 me_name = ID_or_name(&me, source_p->from);
176 nick = ID_or_name(source_p, source_p->from);
177
178 sendto_one(source_p, form_str(RPL_ADMINME),
179 me_name, nick, me.name);
180 if (AdminInfo.name != NULL)
181 sendto_one(source_p, form_str(RPL_ADMINLOC1),
182 me_name, nick, AdminInfo.name);
183 if (AdminInfo.description != NULL)
184 sendto_one(source_p, form_str(RPL_ADMINLOC2),
185 me_name, nick, AdminInfo.description);
186 if (AdminInfo.email != NULL)
187 sendto_one(source_p, form_str(RPL_ADMINEMAIL),
188 me_name, nick, AdminInfo.email);
189 }

Properties

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

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