]>
Commit | Line | Data |
---|---|---|
212380e3 | 1 | /* This code is in the public domain. |
cda8e9b8 | 2 | * $Id: newconf.c 3550 2007-08-09 06:47:26Z nenolod $ |
212380e3 | 3 | */ |
4 | ||
5 | #include "stdinc.h" | |
6 | ||
7 | #ifdef HAVE_LIBCRYPTO | |
8 | #include <openssl/pem.h> | |
9 | #include <openssl/rsa.h> | |
10 | #endif | |
11 | ||
212380e3 | 12 | #include "newconf.h" |
212380e3 | 13 | #include "ircd_defs.h" |
212380e3 | 14 | #include "common.h" |
d3455e2c | 15 | #include "logger.h" |
212380e3 | 16 | #include "s_conf.h" |
17 | #include "s_user.h" | |
18 | #include "s_newconf.h" | |
19 | #include "send.h" | |
20 | #include "setup.h" | |
21 | #include "modules.h" | |
22 | #include "listener.h" | |
23 | #include "hostmask.h" | |
24 | #include "s_serv.h" | |
212380e3 | 25 | #include "hash.h" |
26 | #include "cache.h" | |
27 | #include "ircd.h" | |
28 | #include "snomask.h" | |
29 | #include "blacklist.h" | |
8db00894 | 30 | #include "sslproc.h" |
de0e9f37 | 31 | #include "privilege.h" |
212380e3 | 32 | |
33 | #define CF_TYPE(x) ((x) & CF_MTYPE) | |
34 | ||
35 | struct TopConf *conf_cur_block; | |
36 | static char *conf_cur_block_name; | |
37 | ||
af81d5a0 | 38 | static rb_dlink_list conf_items; |
212380e3 | 39 | |
40 | static struct ConfItem *yy_aconf = NULL; | |
41 | ||
42 | static struct Class *yy_class = NULL; | |
43 | ||
44 | static struct remote_conf *yy_shared = NULL; | |
45 | static struct server_conf *yy_server = NULL; | |
46 | ||
af81d5a0 WP |
47 | static rb_dlink_list yy_aconf_list; |
48 | static rb_dlink_list yy_oper_list; | |
49 | static rb_dlink_list yy_shared_list; | |
50 | static rb_dlink_list yy_cluster_list; | |
212380e3 | 51 | static struct oper_conf *yy_oper = NULL; |
52 | ||
53 | static struct alias_entry *yy_alias = NULL; | |
54 | ||
55 | static char *yy_blacklist_host = NULL; | |
56 | static char *yy_blacklist_reason = NULL; | |
de0e9f37 | 57 | static char *yy_privset_extends = NULL; |
212380e3 | 58 | |
59 | static const char * | |
60 | conf_strtype(int type) | |
61 | { | |
62 | switch (type & CF_MTYPE) | |
63 | { | |
64 | case CF_INT: | |
65 | return "integer value"; | |
66 | case CF_STRING: | |
67 | return "unquoted string"; | |
68 | case CF_YESNO: | |
69 | return "yes/no value"; | |
70 | case CF_QSTRING: | |
71 | return "quoted string"; | |
72 | case CF_TIME: | |
73 | return "time/size value"; | |
74 | default: | |
75 | return "unknown type"; | |
76 | } | |
77 | } | |
78 | ||
79 | int | |
80 | add_top_conf(const char *name, int (*sfunc) (struct TopConf *), | |
81 | int (*efunc) (struct TopConf *), struct ConfEntry *items) | |
82 | { | |
83 | struct TopConf *tc; | |
84 | ||
8e43b0b4 | 85 | tc = rb_malloc(sizeof(struct TopConf)); |
212380e3 | 86 | |
d7f753cd | 87 | tc->tc_name = name; |
212380e3 | 88 | tc->tc_sfunc = sfunc; |
89 | tc->tc_efunc = efunc; | |
90 | tc->tc_entries = items; | |
91 | ||
af81d5a0 | 92 | rb_dlinkAddAlloc(tc, &conf_items); |
212380e3 | 93 | return 0; |
94 | } | |
95 | ||
96 | struct TopConf * | |
97 | find_top_conf(const char *name) | |
98 | { | |
af81d5a0 | 99 | rb_dlink_node *d; |
212380e3 | 100 | struct TopConf *tc; |
101 | ||
8e69bb4e | 102 | RB_DLINK_FOREACH(d, conf_items.head) |
212380e3 | 103 | { |
104 | tc = d->data; | |
105 | if(strcasecmp(tc->tc_name, name) == 0) | |
106 | return tc; | |
107 | } | |
108 | ||
109 | return NULL; | |
110 | } | |
111 | ||
112 | ||
113 | struct ConfEntry * | |
114 | find_conf_item(const struct TopConf *top, const char *name) | |
115 | { | |
116 | struct ConfEntry *cf; | |
af81d5a0 | 117 | rb_dlink_node *d; |
212380e3 | 118 | |
119 | if(top->tc_entries) | |
120 | { | |
121 | int i; | |
122 | ||
123 | for(i = 0; top->tc_entries[i].cf_type; i++) | |
124 | { | |
125 | cf = &top->tc_entries[i]; | |
126 | ||
127 | if(!strcasecmp(cf->cf_name, name)) | |
128 | return cf; | |
129 | } | |
130 | } | |
131 | ||
8e69bb4e | 132 | RB_DLINK_FOREACH(d, top->tc_items.head) |
212380e3 | 133 | { |
134 | cf = d->data; | |
135 | if(strcasecmp(cf->cf_name, name) == 0) | |
136 | return cf; | |
137 | } | |
138 | ||
139 | return NULL; | |
140 | } | |
141 | ||
142 | int | |
143 | remove_top_conf(char *name) | |
144 | { | |
145 | struct TopConf *tc; | |
af81d5a0 | 146 | rb_dlink_node *ptr; |
212380e3 | 147 | |
148 | if((tc = find_top_conf(name)) == NULL) | |
149 | return -1; | |
150 | ||
af81d5a0 | 151 | if((ptr = rb_dlinkFind(tc, &conf_items)) == NULL) |
212380e3 | 152 | return -1; |
153 | ||
af81d5a0 | 154 | rb_dlinkDestroy(ptr, &conf_items); |
90a3c35b | 155 | rb_free(tc); |
212380e3 | 156 | |
157 | return 0; | |
158 | } | |
159 | ||
160 | static void | |
161 | conf_set_serverinfo_name(void *data) | |
162 | { | |
163 | if(ServerInfo.name == NULL) | |
164 | { | |
165 | const char *s; | |
166 | int dots = 0; | |
167 | ||
168 | for(s = data; *s != '\0'; s++) | |
169 | { | |
170 | if(!IsServChar(*s)) | |
171 | { | |
172 | conf_report_error("Ignoring serverinfo::name " | |
173 | "-- bogus servername."); | |
174 | return; | |
175 | } | |
176 | else if(*s == '.') | |
177 | ++dots; | |
178 | } | |
179 | ||
180 | if(!dots) | |
181 | { | |
182 | conf_report_error("Ignoring serverinfo::name -- must contain '.'"); | |
183 | return; | |
184 | } | |
185 | ||
186 | s = data; | |
187 | ||
188 | if(IsDigit(*s)) | |
189 | { | |
190 | conf_report_error("Ignoring serverinfo::name -- cannot begin with digit."); | |
191 | return; | |
192 | } | |
193 | ||
194 | /* the ircd will exit() in main() if we dont set one */ | |
195 | if(strlen(s) <= HOSTLEN) | |
62d28946 | 196 | ServerInfo.name = rb_strdup((char *) data); |
212380e3 | 197 | } |
198 | } | |
199 | ||
200 | static void | |
201 | conf_set_serverinfo_sid(void *data) | |
202 | { | |
203 | char *sid = data; | |
204 | ||
205 | if(ServerInfo.sid[0] == '\0') | |
206 | { | |
207 | if(!IsDigit(sid[0]) || !IsIdChar(sid[1]) || | |
208 | !IsIdChar(sid[2]) || sid[3] != '\0') | |
209 | { | |
210 | conf_report_error("Ignoring serverinfo::sid " | |
211 | "-- bogus sid."); | |
212 | return; | |
213 | } | |
214 | ||
215 | strcpy(ServerInfo.sid, sid); | |
216 | } | |
217 | } | |
218 | ||
219 | static void | |
220 | conf_set_serverinfo_network_name(void *data) | |
221 | { | |
222 | char *p; | |
223 | ||
224 | if((p = strchr((char *) data, ' '))) | |
225 | *p = '\0'; | |
226 | ||
90a3c35b | 227 | rb_free(ServerInfo.network_name); |
62d28946 | 228 | ServerInfo.network_name = rb_strdup((char *) data); |
212380e3 | 229 | } |
230 | ||
231 | static void | |
232 | conf_set_serverinfo_vhost(void *data) | |
233 | { | |
9879cd59 | 234 | if(rb_inet_pton(AF_INET, (char *) data, &ServerInfo.ip.sin_addr) <= 0) |
212380e3 | 235 | { |
236 | conf_report_error("Invalid netmask for server IPv4 vhost (%s)", (char *) data); | |
237 | return; | |
238 | } | |
239 | ServerInfo.ip.sin_family = AF_INET; | |
240 | ServerInfo.specific_ipv4_vhost = 1; | |
241 | } | |
242 | ||
243 | static void | |
244 | conf_set_serverinfo_vhost6(void *data) | |
245 | { | |
2c2e0aa9 | 246 | #ifdef RB_IPV6 |
9879cd59 | 247 | if(rb_inet_pton(AF_INET6, (char *) data, &ServerInfo.ip6.sin6_addr) <= 0) |
212380e3 | 248 | { |
249 | conf_report_error("Invalid netmask for server IPv6 vhost (%s)", (char *) data); | |
250 | return; | |
251 | } | |
252 | ||
253 | ServerInfo.specific_ipv6_vhost = 1; | |
254 | ServerInfo.ip6.sin6_family = AF_INET6; | |
255 | #else | |
256 | conf_report_error("Warning -- ignoring serverinfo::vhost6 -- IPv6 support not available."); | |
257 | #endif | |
258 | } | |
259 | ||
260 | static void | |
261 | conf_set_modules_module(void *data) | |
262 | { | |
263 | #ifndef STATIC_MODULES | |
264 | char *m_bn; | |
265 | ||
3b0f3294 | 266 | m_bn = rb_basename((char *) data); |
212380e3 | 267 | |
268 | if(findmodule_byname(m_bn) != -1) | |
269 | return; | |
270 | ||
271 | load_one_module((char *) data, 0); | |
272 | ||
90a3c35b | 273 | rb_free(m_bn); |
212380e3 | 274 | #else |
275 | conf_report_error("Ignoring modules::module -- loadable module support not present."); | |
276 | #endif | |
277 | } | |
278 | ||
279 | static void | |
280 | conf_set_modules_path(void *data) | |
281 | { | |
282 | #ifndef STATIC_MODULES | |
283 | mod_add_path((char *) data); | |
284 | #else | |
285 | conf_report_error("Ignoring modules::path -- loadable module support not present."); | |
286 | #endif | |
287 | } | |
288 | ||
289 | struct mode_table | |
290 | { | |
291 | const char *name; | |
292 | int mode; | |
293 | }; | |
294 | ||
295 | /* *INDENT-OFF* */ | |
296 | static struct mode_table umode_table[] = { | |
297 | {"callerid", UMODE_CALLERID }, | |
298 | {"deaf", UMODE_DEAF }, | |
299 | {"invisible", UMODE_INVISIBLE }, | |
300 | {"locops", UMODE_LOCOPS }, | |
301 | {"noforward", UMODE_NOFORWARD }, | |
302 | {"regonlymsg", UMODE_REGONLYMSG}, | |
303 | {"servnotice", UMODE_SERVNOTICE}, | |
304 | {"wallop", UMODE_WALLOP }, | |
305 | {"operwall", UMODE_OPERWALL }, | |
2678f87a | 306 | {"noctcp", UMODE_NOCTCP }, |
854f6bd0 | 307 | {"noinvite", UMODE_NOINVITE }, |
930629c5 | 308 | {"bot", UMODE_BOT }, |
212380e3 | 309 | {NULL, 0} |
310 | }; | |
311 | ||
d2b16c20 | 312 | static struct mode_table oper_table[] = { |
212380e3 | 313 | {"encrypted", OPER_ENCRYPTED }, |
663bbb28 | 314 | {"need_ssl", OPER_NEEDSSL }, |
212380e3 | 315 | {NULL, 0} |
316 | }; | |
317 | ||
318 | static struct mode_table auth_table[] = { | |
319 | {"encrypted", CONF_FLAGS_ENCRYPTED }, | |
320 | {"spoof_notice", CONF_FLAGS_SPOOF_NOTICE }, | |
321 | {"exceed_limit", CONF_FLAGS_NOLIMIT }, | |
322 | {"dnsbl_exempt", CONF_FLAGS_EXEMPTDNSBL }, | |
323 | {"kline_exempt", CONF_FLAGS_EXEMPTKLINE }, | |
212380e3 | 324 | {"flood_exempt", CONF_FLAGS_EXEMPTFLOOD }, |
325 | {"spambot_exempt", CONF_FLAGS_EXEMPTSPAMBOT }, | |
326 | {"shide_exempt", CONF_FLAGS_EXEMPTSHIDE }, | |
327 | {"jupe_exempt", CONF_FLAGS_EXEMPTJUPE }, | |
328 | {"resv_exempt", CONF_FLAGS_EXEMPTRESV }, | |
329 | {"no_tilde", CONF_FLAGS_NO_TILDE }, | |
330 | {"need_ident", CONF_FLAGS_NEED_IDENTD }, | |
331 | {"have_ident", CONF_FLAGS_NEED_IDENTD }, | |
663bbb28 | 332 | {"need_ssl", CONF_FLAGS_NEED_SSL }, |
212380e3 | 333 | {"need_sasl", CONF_FLAGS_NEED_SASL }, |
334 | {NULL, 0} | |
335 | }; | |
336 | ||
337 | static struct mode_table connect_table[] = { | |
338 | { "autoconn", SERVER_AUTOCONN }, | |
339 | { "compressed", SERVER_COMPRESSED }, | |
340 | { "encrypted", SERVER_ENCRYPTED }, | |
341 | { "topicburst", SERVER_TB }, | |
8db00894 | 342 | { "ssl", SERVER_SSL }, |
212380e3 | 343 | { NULL, 0 }, |
344 | }; | |
345 | ||
346 | static struct mode_table cluster_table[] = { | |
347 | { "kline", SHARED_PKLINE }, | |
348 | { "tkline", SHARED_TKLINE }, | |
349 | { "unkline", SHARED_UNKLINE }, | |
350 | { "locops", SHARED_LOCOPS }, | |
351 | { "xline", SHARED_PXLINE }, | |
352 | { "txline", SHARED_TXLINE }, | |
353 | { "unxline", SHARED_UNXLINE }, | |
354 | { "resv", SHARED_PRESV }, | |
355 | { "tresv", SHARED_TRESV }, | |
356 | { "unresv", SHARED_UNRESV }, | |
357 | { "all", CLUSTER_ALL }, | |
358 | {NULL, 0} | |
359 | }; | |
360 | ||
361 | static struct mode_table shared_table[] = | |
362 | { | |
363 | { "kline", SHARED_PKLINE|SHARED_TKLINE }, | |
364 | { "xline", SHARED_PXLINE|SHARED_TXLINE }, | |
365 | { "resv", SHARED_PRESV|SHARED_TRESV }, | |
45be325c VY |
366 | { "dline", SHARED_PDLINE|SHARED_TDLINE }, |
367 | { "tdline", SHARED_TDLINE }, | |
368 | { "pdline", SHARED_PDLINE }, | |
369 | { "undline", SHARED_UNDLINE }, | |
212380e3 | 370 | { "tkline", SHARED_TKLINE }, |
371 | { "unkline", SHARED_UNKLINE }, | |
372 | { "txline", SHARED_TXLINE }, | |
373 | { "unxline", SHARED_UNXLINE }, | |
374 | { "tresv", SHARED_TRESV }, | |
375 | { "unresv", SHARED_UNRESV }, | |
376 | { "locops", SHARED_LOCOPS }, | |
377 | { "rehash", SHARED_REHASH }, | |
378 | { "all", SHARED_ALL }, | |
379 | { "none", 0 }, | |
380 | {NULL, 0} | |
381 | }; | |
382 | /* *INDENT-ON* */ | |
383 | ||
384 | static int | |
385 | find_umode(struct mode_table *tab, const char *name) | |
386 | { | |
387 | int i; | |
388 | ||
389 | for (i = 0; tab[i].name; i++) | |
390 | { | |
391 | if(strcmp(tab[i].name, name) == 0) | |
392 | return tab[i].mode; | |
393 | } | |
394 | ||
395 | return -1; | |
396 | } | |
397 | ||
398 | static void | |
399 | set_modes_from_table(int *modes, const char *whatis, struct mode_table *tab, conf_parm_t * args) | |
400 | { | |
401 | for (; args; args = args->next) | |
402 | { | |
403 | const char *umode; | |
404 | int dir = 1; | |
405 | int mode; | |
406 | ||
407 | if((args->type & CF_MTYPE) != CF_STRING) | |
408 | { | |
409 | conf_report_error("Warning -- %s is not a string; ignoring.", whatis); | |
410 | continue; | |
411 | } | |
412 | ||
413 | umode = args->v.string; | |
414 | ||
415 | if(*umode == '~') | |
416 | { | |
417 | dir = 0; | |
418 | umode++; | |
419 | } | |
420 | ||
421 | mode = find_umode(tab, umode); | |
422 | ||
423 | if(mode == -1) | |
424 | { | |
425 | conf_report_error("Warning -- unknown %s %s.", whatis, args->v.string); | |
426 | continue; | |
427 | } | |
428 | ||
429 | if(mode) | |
430 | { | |
431 | if(dir) | |
432 | *modes |= mode; | |
433 | else | |
434 | *modes &= ~mode; | |
435 | } | |
436 | else | |
437 | *modes = 0; | |
438 | } | |
439 | } | |
440 | ||
de0e9f37 WP |
441 | static void |
442 | conf_set_privset_extends(void *data) | |
443 | { | |
444 | yy_privset_extends = rb_strdup((char *) data); | |
445 | } | |
446 | ||
447 | static void | |
448 | conf_set_privset_privs(void *data) | |
449 | { | |
450 | char *privs = NULL; | |
451 | conf_parm_t *args = data; | |
452 | ||
453 | for (; args; args = args->next) | |
454 | { | |
455 | if (privs == NULL) | |
456 | privs = rb_strdup(args->v.string); | |
457 | else | |
458 | { | |
459 | char *privs_old = privs; | |
460 | ||
461 | privs = rb_malloc(strlen(privs_old) + 1 + strlen(args->v.string) + 1); | |
39352a39 | 462 | strcpy(privs, privs_old); |
de0e9f37 WP |
463 | strcat(privs, " "); |
464 | strcat(privs, args->v.string); | |
465 | ||
466 | rb_free(privs_old); | |
467 | } | |
468 | } | |
469 | ||
470 | if (privs) | |
471 | { | |
472 | if (yy_privset_extends) | |
473 | { | |
474 | struct PrivilegeSet *set = privilegeset_get(yy_privset_extends); | |
475 | ||
476 | if (!set) | |
477 | { | |
5a6d4202 | 478 | conf_report_error("Warning -- unknown parent privilege set %s for %s; assuming defaults", yy_privset_extends, conf_cur_block_name); |
de0e9f37 | 479 | |
5a6d4202 | 480 | set = privilegeset_get("default"); |
de0e9f37 WP |
481 | } |
482 | ||
483 | privilegeset_extend(set, conf_cur_block_name != NULL ? conf_cur_block_name : "<unknown>", privs, 0); | |
484 | ||
485 | rb_free(yy_privset_extends); | |
486 | yy_privset_extends = NULL; | |
487 | } | |
488 | else | |
489 | privilegeset_set_new(conf_cur_block_name != NULL ? conf_cur_block_name : "<unknown>", privs, 0); | |
490 | ||
491 | rb_free(privs); | |
492 | } | |
493 | } | |
494 | ||
212380e3 | 495 | static int |
496 | conf_begin_oper(struct TopConf *tc) | |
497 | { | |
af81d5a0 | 498 | rb_dlink_node *ptr; |
90a3c35b | 499 | rb_dlink_node *next_ptr; |
212380e3 | 500 | |
501 | if(yy_oper != NULL) | |
502 | { | |
503 | free_oper_conf(yy_oper); | |
504 | yy_oper = NULL; | |
505 | } | |
506 | ||
90a3c35b | 507 | RB_DLINK_FOREACH_SAFE(ptr, next_ptr, yy_oper_list.head) |
212380e3 | 508 | { |
509 | free_oper_conf(ptr->data); | |
af81d5a0 | 510 | rb_dlinkDestroy(ptr, &yy_oper_list); |
212380e3 | 511 | } |
512 | ||
513 | yy_oper = make_oper_conf(); | |
850b23f3 | 514 | yy_oper->flags |= OPER_ENCRYPTED; |
212380e3 | 515 | |
516 | return 0; | |
517 | } | |
518 | ||
519 | static int | |
520 | conf_end_oper(struct TopConf *tc) | |
521 | { | |
522 | struct oper_conf *yy_tmpoper; | |
af81d5a0 | 523 | rb_dlink_node *ptr; |
90a3c35b | 524 | rb_dlink_node *next_ptr; |
212380e3 | 525 | |
526 | if(conf_cur_block_name != NULL) | |
527 | { | |
528 | if(strlen(conf_cur_block_name) > OPERNICKLEN) | |
529 | conf_cur_block_name[OPERNICKLEN] = '\0'; | |
530 | ||
62d28946 | 531 | yy_oper->name = rb_strdup(conf_cur_block_name); |
212380e3 | 532 | } |
533 | ||
534 | if(EmptyString(yy_oper->name)) | |
535 | { | |
536 | conf_report_error("Ignoring operator block -- missing name."); | |
537 | return 0; | |
538 | } | |
539 | ||
540 | #ifdef HAVE_LIBCRYPTO | |
541 | if(EmptyString(yy_oper->passwd) && EmptyString(yy_oper->rsa_pubkey_file)) | |
542 | #else | |
543 | if(EmptyString(yy_oper->passwd)) | |
544 | #endif | |
545 | { | |
546 | conf_report_error("Ignoring operator block for %s -- missing password", | |
547 | yy_oper->name); | |
548 | return 0; | |
549 | } | |
550 | ||
220c6340 JT |
551 | |
552 | if (!yy_oper->privset) | |
553 | yy_oper->privset = privilegeset_get("default"); | |
554 | ||
212380e3 | 555 | /* now, yy_oper_list contains a stack of oper_conf's with just user |
556 | * and host in, yy_oper contains the rest of the information which | |
557 | * we need to copy into each element in yy_oper_list | |
558 | */ | |
90a3c35b | 559 | RB_DLINK_FOREACH_SAFE(ptr, next_ptr, yy_oper_list.head) |
212380e3 | 560 | { |
561 | yy_tmpoper = ptr->data; | |
562 | ||
62d28946 | 563 | yy_tmpoper->name = rb_strdup(yy_oper->name); |
212380e3 | 564 | |
565 | /* could be an rsa key instead.. */ | |
566 | if(!EmptyString(yy_oper->passwd)) | |
62d28946 | 567 | yy_tmpoper->passwd = rb_strdup(yy_oper->passwd); |
212380e3 | 568 | |
569 | yy_tmpoper->flags = yy_oper->flags; | |
570 | yy_tmpoper->umodes = yy_oper->umodes; | |
571 | yy_tmpoper->snomask = yy_oper->snomask; | |
b8be4a3f | 572 | yy_tmpoper->privset = yy_oper->privset; |
212380e3 | 573 | |
574 | #ifdef HAVE_LIBCRYPTO | |
575 | if(yy_oper->rsa_pubkey_file) | |
576 | { | |
577 | BIO *file; | |
578 | ||
579 | if((file = BIO_new_file(yy_oper->rsa_pubkey_file, "r")) == NULL) | |
580 | { | |
581 | conf_report_error("Ignoring operator block for %s -- " | |
582 | "rsa_public_key_file cant be opened", | |
583 | yy_tmpoper->name); | |
584 | return 0; | |
585 | } | |
586 | ||
587 | yy_tmpoper->rsa_pubkey = | |
588 | (RSA *) PEM_read_bio_RSA_PUBKEY(file, NULL, 0, NULL); | |
589 | ||
c422d2a0 | 590 | (void)BIO_set_close(file, BIO_CLOSE); |
212380e3 | 591 | BIO_free(file); |
592 | ||
593 | if(yy_tmpoper->rsa_pubkey == NULL) | |
594 | { | |
595 | conf_report_error("Ignoring operator block for %s -- " | |
596 | "rsa_public_key_file key invalid; check syntax", | |
597 | yy_tmpoper->name); | |
598 | return 0; | |
599 | } | |
600 | } | |
601 | #endif | |
602 | ||
603 | /* all is ok, put it on oper_conf_list */ | |
af81d5a0 | 604 | rb_dlinkMoveNode(ptr, &yy_oper_list, &oper_conf_list); |
212380e3 | 605 | } |
606 | ||
607 | free_oper_conf(yy_oper); | |
608 | yy_oper = NULL; | |
609 | ||
610 | return 0; | |
611 | } | |
612 | ||
613 | static void | |
614 | conf_set_oper_flags(void *data) | |
615 | { | |
616 | conf_parm_t *args = data; | |
617 | ||
d2b16c20 | 618 | set_modes_from_table(&yy_oper->flags, "flag", oper_table, args); |
212380e3 | 619 | } |
620 | ||
d8a023ed WP |
621 | static void |
622 | conf_set_oper_fingerprint(void *data) | |
623 | { | |
624 | yy_oper->certfp = rb_strdup((char *) data); | |
625 | } | |
626 | ||
b8be4a3f WP |
627 | static void |
628 | conf_set_oper_privset(void *data) | |
629 | { | |
630 | yy_oper->privset = privilegeset_get((char *) data); | |
631 | } | |
632 | ||
212380e3 | 633 | static void |
634 | conf_set_oper_user(void *data) | |
635 | { | |
636 | struct oper_conf *yy_tmpoper; | |
637 | char *p; | |
638 | char *host = (char *) data; | |
639 | ||
640 | yy_tmpoper = make_oper_conf(); | |
641 | ||
642 | if((p = strchr(host, '@'))) | |
643 | { | |
644 | *p++ = '\0'; | |
645 | ||
62d28946 VY |
646 | yy_tmpoper->username = rb_strdup(host); |
647 | yy_tmpoper->host = rb_strdup(p); | |
212380e3 | 648 | } |
649 | else | |
650 | { | |
651 | ||
62d28946 VY |
652 | yy_tmpoper->username = rb_strdup("*"); |
653 | yy_tmpoper->host = rb_strdup(host); | |
212380e3 | 654 | } |
655 | ||
656 | if(EmptyString(yy_tmpoper->username) || EmptyString(yy_tmpoper->host)) | |
657 | { | |
658 | conf_report_error("Ignoring user -- missing username/host"); | |
659 | free_oper_conf(yy_tmpoper); | |
660 | return; | |
661 | } | |
662 | ||
af81d5a0 | 663 | rb_dlinkAddAlloc(yy_tmpoper, &yy_oper_list); |
212380e3 | 664 | } |
665 | ||
666 | static void | |
667 | conf_set_oper_password(void *data) | |
668 | { | |
669 | if(yy_oper->passwd) | |
670 | { | |
671 | memset(yy_oper->passwd, 0, strlen(yy_oper->passwd)); | |
90a3c35b | 672 | rb_free(yy_oper->passwd); |
212380e3 | 673 | } |
674 | ||
62d28946 | 675 | yy_oper->passwd = rb_strdup((char *) data); |
212380e3 | 676 | } |
677 | ||
678 | static void | |
679 | conf_set_oper_rsa_public_key_file(void *data) | |
680 | { | |
681 | #ifdef HAVE_LIBCRYPTO | |
90a3c35b | 682 | rb_free(yy_oper->rsa_pubkey_file); |
62d28946 | 683 | yy_oper->rsa_pubkey_file = rb_strdup((char *) data); |
212380e3 | 684 | #else |
685 | conf_report_error("Warning -- ignoring rsa_public_key_file (OpenSSL support not available"); | |
686 | #endif | |
687 | } | |
688 | ||
689 | static void | |
690 | conf_set_oper_umodes(void *data) | |
691 | { | |
692 | set_modes_from_table(&yy_oper->umodes, "umode", umode_table, data); | |
693 | } | |
694 | ||
695 | static void | |
696 | conf_set_oper_snomask(void *data) | |
697 | { | |
698 | yy_oper->snomask = parse_snobuf_to_mask(0, (const char *) data); | |
699 | } | |
700 | ||
701 | static int | |
702 | conf_begin_class(struct TopConf *tc) | |
703 | { | |
704 | if(yy_class) | |
705 | free_class(yy_class); | |
706 | ||
707 | yy_class = make_class(); | |
708 | return 0; | |
709 | } | |
710 | ||
711 | static int | |
712 | conf_end_class(struct TopConf *tc) | |
713 | { | |
714 | if(conf_cur_block_name != NULL) | |
62d28946 | 715 | yy_class->class_name = rb_strdup(conf_cur_block_name); |
212380e3 | 716 | |
717 | if(EmptyString(yy_class->class_name)) | |
718 | { | |
719 | conf_report_error("Ignoring connect block -- missing name."); | |
720 | return 0; | |
721 | } | |
722 | ||
723 | add_class(yy_class); | |
724 | yy_class = NULL; | |
725 | return 0; | |
726 | } | |
727 | ||
728 | static void | |
729 | conf_set_class_ping_time(void *data) | |
730 | { | |
731 | yy_class->ping_freq = *(unsigned int *) data; | |
732 | } | |
733 | ||
734 | static void | |
c8d85889 | 735 | conf_set_class_cidr_ipv4_bitlen(void *data) |
212380e3 | 736 | { |
c8d85889 JT |
737 | unsigned int maxsize = 32; |
738 | if(*(unsigned int *) data > maxsize) | |
739 | conf_report_error | |
740 | ("class::cidr_ipv4_bitlen argument exceeds maxsize (%d > %d) - ignoring.", | |
741 | *(unsigned int *) data, maxsize); | |
742 | else | |
743 | yy_class->cidr_ipv4_bitlen = *(unsigned int *) data; | |
744 | ||
745 | } | |
746 | ||
2c2e0aa9 | 747 | #ifdef RB_IPV6 |
c8d85889 JT |
748 | static void |
749 | conf_set_class_cidr_ipv6_bitlen(void *data) | |
750 | { | |
212380e3 | 751 | unsigned int maxsize = 128; |
212380e3 | 752 | if(*(unsigned int *) data > maxsize) |
753 | conf_report_error | |
c8d85889 | 754 | ("class::cidr_ipv6_bitlen argument exceeds maxsize (%d > %d) - ignoring.", |
212380e3 | 755 | *(unsigned int *) data, maxsize); |
756 | else | |
c8d85889 | 757 | yy_class->cidr_ipv6_bitlen = *(unsigned int *) data; |
212380e3 | 758 | |
759 | } | |
c8d85889 JT |
760 | #endif |
761 | ||
212380e3 | 762 | static void |
763 | conf_set_class_number_per_cidr(void *data) | |
764 | { | |
765 | yy_class->cidr_amount = *(unsigned int *) data; | |
766 | } | |
767 | ||
768 | static void | |
769 | conf_set_class_number_per_ip(void *data) | |
770 | { | |
771 | yy_class->max_local = *(unsigned int *) data; | |
772 | } | |
773 | ||
774 | ||
775 | static void | |
776 | conf_set_class_number_per_ip_global(void *data) | |
777 | { | |
778 | yy_class->max_global = *(unsigned int *) data; | |
779 | } | |
780 | ||
781 | static void | |
782 | conf_set_class_number_per_ident(void *data) | |
783 | { | |
784 | yy_class->max_ident = *(unsigned int *) data; | |
785 | } | |
786 | ||
787 | static void | |
788 | conf_set_class_connectfreq(void *data) | |
789 | { | |
790 | yy_class->con_freq = *(unsigned int *) data; | |
791 | } | |
792 | ||
793 | static void | |
794 | conf_set_class_max_number(void *data) | |
795 | { | |
796 | yy_class->max_total = *(unsigned int *) data; | |
797 | } | |
798 | ||
799 | static void | |
800 | conf_set_class_sendq(void *data) | |
801 | { | |
802 | yy_class->max_sendq = *(unsigned int *) data; | |
803 | } | |
804 | ||
805 | static char *listener_address; | |
806 | ||
807 | static int | |
808 | conf_begin_listen(struct TopConf *tc) | |
809 | { | |
90a3c35b | 810 | rb_free(listener_address); |
212380e3 | 811 | listener_address = NULL; |
812 | return 0; | |
813 | } | |
814 | ||
815 | static int | |
816 | conf_end_listen(struct TopConf *tc) | |
817 | { | |
90a3c35b | 818 | rb_free(listener_address); |
212380e3 | 819 | listener_address = NULL; |
820 | return 0; | |
821 | } | |
822 | ||
8db00894 VY |
823 | |
824 | ||
212380e3 | 825 | static void |
8db00894 | 826 | conf_set_listen_port_both(void *data, int ssl) |
212380e3 | 827 | { |
828 | conf_parm_t *args = data; | |
829 | for (; args; args = args->next) | |
830 | { | |
831 | if((args->type & CF_MTYPE) != CF_INT) | |
832 | { | |
833 | conf_report_error | |
834 | ("listener::port argument is not an integer " "-- ignoring."); | |
835 | continue; | |
836 | } | |
837 | if(listener_address == NULL) | |
838 | { | |
8db00894 | 839 | add_listener(args->v.number, listener_address, AF_INET, ssl); |
2c2e0aa9 | 840 | #ifdef RB_IPV6 |
8db00894 | 841 | add_listener(args->v.number, listener_address, AF_INET6, ssl); |
212380e3 | 842 | #endif |
843 | } | |
844 | else | |
845 | { | |
846 | int family; | |
2c2e0aa9 | 847 | #ifdef RB_IPV6 |
212380e3 | 848 | if(strchr(listener_address, ':') != NULL) |
849 | family = AF_INET6; | |
850 | else | |
851 | #endif | |
852 | family = AF_INET; | |
853 | ||
8db00894 | 854 | add_listener(args->v.number, listener_address, family, ssl); |
212380e3 | 855 | |
856 | } | |
857 | ||
858 | } | |
859 | } | |
860 | ||
b717a466 JT |
861 | static void |
862 | conf_set_listen_port(void *data) | |
863 | { | |
864 | conf_set_listen_port_both(data, 0); | |
865 | } | |
866 | ||
867 | static void | |
868 | conf_set_listen_sslport(void *data) | |
869 | { | |
870 | conf_set_listen_port_both(data, 1); | |
8db00894 VY |
871 | } |
872 | ||
212380e3 | 873 | static void |
874 | conf_set_listen_address(void *data) | |
875 | { | |
90a3c35b | 876 | rb_free(listener_address); |
62d28946 | 877 | listener_address = rb_strdup(data); |
212380e3 | 878 | } |
879 | ||
880 | static int | |
881 | conf_begin_auth(struct TopConf *tc) | |
882 | { | |
af81d5a0 | 883 | rb_dlink_node *ptr; |
90a3c35b | 884 | rb_dlink_node *next_ptr; |
212380e3 | 885 | |
886 | if(yy_aconf) | |
887 | free_conf(yy_aconf); | |
888 | ||
90a3c35b | 889 | RB_DLINK_FOREACH_SAFE(ptr, next_ptr, yy_aconf_list.head) |
212380e3 | 890 | { |
891 | free_conf(ptr->data); | |
af81d5a0 | 892 | rb_dlinkDestroy(ptr, &yy_aconf_list); |
212380e3 | 893 | } |
894 | ||
895 | yy_aconf = make_conf(); | |
896 | yy_aconf->status = CONF_CLIENT; | |
897 | ||
898 | return 0; | |
899 | } | |
900 | ||
901 | static int | |
902 | conf_end_auth(struct TopConf *tc) | |
903 | { | |
67cc1f0c | 904 | struct ConfItem *yy_tmp, *found_conf; |
af81d5a0 | 905 | rb_dlink_node *ptr; |
90a3c35b | 906 | rb_dlink_node *next_ptr; |
212380e3 | 907 | |
908 | if(EmptyString(yy_aconf->name)) | |
62d28946 | 909 | yy_aconf->name = rb_strdup("NOMATCH"); |
212380e3 | 910 | |
911 | /* didnt even get one ->host? */ | |
912 | if(EmptyString(yy_aconf->host)) | |
913 | { | |
914 | conf_report_error("Ignoring auth block -- missing user@host"); | |
915 | return 0; | |
916 | } | |
917 | ||
918 | /* so the stacking works in order.. */ | |
919 | collapse(yy_aconf->user); | |
920 | collapse(yy_aconf->host); | |
921 | conf_add_class_to_conf(yy_aconf); | |
67cc1f0c | 922 | if ((found_conf = find_exact_conf_by_address("*", CONF_CLIENT, "*")) && found_conf->spasswd == NULL) |
4ffad8e6 | 923 | conf_report_error("Ignoring redundant auth block (after *@*)"); |
67cc1f0c | 924 | else if ((found_conf = find_exact_conf_by_address(yy_aconf->host, CONF_CLIENT, yy_aconf->user)) && |
cfc83348 | 925 | (!found_conf->spasswd || (yy_aconf->spasswd && |
67cc1f0c | 926 | 0 == irccmp(found_conf->spasswd, yy_aconf->spasswd)))) |
4ffad8e6 JT |
927 | conf_report_error("Ignoring duplicate auth block for %s@%s", |
928 | yy_aconf->user, yy_aconf->host); | |
929 | else | |
930 | add_conf_by_address(yy_aconf->host, CONF_CLIENT, yy_aconf->user, yy_aconf->spasswd, yy_aconf); | |
212380e3 | 931 | |
90a3c35b | 932 | RB_DLINK_FOREACH_SAFE(ptr, next_ptr, yy_aconf_list.head) |
212380e3 | 933 | { |
934 | yy_tmp = ptr->data; | |
935 | ||
936 | if(yy_aconf->passwd) | |
62d28946 | 937 | yy_tmp->passwd = rb_strdup(yy_aconf->passwd); |
212380e3 | 938 | |
969a1ae6 VY |
939 | if(yy_aconf->spasswd) |
940 | yy_tmp->spasswd = rb_strdup(yy_aconf->spasswd); | |
941 | ||
212380e3 | 942 | /* this will always exist.. */ |
62d28946 | 943 | yy_tmp->name = rb_strdup(yy_aconf->name); |
212380e3 | 944 | |
945 | if(yy_aconf->className) | |
62d28946 | 946 | yy_tmp->className = rb_strdup(yy_aconf->className); |
212380e3 | 947 | |
948 | yy_tmp->flags = yy_aconf->flags; | |
949 | yy_tmp->port = yy_aconf->port; | |
950 | ||
951 | collapse(yy_tmp->user); | |
952 | collapse(yy_tmp->host); | |
953 | ||
954 | conf_add_class_to_conf(yy_tmp); | |
955 | ||
4ffad8e6 JT |
956 | if (find_exact_conf_by_address("*", CONF_CLIENT, "*")) |
957 | conf_report_error("Ignoring redundant auth block (after *@*)"); | |
958 | else if (find_exact_conf_by_address(yy_tmp->host, CONF_CLIENT, yy_tmp->user)) | |
959 | conf_report_error("Ignoring duplicate auth block for %s@%s", | |
960 | yy_tmp->user, yy_tmp->host); | |
961 | else | |
962 | add_conf_by_address(yy_tmp->host, CONF_CLIENT, yy_tmp->user, yy_tmp->spasswd, yy_tmp); | |
af81d5a0 | 963 | rb_dlinkDestroy(ptr, &yy_aconf_list); |
212380e3 | 964 | } |
965 | ||
966 | yy_aconf = NULL; | |
967 | return 0; | |
968 | } | |
969 | ||
970 | static void | |
971 | conf_set_auth_user(void *data) | |
972 | { | |
973 | struct ConfItem *yy_tmp; | |
974 | char *p; | |
975 | ||
976 | /* The first user= line doesn't allocate a new conf */ | |
977 | if(!EmptyString(yy_aconf->host)) | |
978 | { | |
979 | yy_tmp = make_conf(); | |
980 | yy_tmp->status = CONF_CLIENT; | |
981 | } | |
982 | else | |
983 | yy_tmp = yy_aconf; | |
984 | ||
985 | if((p = strchr(data, '@'))) | |
986 | { | |
987 | *p++ = '\0'; | |
988 | ||
62d28946 VY |
989 | yy_tmp->user = rb_strdup(data); |
990 | yy_tmp->host = rb_strdup(p); | |
212380e3 | 991 | } |
992 | else | |
993 | { | |
62d28946 VY |
994 | yy_tmp->user = rb_strdup("*"); |
995 | yy_tmp->host = rb_strdup(data); | |
212380e3 | 996 | } |
997 | ||
998 | if(yy_aconf != yy_tmp) | |
af81d5a0 | 999 | rb_dlinkAddAlloc(yy_tmp, &yy_aconf_list); |
212380e3 | 1000 | } |
1001 | ||
969a1ae6 VY |
1002 | static void |
1003 | conf_set_auth_auth_user(void *data) | |
1004 | { | |
1005 | if(yy_aconf->spasswd) | |
1006 | memset(yy_aconf->spasswd, 0, strlen(yy_aconf->spasswd)); | |
1007 | rb_free(yy_aconf->spasswd); | |
1008 | yy_aconf->spasswd = rb_strdup(data); | |
1009 | } | |
1010 | ||
212380e3 | 1011 | static void |
1012 | conf_set_auth_passwd(void *data) | |
1013 | { | |
1014 | if(yy_aconf->passwd) | |
1015 | memset(yy_aconf->passwd, 0, strlen(yy_aconf->passwd)); | |
90a3c35b | 1016 | rb_free(yy_aconf->passwd); |
62d28946 | 1017 | yy_aconf->passwd = rb_strdup(data); |
212380e3 | 1018 | } |
1019 | ||
fa72cee1 JH |
1020 | static void |
1021 | conf_set_auth_autojoin(void *data) | |
1022 | { | |
1023 | if(yy_aconf->autojoin) | |
1024 | memset(yy_aconf->autojoin, 0, strlen(yy_aconf->autojoin)); | |
1025 | rb_free(yy_aconf->autojoin); | |
1026 | yy_aconf->autojoin = rb_strdup(data); | |
1027 | } | |
1028 | ||
87f58b4f JH |
1029 | static void |
1030 | conf_set_auth_autojoin_opers(void *data) | |
1031 | { | |
1032 | if(yy_aconf->autojoin_opers) | |
1033 | memset(yy_aconf->autojoin_opers, 0, strlen(yy_aconf->autojoin)); | |
1034 | rb_free(yy_aconf->autojoin_opers); | |
1035 | yy_aconf->autojoin_opers = rb_strdup(data); | |
1036 | } | |
1037 | ||
212380e3 | 1038 | static void |
1039 | conf_set_auth_spoof(void *data) | |
1040 | { | |
1041 | char *p; | |
1042 | char *user = NULL; | |
1043 | char *host = NULL; | |
1044 | ||
1045 | host = data; | |
1046 | ||
1047 | /* user@host spoof */ | |
1048 | if((p = strchr(host, '@')) != NULL) | |
1049 | { | |
1050 | *p = '\0'; | |
1051 | user = data; | |
1052 | host = p+1; | |
1053 | ||
1054 | if(EmptyString(user)) | |
1055 | { | |
1056 | conf_report_error("Warning -- spoof ident empty."); | |
1057 | return; | |
1058 | } | |
1059 | ||
1060 | if(strlen(user) > USERLEN) | |
1061 | { | |
1062 | conf_report_error("Warning -- spoof ident length invalid."); | |
1063 | return; | |
1064 | } | |
1065 | ||
1066 | if(!valid_username(user)) | |
1067 | { | |
1068 | conf_report_error("Warning -- invalid spoof (ident)."); | |
1069 | return; | |
1070 | } | |
1071 | ||
1072 | /* this must be restored! */ | |
1073 | *p = '@'; | |
1074 | } | |
1075 | ||
1076 | if(EmptyString(host)) | |
1077 | { | |
1078 | conf_report_error("Warning -- spoof host empty."); | |
1079 | return; | |
1080 | } | |
1081 | ||
1082 | if(strlen(host) > HOSTLEN) | |
1083 | { | |
1084 | conf_report_error("Warning -- spoof host length invalid."); | |
1085 | return; | |
1086 | } | |
1087 | ||
1088 | if(!valid_hostname(host)) | |
1089 | { | |
1090 | conf_report_error("Warning -- invalid spoof (host)."); | |
1091 | return; | |
1092 | } | |
1093 | ||
90a3c35b | 1094 | rb_free(yy_aconf->name); |
62d28946 | 1095 | yy_aconf->name = rb_strdup(data); |
212380e3 | 1096 | yy_aconf->flags |= CONF_FLAGS_SPOOF_IP; |
1097 | } | |
1098 | ||
1099 | static void | |
1100 | conf_set_auth_flags(void *data) | |
1101 | { | |
1102 | conf_parm_t *args = data; | |
1103 | ||
1104 | set_modes_from_table((int *) &yy_aconf->flags, "flag", auth_table, args); | |
1105 | } | |
1106 | ||
1107 | static void | |
1108 | conf_set_auth_redir_serv(void *data) | |
1109 | { | |
1110 | yy_aconf->flags |= CONF_FLAGS_REDIR; | |
90a3c35b | 1111 | rb_free(yy_aconf->name); |
62d28946 | 1112 | yy_aconf->name = rb_strdup(data); |
212380e3 | 1113 | } |
1114 | ||
1115 | static void | |
1116 | conf_set_auth_redir_port(void *data) | |
1117 | { | |
1118 | int port = *(unsigned int *) data; | |
1119 | ||
1120 | yy_aconf->flags |= CONF_FLAGS_REDIR; | |
1121 | yy_aconf->port = port; | |
1122 | } | |
1123 | ||
1124 | static void | |
1125 | conf_set_auth_class(void *data) | |
1126 | { | |
90a3c35b | 1127 | rb_free(yy_aconf->className); |
62d28946 | 1128 | yy_aconf->className = rb_strdup(data); |
212380e3 | 1129 | } |
1130 | ||
1131 | /* ok, shared_oper handles the stacking, shared_flags handles adding | |
1132 | * things.. so all we need to do when we start and end a shared block, is | |
1133 | * clean up anything thats been left over. | |
1134 | */ | |
1135 | static int | |
1136 | conf_cleanup_shared(struct TopConf *tc) | |
1137 | { | |
90a3c35b | 1138 | rb_dlink_node *ptr, *next_ptr; |
212380e3 | 1139 | |
90a3c35b | 1140 | RB_DLINK_FOREACH_SAFE(ptr, next_ptr, yy_shared_list.head) |
212380e3 | 1141 | { |
1142 | free_remote_conf(ptr->data); | |
af81d5a0 | 1143 | rb_dlinkDestroy(ptr, &yy_shared_list); |
212380e3 | 1144 | } |
1145 | ||
1146 | if(yy_shared != NULL) | |
1147 | { | |
1148 | free_remote_conf(yy_shared); | |
1149 | yy_shared = NULL; | |
1150 | } | |
1151 | ||
1152 | return 0; | |
1153 | } | |
1154 | ||
1155 | static void | |
1156 | conf_set_shared_oper(void *data) | |
1157 | { | |
1158 | conf_parm_t *args = data; | |
1159 | const char *username; | |
1160 | char *p; | |
1161 | ||
1162 | if(yy_shared != NULL) | |
1163 | free_remote_conf(yy_shared); | |
1164 | ||
1165 | yy_shared = make_remote_conf(); | |
1166 | ||
1167 | if(args->next != NULL) | |
1168 | { | |
1169 | if((args->type & CF_MTYPE) != CF_QSTRING) | |
1170 | { | |
1171 | conf_report_error("Ignoring shared::oper -- server is not a qstring"); | |
1172 | return; | |
1173 | } | |
1174 | ||
62d28946 | 1175 | yy_shared->server = rb_strdup(args->v.string); |
212380e3 | 1176 | args = args->next; |
1177 | } | |
1178 | else | |
62d28946 | 1179 | yy_shared->server = rb_strdup("*"); |
212380e3 | 1180 | |
1181 | if((args->type & CF_MTYPE) != CF_QSTRING) | |
1182 | { | |
1183 | conf_report_error("Ignoring shared::oper -- oper is not a qstring"); | |
1184 | return; | |
1185 | } | |
1186 | ||
1187 | if((p = strchr(args->v.string, '@')) == NULL) | |
1188 | { | |
1189 | conf_report_error("Ignoring shard::oper -- oper is not a user@host"); | |
1190 | return; | |
1191 | } | |
1192 | ||
1193 | username = args->v.string; | |
1194 | *p++ = '\0'; | |
1195 | ||
1196 | if(EmptyString(p)) | |
62d28946 | 1197 | yy_shared->host = rb_strdup("*"); |
212380e3 | 1198 | else |
62d28946 | 1199 | yy_shared->host = rb_strdup(p); |
212380e3 | 1200 | |
1201 | if(EmptyString(username)) | |
62d28946 | 1202 | yy_shared->username = rb_strdup("*"); |
212380e3 | 1203 | else |
62d28946 | 1204 | yy_shared->username = rb_strdup(username); |
212380e3 | 1205 | |
af81d5a0 | 1206 | rb_dlinkAddAlloc(yy_shared, &yy_shared_list); |
212380e3 | 1207 | yy_shared = NULL; |
1208 | } | |
1209 | ||
1210 | static void | |
1211 | conf_set_shared_flags(void *data) | |
1212 | { | |
1213 | conf_parm_t *args = data; | |
1214 | int flags = 0; | |
90a3c35b | 1215 | rb_dlink_node *ptr, *next_ptr; |
212380e3 | 1216 | |
1217 | if(yy_shared != NULL) | |
1218 | free_remote_conf(yy_shared); | |
1219 | ||
1220 | set_modes_from_table(&flags, "flag", shared_table, args); | |
1221 | ||
90a3c35b | 1222 | RB_DLINK_FOREACH_SAFE(ptr, next_ptr, yy_shared_list.head) |
212380e3 | 1223 | { |
1224 | yy_shared = ptr->data; | |
1225 | ||
1226 | yy_shared->flags = flags; | |
af81d5a0 WP |
1227 | rb_dlinkDestroy(ptr, &yy_shared_list); |
1228 | rb_dlinkAddTail(yy_shared, &yy_shared->node, &shared_conf_list); | |
212380e3 | 1229 | } |
1230 | ||
1231 | yy_shared = NULL; | |
1232 | } | |
1233 | ||
1234 | static int | |
1235 | conf_begin_connect(struct TopConf *tc) | |
1236 | { | |
1237 | if(yy_server) | |
1238 | free_server_conf(yy_server); | |
1239 | ||
1240 | yy_server = make_server_conf(); | |
1241 | yy_server->port = PORTNUM; | |
a71d09f4 | 1242 | yy_server->flags |= SERVER_TB; |
212380e3 | 1243 | |
1244 | if(conf_cur_block_name != NULL) | |
62d28946 | 1245 | yy_server->name = rb_strdup(conf_cur_block_name); |
212380e3 | 1246 | |
1247 | return 0; | |
1248 | } | |
1249 | ||
1250 | static int | |
1251 | conf_end_connect(struct TopConf *tc) | |
1252 | { | |
1253 | if(EmptyString(yy_server->name)) | |
1254 | { | |
1255 | conf_report_error("Ignoring connect block -- missing name."); | |
1256 | return 0; | |
1257 | } | |
1258 | ||
1259 | if(ServerInfo.name != NULL && !irccmp(ServerInfo.name, yy_server->name)) | |
1260 | { | |
1261 | conf_report_error("Ignoring connect block for %s -- name is equal to my own name.", | |
1262 | yy_server->name); | |
1263 | return 0; | |
1264 | } | |
1265 | ||
1266 | if(EmptyString(yy_server->passwd) || EmptyString(yy_server->spasswd)) | |
1267 | { | |
1268 | conf_report_error("Ignoring connect block for %s -- missing password.", | |
1269 | yy_server->name); | |
1270 | return 0; | |
1271 | } | |
1272 | ||
1273 | if(EmptyString(yy_server->host)) | |
1274 | { | |
1275 | conf_report_error("Ignoring connect block for %s -- missing host.", | |
1276 | yy_server->name); | |
1277 | return 0; | |
1278 | } | |
1279 | ||
1280 | #ifndef HAVE_LIBZ | |
1281 | if(ServerConfCompressed(yy_server)) | |
1282 | { | |
1283 | conf_report_error("Ignoring connect::flags::compressed -- zlib not available."); | |
1284 | yy_server->flags &= ~SERVER_COMPRESSED; | |
1285 | } | |
1286 | #endif | |
1287 | ||
1288 | add_server_conf(yy_server); | |
af81d5a0 | 1289 | rb_dlinkAdd(yy_server, &yy_server->node, &server_conf_list); |
212380e3 | 1290 | |
1291 | yy_server = NULL; | |
1292 | return 0; | |
1293 | } | |
1294 | ||
1295 | static void | |
1296 | conf_set_connect_host(void *data) | |
1297 | { | |
90a3c35b | 1298 | rb_free(yy_server->host); |
62d28946 | 1299 | yy_server->host = rb_strdup(data); |
212380e3 | 1300 | if (strchr(yy_server->host, ':')) |
1301 | yy_server->aftype = AF_INET6; | |
1302 | } | |
1303 | ||
1304 | static void | |
1305 | conf_set_connect_vhost(void *data) | |
1306 | { | |
9879cd59 | 1307 | if(rb_inet_pton_sock(data, (struct sockaddr *)&yy_server->my_ipnum) <= 0) |
212380e3 | 1308 | { |
1309 | conf_report_error("Invalid netmask for server vhost (%s)", | |
1310 | (char *) data); | |
1311 | return; | |
1312 | } | |
1313 | ||
1314 | yy_server->flags |= SERVER_VHOSTED; | |
1315 | } | |
1316 | ||
1317 | static void | |
1318 | conf_set_connect_send_password(void *data) | |
1319 | { | |
1320 | if(yy_server->spasswd) | |
1321 | { | |
1322 | memset(yy_server->spasswd, 0, strlen(yy_server->spasswd)); | |
90a3c35b | 1323 | rb_free(yy_server->spasswd); |
212380e3 | 1324 | } |
1325 | ||
62d28946 | 1326 | yy_server->spasswd = rb_strdup(data); |
212380e3 | 1327 | } |
1328 | ||
1329 | static void | |
1330 | conf_set_connect_accept_password(void *data) | |
1331 | { | |
1332 | if(yy_server->passwd) | |
1333 | { | |
1334 | memset(yy_server->passwd, 0, strlen(yy_server->passwd)); | |
90a3c35b | 1335 | rb_free(yy_server->passwd); |
212380e3 | 1336 | } |
62d28946 | 1337 | yy_server->passwd = rb_strdup(data); |
212380e3 | 1338 | } |
1339 | ||
1340 | static void | |
1341 | conf_set_connect_port(void *data) | |
1342 | { | |
1343 | int port = *(unsigned int *) data; | |
1344 | ||
1345 | if(port < 1) | |
1346 | port = PORTNUM; | |
1347 | ||
1348 | yy_server->port = port; | |
1349 | } | |
1350 | ||
1351 | static void | |
1352 | conf_set_connect_aftype(void *data) | |
1353 | { | |
1354 | char *aft = data; | |
1355 | ||
1356 | if(strcasecmp(aft, "ipv4") == 0) | |
1357 | yy_server->aftype = AF_INET; | |
2c2e0aa9 | 1358 | #ifdef RB_IPV6 |
212380e3 | 1359 | else if(strcasecmp(aft, "ipv6") == 0) |
1360 | yy_server->aftype = AF_INET6; | |
1361 | #endif | |
1362 | else | |
1363 | conf_report_error("connect::aftype '%s' is unknown.", aft); | |
1364 | } | |
1365 | ||
1366 | static void | |
1367 | conf_set_connect_flags(void *data) | |
1368 | { | |
1369 | conf_parm_t *args = data; | |
1370 | ||
1371 | /* note, we allow them to set compressed, then remove it later if | |
1372 | * they do and LIBZ isnt available | |
1373 | */ | |
1374 | set_modes_from_table(&yy_server->flags, "flag", connect_table, args); | |
1375 | } | |
1376 | ||
1377 | static void | |
1378 | conf_set_connect_hub_mask(void *data) | |
1379 | { | |
1380 | struct remote_conf *yy_hub; | |
1381 | ||
1382 | if(EmptyString(yy_server->name)) | |
1383 | return; | |
1384 | ||
1385 | yy_hub = make_remote_conf(); | |
1386 | yy_hub->flags = CONF_HUB; | |
1387 | ||
62d28946 VY |
1388 | yy_hub->host = rb_strdup(data); |
1389 | yy_hub->server = rb_strdup(yy_server->name); | |
af81d5a0 | 1390 | rb_dlinkAdd(yy_hub, &yy_hub->node, &hubleaf_conf_list); |
212380e3 | 1391 | } |
1392 | ||
1393 | static void | |
1394 | conf_set_connect_leaf_mask(void *data) | |
1395 | { | |
1396 | struct remote_conf *yy_leaf; | |
1397 | ||
1398 | if(EmptyString(yy_server->name)) | |
1399 | return; | |
1400 | ||
1401 | yy_leaf = make_remote_conf(); | |
1402 | yy_leaf->flags = CONF_LEAF; | |
1403 | ||
62d28946 VY |
1404 | yy_leaf->host = rb_strdup(data); |
1405 | yy_leaf->server = rb_strdup(yy_server->name); | |
af81d5a0 | 1406 | rb_dlinkAdd(yy_leaf, &yy_leaf->node, &hubleaf_conf_list); |
212380e3 | 1407 | } |
1408 | ||
1409 | static void | |
1410 | conf_set_connect_class(void *data) | |
1411 | { | |
90a3c35b | 1412 | rb_free(yy_server->class_name); |
62d28946 | 1413 | yy_server->class_name = rb_strdup(data); |
212380e3 | 1414 | } |
1415 | ||
1416 | static void | |
1417 | conf_set_exempt_ip(void *data) | |
1418 | { | |
1419 | struct ConfItem *yy_tmp; | |
1420 | ||
1421 | if(parse_netmask(data, NULL, NULL) == HM_HOST) | |
1422 | { | |
1423 | conf_report_error("Ignoring exempt -- invalid exempt::ip."); | |
1424 | return; | |
1425 | } | |
1426 | ||
1427 | yy_tmp = make_conf(); | |
62d28946 VY |
1428 | yy_tmp->passwd = rb_strdup("*"); |
1429 | yy_tmp->host = rb_strdup(data); | |
212380e3 | 1430 | yy_tmp->status = CONF_EXEMPTDLINE; |
969a1ae6 | 1431 | add_conf_by_address(yy_tmp->host, CONF_EXEMPTDLINE, NULL, NULL, yy_tmp); |
212380e3 | 1432 | } |
1433 | ||
1434 | static int | |
1435 | conf_cleanup_cluster(struct TopConf *tc) | |
1436 | { | |
90a3c35b | 1437 | rb_dlink_node *ptr, *next_ptr; |
212380e3 | 1438 | |
90a3c35b | 1439 | RB_DLINK_FOREACH_SAFE(ptr, next_ptr, yy_cluster_list.head) |
212380e3 | 1440 | { |
1441 | free_remote_conf(ptr->data); | |
af81d5a0 | 1442 | rb_dlinkDestroy(ptr, &yy_cluster_list); |
212380e3 | 1443 | } |
1444 | ||
1445 | if(yy_shared != NULL) | |
1446 | { | |
1447 | free_remote_conf(yy_shared); | |
1448 | yy_shared = NULL; | |
1449 | } | |
1450 | ||
1451 | return 0; | |
1452 | } | |
1453 | ||
1454 | static void | |
1455 | conf_set_cluster_name(void *data) | |
1456 | { | |
1457 | if(yy_shared != NULL) | |
1458 | free_remote_conf(yy_shared); | |
1459 | ||
1460 | yy_shared = make_remote_conf(); | |
62d28946 | 1461 | yy_shared->server = rb_strdup(data); |
af81d5a0 | 1462 | rb_dlinkAddAlloc(yy_shared, &yy_cluster_list); |
212380e3 | 1463 | |
1464 | yy_shared = NULL; | |
1465 | } | |
1466 | ||
1467 | static void | |
1468 | conf_set_cluster_flags(void *data) | |
1469 | { | |
1470 | conf_parm_t *args = data; | |
1471 | int flags = 0; | |
90a3c35b | 1472 | rb_dlink_node *ptr, *next_ptr; |
212380e3 | 1473 | |
1474 | if(yy_shared != NULL) | |
1475 | free_remote_conf(yy_shared); | |
1476 | ||
1477 | set_modes_from_table(&flags, "flag", cluster_table, args); | |
1478 | ||
90a3c35b | 1479 | RB_DLINK_FOREACH_SAFE(ptr, next_ptr, yy_cluster_list.head) |
212380e3 | 1480 | { |
1481 | yy_shared = ptr->data; | |
1482 | yy_shared->flags = flags; | |
af81d5a0 WP |
1483 | rb_dlinkAddTail(yy_shared, &yy_shared->node, &cluster_conf_list); |
1484 | rb_dlinkDestroy(ptr, &yy_cluster_list); | |
212380e3 | 1485 | } |
1486 | ||
1487 | yy_shared = NULL; | |
1488 | } | |
1489 | ||
1490 | static void | |
1491 | conf_set_general_havent_read_conf(void *data) | |
1492 | { | |
1493 | if(*(unsigned int *) data) | |
1494 | { | |
1495 | conf_report_error("You haven't read your config file properly."); | |
1496 | conf_report_error | |
1497 | ("There is a line in the example conf that will kill your server if not removed."); | |
1498 | conf_report_error | |
1499 | ("Consider actually reading/editing the conf file, and removing this line."); | |
1500 | if (!testing_conf) | |
1501 | exit(0); | |
1502 | } | |
1503 | } | |
1504 | ||
1505 | static void | |
1506 | conf_set_general_hide_error_messages(void *data) | |
1507 | { | |
1508 | char *val = data; | |
1509 | ||
1510 | if(strcasecmp(val, "yes") == 0) | |
1511 | ConfigFileEntry.hide_error_messages = 2; | |
1512 | else if(strcasecmp(val, "opers") == 0) | |
1513 | ConfigFileEntry.hide_error_messages = 1; | |
1514 | else if(strcasecmp(val, "no") == 0) | |
1515 | ConfigFileEntry.hide_error_messages = 0; | |
1516 | else | |
1517 | conf_report_error("Invalid setting '%s' for general::hide_error_messages.", val); | |
1518 | } | |
1519 | ||
1520 | static void | |
1521 | conf_set_general_kline_delay(void *data) | |
1522 | { | |
1523 | ConfigFileEntry.kline_delay = *(unsigned int *) data; | |
1524 | ||
1525 | /* THIS MUST BE HERE to stop us being unable to check klines */ | |
1526 | kline_queued = 0; | |
1527 | } | |
1528 | ||
1529 | static void | |
1530 | conf_set_general_stats_k_oper_only(void *data) | |
1531 | { | |
1532 | char *val = data; | |
1533 | ||
1534 | if(strcasecmp(val, "yes") == 0) | |
1535 | ConfigFileEntry.stats_k_oper_only = 2; | |
1536 | else if(strcasecmp(val, "masked") == 0) | |
1537 | ConfigFileEntry.stats_k_oper_only = 1; | |
1538 | else if(strcasecmp(val, "no") == 0) | |
1539 | ConfigFileEntry.stats_k_oper_only = 0; | |
1540 | else | |
1541 | conf_report_error("Invalid setting '%s' for general::stats_k_oper_only.", val); | |
1542 | } | |
1543 | ||
1544 | static void | |
1545 | conf_set_general_stats_i_oper_only(void *data) | |
1546 | { | |
1547 | char *val = data; | |
1548 | ||
1549 | if(strcasecmp(val, "yes") == 0) | |
1550 | ConfigFileEntry.stats_i_oper_only = 2; | |
1551 | else if(strcasecmp(val, "masked") == 0) | |
1552 | ConfigFileEntry.stats_i_oper_only = 1; | |
1553 | else if(strcasecmp(val, "no") == 0) | |
1554 | ConfigFileEntry.stats_i_oper_only = 0; | |
1555 | else | |
1556 | conf_report_error("Invalid setting '%s' for general::stats_i_oper_only.", val); | |
1557 | } | |
1558 | ||
1559 | static void | |
1560 | conf_set_general_compression_level(void *data) | |
1561 | { | |
1562 | #ifdef HAVE_LIBZ | |
1563 | ConfigFileEntry.compression_level = *(unsigned int *) data; | |
1564 | ||
1565 | if((ConfigFileEntry.compression_level < 1) || (ConfigFileEntry.compression_level > 9)) | |
1566 | { | |
1567 | conf_report_error | |
1568 | ("Invalid general::compression_level %d -- using default.", | |
1569 | ConfigFileEntry.compression_level); | |
1570 | ConfigFileEntry.compression_level = 0; | |
1571 | } | |
1572 | #else | |
1573 | conf_report_error("Ignoring general::compression_level -- zlib not available."); | |
1574 | #endif | |
1575 | } | |
1576 | ||
1577 | static void | |
1578 | conf_set_general_default_umodes(void *data) | |
1579 | { | |
1580 | char *pm; | |
1581 | int what = MODE_ADD, flag; | |
1582 | ||
1583 | ConfigFileEntry.default_umodes = 0; | |
1584 | for (pm = (char *) data; *pm; pm++) | |
1585 | { | |
1586 | switch (*pm) | |
1587 | { | |
1588 | case '+': | |
1589 | what = MODE_ADD; | |
1590 | break; | |
1591 | case '-': | |
1592 | what = MODE_DEL; | |
1593 | break; | |
1594 | ||
1595 | /* don't allow +o */ | |
1596 | case 'o': | |
1597 | case 'S': | |
1598 | case ' ': | |
1599 | break; | |
1600 | ||
1601 | default: | |
1602 | if ((flag = user_modes[(unsigned char) *pm])) | |
1603 | { | |
1604 | /* Proper value has probably not yet been set | |
1605 | * so don't check oper_only_umodes -- jilles */ | |
1606 | if (what == MODE_ADD) | |
1607 | ConfigFileEntry.default_umodes |= flag; | |
1608 | else | |
1609 | ConfigFileEntry.default_umodes &= ~flag; | |
1610 | } | |
1611 | break; | |
1612 | } | |
1613 | } | |
1614 | } | |
1615 | ||
1616 | static void | |
1617 | conf_set_general_oper_umodes(void *data) | |
1618 | { | |
1619 | set_modes_from_table(&ConfigFileEntry.oper_umodes, "umode", umode_table, data); | |
1620 | } | |
1621 | ||
1622 | static void | |
1623 | conf_set_general_oper_only_umodes(void *data) | |
1624 | { | |
1625 | set_modes_from_table(&ConfigFileEntry.oper_only_umodes, "umode", umode_table, data); | |
1626 | } | |
1627 | ||
1628 | static void | |
1629 | conf_set_general_oper_snomask(void *data) | |
1630 | { | |
1631 | char *pm; | |
1632 | int what = MODE_ADD, flag; | |
1633 | ||
1634 | ConfigFileEntry.oper_snomask = 0; | |
1635 | for (pm = (char *) data; *pm; pm++) | |
1636 | { | |
1637 | switch (*pm) | |
1638 | { | |
1639 | case '+': | |
1640 | what = MODE_ADD; | |
1641 | break; | |
1642 | case '-': | |
1643 | what = MODE_DEL; | |
1644 | break; | |
1645 | ||
1646 | default: | |
1647 | if ((flag = snomask_modes[(unsigned char) *pm])) | |
1648 | { | |
1649 | if (what == MODE_ADD) | |
1650 | ConfigFileEntry.oper_snomask |= flag; | |
1651 | else | |
1652 | ConfigFileEntry.oper_snomask &= ~flag; | |
1653 | } | |
1654 | break; | |
1655 | } | |
1656 | } | |
1657 | } | |
1658 | ||
1659 | static void | |
1660 | conf_set_serverhide_links_delay(void *data) | |
1661 | { | |
1662 | int val = *(unsigned int *) data; | |
1663 | ||
212380e3 | 1664 | ConfigServerHide.links_delay = val; |
1665 | } | |
1666 | ||
1667 | static int | |
1668 | conf_begin_service(struct TopConf *tc) | |
1669 | { | |
1670 | struct Client *target_p; | |
af81d5a0 | 1671 | rb_dlink_node *ptr; |
212380e3 | 1672 | |
8e69bb4e | 1673 | RB_DLINK_FOREACH(ptr, global_serv_list.head) |
212380e3 | 1674 | { |
1675 | target_p = ptr->data; | |
1676 | ||
1677 | target_p->flags &= ~FLAGS_SERVICE; | |
1678 | } | |
1679 | ||
1680 | return 0; | |
1681 | } | |
1682 | ||
1683 | static void | |
1684 | conf_set_service_name(void *data) | |
1685 | { | |
1686 | struct Client *target_p; | |
1687 | const char *s; | |
1688 | char *tmp; | |
1689 | int dots = 0; | |
1690 | ||
1691 | for(s = data; *s != '\0'; s++) | |
1692 | { | |
1693 | if(!IsServChar(*s)) | |
1694 | { | |
1695 | conf_report_error("Ignoring service::name " | |
1696 | "-- bogus servername."); | |
1697 | return; | |
1698 | } | |
1699 | else if(*s == '.') | |
1700 | dots++; | |
1701 | } | |
1702 | ||
1703 | if(!dots) | |
1704 | { | |
1705 | conf_report_error("Ignoring service::name -- must contain '.'"); | |
1706 | return; | |
1707 | } | |
1708 | ||
62d28946 | 1709 | tmp = rb_strdup(data); |
af81d5a0 | 1710 | rb_dlinkAddAlloc(tmp, &service_list); |
212380e3 | 1711 | |
1712 | if((target_p = find_server(NULL, tmp))) | |
1713 | target_p->flags |= FLAGS_SERVICE; | |
1714 | } | |
1715 | ||
212380e3 | 1716 | static int |
1717 | conf_begin_alias(struct TopConf *tc) | |
1718 | { | |
8e43b0b4 | 1719 | yy_alias = rb_malloc(sizeof(struct alias_entry)); |
212380e3 | 1720 | |
1721 | if (conf_cur_block_name != NULL) | |
62d28946 | 1722 | yy_alias->name = rb_strdup(conf_cur_block_name); |
212380e3 | 1723 | |
1724 | yy_alias->flags = 0; | |
1725 | yy_alias->hits = 0; | |
1726 | ||
1727 | return 0; | |
1728 | } | |
1729 | ||
1730 | static int | |
1731 | conf_end_alias(struct TopConf *tc) | |
1732 | { | |
212380e3 | 1733 | if (yy_alias == NULL) |
1734 | return -1; | |
1735 | ||
1736 | if (yy_alias->name == NULL) | |
1737 | { | |
1738 | conf_report_error("Ignoring alias -- must have a name."); | |
1739 | ||
90a3c35b | 1740 | rb_free(yy_alias); |
212380e3 | 1741 | |
1742 | return -1; | |
1743 | } | |
1744 | ||
1745 | if (yy_alias->target == NULL) | |
1746 | { | |
1747 | conf_report_error("Ignoring alias -- must have a target."); | |
1748 | ||
90a3c35b | 1749 | rb_free(yy_alias); |
212380e3 | 1750 | |
1751 | return -1; | |
1752 | } | |
1753 | ||
8ac75529 | 1754 | irc_dictionary_add(alias_dict, yy_alias->name, yy_alias); |
212380e3 | 1755 | |
1756 | return 0; | |
1757 | } | |
1758 | ||
1759 | static void | |
1760 | conf_set_alias_name(void *data) | |
1761 | { | |
1762 | if (data == NULL || yy_alias == NULL) /* this shouldn't ever happen */ | |
1763 | return; | |
1764 | ||
62d28946 | 1765 | yy_alias->name = rb_strdup(data); |
212380e3 | 1766 | } |
1767 | ||
1768 | static void | |
1769 | conf_set_alias_target(void *data) | |
1770 | { | |
1771 | if (data == NULL || yy_alias == NULL) /* this shouldn't ever happen */ | |
1772 | return; | |
1773 | ||
62d28946 | 1774 | yy_alias->target = rb_strdup(data); |
212380e3 | 1775 | } |
1776 | ||
1777 | static void | |
1778 | conf_set_blacklist_host(void *data) | |
1779 | { | |
62d28946 | 1780 | yy_blacklist_host = rb_strdup(data); |
212380e3 | 1781 | } |
1782 | ||
1783 | static void | |
1784 | conf_set_blacklist_reason(void *data) | |
1785 | { | |
62d28946 | 1786 | yy_blacklist_reason = rb_strdup(data); |
212380e3 | 1787 | |
1788 | if (yy_blacklist_host && yy_blacklist_reason) | |
1789 | { | |
1790 | new_blacklist(yy_blacklist_host, yy_blacklist_reason); | |
90a3c35b VY |
1791 | rb_free(yy_blacklist_host); |
1792 | rb_free(yy_blacklist_reason); | |
212380e3 | 1793 | yy_blacklist_host = NULL; |
1794 | yy_blacklist_reason = NULL; | |
1795 | } | |
1796 | } | |
1797 | ||
1798 | /* public functions */ | |
1799 | ||
1800 | ||
1801 | void | |
1802 | conf_report_error(const char *fmt, ...) | |
1803 | { | |
1804 | va_list ap; | |
1805 | char msg[IRCD_BUFSIZE + 1] = { 0 }; | |
1806 | ||
1807 | va_start(ap, fmt); | |
40da7781 | 1808 | rb_vsnprintf(msg, IRCD_BUFSIZE, fmt, ap); |
212380e3 | 1809 | va_end(ap); |
1810 | ||
1811 | if (testing_conf) | |
1812 | { | |
1813 | fprintf(stderr, "\"%s\", line %d: %s\n", current_file, lineno + 1, msg); | |
1814 | return; | |
1815 | } | |
1816 | ||
1817 | ierror("\"%s\", line %d: %s", current_file, lineno + 1, msg); | |
1818 | sendto_realops_snomask(SNO_GENERAL, L_ALL, "\"%s\", line %d: %s", current_file, lineno + 1, msg); | |
1819 | } | |
1820 | ||
1821 | int | |
1822 | conf_start_block(char *block, char *name) | |
1823 | { | |
1824 | if((conf_cur_block = find_top_conf(block)) == NULL) | |
1825 | { | |
1826 | conf_report_error("Configuration block '%s' is not defined.", block); | |
1827 | return -1; | |
1828 | } | |
1829 | ||
1830 | if(name) | |
62d28946 | 1831 | conf_cur_block_name = rb_strdup(name); |
212380e3 | 1832 | else |
1833 | conf_cur_block_name = NULL; | |
1834 | ||
1835 | if(conf_cur_block->tc_sfunc) | |
1836 | if(conf_cur_block->tc_sfunc(conf_cur_block) < 0) | |
1837 | return -1; | |
1838 | ||
1839 | return 0; | |
1840 | } | |
1841 | ||
1842 | int | |
1843 | conf_end_block(struct TopConf *tc) | |
1844 | { | |
1845 | if(tc->tc_efunc) | |
1846 | return tc->tc_efunc(tc); | |
1847 | ||
90a3c35b | 1848 | rb_free(conf_cur_block_name); |
212380e3 | 1849 | return 0; |
1850 | } | |
1851 | ||
1852 | static void | |
1853 | conf_set_generic_int(void *data, void *location) | |
1854 | { | |
1855 | *((int *) location) = *((unsigned int *) data); | |
1856 | } | |
1857 | ||
1858 | static void | |
1859 | conf_set_generic_string(void *data, int len, void *location) | |
1860 | { | |
1861 | char **loc = location; | |
1862 | char *input = data; | |
1863 | ||
aa65834c | 1864 | if(len && strlen(input) > (unsigned int)len) |
212380e3 | 1865 | input[len] = '\0'; |
1866 | ||
90a3c35b | 1867 | rb_free(*loc); |
62d28946 | 1868 | *loc = rb_strdup(input); |
212380e3 | 1869 | } |
1870 | ||
1871 | int | |
1872 | conf_call_set(struct TopConf *tc, char *item, conf_parm_t * value, int type) | |
1873 | { | |
1874 | struct ConfEntry *cf; | |
1875 | conf_parm_t *cp; | |
1876 | ||
1877 | if(!tc) | |
1878 | return -1; | |
1879 | ||
1880 | if((cf = find_conf_item(tc, item)) == NULL) | |
1881 | { | |
1882 | conf_report_error | |
1883 | ("Non-existant configuration setting %s::%s.", tc->tc_name, (char *) item); | |
1884 | return -1; | |
1885 | } | |
1886 | ||
1887 | /* if it takes one thing, make sure they only passed one thing, | |
1888 | and handle as needed. */ | |
1889 | if(value->type & CF_FLIST && !cf->cf_type & CF_FLIST) | |
1890 | { | |
1891 | conf_report_error | |
1892 | ("Option %s::%s does not take a list of values.", tc->tc_name, item); | |
1893 | return -1; | |
1894 | } | |
1895 | ||
1896 | cp = value->v.list; | |
1897 | ||
1898 | ||
1899 | if(CF_TYPE(value->v.list->type) != CF_TYPE(cf->cf_type)) | |
1900 | { | |
1901 | /* if it expects a string value, but we got a yesno, | |
1902 | * convert it back | |
1903 | */ | |
1904 | if((CF_TYPE(value->v.list->type) == CF_YESNO) && | |
1905 | (CF_TYPE(cf->cf_type) == CF_STRING)) | |
1906 | { | |
1907 | value->v.list->type = CF_STRING; | |
1908 | ||
1909 | if(cp->v.number == 1) | |
62d28946 | 1910 | cp->v.string = rb_strdup("yes"); |
212380e3 | 1911 | else |
62d28946 | 1912 | cp->v.string = rb_strdup("no"); |
212380e3 | 1913 | } |
1914 | ||
1915 | /* maybe it's a CF_TIME and they passed CF_INT -- | |
1916 | should still be valid */ | |
1917 | else if(!((CF_TYPE(value->v.list->type) == CF_INT) && | |
1918 | (CF_TYPE(cf->cf_type) == CF_TIME))) | |
1919 | { | |
1920 | conf_report_error | |
1921 | ("Wrong type for %s::%s (expected %s, got %s)", | |
1922 | tc->tc_name, (char *) item, | |
1923 | conf_strtype(cf->cf_type), conf_strtype(value->v.list->type)); | |
1924 | return -1; | |
1925 | } | |
1926 | } | |
1927 | ||
1928 | if(cf->cf_type & CF_FLIST) | |
1929 | { | |
1930 | #if 0 | |
1931 | if(cf->cf_arg) | |
1932 | conf_set_generic_list(value->v.list, cf->cf_arg); | |
1933 | else | |
1934 | #endif | |
1935 | /* just pass it the extended argument list */ | |
1936 | cf->cf_func(value->v.list); | |
1937 | } | |
1938 | else | |
1939 | { | |
1940 | /* it's old-style, needs only one arg */ | |
1941 | switch (cf->cf_type) | |
1942 | { | |
1943 | case CF_INT: | |
1944 | case CF_TIME: | |
1945 | case CF_YESNO: | |
1946 | if(cf->cf_arg) | |
1947 | conf_set_generic_int(&cp->v.number, cf->cf_arg); | |
1948 | else | |
1949 | cf->cf_func(&cp->v.number); | |
1950 | break; | |
1951 | case CF_STRING: | |
1952 | case CF_QSTRING: | |
1953 | if(EmptyString(cp->v.string)) | |
1954 | conf_report_error("Ignoring %s::%s -- empty field", | |
1955 | tc->tc_name, item); | |
1956 | else if(cf->cf_arg) | |
1957 | conf_set_generic_string(cp->v.string, cf->cf_len, cf->cf_arg); | |
1958 | else | |
1959 | cf->cf_func(cp->v.string); | |
1960 | break; | |
1961 | } | |
1962 | } | |
1963 | ||
1964 | ||
1965 | return 0; | |
1966 | } | |
1967 | ||
1968 | int | |
1969 | add_conf_item(const char *topconf, const char *name, int type, void (*func) (void *)) | |
1970 | { | |
1971 | struct TopConf *tc; | |
1972 | struct ConfEntry *cf; | |
1973 | ||
1974 | if((tc = find_top_conf(topconf)) == NULL) | |
1975 | return -1; | |
1976 | ||
1977 | if((cf = find_conf_item(tc, name)) != NULL) | |
1978 | return -1; | |
1979 | ||
8e43b0b4 | 1980 | cf = rb_malloc(sizeof(struct ConfEntry)); |
212380e3 | 1981 | |
d7f753cd | 1982 | cf->cf_name = name; |
212380e3 | 1983 | cf->cf_type = type; |
1984 | cf->cf_func = func; | |
1985 | cf->cf_arg = NULL; | |
1986 | ||
af81d5a0 | 1987 | rb_dlinkAddAlloc(cf, &tc->tc_items); |
212380e3 | 1988 | |
1989 | return 0; | |
1990 | } | |
1991 | ||
1992 | int | |
1993 | remove_conf_item(const char *topconf, const char *name) | |
1994 | { | |
1995 | struct TopConf *tc; | |
1996 | struct ConfEntry *cf; | |
af81d5a0 | 1997 | rb_dlink_node *ptr; |
212380e3 | 1998 | |
1999 | if((tc = find_top_conf(topconf)) == NULL) | |
2000 | return -1; | |
2001 | ||
2002 | if((cf = find_conf_item(tc, name)) == NULL) | |
2003 | return -1; | |
2004 | ||
af81d5a0 | 2005 | if((ptr = rb_dlinkFind(cf, &tc->tc_items)) == NULL) |
212380e3 | 2006 | return -1; |
2007 | ||
af81d5a0 | 2008 | rb_dlinkDestroy(ptr, &tc->tc_items); |
90a3c35b | 2009 | rb_free(cf); |
212380e3 | 2010 | |
2011 | return 0; | |
2012 | } | |
2013 | ||
2014 | /* *INDENT-OFF* */ | |
2015 | static struct ConfEntry conf_serverinfo_table[] = | |
2016 | { | |
2017 | { "description", CF_QSTRING, NULL, 0, &ServerInfo.description }, | |
2018 | { "network_desc", CF_QSTRING, NULL, 0, &ServerInfo.network_desc }, | |
2019 | { "hub", CF_YESNO, NULL, 0, &ServerInfo.hub }, | |
212380e3 | 2020 | |
2021 | { "network_name", CF_QSTRING, conf_set_serverinfo_network_name, 0, NULL }, | |
2022 | { "name", CF_QSTRING, conf_set_serverinfo_name, 0, NULL }, | |
2023 | { "sid", CF_QSTRING, conf_set_serverinfo_sid, 0, NULL }, | |
2024 | { "vhost", CF_QSTRING, conf_set_serverinfo_vhost, 0, NULL }, | |
2025 | { "vhost6", CF_QSTRING, conf_set_serverinfo_vhost6, 0, NULL }, | |
2026 | ||
b717a466 JT |
2027 | { "ssl_private_key", CF_QSTRING, NULL, 0, &ServerInfo.ssl_private_key }, |
2028 | { "ssl_ca_cert", CF_QSTRING, NULL, 0, &ServerInfo.ssl_ca_cert }, | |
2029 | { "ssl_cert", CF_QSTRING, NULL, 0, &ServerInfo.ssl_cert }, | |
2030 | { "ssl_dh_params", CF_QSTRING, NULL, 0, &ServerInfo.ssl_dh_params }, | |
8db00894 VY |
2031 | { "ssld_count", CF_INT, NULL, 0, &ServerInfo.ssld_count }, |
2032 | ||
3fe90825 | 2033 | { "default_max_clients",CF_INT, NULL, 0, &ServerInfo.default_max_clients }, |
c2d96fcb | 2034 | |
212380e3 | 2035 | { "\0", 0, NULL, 0, NULL } |
2036 | }; | |
2037 | ||
2038 | static struct ConfEntry conf_admin_table[] = | |
2039 | { | |
2040 | { "name", CF_QSTRING, NULL, 200, &AdminInfo.name }, | |
2041 | { "description",CF_QSTRING, NULL, 200, &AdminInfo.description }, | |
2042 | { "email", CF_QSTRING, NULL, 200, &AdminInfo.email }, | |
2043 | { "\0", 0, NULL, 0, NULL } | |
2044 | }; | |
2045 | ||
2046 | static struct ConfEntry conf_log_table[] = | |
2047 | { | |
2048 | { "fname_userlog", CF_QSTRING, NULL, MAXPATHLEN, &ConfigFileEntry.fname_userlog }, | |
2049 | { "fname_fuserlog", CF_QSTRING, NULL, MAXPATHLEN, &ConfigFileEntry.fname_fuserlog }, | |
2050 | { "fname_operlog", CF_QSTRING, NULL, MAXPATHLEN, &ConfigFileEntry.fname_operlog }, | |
2051 | { "fname_foperlog", CF_QSTRING, NULL, MAXPATHLEN, &ConfigFileEntry.fname_foperlog }, | |
2052 | { "fname_serverlog", CF_QSTRING, NULL, MAXPATHLEN, &ConfigFileEntry.fname_serverlog }, | |
2053 | { "fname_killlog", CF_QSTRING, NULL, MAXPATHLEN, &ConfigFileEntry.fname_killlog }, | |
212380e3 | 2054 | { "fname_klinelog", CF_QSTRING, NULL, MAXPATHLEN, &ConfigFileEntry.fname_klinelog }, |
2055 | { "fname_operspylog", CF_QSTRING, NULL, MAXPATHLEN, &ConfigFileEntry.fname_operspylog }, | |
2056 | { "fname_ioerrorlog", CF_QSTRING, NULL, MAXPATHLEN, &ConfigFileEntry.fname_ioerrorlog }, | |
2057 | { "\0", 0, NULL, 0, NULL } | |
2058 | }; | |
2059 | ||
2060 | static struct ConfEntry conf_operator_table[] = | |
2061 | { | |
2062 | { "rsa_public_key_file", CF_QSTRING, conf_set_oper_rsa_public_key_file, 0, NULL }, | |
2063 | { "flags", CF_STRING | CF_FLIST, conf_set_oper_flags, 0, NULL }, | |
2064 | { "umodes", CF_STRING | CF_FLIST, conf_set_oper_umodes, 0, NULL }, | |
b8be4a3f | 2065 | { "privset", CF_QSTRING, conf_set_oper_privset, 0, NULL }, |
212380e3 | 2066 | { "snomask", CF_QSTRING, conf_set_oper_snomask, 0, NULL }, |
2067 | { "user", CF_QSTRING, conf_set_oper_user, 0, NULL }, | |
2068 | { "password", CF_QSTRING, conf_set_oper_password, 0, NULL }, | |
d8a023ed | 2069 | { "fingerprint", CF_QSTRING, conf_set_oper_fingerprint, 0, NULL }, |
212380e3 | 2070 | { "\0", 0, NULL, 0, NULL } |
2071 | }; | |
2072 | ||
de0e9f37 WP |
2073 | static struct ConfEntry conf_privset_table[] = |
2074 | { | |
2075 | { "extends", CF_QSTRING, conf_set_privset_extends, 0, NULL }, | |
2076 | { "privs", CF_STRING | CF_FLIST, conf_set_privset_privs, 0, NULL }, | |
2077 | { "\0", 0, NULL, 0, NULL } | |
2078 | }; | |
2079 | ||
212380e3 | 2080 | static struct ConfEntry conf_class_table[] = |
2081 | { | |
2082 | { "ping_time", CF_TIME, conf_set_class_ping_time, 0, NULL }, | |
c8d85889 JT |
2083 | { "cidr_ipv4_bitlen", CF_INT, conf_set_class_cidr_ipv4_bitlen, 0, NULL }, |
2084 | #ifdef RB_IPV6 | |
2085 | { "cidr_ipv6_bitlen", CF_INT, conf_set_class_cidr_ipv6_bitlen, 0, NULL }, | |
2086 | #endif | |
212380e3 | 2087 | { "number_per_cidr", CF_INT, conf_set_class_number_per_cidr, 0, NULL }, |
2088 | { "number_per_ip", CF_INT, conf_set_class_number_per_ip, 0, NULL }, | |
2089 | { "number_per_ip_global", CF_INT,conf_set_class_number_per_ip_global, 0, NULL }, | |
2090 | { "number_per_ident", CF_INT, conf_set_class_number_per_ident, 0, NULL }, | |
2091 | { "connectfreq", CF_TIME, conf_set_class_connectfreq, 0, NULL }, | |
2092 | { "max_number", CF_INT, conf_set_class_max_number, 0, NULL }, | |
2093 | { "sendq", CF_TIME, conf_set_class_sendq, 0, NULL }, | |
2094 | { "\0", 0, NULL, 0, NULL } | |
2095 | }; | |
2096 | ||
2097 | static struct ConfEntry conf_auth_table[] = | |
2098 | { | |
2099 | { "user", CF_QSTRING, conf_set_auth_user, 0, NULL }, | |
969a1ae6 | 2100 | { "auth_user", CF_QSTRING, conf_set_auth_auth_user, 0, NULL }, |
212380e3 | 2101 | { "password", CF_QSTRING, conf_set_auth_passwd, 0, NULL }, |
2102 | { "class", CF_QSTRING, conf_set_auth_class, 0, NULL }, | |
2103 | { "spoof", CF_QSTRING, conf_set_auth_spoof, 0, NULL }, | |
fa72cee1 | 2104 | { "autojoin", CF_QSTRING, conf_set_auth_autojoin, 0, NULL }, |
87f58b4f | 2105 | { "autojoin_opers", CF_QSTRING, conf_set_auth_autojoin_opers, 0, NULL }, |
212380e3 | 2106 | { "redirserv", CF_QSTRING, conf_set_auth_redir_serv, 0, NULL }, |
2107 | { "redirport", CF_INT, conf_set_auth_redir_port, 0, NULL }, | |
2108 | { "flags", CF_STRING | CF_FLIST, conf_set_auth_flags, 0, NULL }, | |
2109 | { "\0", 0, NULL, 0, NULL } | |
2110 | }; | |
2111 | ||
2112 | static struct ConfEntry conf_connect_table[] = | |
2113 | { | |
2114 | { "send_password", CF_QSTRING, conf_set_connect_send_password, 0, NULL }, | |
2115 | { "accept_password", CF_QSTRING, conf_set_connect_accept_password, 0, NULL }, | |
2116 | { "flags", CF_STRING | CF_FLIST, conf_set_connect_flags, 0, NULL }, | |
2117 | { "host", CF_QSTRING, conf_set_connect_host, 0, NULL }, | |
2118 | { "vhost", CF_QSTRING, conf_set_connect_vhost, 0, NULL }, | |
2119 | { "port", CF_INT, conf_set_connect_port, 0, NULL }, | |
2120 | { "aftype", CF_STRING, conf_set_connect_aftype, 0, NULL }, | |
2121 | { "hub_mask", CF_QSTRING, conf_set_connect_hub_mask, 0, NULL }, | |
2122 | { "leaf_mask", CF_QSTRING, conf_set_connect_leaf_mask, 0, NULL }, | |
2123 | { "class", CF_QSTRING, conf_set_connect_class, 0, NULL }, | |
2124 | { "\0", 0, NULL, 0, NULL } | |
2125 | }; | |
2126 | ||
2127 | static struct ConfEntry conf_general_table[] = | |
2128 | { | |
2129 | { "oper_only_umodes", CF_STRING | CF_FLIST, conf_set_general_oper_only_umodes, 0, NULL }, | |
2130 | { "oper_umodes", CF_STRING | CF_FLIST, conf_set_general_oper_umodes, 0, NULL }, | |
2131 | { "oper_snomask", CF_QSTRING, conf_set_general_oper_snomask, 0, NULL }, | |
2132 | { "compression_level", CF_INT, conf_set_general_compression_level, 0, NULL }, | |
2133 | { "havent_read_conf", CF_YESNO, conf_set_general_havent_read_conf, 0, NULL }, | |
2134 | { "hide_error_messages",CF_STRING, conf_set_general_hide_error_messages,0, NULL }, | |
2135 | { "kline_delay", CF_TIME, conf_set_general_kline_delay, 0, NULL }, | |
2136 | { "stats_k_oper_only", CF_STRING, conf_set_general_stats_k_oper_only, 0, NULL }, | |
2137 | { "stats_i_oper_only", CF_STRING, conf_set_general_stats_i_oper_only, 0, NULL }, | |
2138 | { "default_umodes", CF_QSTRING, conf_set_general_default_umodes, 0, NULL }, | |
2139 | ||
2140 | { "default_operstring", CF_QSTRING, NULL, REALLEN, &ConfigFileEntry.default_operstring }, | |
2141 | { "default_adminstring",CF_QSTRING, NULL, REALLEN, &ConfigFileEntry.default_adminstring }, | |
2142 | { "servicestring", CF_QSTRING, NULL, REALLEN, &ConfigFileEntry.servicestring }, | |
2143 | { "egdpool_path", CF_QSTRING, NULL, MAXPATHLEN, &ConfigFileEntry.egdpool_path }, | |
2144 | { "kline_reason", CF_QSTRING, NULL, REALLEN, &ConfigFileEntry.kline_reason }, | |
2145 | { "identify_service", CF_QSTRING, NULL, REALLEN, &ConfigFileEntry.identifyservice }, | |
2146 | { "identify_command", CF_QSTRING, NULL, REALLEN, &ConfigFileEntry.identifycommand }, | |
212380e3 | 2147 | |
2148 | { "anti_spam_exit_message_time", CF_TIME, NULL, 0, &ConfigFileEntry.anti_spam_exit_message_time }, | |
2149 | { "disable_fake_channels", CF_YESNO, NULL, 0, &ConfigFileEntry.disable_fake_channels }, | |
2150 | { "min_nonwildcard_simple", CF_INT, NULL, 0, &ConfigFileEntry.min_nonwildcard_simple }, | |
2151 | { "non_redundant_klines", CF_YESNO, NULL, 0, &ConfigFileEntry.non_redundant_klines }, | |
2152 | { "tkline_expire_notices", CF_YESNO, NULL, 0, &ConfigFileEntry.tkline_expire_notices }, | |
2153 | ||
2154 | { "anti_nick_flood", CF_YESNO, NULL, 0, &ConfigFileEntry.anti_nick_flood }, | |
2155 | { "burst_away", CF_YESNO, NULL, 0, &ConfigFileEntry.burst_away }, | |
2156 | { "caller_id_wait", CF_TIME, NULL, 0, &ConfigFileEntry.caller_id_wait }, | |
2157 | { "client_exit", CF_YESNO, NULL, 0, &ConfigFileEntry.client_exit }, | |
2158 | { "client_flood", CF_INT, NULL, 0, &ConfigFileEntry.client_flood }, | |
2159 | { "collision_fnc", CF_YESNO, NULL, 0, &ConfigFileEntry.collision_fnc }, | |
2160 | { "connect_timeout", CF_TIME, NULL, 0, &ConfigFileEntry.connect_timeout }, | |
2161 | { "default_floodcount", CF_INT, NULL, 0, &ConfigFileEntry.default_floodcount }, | |
2162 | { "disable_auth", CF_YESNO, NULL, 0, &ConfigFileEntry.disable_auth }, | |
212380e3 | 2163 | { "dots_in_ident", CF_INT, NULL, 0, &ConfigFileEntry.dots_in_ident }, |
2164 | { "failed_oper_notice", CF_YESNO, NULL, 0, &ConfigFileEntry.failed_oper_notice }, | |
212380e3 | 2165 | { "global_snotices", CF_YESNO, NULL, 0, &ConfigFileEntry.global_snotices }, |
212380e3 | 2166 | { "hide_spoof_ips", CF_YESNO, NULL, 0, &ConfigFileEntry.hide_spoof_ips }, |
2167 | { "dline_with_reason", CF_YESNO, NULL, 0, &ConfigFileEntry.dline_with_reason }, | |
2168 | { "kline_with_reason", CF_YESNO, NULL, 0, &ConfigFileEntry.kline_with_reason }, | |
2169 | { "map_oper_only", CF_YESNO, NULL, 0, &ConfigFileEntry.map_oper_only }, | |
2170 | { "max_accept", CF_INT, NULL, 0, &ConfigFileEntry.max_accept }, | |
2171 | { "max_monitor", CF_INT, NULL, 0, &ConfigFileEntry.max_monitor }, | |
2172 | { "max_nick_time", CF_TIME, NULL, 0, &ConfigFileEntry.max_nick_time }, | |
2173 | { "max_nick_changes", CF_INT, NULL, 0, &ConfigFileEntry.max_nick_changes }, | |
2174 | { "max_targets", CF_INT, NULL, 0, &ConfigFileEntry.max_targets }, | |
2175 | { "min_nonwildcard", CF_INT, NULL, 0, &ConfigFileEntry.min_nonwildcard }, | |
2176 | { "nick_delay", CF_TIME, NULL, 0, &ConfigFileEntry.nick_delay }, | |
2177 | { "no_oper_flood", CF_YESNO, NULL, 0, &ConfigFileEntry.no_oper_flood }, | |
2178 | { "operspy_admin_only", CF_YESNO, NULL, 0, &ConfigFileEntry.operspy_admin_only }, | |
2179 | { "operspy_dont_care_user_info", CF_YESNO, NULL, 0, &ConfigFileEntry.operspy_dont_care_user_info }, | |
2180 | { "pace_wait", CF_TIME, NULL, 0, &ConfigFileEntry.pace_wait }, | |
2181 | { "pace_wait_simple", CF_TIME, NULL, 0, &ConfigFileEntry.pace_wait_simple }, | |
2182 | { "ping_cookie", CF_YESNO, NULL, 0, &ConfigFileEntry.ping_cookie }, | |
2183 | { "reject_after_count", CF_INT, NULL, 0, &ConfigFileEntry.reject_after_count }, | |
2184 | { "reject_ban_time", CF_TIME, NULL, 0, &ConfigFileEntry.reject_ban_time }, | |
2185 | { "reject_duration", CF_TIME, NULL, 0, &ConfigFileEntry.reject_duration }, | |
d1275a8f JT |
2186 | { "throttle_count", CF_INT, NULL, 0, &ConfigFileEntry.throttle_count }, |
2187 | { "throttle_duration", CF_TIME, NULL, 0, &ConfigFileEntry.throttle_duration }, | |
212380e3 | 2188 | { "short_motd", CF_YESNO, NULL, 0, &ConfigFileEntry.short_motd }, |
2189 | { "stats_c_oper_only", CF_YESNO, NULL, 0, &ConfigFileEntry.stats_c_oper_only }, | |
2190 | { "stats_e_disabled", CF_YESNO, NULL, 0, &ConfigFileEntry.stats_e_disabled }, | |
2191 | { "stats_h_oper_only", CF_YESNO, NULL, 0, &ConfigFileEntry.stats_h_oper_only }, | |
2192 | { "stats_o_oper_only", CF_YESNO, NULL, 0, &ConfigFileEntry.stats_o_oper_only }, | |
2193 | { "stats_P_oper_only", CF_YESNO, NULL, 0, &ConfigFileEntry.stats_P_oper_only }, | |
2194 | { "stats_y_oper_only", CF_YESNO, NULL, 0, &ConfigFileEntry.stats_y_oper_only }, | |
2195 | { "target_change", CF_YESNO, NULL, 0, &ConfigFileEntry.target_change }, | |
2196 | { "ts_max_delta", CF_TIME, NULL, 0, &ConfigFileEntry.ts_max_delta }, | |
2197 | { "use_egd", CF_YESNO, NULL, 0, &ConfigFileEntry.use_egd }, | |
2198 | { "ts_warn_delta", CF_TIME, NULL, 0, &ConfigFileEntry.ts_warn_delta }, | |
2199 | { "use_whois_actually", CF_YESNO, NULL, 0, &ConfigFileEntry.use_whois_actually }, | |
2200 | { "warn_no_nline", CF_YESNO, NULL, 0, &ConfigFileEntry.warn_no_nline }, | |
2201 | { "\0", 0, NULL, 0, NULL } | |
2202 | }; | |
2203 | ||
2204 | static struct ConfEntry conf_channel_table[] = | |
2205 | { | |
2206 | { "default_split_user_count", CF_INT, NULL, 0, &ConfigChannel.default_split_user_count }, | |
2207 | { "default_split_server_count", CF_INT, NULL, 0, &ConfigChannel.default_split_server_count }, | |
2208 | { "burst_topicwho", CF_YESNO, NULL, 0, &ConfigChannel.burst_topicwho }, | |
212380e3 | 2209 | { "kick_on_split_riding", CF_YESNO, NULL, 0, &ConfigChannel.kick_on_split_riding }, |
2210 | { "knock_delay", CF_TIME, NULL, 0, &ConfigChannel.knock_delay }, | |
2211 | { "knock_delay_channel",CF_TIME, NULL, 0, &ConfigChannel.knock_delay_channel }, | |
2212 | { "max_bans", CF_INT, NULL, 0, &ConfigChannel.max_bans }, | |
2213 | { "max_bans_large", CF_INT, NULL, 0, &ConfigChannel.max_bans_large }, | |
2214 | { "max_chans_per_user", CF_INT, NULL, 0, &ConfigChannel.max_chans_per_user }, | |
2215 | { "no_create_on_split", CF_YESNO, NULL, 0, &ConfigChannel.no_create_on_split }, | |
2216 | { "no_join_on_split", CF_YESNO, NULL, 0, &ConfigChannel.no_join_on_split }, | |
dea418e9 | 2217 | { "only_ascii_channels", CF_YESNO, NULL, 0, &ConfigChannel.only_ascii_channels }, |
c3a0fde2 | 2218 | { "cycle_host_change", CF_YESNO, NULL, 0, &ConfigChannel.cycle_host_change }, |
212380e3 | 2219 | { "use_except", CF_YESNO, NULL, 0, &ConfigChannel.use_except }, |
2220 | { "use_invex", CF_YESNO, NULL, 0, &ConfigChannel.use_invex }, | |
2221 | { "use_knock", CF_YESNO, NULL, 0, &ConfigChannel.use_knock }, | |
2222 | { "use_forward", CF_YESNO, NULL, 0, &ConfigChannel.use_forward }, | |
100563e8 | 2223 | { "resv_forcepart", CF_YESNO, NULL, 0, &ConfigChannel.resv_forcepart }, |
212380e3 | 2224 | { "\0", 0, NULL, 0, NULL } |
2225 | }; | |
2226 | ||
2227 | static struct ConfEntry conf_serverhide_table[] = | |
2228 | { | |
2229 | { "disable_hidden", CF_YESNO, NULL, 0, &ConfigServerHide.disable_hidden }, | |
2230 | { "flatten_links", CF_YESNO, NULL, 0, &ConfigServerHide.flatten_links }, | |
2231 | { "hidden", CF_YESNO, NULL, 0, &ConfigServerHide.hidden }, | |
2232 | { "links_delay", CF_TIME, conf_set_serverhide_links_delay, 0, NULL }, | |
2233 | { "\0", 0, NULL, 0, NULL } | |
2234 | }; | |
2235 | /* *INDENT-ON* */ | |
2236 | ||
2237 | void | |
2238 | newconf_init() | |
2239 | { | |
2240 | add_top_conf("modules", NULL, NULL, NULL); | |
2241 | add_conf_item("modules", "path", CF_QSTRING, conf_set_modules_path); | |
2242 | add_conf_item("modules", "module", CF_QSTRING, conf_set_modules_module); | |
2243 | ||
2244 | add_top_conf("serverinfo", NULL, NULL, conf_serverinfo_table); | |
2245 | add_top_conf("admin", NULL, NULL, conf_admin_table); | |
2246 | add_top_conf("log", NULL, NULL, conf_log_table); | |
2247 | add_top_conf("operator", conf_begin_oper, conf_end_oper, conf_operator_table); | |
2248 | add_top_conf("class", conf_begin_class, conf_end_class, conf_class_table); | |
de0e9f37 | 2249 | add_top_conf("privset", NULL, NULL, conf_privset_table); |
212380e3 | 2250 | |
2251 | add_top_conf("listen", conf_begin_listen, conf_end_listen, NULL); | |
2252 | add_conf_item("listen", "port", CF_INT | CF_FLIST, conf_set_listen_port); | |
8db00894 | 2253 | add_conf_item("listen", "sslport", CF_INT | CF_FLIST, conf_set_listen_sslport); |
212380e3 | 2254 | add_conf_item("listen", "ip", CF_QSTRING, conf_set_listen_address); |
2255 | add_conf_item("listen", "host", CF_QSTRING, conf_set_listen_address); | |
2256 | ||
2257 | add_top_conf("auth", conf_begin_auth, conf_end_auth, conf_auth_table); | |
2258 | ||
2259 | add_top_conf("shared", conf_cleanup_shared, conf_cleanup_shared, NULL); | |
2260 | add_conf_item("shared", "oper", CF_QSTRING|CF_FLIST, conf_set_shared_oper); | |
2261 | add_conf_item("shared", "flags", CF_STRING | CF_FLIST, conf_set_shared_flags); | |
2262 | ||
2263 | add_top_conf("connect", conf_begin_connect, conf_end_connect, conf_connect_table); | |
2264 | ||
2265 | add_top_conf("exempt", NULL, NULL, NULL); | |
2266 | add_conf_item("exempt", "ip", CF_QSTRING, conf_set_exempt_ip); | |
2267 | ||
2268 | add_top_conf("cluster", conf_cleanup_cluster, conf_cleanup_cluster, NULL); | |
2269 | add_conf_item("cluster", "name", CF_QSTRING, conf_set_cluster_name); | |
2270 | add_conf_item("cluster", "flags", CF_STRING | CF_FLIST, conf_set_cluster_flags); | |
2271 | ||
2272 | add_top_conf("general", NULL, NULL, conf_general_table); | |
2273 | add_top_conf("channel", NULL, NULL, conf_channel_table); | |
2274 | add_top_conf("serverhide", NULL, NULL, conf_serverhide_table); | |
2275 | ||
2276 | add_top_conf("service", conf_begin_service, NULL, NULL); | |
2277 | add_conf_item("service", "name", CF_QSTRING, conf_set_service_name); | |
2278 | ||
2279 | add_top_conf("alias", conf_begin_alias, conf_end_alias, NULL); | |
2280 | add_conf_item("alias", "name", CF_QSTRING, conf_set_alias_name); | |
2281 | add_conf_item("alias", "target", CF_QSTRING, conf_set_alias_target); | |
2282 | ||
2283 | add_top_conf("blacklist", NULL, NULL, NULL); | |
2284 | add_conf_item("blacklist", "host", CF_QSTRING, conf_set_blacklist_host); | |
2285 | add_conf_item("blacklist", "reject_reason", CF_QSTRING, conf_set_blacklist_reason); | |
2286 | } |