ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/src/conf/general.c
Revision: 742
Committed: Sun Jul 23 14:10:50 2006 UTC (20 years ago) by adx
Content type: text/x-csrc
File size: 13797 byte(s)
Log Message:
+ moved isupport handling from s_conf.c

File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 * general.c: Defines the general{} block of ircd.conf.
4 *
5 * Copyright (C) 2005 by the Hybrid Development Team.
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 * $Id$
23 */
24
25 #include "stdinc.h"
26 #include "conf/conf.h"
27 #include "client.h"
28 #include "numeric.h"
29 #include "s_serv.h"
30 #include "s_user.h"
31
32 struct GeneralConf General;
33
34 static dlink_node *hreset, *hverify;
35
36 /*
37 * reset_general()
38 *
39 * Sets up default values before a rehash.
40 *
41 * inputs: none
42 * output: none
43 */
44 static void *
45 reset_general(va_list args)
46 {
47 /* Local connection initialization */
48 General.disable_auth = General.ping_cookie = NO;
49 General.dots_in_ident = 0, General.dot_in_ip6_addr = YES;
50 General.short_motd = NO;
51 General.invisible_on_connect = YES;
52
53 /* Registered clients settings */
54 General.max_watch = WATCHSIZE_DEFAULT;
55 General.hide_spoof_ips = General.use_whois_actually = YES;
56 General.burst_away = General.disable_remote_commands = NO;
57 General.stats_o_oper_only = General.stats_P_oper_only = 0,
58 General.stats_i_oper_only = General.stats_k_oper_only = 1;
59
60 /* Abuse protection */
61 General.throttle_time = 10;
62 General.max_targets = MAX_TARGETS_DEFAULT;
63 General.max_accept = 20;
64 General.caller_id_wait = 60;
65 General.opers_bypass_callerid = NO;
66 General.oper_pass_resv = YES;
67 General.client_flood = CLIENT_FLOOD_DEFAULT;
68 General.no_oper_flood = General.true_no_oper_flood = NO;
69 General.pace_wait_simple = 1, General.pace_wait = 10;
70 General.default_floodcount = 8;
71 General.anti_nick_flood = NO;
72 General.max_nick_time = 20, General.max_nick_changes = 5;
73 General.anti_spam_exit_message_time = 0;
74 General.reject_hold_time = General.idletime = 0;
75
76 /* Opers settings */
77 General.oper_only_umodes = UMODE_DEBUG, General.oper_umodes = UMODE_BOTS |
78 UMODE_LOCOPS | UMODE_SERVNOTICE | UMODE_OPERWALL | UMODE_WALLOP;
79 General.kill_chase_time_limit = 90;
80 General.min_nonwildcard = 4, General.min_nonwildcard_simple = 3;
81 General.gline_min_cidr = 16, General.gline_min_cidr6 = 48;
82 General.kline_with_reason = YES;
83 if (!conf_cold)
84 MyFree(General.kline_reason);
85 General.kline_reason = NULL;
86 General.tkline_expire_notices = General.failed_oper_notice = YES;
87
88 /* Server to server options */
89 General.warn_no_nline = YES;
90 General.ignore_bogus_ts = NO;
91 General.ts_warn_delta = TS_WARN_DELTA_DEFAULT, General.ts_max_delta =
92 TS_MAX_DELTA_DEFAULT;
93 if (!conf_cold)
94 MyFree(General.servlink_path);
95 DupString(General.servlink_path, SLPATH);
96 #ifdef HAVE_LIBCRYPTO
97 /* jdc -- This is our default value for a cipher. According to the
98 * CRYPTLINK document (doc/cryptlink.txt), BF/128 must be supported
99 * under all circumstances if cryptlinks are enabled. So,
100 * this will be our default.
101 *
102 * NOTE: I apologise for the hard-coded value of "1" (BF/128).
103 * This should be moved into a find_cipher() routine.
104 */
105 General.default_cipher_preference = &CipherTable[1];
106 #endif
107 General.use_egd = NO;
108 if (!conf_cold)
109 MyFree(General.egdpool_path);
110 General.egdpool_path = NULL;
111 General.compression_level = 0;
112
113 return pass_callback(hreset);
114 }
115
116 /*
117 * verify_general()
118 *
119 * Verifies settings after a rehash.
120 *
121 * inputs: none
122 * output: none
123 */
124 static void *
125 verify_general(va_list args)
126 {
127 General.ts_warn_delta = LIBIO_MAX(General.ts_warn_delta, TS_WARN_DELTA_MIN);
128 General.ts_max_delta = LIBIO_MAX(General.ts_max_delta, TS_MAX_DELTA_MIN);
129 General.client_flood = LIBIO_MAX(General.client_flood, CLIENT_FLOOD_MIN);
130 General.client_flood = LIBIO_MIN(General.client_flood, CLIENT_FLOOD_MAX);
131 General.max_watch = LIBIO_MAX(General.max_watch, WATCHSIZE_MIN);
132
133 add_isupport("MAXTARGETS", NULL, General.max_targets);
134
135 return pass_callback(hverify);
136 }
137
138 /*
139 * stats_oper_only()
140 *
141 * Handles yes/no/masked values.
142 *
143 * inputs:
144 * list - pointer to a dlink list of string pointers
145 * var - where we should write the result
146 * output: none
147 */
148 static void
149 stats_oper_only(void *list, void *var)
150 {
151 char *value;
152
153 if (dlink_list_length((dlink_list *) list) != 1)
154 {
155 error:
156 parse_error("value should be yes/no/masked");
157 return;
158 }
159
160 value = (char *) ((dlink_list *) list)->head->data;
161 if (!irccmp(value, "no"))
162 *(char *) var = 0;
163 else if (!irccmp(value, "masked"))
164 *(char *) var = 1;
165 else if (!irccmp(value, "yes"))
166 *(char *) var = 2;
167 else
168 goto error;
169 }
170
171 /*
172 * set_message_locale()
173 *
174 * Controls the message_locale field.
175 *
176 * inputs:
177 * str - pointer to a string containing locale name
178 * param - unused
179 * output: none
180 */
181 static void
182 set_message_locale(void *str, void *param)
183 {
184 char *loc = (char *) param;
185
186 if (strlen(loc) > LOCALE_LENGTH - 2)
187 loc[LOCALE_LENGTH - 1] = 0;
188
189 set_locale(loc);
190 }
191
192 /*
193 * havent_read_conf()
194 *
195 * Exits the ircd because of lame admin. ;)
196 *
197 * inputs:
198 * value - 1 in example.conf
199 * param - unused
200 * output: none
201 */
202 static void
203 havent_read_conf(void *value, void *param)
204 {
205 if (*(int *) value > 0)
206 {
207 ilog(L_CRIT, "You haven't read your config file properly.");
208 ilog(L_CRIT, "There is a line in the example conf that will kill your "
209 "server if not removed.");
210 ilog(L_CRIT, "Consider actually reading/editing the conf file, and "
211 "removing this line.");
212 exit(0);
213 }
214 }
215
216 /*
217 * set_compression_level()
218 *
219 * Controls the compression_level field.
220 *
221 * inputs:
222 * value - pointer to an integer value containing new level
223 * param - unused
224 * output: none
225 */
226 static void
227 set_compression_level(void *value, void *param)
228 {
229 #ifndef HAVE_LIBZ
230 parse_error("Ignoring compression_level, no zlib support");
231 #else
232 int lvl = *(int *) param;
233
234 if (lvl < 1 || lvl > 9)
235 {
236 parse_error("Ignoring invalid compression_level, using default");
237 General.compression_level = 0;
238 }
239 else
240 General.compression_level = lvl;
241 #endif
242 }
243
244 /*
245 * set_default_cipher()
246 *
247 * Controls the default_cipher_preference field.
248 *
249 * inputs:
250 * value - pointer to cipher name
251 * param - unused
252 * output: none
253 */
254 static void
255 set_default_cipher(void *value, void *param)
256 {
257 #ifndef HAVE_LIBCRYPTO
258 parse_error("no OpenSSL support");
259 #else
260 struct EncCapability *ecap;
261 char *cipher_name;
262
263 General.default_cipher_preference = NULL;
264 cipher_name = (char *) param;
265
266 for (ecap = CipherTable; ecap->name != NULL; ecap++)
267 if (!irccmp(ecap->name, cipher_name) && (ecap->cap && CAP_ENC_MASK))
268 {
269 General.default_cipher_preference = ecap;
270 return;
271 }
272
273 parse_error("invalid cipher");
274 #endif
275 }
276
277 /* XXX this should go to s_user.c to simplify modularisation */
278 static struct UmodeMapping {
279 char *name;
280 unsigned int umode;
281 } umode_mappings[] = {
282 {"bots", UMODE_BOTS},
283 {"cconn", UMODE_CCONN},
284 {"deaf", UMODE_DEAF},
285 {"debug", UMODE_DEBUG},
286 {"full", UMODE_FULL},
287 {"softcallerid", UMODE_SOFTCALLERID},
288 {"callerid", UMODE_CALLERID},
289 {"invisible", UMODE_INVISIBLE},
290 {"skill", UMODE_SKILL},
291 {"locops", UMODE_LOCOPS},
292 {"nchange", UMODE_NCHANGE},
293 {"rej", UMODE_REJ},
294 {"servnotice", UMODE_SERVNOTICE},
295 {"unauth", UMODE_UNAUTH},
296 {"wallop", UMODE_WALLOP},
297 {"external", UMODE_EXTERNAL},
298 {"spy", UMODE_SPY},
299 {"operwall", UMODE_OPERWALL},
300 {NULL, 0}
301 };
302
303 /*
304 * parse_umode_list()
305 *
306 * Parses a list of usermodes.
307 *
308 * inputs:
309 * list - points to a dlink_list of strings to parse
310 * var - where to save the result as unsigned int
311 * output: none
312 */
313 static void
314 parse_umode_list(void *list, void *var)
315 {
316 dlink_node *ptr;
317 char *str;
318 unsigned int umodes = 0;
319 int found;
320 struct UmodeMapping *p;
321
322 DLINK_FOREACH(ptr, ((dlink_list *) list)->head)
323 {
324 str = (char *) ptr->data;
325
326 found = NO;
327 for (p = umode_mappings; p->name; p++)
328 if (!irccmp(str, p->name))
329 {
330 umodes |= p->umode;
331 found = YES;
332 break;
333 }
334
335 if (!found)
336 parse_error("Unknown umode [%s]", str);
337 }
338
339 *(unsigned int *) var = umodes;
340 }
341
342 /*
343 * init_general()
344 *
345 * Defines the general{} conf section.
346 *
347 * inputs: none
348 * output: none
349 */
350 void
351 init_general(void)
352 {
353 struct ConfSection *s = add_conf_section("general", 2);
354
355 hreset = install_hook(reset_conf, reset_general);
356 hverify = install_hook(verify_conf, verify_general);
357
358 /* Local connection initialization */
359 add_conf_field(s, "disable_auth", CT_BOOL, NULL, &General.disable_auth);
360 add_conf_field(s, "ping_cookie", CT_BOOL, NULL, &General.ping_cookie);
361 add_conf_field(s, "dots_in_ident", CT_NUMBER, NULL, &General.dots_in_ident);
362 add_conf_field(s, "dot_in_ip6_addr", CT_BOOL, NULL, &General.dot_in_ip6_addr);
363 add_conf_field(s, "short_motd", CT_BOOL, NULL, &General.short_motd);
364 add_conf_field(s, "invisible_on_connect", CT_BOOL, NULL,
365 &General.invisible_on_connect);
366
367 /* Registered clients settings */
368 add_conf_field(s, "hide_spoof_ips", CT_BOOL, NULL, &General.hide_spoof_ips);
369 add_conf_field(s, "use_whois_actually", CT_BOOL, NULL,
370 &General.use_whois_actually);
371 add_conf_field(s, "burst_away", CT_BOOL, NULL, &General.burst_away);
372 add_conf_field(s, "disable_remote_commands", CT_BOOL, NULL,
373 &General.disable_remote_commands);
374 add_conf_field(s, "message_locale", CT_STRING, set_message_locale, NULL);
375 add_conf_field(s, "stats_o_oper_only", CT_BOOL, NULL,
376 &General.stats_o_oper_only);
377 add_conf_field(s, "stats_P_oper_only", CT_BOOL, NULL,
378 &General.stats_P_oper_only);
379 add_conf_field(s, "stats_i_oper_only", CT_LIST, stats_oper_only,
380 &General.stats_i_oper_only);
381 add_conf_field(s, "stats_k_oper_only", CT_LIST, stats_oper_only,
382 &General.stats_k_oper_only);
383
384 /* Abuse protection */
385 add_conf_field(s, "throttle_time", CT_NUMBER, NULL, &General.throttle_time);
386 add_conf_field(s, "max_targets", CT_NUMBER, NULL, &General.max_targets);
387 add_conf_field(s, "max_accept", CT_NUMBER, NULL, &General.max_accept);
388 add_conf_field(s, "caller_id_wait", CT_TIME, NULL, &General.caller_id_wait);
389 add_conf_field(s, "opers_bypass_callerid", CT_BOOL, NULL,
390 &General.opers_bypass_callerid);
391 add_conf_field(s, "oper_pass_resv", CT_BOOL, NULL, &General.oper_pass_resv);
392 add_conf_field(s, "client_flood", CT_NUMBER, NULL, &General.client_flood);
393 add_conf_field(s, "no_oper_flood", CT_BOOL, NULL, &General.no_oper_flood);
394 add_conf_field(s, "true_no_oper_flood", CT_BOOL, NULL,
395 &General.true_no_oper_flood);
396 add_conf_field(s, "pace_wait_simple", CT_TIME, NULL,
397 &General.pace_wait_simple);
398 add_conf_field(s, "pace_wait", CT_TIME, NULL, &General.pace_wait);
399 add_conf_field(s, "default_floodcount", CT_NUMBER, NULL,
400 &General.default_floodcount);
401 add_conf_field(s, "anti_nick_flood", CT_BOOL, NULL, &General.anti_nick_flood);
402 add_conf_field(s, "max_nick_time", CT_TIME, NULL, &General.max_nick_time);
403 add_conf_field(s, "max_nick_changes", CT_NUMBER, NULL,
404 &General.max_nick_changes);
405 add_conf_field(s, "anti_spam_exit_message_time", CT_TIME, NULL,
406 &General.anti_spam_exit_message_time);
407 add_conf_field(s, "reject_hold_time", CT_TIME, NULL,
408 &General.reject_hold_time);
409 add_conf_field(s, "idletime", CT_TIME, NULL, &General.idletime);
410 add_conf_field(s, "havent_read_conf", CT_NUMBER, havent_read_conf, NULL);
411
412 /* Opers settings */
413 add_conf_field(s, "oper_only_umodes", CT_LIST, parse_umode_list,
414 &General.oper_only_umodes);
415 add_conf_field(s, "oper_umodes", CT_LIST, parse_umode_list,
416 &General.oper_umodes);
417 add_conf_field(s, "kill_chase_time_limit", CT_TIME, NULL,
418 &General.kill_chase_time_limit);
419 add_conf_field(s, "min_nonwildcard", CT_NUMBER, NULL,
420 &General.min_nonwildcard);
421 add_conf_field(s, "min_nonwildcard_simple", CT_NUMBER, NULL,
422 &General.min_nonwildcard_simple);
423 add_conf_field(s, "gline_min_cidr", CT_NUMBER, NULL, &General.gline_min_cidr);
424 add_conf_field(s, "gline_min_cidr6", CT_NUMBER, NULL,
425 &General.gline_min_cidr6);
426 add_conf_field(s, "kline_with_reason", CT_BOOL, NULL,
427 &General.kline_with_reason);
428 add_conf_field(s, "kline_reason", CT_STRING, NULL, &General.kline_reason);
429 add_conf_field(s, "tkline_expire_notices", CT_BOOL, NULL,
430 &General.tkline_expire_notices);
431 add_conf_field(s, "failed_oper_notice", CT_BOOL, NULL,
432 &General.failed_oper_notice);
433
434 /* Server to server options */
435 add_conf_field(s, "warn_no_nline", CT_BOOL, NULL, &General.warn_no_nline);
436 add_conf_field(s, "ignore_bogus_ts", CT_BOOL, NULL, &General.ignore_bogus_ts);
437 add_conf_field(s, "ts_warn_delta", CT_TIME, NULL, &General.ts_warn_delta);
438 add_conf_field(s, "ts_max_delta", CT_TIME, NULL, &General.ts_max_delta);
439 add_conf_field(s, "servlink_path", CT_STRING, NULL, &General.servlink_path);
440 add_conf_field(s, "default_cipher_preference", CT_STRING, set_default_cipher,
441 NULL);
442 add_conf_field(s, "use_egd", CT_BOOL, NULL, &General.use_egd);
443 add_conf_field(s, "egdpool_path", CT_STRING, NULL, &General.egdpool_path);
444 add_conf_field(s, "compression_level", CT_NUMBER, set_compression_level,
445 NULL);
446 add_conf_field(s, "max_watch", CT_BOOL, NULL, &General.max_watch);
447 }

Properties

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