Restore stats_spy hook that was removed in commit 401f2454671ca233e35b0e6e4f3fa4c43cd...
[seven-1.x.git] / src / newconf.c
blob1fb998196ccb18f65e15851d964c6665e35191f9
1 /* {{{ irc-seven: Cows like it.
3 * Copyright (C) 2006 Elfyn McBratney.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to:
18 * Free Software Foundation, Inc.
19 * 51 Franklin St - Fifth Floor
20 * Boston, MA 02110-1301
21 * USA
23 * }}} */
25 /* {{{ Includes. */
26 #include "stdinc.h"
27 #include "memory.h"
28 #include "newconf.h"
29 #include "tools.h"
30 #include "ircd_defs.h"
31 #include "sprintf_irc.h"
32 #include "common.h"
33 #include "s_log.h"
34 #include "s_conf.h"
35 #include "s_user.h"
36 #include "s_newconf.h"
37 #include "send.h"
38 #include "setup.h"
39 #include "modules.h"
40 #include "listener.h"
41 #include "hostmask.h"
42 #include "s_serv.h"
43 #include "event.h"
44 #include "hash.h"
45 #include "cache.h"
46 #include "ircd.h"
47 #include "snomask.h"
48 #include "blacklist.h"
50 #ifdef HAVE_LIBCRYPTO
51 # include <openssl/pem.h>
52 # include <openssl/rsa.h>
53 #endif
54 /* }}} */
56 #define CF_TYPE(x) ((x) & CF_MTYPE)
58 struct TopConf *conf_cur_block;
59 static char *conf_cur_block_name;
61 static dlink_list conf_items;
63 static struct ConfItem *yy_aconf = NULL;
65 static struct Class *yy_class = NULL;
67 static struct remote_conf *yy_shared = NULL;
68 static struct server_conf *yy_server = NULL;
70 static dlink_list yy_aconf_list;
71 static dlink_list yy_oper_list;
72 static dlink_list yy_shared_list;
73 static dlink_list yy_cluster_list;
74 static struct oper_conf *yy_oper = NULL;
76 static struct alias_entry *yy_alias = NULL;
78 static char *yy_blacklist_host = NULL;
79 static char *yy_blacklist_reason = NULL;
81 /* {{{ static const char *conf_strtype() */
82 static const char *
83 conf_strtype (int type)
85 switch (CF_TYPE(type))
87 case CF_INT:
88 return "integer value";
89 case CF_STRING:
90 return "unquoted string";
91 case CF_YESNO:
92 return "yes/no value";
93 case CF_QSTRING:
94 return "quoted string";
95 case CF_TIME:
96 return "time/size value";
97 default:
98 return "unknown type";
101 /* }}} */
103 typedef int (*seven_tconf_cb) (struct TopConf *);
105 /* {{{ int add_top_conf() */
107 add_top_conf (const char *name, seven_tconf_cb start_cb, seven_tconf_cb end_cb,
108 struct ConfEntry *items)
110 struct TopConf *tc = NULL;
112 tc = MyMalloc(sizeof(*tc));
114 DupString(tc->tc_name, name);
115 tc->tc_sfunc = start_cb;
116 tc->tc_efunc = end_cb;
117 tc->tc_entries = items;
118 dlinkAddAlloc(tc, &conf_items);
120 return 0;
122 /* }}} */
124 /* {{{ struct TopConf *find_top_conf() */
125 struct TopConf *
126 find_top_conf (const char *name)
128 dlink_node *cur = NULL;
129 struct TopConf *tc = NULL;
131 DLINK_FOREACH (cur, conf_items.head)
133 tc = cur->data;
134 if(!strcasecmp(tc->tc_name, name))
135 return tc;
138 return NULL;
140 /* }}} */
142 /* {{{ struct ConfEntry *find_conf_item() */
143 struct ConfEntry *
144 find_conf_item (const struct TopConf *top, const char *name)
146 struct ConfEntry *cf = NULL;
147 dlink_node *cur = NULL;
149 if (top->tc_entries)
151 int i;
153 for (i = 0; top->tc_entries[i].cf_type; ++i)
155 cf = &top->tc_entries[i];
156 if (!strcasecmp(cf->cf_name, name))
157 return cf;
161 DLINK_FOREACH (cur, top->tc_items.head)
163 cf = cur->data;
164 if (!strcasecmp(cf->cf_name, name))
165 return cf;
168 return NULL;
170 /* }}} */
172 /* {{{ int remove_top_conf() */
174 remove_top_conf (char *name)
176 struct TopConf *tc = NULL;
177 dlink_node *cur = NULL;
179 if ((tc = find_top_conf(name)) == NULL)
180 return -1;
181 if ((cur = dlinkFind(tc, &conf_items)) == NULL)
182 return -1;
184 dlinkDestroy(cur, &conf_items);
185 MyFree(tc->tc_name);
186 MyFree(tc);
188 return 0;
190 /* }}} */
192 /* {{{ static void conf_set_serverinfo_name() */
193 static void
194 conf_set_serverinfo_name (void *data)
196 const char *s = data;
197 int dots = 0;
199 if (!ServerInfo.name)
201 for (; *s != '\0'; ++s)
203 if (!IsServChar(*s))
205 conf_report_error("Ignoring serverinfo::name "
206 "-- bogus servername.");
207 return;
209 else if (*s == '.')
210 ++dots;
213 if (!dots)
215 conf_report_error("Ignoring serverinfo::name "
216 "-- must contain '.'");
217 return;
220 s = data;
221 if (IsDigit(*s))
223 conf_report_error("Ignoring serverinfo::name "
224 "-- cannot begin with digit.");
225 return;
228 if (strlen(s) <= HOSTLEN)
229 DupString(ServerInfo.name, (char *) data);
232 /* }}} */
234 /* {{{ static void conf_set_serverinfo_sid() */
235 static void
236 conf_set_serverinfo_sid (void *data)
238 char *sid = data;
240 if (*ServerInfo.sid)
241 return;
243 if (!IsDigit(sid[0]) || !IsIdChar(sid[1]) || !IsIdChar(sid[2]) || sid[3])
245 conf_report_error("Ignoring serverinfo::sid "
246 "-- bogus sid.");
247 return;
250 strcpy(ServerInfo.sid, sid);
252 /* }}} */
254 /* {{{ static void conf_set_serverinfo_network_name() */
255 static void
256 conf_set_serverinfo_network_name (void *data)
258 char *p = NULL;
260 if ((p = strchr((char *) data, ' ')))
261 *p = '\0';
263 MyFree(ServerInfo.network_name);
264 DupString(ServerInfo.network_name, (char *) data);
266 /* }}} */
268 /* {{{ static void conf_set_serverinfo_vhost() */
269 static void
270 conf_set_serverinfo_vhost (void *data)
272 if (inetpton(AF_INET, (char *) data, &ServerInfo.ip.sin_addr) <= 0)
274 conf_report_error("Invalid netmask for server IPv4 vhost (%s)",
275 (char *) data);
276 return;
279 ServerInfo.ip.sin_family = AF_INET;
280 ServerInfo.specific_ipv4_vhost = 1;
282 /* }}} */
284 /* {{{ static void conf_set_serverinfo_vhost6() */
285 static void
286 conf_set_serverinfo_vhost6 (void *data)
288 #ifdef IPV6
289 if (inetpton(AF_INET6, (char *) data, &ServerInfo.ip6.sin6_addr) <= 0)
291 conf_report_error("Invalid netmask for server IPv6 vhost (%s)",
292 (char *) data);
293 return;
296 ServerInfo.specific_ipv6_vhost = 1;
297 ServerInfo.ip6.sin6_family = AF_INET6;
298 #else
299 conf_report_error("Warning -- ignoring serverinfo::vhost6 "
300 "-- IPv6 support not available.");
301 #endif
303 /* }}} */
305 /* {{{ static void conf_set_modules_module() */
306 static void
307 conf_set_modules_module (void *data)
309 #ifdef STATIC_MODULES
310 conf_report_error("Ignoring modules::module -- "
311 "loadable module support not present.");
312 #else
313 char *base = NULL;
315 base = irc_basename((char *) data);
316 if (findmodule_byname(base) < 0)
317 return;
319 load_one_module((char *) data, 0);
320 MyFree(base);
321 #endif
323 /* }}} */
325 /* {{{ static void conf_set_modules_path() */
326 static void
327 conf_set_modules_path (void *data)
329 #ifndef STATIC_MODULES
330 mod_add_path((char *) data);
331 #else
332 conf_report_error("Ignoring modules::path -- loadable module support not present.");
333 #endif
335 /* }}} */
337 struct mode_table
339 const char *name;
340 int mode;
343 /* {{{ static struct mode_table umode_table[] = { ... } */
344 static struct mode_table umode_table[] =
346 {"callerid", UMODE_CALLERID},
347 {"deaf", UMODE_DEAF},
348 {"invisible", UMODE_INVISIBLE},
349 {"noforward", UMODE_NOFORWARD},
350 {"regonlymsg", UMODE_REGONLYMSG},
351 {"servnotice", UMODE_SERVNOTICE},
352 {"wallop", UMODE_WALLOP},
353 {"operwall", UMODE_OPERWALL},
354 {"helper", UMODE_HELPER},
355 {"override", UMODE_OVERRIDE},
356 {NULL, 0},
358 /* }}} */
360 /* {{{ struct mode_table flag_table[] = { ... }
362 * Used by modules/m_grant.c so cannot be static.
364 struct mode_table flag_table[] =
366 {"encrypted", OPER_ENCRYPTED},
367 {"kill", OPER_KILL},
368 {"routing", OPER_ROUTING},
369 {"kline", OPER_KLINE},
370 {"unkline", OPER_UNKLINE},
371 {"override", OPER_OVERRIDE},
372 {"mass_notice", OPER_MASSNOTICE},
373 {"rehash", OPER_REHASH},
374 {"die", OPER_DIE},
375 {"admin", OPER_ADMIN},
376 {"hidden_admin", OPER_HADMIN},
377 {"xline", OPER_XLINE},
378 {"operwall", OPER_OPERWALL},
379 {"auspex", OPER_AUSPEX},
380 {"hidden_oper", OPER_INVIS},
381 {"helper", OPER_HELPER},
382 {"set_cmodes", OPER_CMODES},
383 {"resv", OPER_RESV},
384 {"wallops", OPER_WALLOPS},
385 {"scan", OPER_EXPERIMENTAL},
386 {"grant", OPER_GRANT},
387 {"remoteban", OPER_REMOTEBAN},
388 {"staffer", OPER_STAFFER},
389 {NULL, 0},
391 /* }}} */
393 /* {{{ static struct mode_table auth_table[] = { ... } */
394 static struct mode_table auth_table[] =
396 {"encrypted", CONF_FLAGS_ENCRYPTED},
397 {"spoof_notice", CONF_FLAGS_SPOOF_NOTICE},
398 {"exceed_limit", CONF_FLAGS_NOLIMIT},
399 {"dnsbl_exempt", CONF_FLAGS_EXEMPTDNSBL},
400 {"kline_exempt", CONF_FLAGS_EXEMPTKLINE},
401 {"flood_exempt", CONF_FLAGS_EXEMPTFLOOD},
402 {"spambot_exempt", CONF_FLAGS_EXEMPTSPAMBOT},
403 {"shide_exempt", CONF_FLAGS_EXEMPTSHIDE},
404 {"jupe_exempt", CONF_FLAGS_EXEMPTJUPE},
405 {"resv_exempt", CONF_FLAGS_EXEMPTRESV},
406 {"no_tilde", CONF_FLAGS_NO_TILDE},
407 {"need_ident", CONF_FLAGS_NEED_IDENTD},
408 {"have_ident", CONF_FLAGS_NEED_IDENTD},
409 {"need_sasl", CONF_FLAGS_NEED_SASL},
410 {NULL, 0},
412 /* }}} */
414 /* {{{ static struct mode_table connect_table[] = { ... } */
415 static struct mode_table connect_table[] =
417 {"autoconn", SERVER_AUTOCONN},
418 {"compressed", SERVER_COMPRESSED},
419 {"encrypted", SERVER_ENCRYPTED},
420 {"topicburst", SERVER_TB},
421 {NULL, 0},
423 /* }}} */
425 /* {{{ static struct mode_table cluster_table[] = { ... } */
426 static struct mode_table cluster_table[] = {
427 {"kline", SHARED_PKLINE},
428 {"tkline", SHARED_TKLINE},
429 {"unkline", SHARED_UNKLINE},
430 {"xline", SHARED_PXLINE},
431 {"txline", SHARED_TXLINE},
432 {"unxline", SHARED_UNXLINE},
433 {"resv", SHARED_PRESV},
434 {"tresv", SHARED_TRESV},
435 {"unresv", SHARED_UNRESV},
436 {"dline", SHARED_PDLINE},
437 {"tdline", SHARED_TDLINE},
438 {"undline", SHARED_UNDLINE},
439 {"all", CLUSTER_ALL},
440 {NULL, 0},
442 /* }}} */
444 /* {{{ static struct mode_table shared_table[] = { ... } */
445 static struct mode_table shared_table[] =
447 {"kline", SHARED_PKLINE | SHARED_TKLINE},
448 {"xline", SHARED_PXLINE | SHARED_TXLINE},
449 {"resv", SHARED_PRESV | SHARED_TRESV},
450 {"dline", SHARED_PDLINE | SHARED_TDLINE},
451 {"tkline", SHARED_TKLINE},
452 {"unkline", SHARED_UNKLINE},
453 {"txline", SHARED_TXLINE},
454 {"unxline", SHARED_UNXLINE},
455 {"tresv", SHARED_TRESV},
456 {"unresv", SHARED_UNRESV},
457 {"tdline", SHARED_TDLINE},
458 {"undline", SHARED_UNDLINE},
459 {"rehash", SHARED_REHASH},
460 {"grant", SHARED_GRANT},
461 {"die", SHARED_DIE},
462 {"module", SHARED_MODULE},
463 {"all", SHARED_ALL},
464 {"none", 0},
465 {NULL, 0},
467 /* }}} */
469 /* {{{ static int find_umode() */
470 static int
471 find_umode (struct mode_table *tab, const char *name)
473 int i;
475 for (i = 0; tab[i].name; ++i)
477 if (!strcmp(tab[i].name, name))
478 return tab[i].mode;
481 return -1;
483 /* }}} */
485 /* {{{ static void set_modes_from_table() */
486 static void
487 set_modes_from_table (int *modes, const char *whatis, struct mode_table *tab, conf_parm_t *args)
489 const char *umode = NULL;
490 int dir = 1;
491 int mode;
493 for (; args; args = args->next)
495 if (CF_TYPE(args->type) != CF_STRING)
497 conf_report_error("Warning -- %s is not a string; ignoring.",
498 whatis);
499 continue;
502 umode = args->v.string;
503 if (*umode == '~')
504 dir = 0, ++umode;
506 mode = find_umode(tab, umode);
507 if (mode < 0)
509 conf_report_error("Warning -- unknown %s %s.", whatis,
510 args->v.string);
511 continue;
514 if (dir)
515 *modes |= mode;
516 else
517 *modes &= ~mode;
520 /* }}} */
522 /* {{{ static int conf_begin_oper() */
523 static int
524 conf_begin_oper (struct TopConf *tc)
526 dlink_node *cur = NULL;
527 dlink_node *next = NULL;
529 if(yy_oper)
531 free_oper_conf(yy_oper);
532 yy_oper = NULL;
535 DLINK_FOREACH_SAFE (cur, next, yy_oper_list.head)
537 free_oper_conf(cur->data);
538 dlinkDestroy(cur, &yy_oper_list);
541 yy_oper = make_oper_conf();
542 yy_oper->flags |= OPER_ENCRYPTED;
544 return 0;
546 /* }}} */
548 /* {{{ static int conf_end_oper() */
549 static int
550 conf_end_oper (struct TopConf *tc)
552 struct oper_conf *yy_tmpoper = NULL;
553 dlink_node *cur = NULL;
554 dlink_node *next = NULL;
556 if (conf_cur_block_name)
558 if (strlen(conf_cur_block_name) > OPERNICKLEN)
559 conf_cur_block_name[OPERNICKLEN] = '\0';
561 DupString(yy_oper->name, conf_cur_block_name);
564 if (EmptyString(yy_oper->name))
566 conf_report_error("Ignoring operator block -- missing name.");
567 return 0;
570 #ifdef HAVE_LIBCRYPTO
571 if (EmptyString(yy_oper->passwd) && EmptyString(yy_oper->rsa_pubkey_file))
572 #else
573 if (EmptyString(yy_oper->passwd))
574 #endif
576 conf_report_error("Ignoring operator block for %s -- "
577 "missing password", yy_oper->name);
578 return 0;
581 /* now, yy_oper_list contains a stack of oper_conf's with just user
582 * and host in, yy_oper contains the rest of the information which
583 * we need to copy into each element in yy_oper_list
585 DLINK_FOREACH_SAFE (cur, next, yy_oper_list.head)
587 yy_tmpoper = cur->data;
588 DupString(yy_tmpoper->name, yy_oper->name);
590 /* could be an rsa key instead.. */
591 if (!EmptyString(yy_oper->passwd))
592 DupString(yy_tmpoper->passwd, yy_oper->passwd);
594 yy_tmpoper->flags = yy_oper->flags;
595 yy_tmpoper->umodes = yy_oper->umodes;
596 yy_tmpoper->snomask = yy_oper->snomask;
597 yy_tmpoper->allowed_snomask = yy_oper->allowed_snomask;
599 #ifdef HAVE_LIBCRYPTO
600 if (yy_oper->rsa_pubkey_file)
602 BIO *file = NULL;
604 if ((file = BIO_new_file(yy_oper->rsa_pubkey_file, "r")) == NULL)
606 conf_report_error("Ignoring operator block for %s -- "
607 "rsa_public_key_file cant be opened",
608 yy_tmpoper->name);
609 return 0;
612 yy_tmpoper->rsa_pubkey = (RSA *) PEM_read_bio_RSA_PUBKEY(file,
613 NULL, 0, NULL);
615 BIO_set_close(file, BIO_CLOSE);
616 BIO_free(file);
618 if (!yy_tmpoper->rsa_pubkey)
620 conf_report_error("Ignoring operator block for %s -- "
621 "rsa_public_key_file key invalid; check syntax",
622 yy_tmpoper->name);
623 return 0;
626 #endif
628 /* all is ok, put it on oper_conf_list */
629 dlinkMoveNode(cur, &yy_oper_list, &oper_conf_list);
632 free_oper_conf(yy_oper);
633 yy_oper = NULL;
635 return 0;
637 /* }}} */
639 /* {{{ static void conf_set_oper_flags() */
640 static void
641 conf_set_oper_flags (void *data)
643 conf_parm_t *args = data;
645 set_modes_from_table(&yy_oper->flags, "flag", flag_table, args);
647 /* }}} */
649 /* {{{ static void conf_set_oper_user() */
650 static void
651 conf_set_oper_user (void *data)
653 struct oper_conf *yy_tmpoper = NULL;
654 char *p = NULL;
655 char *host = (char *) data;
657 yy_tmpoper = make_oper_conf();
659 if ((p = strchr(host, '@')))
661 *p++ = '\0';
663 DupString(yy_tmpoper->username, host);
664 DupString(yy_tmpoper->host, p);
666 else
669 DupString(yy_tmpoper->username, "*");
670 DupString(yy_tmpoper->host, host);
673 if (EmptyString(yy_tmpoper->username) || EmptyString(yy_tmpoper->host))
675 conf_report_error("Ignoring user -- missing username/host");
676 free_oper_conf(yy_tmpoper);
677 return;
680 dlinkAddAlloc(yy_tmpoper, &yy_oper_list);
682 /* }}} */
684 /* {{{ static void conf_set_oper_password() */
685 static void
686 conf_set_oper_password (void *data)
688 if (yy_oper->passwd)
690 memset(yy_oper->passwd, 0, strlen(yy_oper->passwd));
691 MyFree(yy_oper->passwd);
694 DupString(yy_oper->passwd, (char *) data);
696 /* }}} */
698 /* {{{ static void conf_set_oper_rsa_public_key_file() */
699 static void
700 conf_set_oper_rsa_public_key_file (void *data)
702 #ifdef HAVE_LIBCRYPTO
703 MyFree(yy_oper->rsa_pubkey_file);
704 DupString(yy_oper->rsa_pubkey_file, (char *) data);
705 #else
706 conf_report_error("Warning -- ignoring rsa_public_key_file "
707 "(OpenSSL support not available");
708 #endif
710 /* }}} */
712 /* {{{ static void conf_set_oper_umodes() */
713 static void
714 conf_set_oper_umodes (void *data)
716 set_modes_from_table(&yy_oper->umodes, "umode", umode_table, data);
718 /* }}} */
720 /* {{{ static void conf_set_oper_snomask() */
721 static void
722 conf_set_oper_snomask (void *data)
724 yy_oper->snomask = parse_snobuf_to_mask(0, (const char *) data);
726 /* }}} */
728 /* {{{ static void conf_set_oper_allowed_snomask() */
729 static void
730 conf_set_oper_allowed_snomask (void *data)
732 yy_oper->allowed_snomask = parse_snobuf_to_mask(0, (const char *) data);
734 /* }}} */
736 /* {{{ static int conf_begin_class() */
737 static int
738 conf_begin_class (struct TopConf *tc)
740 if (yy_class)
741 free_class(yy_class);
743 yy_class = make_class();
744 return 0;
746 /* }}} */
748 /* {{{ static int conf_end_class() */
749 static int
750 conf_end_class (struct TopConf *tc)
752 if(conf_cur_block_name)
753 DupString(yy_class->class_name, conf_cur_block_name);
755 if (EmptyString(yy_class->class_name))
757 conf_report_error("Ignoring connect block -- missing name.");
758 return 0;
761 add_class(yy_class);
762 yy_class = NULL;
764 return 0;
766 /* }}} */
768 /* {{{ static void conf_set_class_ping_time() */
769 static void
770 conf_set_class_ping_time (void *data)
772 yy_class->ping_freq = *((unsigned int *) data);
774 /* }}} */
776 #ifndef IPV6
777 # define CIDR_BITS 32
778 #else
779 # define CIDR_BITS 128
780 #endif
782 /* {{{ static void conf_set_class_cidr_bitlen() */
783 static void
784 conf_set_class_cidr_bitlen (void *data)
786 unsigned int maxsize = CIDR_BITS;
788 if (*((unsigned int *) data) > maxsize)
789 conf_report_error(
790 "class::cidr_bitlen argument exceeds maxsize "
791 "(%d > %d) - ignoring.",
792 *((unsigned int *) data), maxsize);
793 else
794 yy_class->cidr_bitlen = *((unsigned int *) data);
796 /* }}} */
798 /* {{{ static void conf_set_class_number_per_cidr() */
799 static void
800 conf_set_class_number_per_cidr (void *data)
802 yy_class->cidr_amount = *((unsigned int *) data);
804 /* }}} */
806 /* {{{ static void conf_set_class_number_per_ip() */
807 static void
808 conf_set_class_number_per_ip (void *data)
810 yy_class->max_local = *((unsigned int *) data);
812 /* }}} */
814 /* {{{ static void conf_set_class_number_per_ip_global() */
815 static void
816 conf_set_class_number_per_ip_global (void *data)
818 yy_class->max_global = *((unsigned int *) data);
820 /* }}} */
822 /* {{{ static void conf_set_class_number_per_ident() */
823 static void
824 conf_set_class_number_per_ident (void *data)
826 yy_class->max_ident = *((unsigned int *) data);
828 /* }}} */
830 /* {{{ static void conf_set_class_connectfreq() */
831 static void
832 conf_set_class_connectfreq (void *data)
834 yy_class->con_freq = *((unsigned int *) data);
836 /* }}} */
838 /* {{{ static void conf_set_class_max_number() */
839 static void
840 conf_set_class_max_number (void *data)
842 yy_class->max_total = *((unsigned int *) data);
844 /* }}} */
846 /* {{{ static void conf_set_class_sendq() */
847 static void
848 conf_set_class_sendq (void *data)
850 yy_class->max_sendq = *((unsigned int *) data);
852 /* }}} */
854 static char *listener_address;
856 /* {{{ static int conf_begin_listen() */
857 static int
858 conf_begin_listen (struct TopConf *tc)
860 if (listener_address)
862 MyFree(listener_address);
863 listener_address = NULL;
866 return 0;
868 /* }}} */
870 /* {{{ static int conf_end_listen() */
871 static int
872 conf_end_listen (struct TopConf *tc)
874 if (listener_address)
876 MyFree(listener_address);
877 listener_address = NULL;
880 return 0;
882 /* }}} */
884 /* {{{ static void conf_set_listen_port() */
885 static void
886 conf_set_listen_port (void *data)
888 conf_parm_t *args = data;
889 int family;
891 for (; args; args = args->next)
893 if (CF_TYPE(args->type) != CF_INT)
895 conf_report_error("listener::port argument is not an "
896 "integer -- ignoring.");
897 continue;
900 if (!listener_address)
902 add_listener(args->v.number, listener_address, AF_INET);
903 #ifdef IPV6
904 add_listener(args->v.number, listener_address, AF_INET6);
905 #endif
907 else
909 #ifdef IPV6
910 if (strchr(listener_address, ':'))
911 family = AF_INET6;
912 else
913 #endif
914 family = AF_INET;
916 add_listener(args->v.number, listener_address, family);
920 /* }}} */
922 /* {{{ static void conf_set_listen_address() */
923 static void
924 conf_set_listen_address (void *data)
926 if (listener_address)
927 MyFree(listener_address);
929 DupString(listener_address, data);
931 /* }}} */
933 /* {{{ static int conf_begin_auth() */
934 static int
935 conf_begin_auth (struct TopConf *tc)
937 dlink_node *cur = NULL;
938 dlink_node *next = NULL;
940 if (yy_aconf)
941 free_conf(yy_aconf);
943 DLINK_FOREACH_SAFE (cur, next, yy_aconf_list.head)
945 free_conf(cur->data);
946 dlinkDestroy(cur, &yy_aconf_list);
949 yy_aconf = make_conf();
950 yy_aconf->status = CONF_CLIENT;
952 return 0;
954 /* }}} */
956 /* {{{ static int conf_end_auth() */
957 static int
958 conf_end_auth (struct TopConf *tc)
960 struct ConfItem *yy_tmp = NULL;
961 dlink_node *cur = NULL;
962 dlink_node *next = NULL;
964 if (EmptyString(yy_aconf->name))
965 DupString(yy_aconf->name, "NOMATCH");
967 if(EmptyString(yy_aconf->host))
969 conf_report_error("Ignoring auth block -- missing user@host");
970 return 0;
973 /* so the stacking works in order.. */
974 collapse(yy_aconf->user);
975 collapse(yy_aconf->host);
976 conf_add_class_to_conf(yy_aconf);
977 add_conf_by_address(yy_aconf->host, CONF_CLIENT, yy_aconf->user, yy_aconf);
979 DLINK_FOREACH_SAFE (cur, next, yy_aconf_list.head)
981 yy_tmp = cur->data;
983 if(yy_aconf->passwd)
984 DupString(yy_tmp->passwd, yy_aconf->passwd);
986 DupString(yy_tmp->name, yy_aconf->name);
987 if(yy_aconf->className)
988 DupString(yy_tmp->className, yy_aconf->className);
990 yy_tmp->flags = yy_aconf->flags;
991 yy_tmp->port = yy_aconf->port;
993 collapse(yy_tmp->user);
994 collapse(yy_tmp->host);
996 conf_add_class_to_conf(yy_tmp);
997 add_conf_by_address(yy_tmp->host, CONF_CLIENT, yy_tmp->user, yy_tmp);
999 dlinkDestroy(cur, &yy_aconf_list);
1002 yy_aconf = NULL;
1003 return 0;
1005 /* }}} */
1007 /* {{{ static void conf_set_auth_user() */
1008 static void
1009 conf_set_auth_user (void *data)
1011 struct ConfItem *yy_tmp = NULL;
1012 char *p = NULL;
1014 /* The first user= line doesn't allocate a new conf */
1015 if (!EmptyString(yy_aconf->host))
1017 yy_tmp = make_conf();
1018 yy_tmp->status = CONF_CLIENT;
1020 else
1021 yy_tmp = yy_aconf;
1023 if ((p = strchr(data, '@')))
1025 *p++ = '\0';
1027 DupString(yy_tmp->user, data);
1028 DupString(yy_tmp->host, p);
1030 else
1032 DupString(yy_tmp->user, "*");
1033 DupString(yy_tmp->host, data);
1036 if (yy_aconf != yy_tmp)
1037 dlinkAddAlloc(yy_tmp, &yy_aconf_list);
1039 /* }}} */
1041 /* {{{ static void conf_set_auth_passwd() */
1042 static void
1043 conf_set_auth_passwd (void *data)
1045 if(yy_aconf->passwd)
1046 memset(yy_aconf->passwd, 0, strlen(yy_aconf->passwd));
1048 MyFree(yy_aconf->passwd);
1049 DupString(yy_aconf->passwd, data);
1051 /* }}} */
1053 /* {{{ static void conf_set_auth_spoof() */
1054 static void
1055 conf_set_auth_spoof (void *data)
1057 char *p = NULL;
1058 char *user = NULL;
1059 char *host = NULL;
1061 host = data;
1062 if ((p = strchr(host, '@')))
1064 *p = '\0';
1065 user = data;
1066 host = p + 1;
1068 if (EmptyString(user))
1070 conf_report_error("Warning -- spoof ident empty.");
1071 return;
1073 else if (strlen(user) > USERLEN)
1075 conf_report_error("Warning -- spoof ident length invalid.");
1076 return;
1078 else if (!valid_username(user))
1080 conf_report_error("Warning -- invalid spoof (ident).");
1081 return;
1084 *p = '@';
1087 if (EmptyString(host))
1089 conf_report_error("Warning -- spoof host empty.");
1090 return;
1092 else if (strlen(host) > HOSTLEN)
1094 conf_report_error("Warning -- spoof host length invalid.");
1095 return;
1097 else if (!valid_hostname(host))
1099 conf_report_error("Warning -- invalid spoof (host).");
1100 return;
1103 MyFree(yy_aconf->name);
1104 DupString(yy_aconf->name, data);
1105 yy_aconf->flags |= CONF_FLAGS_SPOOF_IP;
1107 /* }}} */
1109 /* {{{ static void conf_set_auth_flags() */
1110 static void
1111 conf_set_auth_flags (void *data)
1113 conf_parm_t *args = data;
1115 set_modes_from_table((int *) &yy_aconf->flags, "flag", auth_table, args);
1117 /* }}} */
1119 /* {{{ static void conf_set_auth_redir_serv() */
1120 static void
1121 conf_set_auth_redir_serv (void *data)
1123 yy_aconf->flags |= CONF_FLAGS_REDIR;
1124 MyFree(yy_aconf->name);
1125 DupString(yy_aconf->name, data);
1127 /* }}} */
1129 /* {{{ static void conf_set_auth_redir_port() */
1130 static void
1131 conf_set_auth_redir_port (void *data)
1133 int port = *((unsigned int *) data);
1135 yy_aconf->flags |= CONF_FLAGS_REDIR;
1136 yy_aconf->port = port;
1138 /* }}} */
1140 /* {{{ static void conf_set_auth_class() */
1141 static void
1142 conf_set_auth_class (void *data)
1144 MyFree(yy_aconf->className);
1145 DupString(yy_aconf->className, data);
1147 /* }}} */
1149 /* {{{ static int conf_cleanup_shared()
1151 * ok, shared_oper handles the stacking, shared_flags handles adding
1152 * things.. so all we need to do when we start and end a shared block, is
1153 * clean up anything thats been left over.
1155 static int
1156 conf_cleanup_shared (struct TopConf *tc)
1158 dlink_node *cur = NULL;
1159 dlink_node *next = NULL;
1161 DLINK_FOREACH_SAFE (cur, next, yy_shared_list.head)
1163 free_remote_conf(cur->data);
1164 dlinkDestroy(cur, &yy_shared_list);
1167 if(yy_shared)
1169 free_remote_conf(yy_shared);
1170 yy_shared = NULL;
1173 return 0;
1175 /* }}} */
1177 /* {{{ static void conf_set_shared_oper() */
1178 static void
1179 conf_set_shared_oper (void *data)
1181 conf_parm_t *args = data;
1182 const char *username = NULL;
1183 char *p = NULL;
1185 if (yy_shared)
1186 free_remote_conf(yy_shared);
1188 yy_shared = make_remote_conf();
1189 if (args->next)
1191 if (CF_TYPE(args->type) != CF_QSTRING)
1193 conf_report_error("Ignoring shared::oper -- server is not a qstring");
1194 return;
1197 DupString(yy_shared->server, args->v.string);
1198 args = args->next;
1200 else
1201 DupString(yy_shared->server, "*");
1203 if (CF_TYPE(args->type) != CF_QSTRING)
1205 conf_report_error("Ignoring shared::oper -- oper is not a qstring");
1206 return;
1208 else if ((p = strchr(args->v.string, '@')) == NULL)
1210 conf_report_error("Ignoring shard::oper -- oper is not a user@host");
1211 return;
1214 username = args->v.string;
1215 *p++ = '\0';
1217 if (EmptyString(p))
1218 DupString(yy_shared->host, "*");
1219 else
1220 DupString(yy_shared->host, p);
1222 if (EmptyString(username))
1223 DupString(yy_shared->username, "*");
1224 else
1225 DupString(yy_shared->username, username);
1227 dlinkAddAlloc(yy_shared, &yy_shared_list);
1228 yy_shared = NULL;
1230 /* }}} */
1232 /* {{{ static void conf_set_shared_flags() */
1233 static void
1234 conf_set_shared_flags (void *data)
1236 conf_parm_t *args = data;
1237 int flags = 0;
1238 dlink_node *cur = NULL;
1239 dlink_node *next = NULL;
1241 if (yy_shared)
1242 free_remote_conf(yy_shared);
1244 set_modes_from_table(&flags, "flag", shared_table, args);
1245 DLINK_FOREACH_SAFE (cur, next, yy_shared_list.head)
1247 yy_shared = cur->data;
1248 yy_shared->flags = flags;
1250 dlinkDestroy(cur, &yy_shared_list);
1251 dlinkAddTail(yy_shared, &yy_shared->node, &shared_conf_list);
1254 yy_shared = NULL;
1256 /* }}} */
1258 /* {{{ static int conf_begin_connect() */
1259 static int
1260 conf_begin_connect (struct TopConf *tc)
1262 if (yy_server)
1263 free_server_conf(yy_server);
1265 yy_server = make_server_conf();
1266 yy_server->port = PORTNUM;
1268 if (conf_cur_block_name)
1269 DupString(yy_server->name, conf_cur_block_name);
1271 return 0;
1273 /* }}} */
1275 /* {{{ static int conf_end_connect() */
1276 static int
1277 conf_end_connect (struct TopConf *tc)
1279 if (EmptyString(yy_server->name))
1281 conf_report_error("Ignoring connect block -- missing name.");
1282 return 0;
1284 else if (ServerInfo.name && !irccmp(ServerInfo.name, yy_server->name))
1286 conf_report_error("Ignoring connect block for %s "
1287 "-- name is equal to my own name.",
1288 yy_server->name);
1289 return 0;
1291 else if (EmptyString(yy_server->passwd) || EmptyString(yy_server->spasswd))
1293 conf_report_error("Ignoring connect block for %s "
1294 "-- missing password.", yy_server->name);
1295 return 0;
1297 else if (EmptyString(yy_server->host))
1299 conf_report_error("Ignoring connect block for %s -- missing host.",
1300 yy_server->name);
1301 return 0;
1304 #ifndef HAVE_LIBZ
1305 if (ServerConfCompressed(yy_server))
1307 conf_report_error("Ignoring connect::flags::compressed -- zlib not available.");
1308 yy_server->flags &= ~SERVER_COMPRESSED;
1310 #endif
1312 add_server_conf(yy_server);
1313 dlinkAdd(yy_server, &yy_server->node, &server_conf_list);
1314 yy_server = NULL;
1316 return 0;
1318 /* }}} */
1320 /* {{{ static void conf_set_connect_host() */
1321 static void
1322 conf_set_connect_host (void *data)
1324 if (yy_server->host)
1325 MyFree(yy_server->host);
1327 DupString(yy_server->host, data);
1328 if (strchr(yy_server->host, ':'))
1329 yy_server->aftype = AF_INET6;
1331 /* }}} */
1333 /* {{{ static void conf_set_connect_vhost() */
1334 static void
1335 conf_set_connect_vhost (void *data)
1337 if (inetpton_sock(data, (struct sockaddr *) &yy_server->my_ipnum) <= 0)
1339 conf_report_error("Invalid netmask for server vhost (%s)",
1340 (char *) data);
1341 return;
1344 yy_server->flags |= SERVER_VHOSTED;
1346 /* }}} */
1348 /* {{{ static void conf_set_connect_send_password() */
1349 static void
1350 conf_set_connect_send_password (void *data)
1352 if (yy_server->spasswd)
1354 memset(yy_server->spasswd, 0, strlen(yy_server->spasswd));
1355 MyFree(yy_server->spasswd);
1358 DupString(yy_server->spasswd, data);
1360 /* }}} */
1362 /* {{{ static void conf_set_connect_accept_password() */
1363 static void
1364 conf_set_connect_accept_password (void *data)
1366 if (yy_server->passwd)
1368 memset(yy_server->passwd, 0, strlen(yy_server->passwd));
1369 MyFree(yy_server->passwd);
1372 DupString(yy_server->passwd, data);
1374 /* }}} */
1376 /* {{{ static void conf_set_connect_port() */
1377 static void
1378 conf_set_connect_port (void *data)
1380 int port = *((unsigned int *) data);
1382 if(port < 1)
1383 port = PORTNUM;
1385 yy_server->port = port;
1387 /* }}} */
1389 /* {{{ static void conf_set_connect_aftype() */
1390 static void
1391 conf_set_connect_aftype (void *data)
1393 char *aft = data;
1395 if (!strcasecmp(aft, "ipv4"))
1396 yy_server->aftype = AF_INET;
1397 #ifdef IPV6
1398 else if(!strcasecmp(aft, "ipv6"))
1399 yy_server->aftype = AF_INET6;
1400 #endif
1401 else
1402 conf_report_error("connect::aftype '%s' is unknown.", aft);
1404 /* }}} */
1406 /* {{{ static void conf_set_connect_flags() */
1407 static void
1408 conf_set_connect_flags (void *data)
1410 conf_parm_t *args = data;
1412 set_modes_from_table(&yy_server->flags, "flag", connect_table, args);
1414 /* }}} */
1416 /* {{{ static void conf_set_connect_hub_mask() */
1417 static void
1418 conf_set_connect_hub_mask (void *data)
1420 struct remote_conf *yy_hub = NULL;
1422 if (EmptyString(yy_server->name))
1423 return;
1425 yy_hub = make_remote_conf();
1426 yy_hub->flags = CONF_HUB;
1428 DupString(yy_hub->host, data);
1429 DupString(yy_hub->server, yy_server->name);
1430 dlinkAdd(yy_hub, &yy_hub->node, &hubleaf_conf_list);
1432 /* }}} */
1434 /* {{{ static void conf_set_connect_leaf_mask() */
1435 static void
1436 conf_set_connect_leaf_mask (void *data)
1438 struct remote_conf *yy_leaf = NULL;
1440 if (EmptyString(yy_server->name))
1441 return;
1443 yy_leaf = make_remote_conf();
1444 yy_leaf->flags = CONF_LEAF;
1446 DupString(yy_leaf->host, data);
1447 DupString(yy_leaf->server, yy_server->name);
1448 dlinkAdd(yy_leaf, &yy_leaf->node, &hubleaf_conf_list);
1450 /* }}} */
1452 /* {{{ static void conf_set_connect_class() */
1453 static void
1454 conf_set_connect_class(void *data)
1456 MyFree(yy_server->class_name);
1457 DupString(yy_server->class_name, data);
1459 /* }}} */
1461 /* {{{ static void conf_set_exempt_ip() */
1462 static void
1463 conf_set_exempt_ip(void *data)
1465 struct ConfItem *yy_tmp = NULL;
1467 if (parse_netmask(data, NULL, NULL) == HM_HOST)
1469 conf_report_error("Ignoring exempt -- invalid exempt::ip.");
1470 return;
1473 yy_tmp = make_conf();
1474 DupString(yy_tmp->passwd, "*");
1475 DupString(yy_tmp->host, data);
1476 yy_tmp->status = CONF_EXEMPTDLINE;
1477 add_conf_by_address(yy_tmp->host, CONF_EXEMPTDLINE, NULL, yy_tmp);
1479 /* }}} */
1481 /* {{{ static int conf_cleanup_cluster() */
1482 static int
1483 conf_cleanup_cluster (struct TopConf *tc)
1485 dlink_node *cur = NULL;
1486 dlink_node *next = NULL;
1488 DLINK_FOREACH_SAFE (cur, next, yy_cluster_list.head)
1490 free_remote_conf(cur->data);
1491 dlinkDestroy(cur, &yy_cluster_list);
1494 if (yy_shared)
1496 free_remote_conf(yy_shared);
1497 yy_shared = NULL;
1500 return 0;
1502 /* }}} */
1504 /* {{{ static void conf_set_cluster_name() */
1505 static void
1506 conf_set_cluster_name (void *data)
1508 if (yy_shared)
1509 free_remote_conf(yy_shared);
1511 yy_shared = make_remote_conf();
1512 DupString(yy_shared->server, data);
1513 dlinkAddAlloc(yy_shared, &yy_cluster_list);
1515 yy_shared = NULL;
1517 /* }}} */
1519 /* {{{ static void conf_set_cluster_flags() */
1520 static void
1521 conf_set_cluster_flags (void *data)
1523 conf_parm_t *args = data;
1524 int flags = 0;
1525 dlink_node *cur = NULL;
1526 dlink_node *next = NULL;
1528 if(yy_shared)
1529 free_remote_conf(yy_shared);
1531 set_modes_from_table(&flags, "flag", cluster_table, args);
1532 DLINK_FOREACH_SAFE (cur, next, yy_cluster_list.head)
1534 yy_shared = cur->data;
1535 yy_shared->flags = flags;
1536 dlinkAddTail(yy_shared, &yy_shared->node, &cluster_conf_list);
1537 dlinkDestroy(cur, &yy_cluster_list);
1540 yy_shared = NULL;
1542 /* }}} */
1544 /* {{{ static void conf_set_general_havent_read_conf() */
1545 static void
1546 conf_set_general_havent_read_conf (void *data)
1548 if (*((unsigned int *) data))
1550 conf_report_error("You haven't read your config file properly.");
1551 conf_report_error("There is a line in the example conf that will "
1552 "kill your server if not removed.");
1553 conf_report_error("Consider actually reading/editing the conf "
1554 "file, and removing this line.");
1556 if (!testing_conf)
1557 exit(0);
1560 /* }}} */
1562 /* {{{ static void conf_set_general_hide_error_messages() */
1563 static void
1564 conf_set_general_hide_error_messages (void *data)
1566 char *val = data;
1568 if (!strcasecmp(val, "yes"))
1569 ConfigFileEntry.hide_error_messages = 2;
1570 else if (!strcasecmp(val, "opers"))
1571 ConfigFileEntry.hide_error_messages = 1;
1572 else if(!strcasecmp(val, "no"))
1573 ConfigFileEntry.hide_error_messages = 0;
1574 else
1575 conf_report_error("Invalid setting '%s' for "
1576 "general::hide_error_messages.", val);
1578 /* }}} */
1580 /* {{{ static void conf_set_general_kline_delay() */
1581 static void
1582 conf_set_general_kline_delay (void *data)
1584 ConfigFileEntry.kline_delay = *((unsigned int *) data);
1585 kline_queued = 0;
1587 /* }}} */
1589 /* {{{ static void conf_set_general_stats_k_oper_only() */
1590 static void
1591 conf_set_general_stats_k_oper_only(void *data)
1593 char *val = data;
1595 if (!strcasecmp(val, "yes"))
1596 ConfigFileEntry.stats_k_oper_only = 2;
1597 else if (!strcasecmp(val, "masked"))
1598 ConfigFileEntry.stats_k_oper_only = 1;
1599 else if (!strcasecmp(val, "no"))
1600 ConfigFileEntry.stats_k_oper_only = 0;
1601 else
1602 conf_report_error("Invalid setting '%s' for "
1603 "general::stats_k_oper_only.", val);
1605 /* }}} */
1607 /* {{{ static void conf_set_general_stats_i_oper_only() */
1608 static void
1609 conf_set_general_stats_i_oper_only (void *data)
1611 char *val = data;
1613 if (!strcasecmp(val, "yes"))
1614 ConfigFileEntry.stats_i_oper_only = 2;
1615 else if (!strcasecmp(val, "masked"))
1616 ConfigFileEntry.stats_i_oper_only = 1;
1617 else if (!strcasecmp(val, "no"))
1618 ConfigFileEntry.stats_i_oper_only = 0;
1619 else
1620 conf_report_error("Invalid setting '%s' for "
1621 "general::stats_i_oper_only.", val);
1623 /* }}} */
1625 /* {{{ static void conf_set_general_compression_level() */
1626 static void
1627 conf_set_general_compression_level (void *data)
1629 #ifdef HAVE_LIBZ
1630 ConfigFileEntry.compression_level = *((unsigned int *) data);
1632 if ((ConfigFileEntry.compression_level < 1) || (ConfigFileEntry.compression_level > 9))
1634 conf_report_error("Invalid general::compression_level %d "
1635 "-- using default.",
1636 ConfigFileEntry.compression_level);
1637 ConfigFileEntry.compression_level = 0;
1639 #else
1640 conf_report_error("Ignoring general::compression_level "
1641 "-- zlib not available.");
1642 #endif
1644 /* }}} */
1646 /* {{{ static void conf_set_general_default_umodes() */
1647 static void
1648 conf_set_general_default_umodes (void *data)
1650 char *pm = NULL;
1651 int what = MODE_ADD;
1652 int flag;
1654 ConfigFileEntry.default_umodes = 0;
1655 for (pm = (char *) data; *pm; ++pm)
1657 switch (*pm)
1659 case '+':
1660 what = MODE_ADD;
1661 break;
1662 case '-':
1663 what = MODE_DEL;
1664 break;
1666 /* don't allow +o */
1667 case 'o':
1668 case 'S':
1669 case ' ':
1670 break;
1672 default:
1673 if ((flag = user_modes[(unsigned char) *pm]))
1675 /* Proper value has probably not yet been set
1676 * so don't check oper_only_umodes -- jilles */
1677 if (what == MODE_ADD)
1678 ConfigFileEntry.default_umodes |= flag;
1679 else
1680 ConfigFileEntry.default_umodes &= ~flag;
1682 break;
1686 /* }}} */
1688 /* {{{ static void conf_set_general_oper_umodes() */
1689 static void
1690 conf_set_general_oper_umodes (void *data)
1692 set_modes_from_table(&ConfigFileEntry.oper_umodes, "umode",
1693 umode_table, data);
1695 /* }}} */
1697 /* {{{ static void conf_set_general_oper_only_umodes() */
1698 static void
1699 conf_set_general_oper_only_umodes (void *data)
1701 set_modes_from_table(&ConfigFileEntry.oper_only_umodes, "umode",
1702 umode_table, data);
1704 /* }}} */
1706 /* {{{ static void conf_set_general_oper_snomask() */
1707 static void
1708 conf_set_general_oper_snomask (void *data)
1710 char *pm = NULL;
1711 int what = MODE_ADD;
1712 int flag;
1714 ConfigFileEntry.oper_snomask = 0;
1715 for (pm = (char *) data; *pm; ++pm)
1717 switch (*pm)
1719 case '+':
1720 what = MODE_ADD;
1721 break;
1722 case '-':
1723 what = MODE_DEL;
1724 break;
1726 default:
1727 if ((flag = snomask_modes[(unsigned char) *pm]))
1729 if (what == MODE_ADD)
1730 ConfigFileEntry.oper_snomask |= flag;
1731 else
1732 ConfigFileEntry.oper_snomask &= ~flag;
1734 break;
1738 /* }}} */
1740 /* {{{ static void conf_set_serverhide_links_delay() */
1741 static void
1742 conf_set_serverhide_links_delay (void *data)
1744 int val = *((unsigned int *) data);
1746 if ((val > 0) && ConfigServerHide.links_disabled == 1)
1748 eventAddIsh("cache_links", cache_links, NULL, val);
1749 ConfigServerHide.links_disabled = 0;
1751 else if (val != ConfigServerHide.links_delay)
1752 eventUpdate("cache_links", val);
1754 ConfigServerHide.links_delay = val;
1756 /* }}} */
1758 /* {{{ static int conf_begin_service() */
1759 static int
1760 conf_begin_service (struct TopConf *tc)
1762 struct Client *target_p = NULL;
1763 dlink_node *cur = NULL;
1765 DLINK_FOREACH (cur, global_serv_list.head)
1767 target_p = cur->data;
1768 target_p->flags &= ~FLAGS_SERVICE;
1771 return 0;
1773 /* }}} */
1775 /* {{{ static void conf_set_service_name() */
1776 static void
1777 conf_set_service_name (void *data)
1779 struct Client *target_p = NULL;
1780 const char *s = data;
1781 char *tmp = NULL;
1782 int dots = 0;
1784 for (; *s != '\0'; s++)
1786 if (!IsServChar(*s))
1788 conf_report_error("Ignoring service::name "
1789 "-- bogus servername.");
1790 return;
1792 else if (*s == '.')
1793 dots++;
1796 if (!dots)
1798 conf_report_error("Ignoring service::name -- must contain '.'");
1799 return;
1802 DupString(tmp, data);
1803 dlinkAddAlloc(tmp, &service_list);
1805 if ((target_p = find_server(NULL, tmp)))
1806 target_p->flags |= FLAGS_SERVICE;
1808 /* }}} */
1810 /* {{{ static int alias_hash() */
1811 static int
1812 alias_hash (const char *p)
1814 int hash_val = 0;
1816 while (*p)
1818 hash_val += ((int) (*p) & 0xDF);
1819 p++;
1822 return (hash_val % MAX_MSG_HASH);
1824 /* }}} */
1826 /* {{{ static int conf_begin_alias() */
1827 static int
1828 conf_begin_alias (struct TopConf *tc)
1830 yy_alias = MyMalloc(sizeof(struct alias_entry));
1832 if (conf_cur_block_name)
1833 DupString(yy_alias->name, conf_cur_block_name);
1835 yy_alias->flags = 0;
1836 yy_alias->hits = 0;
1838 return 0;
1840 /* }}} */
1842 /* {{{ static int conf_end_alias() */
1843 static int
1844 conf_end_alias (struct TopConf *tc)
1846 int hashval;
1848 if (!yy_alias)
1849 return -1;
1851 if (!yy_alias->name)
1853 conf_report_error("Ignoring alias -- must have a name.");
1854 MyFree(yy_alias);
1856 return -1;
1858 else if (!yy_alias->target)
1860 conf_report_error("Ignoring alias -- must have a target.");
1861 MyFree(yy_alias);
1863 return -1;
1866 hashval = alias_hash(yy_alias->name);
1867 dlinkAddAlloc(yy_alias, &alias_hash_table[hashval]);
1869 return 0;
1871 /* }}} */
1873 /* {{{ static void conf_set_alias_name() */
1874 static void
1875 conf_set_alias_name (void *data)
1877 /* should never happen. */
1878 if (!data || !yy_alias)
1879 return;
1881 DupString(yy_alias->name, data);
1883 /* }}} */
1885 /* {{{ static void conf_set_alias_target() */
1886 static void
1887 conf_set_alias_target (void *data)
1889 /* should never happen. */
1890 if (!data || !yy_alias)
1891 return;
1893 DupString(yy_alias->target, data);
1895 /* }}} */
1897 /* {{{ static void conf_set_blacklist_host() */
1898 static void
1899 conf_set_blacklist_host (void *data)
1901 DupString(yy_blacklist_host, data);
1903 /* }}} */
1905 /* {{{ static void conf_set_blacklist_reason() */
1906 static void
1907 conf_set_blacklist_reason (void *data)
1909 DupString(yy_blacklist_reason, data);
1911 if (yy_blacklist_host && yy_blacklist_reason)
1913 new_blacklist(yy_blacklist_host, yy_blacklist_reason);
1914 MyFree(yy_blacklist_host);
1915 MyFree(yy_blacklist_reason);
1916 yy_blacklist_host = NULL;
1917 yy_blacklist_reason = NULL;
1920 /* }}} */
1923 * Public Functions.
1926 /* {{{ void conf_report_error() */
1927 void
1928 conf_report_error (const char *fmt, ...)
1930 va_list ap;
1931 char msg[IRCD_BUFSIZE + 1] = {0};
1933 va_start(ap, fmt);
1934 ircvsnprintf(msg, IRCD_BUFSIZE, fmt, ap);
1935 va_end(ap);
1937 if (testing_conf)
1939 fprintf(stderr, "\"%s\", line %d: %s\n", current_file,
1940 lineno + 1, msg);
1941 return;
1944 ierror("\"%s\", line %d: %s", current_file, lineno + 1, msg);
1945 sendto_realops_snomask(SNO_GENERAL, L_ALL, "\"%s\", line %d: %s",
1946 current_file, lineno + 1, msg);
1948 /* }}} */
1950 /* {{{ int conf_start_block() */
1952 conf_start_block (char *block, char *name)
1954 if (!(conf_cur_block = find_top_conf(block)))
1956 conf_report_error("Configuration block '%s' is not defined.",
1957 block);
1958 return -1;
1961 if (name)
1962 DupString(conf_cur_block_name, name);
1963 else
1964 conf_cur_block_name = NULL;
1966 if (conf_cur_block->tc_sfunc)
1968 if (conf_cur_block->tc_sfunc(conf_cur_block) < 0)
1969 return -1;
1972 return 0;
1974 /* }}} */
1976 /* {{{ int conf_end_block() */
1978 conf_end_block (struct TopConf *tc)
1980 if (tc->tc_efunc)
1981 return tc->tc_efunc(tc);
1983 MyFree(conf_cur_block_name);
1984 return 0;
1986 /* }}} */
1988 /* {{{ static void conf_set_generic_int() */
1989 static void
1990 conf_set_generic_int (void *data, void *location)
1992 *((int *) location) = *((unsigned int *) data);
1994 /* }}} */
1996 /* {{{ static void conf_set_generic_string() */
1997 static void
1998 conf_set_generic_string (void *data, int len, void *location)
2000 char **loc = location;
2001 char *input = data;
2003 if (len && strlen(input) > len)
2004 input[len] = '\0';
2006 MyFree(*loc);
2007 DupString(*loc, input);
2009 /* }}} */
2011 /* {{{ int conf_call_set() */
2013 conf_call_set (struct TopConf *tc, char *item, conf_parm_t * value, int type)
2015 struct ConfEntry *cf = NULL;
2016 conf_parm_t *cp = NULL;
2018 if (!tc)
2019 return -1;
2021 if (!(cf = find_conf_item(tc, item)))
2023 conf_report_error("Non-existant configuration setting %s::%s.",
2024 tc->tc_name, (char *) item);
2025 return -1;
2029 * If this setting is a scalar type make sure we're not given a list.
2031 if (value->type & CF_FLIST && !cf->cf_type & CF_FLIST)
2033 conf_report_error("Option %s::%s does not take a list of values.",
2034 tc->tc_name, item);
2035 return -1;
2038 cp = value->v.list;
2039 if (CF_TYPE(value->v.list->type) != CF_TYPE(cf->cf_type))
2041 if ((CF_TYPE(value->v.list->type) == CF_YESNO) &&
2042 (CF_TYPE(cf->cf_type) == CF_STRING))
2044 value->v.list->type = CF_STRING;
2045 if (cp->v.number == 1)
2046 DupString(cp->v.string, "yes");
2047 else
2048 DupString(cp->v.string, "no");
2050 else if (!((CF_TYPE(value->v.list->type) == CF_INT) &&
2051 (CF_TYPE(cf->cf_type) == CF_TIME)))
2053 conf_report_error(
2054 "Wrong type for %s::%s (expected %s, got %s)",
2055 tc->tc_name, (char *) item,
2056 conf_strtype(cf->cf_type),
2057 conf_strtype(value->v.list->type));
2058 return -1;
2062 if (cf->cf_type & CF_FLIST)
2064 #if 0
2065 if (cf->cf_arg)
2066 conf_set_generic_list(value->v.list, cf->cf_arg);
2067 else
2068 #endif
2069 /* just pass it the extended argument list */
2070 cf->cf_func(value->v.list);
2072 else
2074 /* it's old-style, needs only one arg */
2075 switch (cf->cf_type)
2077 case CF_INT:
2078 case CF_TIME:
2079 case CF_YESNO:
2080 if (cf->cf_arg)
2081 conf_set_generic_int(&cp->v.number, cf->cf_arg);
2082 else
2083 cf->cf_func(&cp->v.number);
2084 break;
2085 case CF_STRING:
2086 case CF_QSTRING:
2087 if (EmptyString(cp->v.string))
2089 conf_report_error("Ignoring %s::%s -- empty field",
2090 tc->tc_name, item);
2092 else if (cf->cf_arg)
2093 conf_set_generic_string(cp->v.string, cf->cf_len, cf->cf_arg);
2094 else
2095 cf->cf_func(cp->v.string);
2096 break;
2100 return 0;
2102 /* }}} */
2104 /* {{{ int add_conf_item() */
2106 add_conf_item (const char *topconf, const char *name, int type, void (*func) (void *))
2108 struct TopConf *tc = NULL;
2109 struct ConfEntry *cf = NULL;
2111 if (!(tc = find_top_conf(topconf)))
2112 return -1;
2113 if ((cf = find_conf_item(tc, name)))
2114 return -1;
2116 cf = MyMalloc(sizeof(struct ConfEntry));
2117 DupString(cf->cf_name, name);
2118 cf->cf_type = type;
2119 cf->cf_func = func;
2120 cf->cf_arg = NULL;
2121 dlinkAddAlloc(cf, &tc->tc_items);
2123 return 0;
2125 /* }}} */
2127 /* {{{ int remove_conf_item() */
2129 remove_conf_item (const char *topconf, const char *name)
2131 struct TopConf *tc = NULL;
2132 struct ConfEntry *cf = NULL;
2133 dlink_node *cur = NULL;
2135 if (!(tc = find_top_conf(topconf)))
2136 return -1;
2137 if (!(cf = find_conf_item(tc, name)))
2138 return -1;
2139 if (!(cur = dlinkFind(cf, &tc->tc_items)))
2140 return -1;
2142 dlinkDestroy(cur, &tc->tc_items);
2143 MyFree(cf);
2145 return 0;
2147 /* }}} */
2150 * TODO: The below structures should really be auto-generated by the build
2151 * system...
2154 /* {{{ static struct ConfEntry conf_serverinfo_table[] = { ... } */
2155 static struct ConfEntry conf_serverinfo_table[] =
2157 {"description", CF_QSTRING, NULL, 0, &ServerInfo.description},
2158 {"network_desc", CF_QSTRING, NULL, 0, &ServerInfo.network_desc},
2159 {"hub", CF_YESNO, NULL, 0, &ServerInfo.hub},
2160 {"use_ts6", CF_YESNO, NULL, 0, &ServerInfo.use_ts6},
2161 {"network_name", CF_QSTRING, conf_set_serverinfo_network_name, 0, NULL},
2162 {"name", CF_QSTRING, conf_set_serverinfo_name, 0, NULL},
2163 {"sid", CF_QSTRING, conf_set_serverinfo_sid, 0, NULL},
2164 {"vhost", CF_QSTRING, conf_set_serverinfo_vhost, 0, NULL},
2165 {"vhost6", CF_QSTRING, conf_set_serverinfo_vhost6, 0, NULL},
2166 {"", 0, NULL, 0, NULL},
2168 /* }}} */
2170 /* {{{ static struct ConfEntry conf_admin_table[] = { ... } */
2171 static struct ConfEntry conf_admin_table[] =
2173 {"name", CF_QSTRING, NULL, 200, &AdminInfo.name},
2174 {"description", CF_QSTRING, NULL, 200, &AdminInfo.description},
2175 {"email", CF_QSTRING, NULL, 200, &AdminInfo.email},
2176 {"", 0, NULL, 0, NULL},
2178 /* }}} */
2180 /* {{{ static struct ConfEntry conf_log_table[] = { ... } */
2181 static struct ConfEntry conf_log_table[] =
2183 {"fname_userlog", CF_QSTRING, NULL, MAXPATHLEN, &ConfigFileEntry.fname_userlog},
2184 {"fname_fuserlog", CF_QSTRING, NULL, MAXPATHLEN, &ConfigFileEntry.fname_fuserlog},
2185 {"fname_operlog", CF_QSTRING, NULL, MAXPATHLEN, &ConfigFileEntry.fname_operlog},
2186 {"fname_foperlog", CF_QSTRING, NULL, MAXPATHLEN, &ConfigFileEntry.fname_foperlog},
2187 {"fname_serverlog", CF_QSTRING, NULL, MAXPATHLEN, &ConfigFileEntry.fname_serverlog},
2188 {"fname_killlog", CF_QSTRING, NULL, MAXPATHLEN, &ConfigFileEntry.fname_killlog},
2189 {"fname_klinelog", CF_QSTRING, NULL, MAXPATHLEN, &ConfigFileEntry.fname_klinelog},
2190 {"fname_ioerrorlog", CF_QSTRING, NULL, MAXPATHLEN, &ConfigFileEntry.fname_ioerrorlog},
2191 {"", 0, NULL, 0, NULL},
2193 /* }}} */
2195 /* {{{ static struct ConfEntry conf_operator_table[] = { ... } */
2196 static struct ConfEntry conf_operator_table[] =
2198 {"rsa_public_key_file", CF_QSTRING, conf_set_oper_rsa_public_key_file, 0, NULL},
2199 {"flags", CF_STRING | CF_FLIST, conf_set_oper_flags, 0, NULL},
2200 {"umodes", CF_STRING | CF_FLIST, conf_set_oper_umodes, 0, NULL},
2201 {"snomask", CF_QSTRING, conf_set_oper_snomask, 0, NULL},
2202 {"allowed_snomask", CF_QSTRING, conf_set_oper_allowed_snomask, 0, NULL},
2203 {"user", CF_QSTRING, conf_set_oper_user, 0, NULL},
2204 {"password", CF_QSTRING, conf_set_oper_password, 0, NULL},
2205 {"", 0, NULL, 0, NULL},
2207 /* }}} */
2209 /* {{{ static struct ConfEntry conf_class_table[] = { ... } */
2210 static struct ConfEntry conf_class_table[] =
2212 {"ping_time", CF_TIME, conf_set_class_ping_time, 0, NULL},
2213 {"cidr_bitlen", CF_INT, conf_set_class_cidr_bitlen, 0, NULL},
2214 {"number_per_cidr", CF_INT, conf_set_class_number_per_cidr, 0, NULL},
2215 {"number_per_ip", CF_INT, conf_set_class_number_per_ip, 0, NULL},
2216 {"number_per_ip_global", CF_INT, conf_set_class_number_per_ip_global, 0, NULL},
2217 {"number_per_ident", CF_INT, conf_set_class_number_per_ident, 0, NULL},
2218 {"connectfreq", CF_TIME, conf_set_class_connectfreq, 0, NULL},
2219 {"max_number", CF_INT, conf_set_class_max_number, 0, NULL},
2220 {"sendq", CF_TIME, conf_set_class_sendq, 0, NULL},
2221 {"", 0, NULL, 0, NULL},
2223 /* }}} */
2225 /* {{{ static struct ConfEntry conf_auth_table[] = { ... } */
2226 static struct ConfEntry conf_auth_table[] =
2228 {"user", CF_QSTRING, conf_set_auth_user, 0, NULL},
2229 {"password", CF_QSTRING, conf_set_auth_passwd, 0, NULL},
2230 {"class", CF_QSTRING, conf_set_auth_class, 0, NULL},
2231 {"spoof", CF_QSTRING, conf_set_auth_spoof, 0, NULL},
2232 {"redirserv", CF_QSTRING, conf_set_auth_redir_serv, 0, NULL},
2233 {"redirport", CF_INT, conf_set_auth_redir_port, 0, NULL},
2234 {"flags", CF_STRING | CF_FLIST, conf_set_auth_flags, 0, NULL},
2235 {"", 0, NULL, 0, NULL},
2237 /* }}} */
2239 /* {{{ static struct ConfEntry conf_connect_table[] = { ... } */
2240 static struct ConfEntry conf_connect_table[] =
2242 {"send_password", CF_QSTRING, conf_set_connect_send_password, 0, NULL},
2243 {"accept_password", CF_QSTRING, conf_set_connect_accept_password, 0, NULL},
2244 {"flags", CF_STRING | CF_FLIST, conf_set_connect_flags, 0, NULL},
2245 {"host", CF_QSTRING, conf_set_connect_host, 0, NULL},
2246 {"vhost", CF_QSTRING, conf_set_connect_vhost, 0, NULL},
2247 {"port", CF_INT, conf_set_connect_port, 0, NULL},
2248 {"aftype", CF_STRING, conf_set_connect_aftype, 0, NULL},
2249 {"hub_mask", CF_QSTRING, conf_set_connect_hub_mask, 0, NULL},
2250 {"leaf_mask", CF_QSTRING, conf_set_connect_leaf_mask, 0, NULL},
2251 {"class", CF_QSTRING, conf_set_connect_class, 0, NULL},
2252 {"", 0, NULL, 0, NULL},
2254 /* }}} */
2256 /* {{{ static struct ConfEntry conf_general_table[] = { ... } */
2257 static struct ConfEntry conf_general_table[] =
2259 {"oper_only_umodes", CF_STRING | CF_FLIST, conf_set_general_oper_only_umodes, 0, NULL},
2260 {"oper_umodes", CF_STRING | CF_FLIST, conf_set_general_oper_umodes, 0, NULL},
2261 {"oper_snomask", CF_QSTRING, conf_set_general_oper_snomask, 0, NULL},
2262 {"compression_level", CF_INT, conf_set_general_compression_level, 0, NULL},
2263 {"havent_read_conf", CF_YESNO, conf_set_general_havent_read_conf, 0, NULL},
2264 {"hide_error_messages", CF_STRING, conf_set_general_hide_error_messages, 0, NULL},
2265 {"kline_delay", CF_TIME, conf_set_general_kline_delay, 0, NULL},
2266 {"stats_k_oper_only", CF_STRING, conf_set_general_stats_k_oper_only, 0, NULL},
2267 {"stats_i_oper_only", CF_STRING, conf_set_general_stats_i_oper_only, 0, NULL},
2268 {"default_umodes", CF_QSTRING, conf_set_general_default_umodes, 0, NULL},
2270 {"default_operstring", CF_QSTRING, NULL, REALLEN, &ConfigFileEntry.default_operstring},
2271 {"default_adminstring", CF_QSTRING, NULL, REALLEN, &ConfigFileEntry.default_adminstring},
2272 {"servicestring", CF_QSTRING, NULL, REALLEN, &ConfigFileEntry.servicestring},
2273 {"egdpool_path", CF_QSTRING, NULL, MAXPATHLEN, &ConfigFileEntry.egdpool_path},
2274 {"identify_service", CF_QSTRING, NULL, REALLEN, &ConfigFileEntry.identifyservice},
2275 {"identify_command", CF_QSTRING, NULL, REALLEN, &ConfigFileEntry.identifycommand},
2276 {"servlink_path", CF_QSTRING, NULL, MAXPATHLEN, &ConfigFileEntry.servlink_path},
2278 {"anti_spam_exit_message_time", CF_TIME, NULL, 0, &ConfigFileEntry.anti_spam_exit_message_time},
2279 {"disable_fake_channels", CF_YESNO, NULL, 0, &ConfigFileEntry.disable_fake_channels},
2280 {"min_nonwildcard_simple", CF_INT, NULL, 0, &ConfigFileEntry.min_nonwildcard_simple},
2281 {"non_redundant_klines", CF_YESNO, NULL, 0, &ConfigFileEntry.non_redundant_klines},
2282 {"tkline_expire_notices", CF_YESNO, NULL, 0, &ConfigFileEntry.tkline_expire_notices},
2284 {"anti_nick_flood", CF_YESNO, NULL, 0, &ConfigFileEntry.anti_nick_flood},
2285 {"burst_away", CF_YESNO, NULL, 0, &ConfigFileEntry.burst_away},
2286 {"caller_id_wait", CF_TIME, NULL, 0, &ConfigFileEntry.caller_id_wait},
2287 {"client_exit", CF_YESNO, NULL, 0, &ConfigFileEntry.client_exit},
2288 {"client_flood", CF_INT, NULL, 0, &ConfigFileEntry.client_flood},
2289 {"collision_fnc", CF_YESNO, NULL, 0, &ConfigFileEntry.collision_fnc},
2290 {"connect_timeout", CF_TIME, NULL, 0, &ConfigFileEntry.connect_timeout},
2291 {"default_floodcount", CF_INT, NULL, 0, &ConfigFileEntry.default_floodcount},
2292 {"disable_auth", CF_YESNO, NULL, 0, &ConfigFileEntry.disable_auth},
2293 {"dot_in_ip6_addr", CF_YESNO, NULL, 0, &ConfigFileEntry.dot_in_ip6_addr},
2294 {"dots_in_ident", CF_INT, NULL, 0, &ConfigFileEntry.dots_in_ident},
2295 {"failed_oper_notice", CF_YESNO, NULL, 0, &ConfigFileEntry.failed_oper_notice},
2296 {"global_snotices", CF_YESNO, NULL, 0, &ConfigFileEntry.global_snotices},
2297 {"idletime", CF_TIME, NULL, 0, &ConfigFileEntry.idletime},
2298 {"hide_spoof_ips", CF_YESNO, NULL, 0, &ConfigFileEntry.hide_spoof_ips},
2299 {"dline_with_reason", CF_YESNO, NULL, 0, &ConfigFileEntry.dline_with_reason},
2300 {"kline_with_reason", CF_YESNO, NULL, 0, &ConfigFileEntry.kline_with_reason},
2301 {"map_oper_only", CF_YESNO, NULL, 0, &ConfigFileEntry.map_oper_only},
2302 {"max_accept", CF_INT, NULL, 0, &ConfigFileEntry.max_accept},
2303 {"max_monitor", CF_INT, NULL, 0, &ConfigFileEntry.max_monitor},
2304 {"max_nick_time", CF_TIME, NULL, 0, &ConfigFileEntry.max_nick_time},
2305 {"max_nick_changes", CF_INT, NULL, 0, &ConfigFileEntry.max_nick_changes},
2306 {"max_targets", CF_INT, NULL, 0, &ConfigFileEntry.max_targets},
2307 {"min_nonwildcard", CF_INT, NULL, 0, &ConfigFileEntry.min_nonwildcard},
2308 {"nick_delay", CF_TIME, NULL, 0, &ConfigFileEntry.nick_delay},
2309 {"no_oper_flood", CF_YESNO, NULL, 0, &ConfigFileEntry.no_oper_flood},
2310 {"pace_wait", CF_TIME, NULL, 0, &ConfigFileEntry.pace_wait},
2311 {"pace_wait_simple", CF_TIME, NULL, 0, &ConfigFileEntry.pace_wait_simple},
2312 {"ping_cookie", CF_YESNO, NULL, 0, &ConfigFileEntry.ping_cookie},
2313 {"reject_after_count", CF_INT, NULL, 0, &ConfigFileEntry.reject_after_count},
2314 {"reject_ban_time", CF_TIME, NULL, 0, &ConfigFileEntry.reject_ban_time},
2315 {"reject_duration", CF_TIME, NULL, 0, &ConfigFileEntry.reject_duration},
2316 {"short_motd", CF_YESNO, NULL, 0, &ConfigFileEntry.short_motd},
2317 {"stats_c_oper_only", CF_YESNO, NULL, 0, &ConfigFileEntry.stats_c_oper_only},
2318 {"stats_e_disabled", CF_YESNO, NULL, 0, &ConfigFileEntry.stats_e_disabled},
2319 {"stats_h_oper_only", CF_YESNO, NULL, 0, &ConfigFileEntry.stats_h_oper_only},
2320 {"stats_o_oper_only", CF_YESNO, NULL, 0, &ConfigFileEntry.stats_o_oper_only},
2321 {"stats_P_oper_only", CF_YESNO, NULL, 0, &ConfigFileEntry.stats_P_oper_only},
2322 {"stats_y_oper_only", CF_YESNO, NULL, 0, &ConfigFileEntry.stats_y_oper_only},
2323 {"target_change", CF_YESNO, NULL, 0, &ConfigFileEntry.target_change},
2324 {"ts_max_delta", CF_TIME, NULL, 0, &ConfigFileEntry.ts_max_delta},
2325 {"use_egd", CF_YESNO, NULL, 0, &ConfigFileEntry.use_egd},
2326 {"ts_warn_delta", CF_TIME, NULL, 0, &ConfigFileEntry.ts_warn_delta},
2327 {"use_whois_actually", CF_YESNO, NULL, 0, &ConfigFileEntry.use_whois_actually},
2328 {"warn_no_nline", CF_YESNO, NULL, 0, &ConfigFileEntry.warn_no_nline},
2329 {"hide_opers", CF_YESNO, NULL, 0, &ConfigFileEntry.hide_opers},
2330 {"allow_kline_on", CF_YESNO, NULL, 0, &ConfigFileEntry.allow_kline_on},
2331 {"no_ping_timeout", CF_YESNO, NULL, 0, &ConfigFileEntry.no_ping_timeout},
2332 {"remote_die", CF_YESNO, NULL, 0, &ConfigFileEntry.remote_die},
2333 {"remote_restart", CF_YESNO, NULL, 0, &ConfigFileEntry.remote_restart},
2334 {"idented_user_prefix", CF_QSTRING, NULL, IDPREFIXLEN, &ConfigFileEntry.idented_user_prefix},
2335 {"unidented_user_prefix", CF_QSTRING, NULL, IDPREFIXLEN, &ConfigFileEntry.unidented_user_prefix},
2336 {"", 0, NULL, 0, NULL},
2338 /* }}} */
2340 /* {{{ static struct ConfEntry conf_channel_table[] = { ... } */
2341 static struct ConfEntry conf_channel_table[] =
2343 {"default_split_user_count", CF_INT, NULL, 0, &ConfigChannel.default_split_user_count},
2344 {"default_split_server_count", CF_INT, NULL, 0, &ConfigChannel.default_split_server_count},
2345 {"burst_topicwho", CF_YESNO, NULL, 0, &ConfigChannel.burst_topicwho},
2346 {"invite_ops_only", CF_YESNO, NULL, 0, &ConfigChannel.invite_ops_only},
2347 {"kick_on_split_riding", CF_YESNO, NULL, 0, &ConfigChannel.kick_on_split_riding},
2348 {"knock_delay", CF_TIME, NULL, 0, &ConfigChannel.knock_delay},
2349 {"knock_delay_channel", CF_TIME, NULL, 0, &ConfigChannel.knock_delay_channel},
2350 {"max_bans", CF_INT, NULL, 0, &ConfigChannel.max_bans},
2351 {"max_bans_large", CF_INT, NULL, 0, &ConfigChannel.max_bans_large},
2352 {"max_chans_per_user", CF_INT, NULL, 0, &ConfigChannel.max_chans_per_user},
2353 {"max_chans_per_user_large", CF_INT, NULL, 0, &ConfigChannel.max_chans_per_user_large},
2354 {"no_create_on_split", CF_YESNO, NULL, 0, &ConfigChannel.no_create_on_split},
2355 {"no_join_on_split", CF_YESNO, NULL, 0, &ConfigChannel.no_join_on_split},
2356 {"use_except", CF_YESNO, NULL, 0, &ConfigChannel.use_except},
2357 {"use_invex", CF_YESNO, NULL, 0, &ConfigChannel.use_invex},
2358 {"use_knock", CF_YESNO, NULL, 0, &ConfigChannel.use_knock},
2359 {"", 0, NULL, 0, NULL},
2361 /* }}} */
2363 /* {{{ static struct ConfEntry conf_serverhide_table[] = { ... } */
2364 static struct ConfEntry conf_serverhide_table[] =
2366 {"disable_hidden", CF_YESNO, NULL, 0, &ConfigServerHide.disable_hidden},
2367 {"flatten_links", CF_YESNO, NULL, 0, &ConfigServerHide.flatten_links},
2368 {"hidden", CF_YESNO, NULL, 0, &ConfigServerHide.hidden},
2369 {"links_delay", CF_TIME, conf_set_serverhide_links_delay, 0, NULL},
2370 {"", 0, NULL, 0, NULL},
2372 /* }}} */
2374 /* {{{ void newconf_init() */
2375 void
2376 newconf_init (void)
2378 add_top_conf("modules", NULL, NULL, NULL);
2379 add_conf_item("modules", "path", CF_QSTRING, conf_set_modules_path);
2380 add_conf_item("modules", "module", CF_QSTRING, conf_set_modules_module);
2382 add_top_conf("serverinfo", NULL, NULL, conf_serverinfo_table);
2383 add_top_conf("admin", NULL, NULL, conf_admin_table);
2384 add_top_conf("log", NULL, NULL, conf_log_table);
2385 add_top_conf("operator", conf_begin_oper, conf_end_oper,
2386 conf_operator_table);
2387 add_top_conf("class", conf_begin_class, conf_end_class,
2388 conf_class_table);
2390 add_top_conf("listen", conf_begin_listen, conf_end_listen, NULL);
2391 add_conf_item("listen", "port", CF_INT | CF_FLIST, conf_set_listen_port);
2392 add_conf_item("listen", "ip", CF_QSTRING, conf_set_listen_address);
2393 add_conf_item("listen", "host", CF_QSTRING, conf_set_listen_address);
2395 add_top_conf("auth", conf_begin_auth, conf_end_auth, conf_auth_table);
2397 add_top_conf("shared", conf_cleanup_shared, conf_cleanup_shared, NULL);
2398 add_conf_item("shared", "oper", CF_QSTRING|CF_FLIST,
2399 conf_set_shared_oper);
2400 add_conf_item("shared", "flags", CF_STRING | CF_FLIST,
2401 conf_set_shared_flags);
2403 add_top_conf("connect", conf_begin_connect, conf_end_connect,
2404 conf_connect_table);
2406 add_top_conf("exempt", NULL, NULL, NULL);
2407 add_conf_item("exempt", "ip", CF_QSTRING, conf_set_exempt_ip);
2409 add_top_conf("cluster", conf_cleanup_cluster, conf_cleanup_cluster, NULL);
2410 add_conf_item("cluster", "name", CF_QSTRING, conf_set_cluster_name);
2411 add_conf_item("cluster", "flags", CF_STRING | CF_FLIST,
2412 conf_set_cluster_flags);
2414 add_top_conf("general", NULL, NULL, conf_general_table);
2415 add_top_conf("channel", NULL, NULL, conf_channel_table);
2416 add_top_conf("serverhide", NULL, NULL, conf_serverhide_table);
2418 add_top_conf("service", conf_begin_service, NULL, NULL);
2419 add_conf_item("service", "name", CF_QSTRING, conf_set_service_name);
2421 add_top_conf("alias", conf_begin_alias, conf_end_alias, NULL);
2422 add_conf_item("alias", "name", CF_QSTRING, conf_set_alias_name);
2423 add_conf_item("alias", "target", CF_QSTRING, conf_set_alias_target);
2425 add_top_conf("blacklist", NULL, NULL, NULL);
2426 add_conf_item("blacklist", "host", CF_QSTRING, conf_set_blacklist_host);
2427 add_conf_item("blacklist", "reject_reason", CF_QSTRING,
2428 conf_set_blacklist_reason);
2432 * vim: ts=8 sw=8 noet fdm=marker tw=80