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