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