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