ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_resv.c
Revision: 6354
Committed: Fri Aug 14 17:53:44 2015 UTC (10 years, 11 months ago) by michael
Content type: text/x-csrc
File size: 6736 byte(s)
Log Message:
- Rename server capabilities flags from CAP_* to CAPAB_*

File Contents

# User Rev Content
1 adx 30 /*
2 michael 2820 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 adx 30 *
4 michael 5347 * Copyright (c) 2001-2015 ircd-hybrid development team
5 adx 30 *
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 michael 4565 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 adx 30 * USA
20     */
21    
22 michael 2820 /*! \file m_resv.c
23 michael 3354 * \brief Includes required functions for processing the RESV command.
24 michael 2820 * \version $Id$
25     */
26    
27 adx 30 #include "stdinc.h"
28     #include "client.h"
29     #include "ircd.h"
30     #include "irc_string.h"
31     #include "numeric.h"
32 michael 3347 #include "server.h"
33 adx 30 #include "send.h"
34     #include "parse.h"
35     #include "modules.h"
36 michael 1309 #include "conf.h"
37     #include "log.h"
38 adx 30 #include "resv.h"
39    
40    
41 michael 3559 /* parse_resv()
42     *
43     * inputs - source_p, NULL supported
44     * - thing to resv
45     * - time_t if tkline
46     * - reason
47     * outputs - none
48     * side effects - parse resv, create if valid
49     */
50     static void
51 michael 6344 parse_resv(struct Client *source_p, const char *name, int tkline_time, const char *reason)
52 michael 3559 {
53 michael 5825 const char *type = "channel";
54     struct MaskItem *conf = NULL;
55 adx 30
56 michael 5825 if (!IsChanPrefix(*name))
57     type = "nick";
58 michael 3559
59 michael 6338 if (!HasFlag(source_p, FLAGS_SERVICE) && !HasUMode(source_p, UMODE_ADMIN) && has_wildcards(name))
60 michael 6329 {
61     if (IsClient(source_p))
62 michael 6335 sendto_one_notice(source_p, &me, ":You must be an admin to perform a wildcard RESV");
63 michael 4890
64 michael 6329 return;
65     }
66 michael 3559
67 michael 6335 if (!valid_wild_card_simple(name + !!IsChanPrefix(*name)))
68 michael 6329 {
69     if (IsClient(source_p))
70 michael 6335 sendto_one_notice(source_p, &me, ":Please include at least %u non-wildcard characters with the resv",
71     ConfigGeneral.min_nonwildcard_simple);
72 michael 4890
73 michael 6329 return;
74 michael 5825 }
75 michael 3559
76 michael 5825 if ((conf = create_resv(name, reason, NULL)) == NULL)
77     {
78     if (IsClient(source_p))
79     sendto_one_notice(source_p, &me, ":A RESV has already been placed on %s: %s", type, name);
80 michael 4890
81 michael 5825 return;
82     }
83 michael 3559
84 michael 5825 conf->setat = CurrentTime;
85     SetConfDatabase(conf);
86 michael 3559
87 michael 5825 if (tkline_time)
88     {
89     if (IsClient(source_p))
90 michael 6339 sendto_one_notice(source_p, &me, ":A %d minute RESV has been placed on %s: %s",
91     tkline_time/60, type, name);
92 michael 4890
93 michael 6318 sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE,
94 michael 6339 "%s has placed a %d minute RESV on %s: %s [%s]",
95 michael 5825 get_oper_name(source_p),
96 michael 6339 tkline_time/60, type,
97 michael 5825 conf->name, conf->reason);
98     ilog(LOG_TYPE_RESV, "%s added temporary %d min. RESV for [%s] [%s]",
99     get_oper_name(source_p), (int)tkline_time/60,
100     conf->name, conf->reason);
101     conf->until = CurrentTime + tkline_time;
102     }
103     else
104     {
105     if (IsClient(source_p))
106 michael 6339 sendto_one_notice(source_p, &me, ":A RESV has been placed on %s: %s",
107     type, name);
108 michael 4890
109 michael 6318 sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE,
110 michael 6339 "%s has placed a RESV on %s: %s [%s]",
111     get_oper_name(source_p), type,
112 michael 5825 conf->name, conf->reason);
113     ilog(LOG_TYPE_RESV, "%s added RESV for [%s] [%s]",
114     get_oper_name(source_p), conf->name, conf->reason);
115 michael 3559 }
116     }
117    
118 adx 30 /* mo_resv()
119 michael 3096 * parv[0] = command
120 adx 30 * parv[1] = channel/nick to forbid
121     */
122 michael 2820 static int
123 michael 3156 mo_resv(struct Client *source_p, int parc, char *parv[])
124 adx 30 {
125     char *resv = NULL;
126     char *reason = NULL;
127     char *target_server = NULL;
128     time_t tkline_time = 0;
129    
130 michael 5776 if (!parse_aline("RESV", source_p, parc, parv, 0, &resv, NULL,
131     &tkline_time, &target_server, &reason))
132 michael 2820 return 0;
133 adx 30
134 michael 3368 if (target_server)
135 adx 30 {
136     /* if a given expire time is given, ENCAP it */
137 michael 3368 if (tkline_time)
138 michael 6354 sendto_match_servs(source_p, target_server, CAPAB_ENCAP,
139 michael 2820 "ENCAP %s RESV %d %s 0 :%s",
140     target_server, (int)tkline_time, resv, reason);
141 adx 30 else
142 michael 6354 sendto_match_servs(source_p, target_server, CAPAB_CLUSTER,
143 michael 6351 "RESV %s 0 %s :%s",
144 michael 2820 target_server, resv, reason);
145 michael 5959
146 adx 30 /* Allow ON to apply local resv as well if it matches */
147 michael 1652 if (match(target_server, me.name))
148 michael 2820 return 0;
149 adx 30 }
150     else
151     {
152 michael 3368 if (tkline_time)
153 michael 6354 cluster_a_line(source_p, "ENCAP", CAPAB_ENCAP, SHARED_RESV,
154 michael 4615 "RESV %d %s 0 :%s", (int)tkline_time, resv, reason);
155 adx 30 else
156 michael 6354 cluster_a_line(source_p, "RESV", CAPAB_KLN, SHARED_RESV,
157 michael 6351 "0 %s :%s", resv, reason);
158 adx 30 }
159    
160     parse_resv(source_p, resv, (int)tkline_time, reason);
161 michael 2820 return 0;
162 adx 30 }
163    
164     /* me_resv()
165     *
166     * inputs - server
167     * - client (oper)
168     * - parc number of arguments
169     * - parv list of arguments
170     * via parv[]
171 michael 3096 * parv[0] = command
172 adx 30 * parv[1] = tkline_time
173     * parv[2] = name
174     * parv[3] = 0
175     * parv[4] = reason
176     * parc should be 5
177     *
178     * outputs - NONE
179     * side effects -
180     */
181 michael 2820 static int
182 michael 3156 me_resv(struct Client *source_p, int parc, char *parv[])
183 adx 30 {
184 michael 4650 if (parc != 5 || EmptyString(parv[4]))
185 michael 2820 return 0;
186 adx 30
187     parse_resv(source_p, parv[2], atoi(parv[1]), parv[4]);
188 michael 2820 return 0;
189 adx 30 }
190    
191     /* ms_resv()
192 michael 3096 * parv[0] = command
193 adx 30 * parv[1] = target server
194 michael 6351 * parv[2] = tkline_time
195     * parv[3] = channel/nick to resv
196     * parv[4] = reason
197 adx 30 */
198 michael 2820 static int
199 michael 3156 ms_resv(struct Client *source_p, int parc, char *parv[])
200 adx 30 {
201 michael 6351 if (parc != 5 || EmptyString(parv[4]))
202 michael 2820 return 0;
203 adx 30
204 michael 6354 sendto_match_servs(source_p, parv[1], CAPAB_CLUSTER, "RESV %s %s %s :%s",
205 michael 6351 parv[1], parv[2], parv[3], parv[4]);
206 adx 30
207 michael 4650 if (match(parv[1], me.name))
208 michael 2820 return 0;
209 adx 30
210 michael 4650 if (HasFlag(source_p, FLAGS_SERVICE) ||
211     find_matching_name_conf(CONF_ULINE, source_p->servptr->name,
212 adx 30 source_p->username, source_p->host,
213     SHARED_RESV))
214 michael 6351 parse_resv(source_p, parv[3], atoi(parv[2]), parv[4]);
215 michael 2820 return 0;
216 adx 30 }
217    
218 michael 2820 static struct Message resv_msgtab =
219     {
220 michael 5881 .cmd = "RESV",
221     .args_min = 3,
222     .args_max = MAXPARA,
223 michael 5893 .handlers[UNREGISTERED_HANDLER] = m_unregistered,
224 michael 5881 .handlers[CLIENT_HANDLER] = m_not_oper,
225     .handlers[SERVER_HANDLER] = ms_resv,
226     .handlers[ENCAP_HANDLER] = me_resv,
227     .handlers[OPER_HANDLER] = mo_resv
228 michael 1230 };
229    
230     static void
231     module_init(void)
232     {
233     mod_add_cmd(&resv_msgtab);
234     }
235    
236     static void
237     module_exit(void)
238     {
239     mod_del_cmd(&resv_msgtab);
240     }
241    
242 michael 2820 struct module module_entry =
243     {
244 michael 1230 .version = "$Revision$",
245     .modinit = module_init,
246     .modexit = module_exit,
247     };

Properties

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