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