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