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