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