ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/modules/m_admin.c
Revision: 270
Committed: Mon Nov 14 19:39:35 2005 UTC (20 years, 8 months ago) by adx
Content type: text/x-csrc
File size: 4531 byte(s)
Log Message:
+ ported rate limiting fixes from 7.2

File Contents

# User Rev Content
1 adx 30 /*
2     * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3     * m_admin.c: Sends administrative information to a user.
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 "handlers.h"
27     #include "client.h"
28     #include "ircd.h"
29     #include "numeric.h"
30     #include "s_conf.h"
31     #include "s_serv.h"
32     #include "send.h"
33     #include "msg.h"
34     #include "parse.h"
35     #include "modules.h"
36    
37     static void m_admin(struct Client *, struct Client *, int, char **);
38     static void mr_admin(struct Client *, struct Client *, int, char **);
39     static void ms_admin(struct Client *, struct Client *, int, char **);
40     static void do_admin(struct Client *);
41    
42     struct Message admin_msgtab = {
43     "ADMIN", 0, 0, 0, 0, MFLG_SLOW | MFLG_UNREG, 0,
44     {mr_admin, m_admin, ms_admin, m_ignore, ms_admin, m_ignore}
45     };
46    
47     #ifndef STATIC_MODULES
48     static struct Callback *admin_cb;
49 knight 31 const char *_version = "$Revision$";
50 adx 30
51     static void *
52     va_admin(va_list args)
53     {
54     do_admin(va_arg(args, struct Client *));
55     return NULL;
56     }
57    
58     void
59     _modinit(void)
60     {
61     admin_cb = register_callback("doing_admin", va_admin);
62     mod_add_cmd(&admin_msgtab);
63     }
64    
65     void
66     _moddeinit(void)
67     {
68     mod_del_cmd(&admin_msgtab);
69     uninstall_hook(admin_cb, va_admin);
70     }
71     #endif
72    
73     /*
74     * mr_admin - ADMIN command handler
75     * parv[0] = sender prefix
76     * parv[1] = servername
77     */
78     static void
79     mr_admin(struct Client *client_p, struct Client *source_p,
80     int parc, char *parv[])
81     {
82     static time_t last_used = 0;
83 adx 270
84     if ((last_used + ConfigFileEntry.pace_wait_simple) > CurrentTime)
85 adx 30 {
86     sendto_one(source_p, form_str(RPL_LOAD2HI),
87     me.name, EmptyString(parv[0]) ? "*" : parv[0]);
88     return;
89     }
90     else
91     last_used = CurrentTime;
92    
93     #ifdef STATIC_MODULES
94     do_admin(client_p);
95     #else
96     execute_callback(admin_cb, source_p, parc, parv);
97     #endif
98     }
99    
100     /*
101     * m_admin - ADMIN command handler
102     * parv[0] = sender prefix
103     * parv[1] = servername
104     */
105     static void
106     m_admin(struct Client *client_p, struct Client *source_p,
107     int parc, char *parv[])
108     {
109     static time_t last_used = 0;
110    
111 adx 270 if ((last_used + ConfigFileEntry.pace_wait_simple) > CurrentTime)
112 adx 30 {
113     sendto_one(source_p,form_str(RPL_LOAD2HI),
114     me.name, source_p->name);
115     return;
116     }
117     else
118     last_used = CurrentTime;
119    
120     if (!ConfigFileEntry.disable_remote)
121     {
122     if (hunt_server(client_p, source_p, ":%s ADMIN :%s", 1, parc, parv) != HUNTED_ISME)
123     return;
124     }
125    
126     #ifdef STATIC_MODULES
127     do_admin(client_p);
128     #else
129     execute_callback(admin_cb, source_p, parc, parv);
130     #endif
131     }
132    
133     /*
134     * ms_admin - ADMIN command handler, used for OPERS as well
135     * parv[0] = sender prefix
136     * parv[1] = servername
137     */
138     static void
139     ms_admin(struct Client *client_p, struct Client *source_p,
140     int parc, char *parv[])
141     {
142     if (hunt_server(client_p, source_p, ":%s ADMIN :%s", 1, parc, parv) != HUNTED_ISME)
143     return;
144    
145     if (IsClient(source_p))
146     #ifdef STATIC_MODULES
147     do_admin(source_p);
148     #else
149     execute_callback(admin_cb, source_p, parc, parv);
150     #endif
151     }
152    
153     /* do_admin()
154     *
155     * inputs - pointer to client to report to
156     * output - none
157     * side effects - admin info is sent to client given
158     */
159     static void
160     do_admin(struct Client *source_p)
161     {
162     const char *me_name;
163     const char *nick;
164    
165     me_name = ID_or_name(&me, source_p->from);
166     nick = ID_or_name(source_p, source_p->from);
167    
168     sendto_one(source_p, form_str(RPL_ADMINME),
169     me_name, nick, me.name);
170     if (AdminInfo.name != NULL)
171     sendto_one(source_p, form_str(RPL_ADMINLOC1),
172     me_name, nick, AdminInfo.name);
173     if (AdminInfo.description != NULL)
174     sendto_one(source_p, form_str(RPL_ADMINLOC2),
175     me_name, nick, AdminInfo.description);
176     if (AdminInfo.email != NULL)
177     sendto_one(source_p, form_str(RPL_ADMINEMAIL),
178     me_name, nick, AdminInfo.email);
179     }

Properties

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