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