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