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