ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_admin.c
Revision: 1243
Committed: Fri Sep 30 10:47:53 2011 UTC (13 years, 10 months ago) by michael
Content type: text/x-csrc
Original Path: ircd-hybrid-8/modules/m_admin.c
File size: 6020 byte(s)
Log Message:
- move content of msg.h, ircd_handler.h and handlers.h into parse.h and
  remove headers accordingly
- killed common.h
- remove m_killhost.c and m_flags.c from contrib/
- sort out unused header includes here and there

File Contents

# User Rev Content
1 adx 30 /*
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 michael 1007 /*! \file m_admin.c
23     * \brief Includes required functions for processing the ADMIN command.
24     * \version $Id$
25     */
26    
27 adx 30 #include "stdinc.h"
28     #include "client.h"
29     #include "ircd.h"
30     #include "numeric.h"
31     #include "s_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 michael 1230 /*! \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 adx 30 {
47 michael 1230 const char *me_name;
48     const char *nick;
49 adx 30
50 michael 1230 sendto_realops_flags(UMODE_SPY, L_ALL,
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     me_name = ID_or_name(&me, source_p->from);
56     nick = ID_or_name(source_p, source_p->from);
57    
58     sendto_one(source_p, form_str(RPL_ADMINME),
59     me_name, nick, me.name);
60     if (AdminInfo.name != NULL)
61     sendto_one(source_p, form_str(RPL_ADMINLOC1),
62     me_name, nick, AdminInfo.name);
63     if (AdminInfo.description != NULL)
64     sendto_one(source_p, form_str(RPL_ADMINLOC2),
65     me_name, nick, AdminInfo.description);
66     if (AdminInfo.email != NULL)
67     sendto_one(source_p, form_str(RPL_ADMINEMAIL),
68     me_name, nick, AdminInfo.email);
69 adx 30 }
70    
71 michael 1007 /*! \brief ADMIN command handler (called by unregistered,
72     * locally connected clients)
73     *
74     * \param client_p Pointer to allocated Client struct with physical connection
75     * to this server, i.e. with an open socket connected.
76     * \param source_p Pointer to allocated Client struct from which the message
77     * originally comes from. This can be a local or remote client.
78     * \param parc Integer holding the number of supplied arguments.
79     * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
80     * pointers.
81     * \note Valid arguments for this command are:
82     * - parv[0] = sender prefix
83 adx 30 */
84     static void
85     mr_admin(struct Client *client_p, struct Client *source_p,
86     int parc, char *parv[])
87     {
88     static time_t last_used = 0;
89 adx 269
90 michael 589 ClearCap(client_p, CAP_TS6);
91    
92 adx 269 if ((last_used + ConfigFileEntry.pace_wait_simple) > CurrentTime)
93 adx 30 {
94     sendto_one(source_p, form_str(RPL_LOAD2HI),
95     me.name, EmptyString(parv[0]) ? "*" : parv[0]);
96     return;
97     }
98    
99 michael 589 last_used = CurrentTime;
100    
101 michael 1144 do_admin(source_p);
102 adx 30 }
103    
104 michael 1007 /*! \brief NICK command handler (called by already registered,
105     * locally connected clients)
106     *
107     * \param client_p Pointer to allocated Client struct with physical connection
108     * to this server, i.e. with an open socket connected.
109     * \param source_p Pointer to allocated Client struct from which the message
110     * originally comes from. This can be a local or remote client.
111     * \param parc Integer holding the number of supplied arguments.
112     * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
113     * pointers.
114     * \note Valid arguments for this command are:
115     * - parv[0] = sender prefix
116     * - parv[1] = nickname/servername
117 adx 30 */
118     static void
119     m_admin(struct Client *client_p, struct Client *source_p,
120     int parc, char *parv[])
121     {
122     static time_t last_used = 0;
123    
124 adx 269 if ((last_used + ConfigFileEntry.pace_wait_simple) > CurrentTime)
125 adx 30 {
126     sendto_one(source_p,form_str(RPL_LOAD2HI),
127     me.name, source_p->name);
128     return;
129     }
130    
131 michael 589 last_used = CurrentTime;
132    
133 adx 30 if (!ConfigFileEntry.disable_remote)
134 michael 589 if (hunt_server(client_p, source_p, ":%s ADMIN :%s", 1,
135     parc, parv) != HUNTED_ISME)
136 adx 30 return;
137    
138 michael 1144 do_admin(source_p);
139 adx 30 }
140    
141 michael 1007 /*! \brief ADMIN command handler (called by operators and
142     * remotely connected clients)
143     *
144     * \param client_p Pointer to allocated Client struct with physical connection
145     * to this server, i.e. with an open socket connected.
146     * \param source_p Pointer to allocated Client struct from which the message
147     * originally comes from. This can be a local or remote client.
148     * \param parc Integer holding the number of supplied arguments.
149     * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
150     * pointers.
151     * \note Valid arguments for this command are:
152     * - parv[0] = sender prefix
153     * - parv[1] = nickname/servername
154 adx 30 */
155     static void
156     ms_admin(struct Client *client_p, struct Client *source_p,
157     int parc, char *parv[])
158     {
159 michael 1144 if (hunt_server(client_p, source_p, ":%s ADMIN :%s", 1,
160     parc, parv) != HUNTED_ISME)
161 adx 30 return;
162    
163     if (IsClient(source_p))
164 michael 1144 do_admin(source_p);
165 adx 30 }
166    
167 michael 1230 static struct Message admin_msgtab = {
168     "ADMIN", 0, 0, 0, MAXPARA, MFLG_SLOW | MFLG_UNREG, 0,
169     {mr_admin, m_admin, ms_admin, m_ignore, ms_admin, m_ignore}
170     };
171    
172 adx 30 static void
173 michael 1230 module_init(void)
174 adx 30 {
175 michael 1230 mod_add_cmd(&admin_msgtab);
176     }
177 adx 30
178 michael 1230 static void
179     module_exit(void)
180     {
181     mod_del_cmd(&admin_msgtab);
182     }
183 michael 1144
184 michael 1230 struct module module_entry = {
185     .node = { NULL, NULL, NULL },
186     .name = NULL,
187     .version = "$Revision$",
188     .handle = NULL,
189     .modinit = module_init,
190     .modexit = module_exit,
191     .flags = 0
192     };

Properties

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