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