Initial import
[ratbox-ambernet.git] / src / newconf.c
blobb8bedffbbca07d630143f399ac25e4534cf218bf
1 /* This code is in the public domain.
2 * $Id: newconf.c 23955 2007-05-14 17:22:36Z leeh $
3 */
5 #include "stdinc.h"
7 #ifdef HAVE_LIBCRYPTO
8 #include <openssl/pem.h>
9 #include <openssl/rsa.h>
10 #endif
12 #include "memory.h"
13 #include "newconf.h"
14 #include "tools.h"
15 #include "ircd_defs.h"
16 #include "sprintf_irc.h"
17 #include "common.h"
18 #include "s_log.h"
19 #include "s_conf.h"
20 #include "s_user.h"
21 #include "s_newconf.h"
22 #include "send.h"
23 #include "setup.h"
24 #include "modules.h"
25 #include "listener.h"
26 #include "hostmask.h"
27 #include "s_serv.h"
28 #include "event.h"
29 #include "hash.h"
30 #include "cache.h"
31 #include "ircd.h"
33 #define CF_TYPE(x) ((x) & CF_MTYPE)
35 struct TopConf *conf_cur_block;
36 static char *conf_cur_block_name;
38 static dlink_list conf_items;
40 static struct ConfItem *yy_aconf = NULL;
41 static char *yy_aconf_class;
43 static struct Class *yy_class = NULL;
45 static struct remote_conf *yy_shared = NULL;
46 static struct server_conf *yy_server = NULL;
48 static dlink_list yy_aconf_list;
49 static dlink_list yy_oper_list;
50 static dlink_list yy_shared_list;
51 static dlink_list yy_cluster_list;
52 static struct oper_conf *yy_oper = NULL;
54 static const char *
55 conf_strtype(int type)
57 switch (type & CF_MTYPE)
59 case CF_INT:
60 return "integer value";
61 case CF_STRING:
62 return "unquoted string";
63 case CF_YESNO:
64 return "yes/no value";
65 case CF_QSTRING:
66 return "quoted string";
67 case CF_TIME:
68 return "time/size value";
69 default:
70 return "unknown type";
74 static int
75 add_top_conf(const char *name, int (*sfunc) (struct TopConf *),
76 int (*efunc) (struct TopConf *), struct ConfEntry *items)
78 struct TopConf *tc;
80 tc = MyMalloc(sizeof(struct TopConf));
82 DupString(tc->tc_name, name);
83 tc->tc_sfunc = sfunc;
84 tc->tc_efunc = efunc;
85 tc->tc_entries = items;
87 dlinkAddAlloc(tc, &conf_items);
88 return 0;
91 static struct TopConf *
92 find_top_conf(const char *name)
94 dlink_node *d;
95 struct TopConf *tc;
97 DLINK_FOREACH(d, conf_items.head)
99 tc = d->data;
100 if(strcasecmp(tc->tc_name, name) == 0)
101 return tc;
104 return NULL;
108 static struct ConfEntry *
109 find_conf_item(const struct TopConf *top, const char *name)
111 struct ConfEntry *cf;
112 dlink_node *d;
114 if(top->tc_entries)
116 int i;
118 for(i = 0; top->tc_entries[i].cf_type; i++)
120 cf = &top->tc_entries[i];
122 if(!strcasecmp(cf->cf_name, name))
123 return cf;
127 DLINK_FOREACH(d, top->tc_items.head)
129 cf = d->data;
130 if(strcasecmp(cf->cf_name, name) == 0)
131 return cf;
134 return NULL;
137 #if 0 /* XXX unused */
138 static int
139 remove_top_conf(char *name)
141 struct TopConf *tc;
142 dlink_node *ptr;
144 if((tc = find_top_conf(name)) == NULL)
145 return -1;
147 if((ptr = dlinkFind(tc, &conf_items)) == NULL)
148 return -1;
150 dlinkDestroy(ptr, &conf_items);
151 MyFree(tc->tc_name);
152 MyFree(tc);
154 return 0;
156 #endif
158 static void
159 conf_set_serverinfo_name(void *data)
161 if(ServerInfo.name == NULL)
163 const char *s;
164 int dots = 0;
166 for(s = data; *s != '\0'; s++)
168 if(!IsServChar(*s))
170 conf_report_error("Ignoring serverinfo::name "
171 "-- bogus servername.");
172 return;
174 else if(*s == '.')
175 ++dots;
178 if(!dots)
180 conf_report_error("Ignoring serverinfo::name -- must contain '.'");
181 return;
184 s = data;
186 if(IsDigit(*s))
188 conf_report_error("Ignoring serverinfo::name -- cannot begin with digit.");
189 return;
192 /* the ircd will exit() in main() if we dont set one */
193 if(strlen(s) <= HOSTLEN)
194 DupString(ServerInfo.name, (char *) data);
198 static void
199 conf_set_serverinfo_sid(void *data)
201 char *sid = data;
203 if(ServerInfo.sid[0] == '\0')
205 if(!IsDigit(sid[0]) || !IsIdChar(sid[1]) ||
206 !IsIdChar(sid[2]) || sid[3] != '\0')
208 conf_report_error("Ignoring serverinfo::sid "
209 "-- bogus sid.");
210 return;
213 strcpy(ServerInfo.sid, sid);
217 static void
218 conf_set_serverinfo_network_name(void *data)
220 char *p;
222 if((p = strchr((char *) data, ' ')))
223 *p = '\0';
225 MyFree(ServerInfo.network_name);
226 DupString(ServerInfo.network_name, (char *) data);
229 static void
230 conf_set_serverinfo_vhost(void *data)
232 if(inetpton(AF_INET, (char *) data, &ServerInfo.ip.sin_addr) <= 0)
234 conf_report_error("Invalid netmask for server IPv4 vhost (%s)", (char *) data);
235 return;
237 ServerInfo.ip.sin_family = AF_INET;
238 ServerInfo.specific_ipv4_vhost = 1;
241 static void
242 conf_set_serverinfo_vhost6(void *data)
244 #ifdef IPV6
245 if(inetpton(AF_INET6, (char *) data, &ServerInfo.ip6.sin6_addr) <= 0)
247 conf_report_error("Invalid netmask for server IPv6 vhost (%s)", (char *) data);
248 return;
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
258 static void
259 conf_set_modules_module(void *data)
261 #ifndef STATIC_MODULES
262 char *m_bn;
264 m_bn = irc_basename((char *) data);
266 if(findmodule_byname(m_bn) != -1)
267 return;
269 load_one_module((char *) data, 0);
271 MyFree(m_bn);
272 #else
273 conf_report_error("Ignoring modules::module -- loadable module support not present.");
274 #endif
277 static void
278 conf_set_modules_path(void *data)
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
287 struct mode_table
289 const char *name;
290 int mode;
293 /* *INDENT-OFF* */
294 static struct mode_table umode_table[] = {
295 {"bots", UMODE_BOTS },
296 {"cconn", UMODE_CCONN },
297 {"cconnext", UMODE_CCONNEXT },
298 {"debug", UMODE_DEBUG },
299 {"full", UMODE_FULL },
300 {"callerid", UMODE_CALLERID },
301 {"invisible", UMODE_INVISIBLE },
302 {"idlehide", UMODE_IDLEHIDE },
303 {"skill", UMODE_SKILL },
304 {"locops", UMODE_LOCOPS },
305 {"nchange", UMODE_NCHANGE },
306 {"rej", UMODE_REJ },
307 {"servnotice", UMODE_SERVNOTICE},
308 {"unauth", UMODE_UNAUTH },
309 {"wallop", UMODE_WALLOP },
310 {"external", UMODE_EXTERNAL },
311 {"spy", UMODE_SPY },
312 {"operwall", UMODE_OPERWALL },
313 {"operspy", UMODE_OPERSPY },
314 {NULL, 0}
317 static struct mode_table flag_table[] = {
318 {"encrypted", OPER_ENCRYPTED },
319 {"local_kill", OPER_LOCKILL },
320 {"global_kill", OPER_GLOBKILL|OPER_LOCKILL },
321 {"remote", OPER_REMOTE },
322 {"kline", OPER_KLINE },
323 {"unkline", OPER_UNKLINE },
324 {"gline", OPER_GLINE },
325 {"nick_changes", OPER_NICKS },
326 {"rehash", OPER_REHASH },
327 {"die", OPER_DIE },
328 {"admin", OPER_ADMIN },
329 {"hidden_admin", OPER_HADMIN },
330 {"xline", OPER_XLINE },
331 {"operwall", OPER_OPERWALL },
332 {"oper_spy", OPER_SPY },
333 {"hidden_oper", OPER_INVIS },
334 {"remoteban", OPER_REMOTEBAN },
335 {NULL, 0}
338 static struct mode_table auth_table[] = {
339 {"encrypted", CONF_FLAGS_ENCRYPTED },
340 {"spoof_notice", CONF_FLAGS_SPOOF_NOTICE },
341 {"exceed_limit", CONF_FLAGS_NOLIMIT },
342 {"kline_exempt", CONF_FLAGS_EXEMPTKLINE },
343 {"gline_exempt", CONF_FLAGS_EXEMPTGLINE },
344 {"flood_exempt", CONF_FLAGS_EXEMPTFLOOD },
345 {"spambot_exempt", CONF_FLAGS_EXEMPTSPAMBOT },
346 {"shide_exempt", CONF_FLAGS_EXEMPTSHIDE },
347 {"jupe_exempt", CONF_FLAGS_EXEMPTJUPE },
348 {"resv_exempt", CONF_FLAGS_EXEMPTRESV },
349 {"no_tilde", CONF_FLAGS_NO_TILDE },
350 {"need_ident", CONF_FLAGS_NEED_IDENTD },
351 {"have_ident", CONF_FLAGS_NEED_IDENTD },
352 {NULL, 0}
355 static struct mode_table connect_table[] = {
356 { "autoconn", SERVER_AUTOCONN },
357 { "compressed", SERVER_COMPRESSED },
358 { "encrypted", SERVER_ENCRYPTED },
359 { "topicburst", SERVER_TB },
360 { NULL, 0 },
363 static struct mode_table cluster_table[] = {
364 { "kline", SHARED_PKLINE },
365 { "tkline", SHARED_TKLINE },
366 { "unkline", SHARED_UNKLINE },
367 { "locops", SHARED_LOCOPS },
368 { "xline", SHARED_PXLINE },
369 { "txline", SHARED_TXLINE },
370 { "unxline", SHARED_UNXLINE },
371 { "resv", SHARED_PRESV },
372 { "tresv", SHARED_TRESV },
373 { "unresv", SHARED_UNRESV },
374 { "all", CLUSTER_ALL },
375 {NULL, 0}
378 static struct mode_table shared_table[] =
380 { "kline", SHARED_PKLINE|SHARED_TKLINE },
381 { "xline", SHARED_PXLINE|SHARED_TXLINE },
382 { "resv", SHARED_PRESV|SHARED_TRESV },
383 { "tkline", SHARED_TKLINE },
384 { "unkline", SHARED_UNKLINE },
385 { "txline", SHARED_TXLINE },
386 { "unxline", SHARED_UNXLINE },
387 { "tresv", SHARED_TRESV },
388 { "unresv", SHARED_UNRESV },
389 { "locops", SHARED_LOCOPS },
390 { "all", SHARED_ALL },
391 { "none", 0 },
392 {NULL, 0}
394 /* *INDENT-ON* */
396 static int
397 find_umode(struct mode_table *tab, const char *name)
399 int i;
401 for (i = 0; tab[i].name; i++)
403 if(strcmp(tab[i].name, name) == 0)
404 return tab[i].mode;
407 return -1;
410 static void
411 set_modes_from_table(int *modes, const char *whatis, struct mode_table *tab, conf_parm_t * args)
413 for (; args; args = args->next)
415 const char *umode;
416 int dir = 1;
417 int mode;
419 if((args->type & CF_MTYPE) != CF_STRING)
421 conf_report_error("Warning -- %s is not a string; ignoring.", whatis);
422 continue;
425 umode = args->v.string;
427 if(*umode == '~')
429 dir = 0;
430 umode++;
433 mode = find_umode(tab, umode);
435 if(mode == -1)
437 conf_report_error("Warning -- unknown %s %s.", whatis, args->v.string);
438 continue;
441 if(mode)
443 if(dir)
444 *modes |= mode;
445 else
446 *modes &= ~mode;
448 else
449 *modes = 0;
453 static int
454 conf_begin_oper(struct TopConf *tc)
456 dlink_node *ptr;
457 dlink_node *next_ptr;
459 if(yy_oper != NULL)
461 free_oper_conf(yy_oper);
462 yy_oper = NULL;
465 DLINK_FOREACH_SAFE(ptr, next_ptr, yy_oper_list.head)
467 free_oper_conf(ptr->data);
468 dlinkDestroy(ptr, &yy_oper_list);
471 yy_oper = make_oper_conf();
472 yy_oper->flags |= OPER_ENCRYPTED|OPER_OPERWALL|OPER_REMOTEBAN;
474 return 0;
477 static int
478 conf_end_oper(struct TopConf *tc)
480 struct oper_conf *yy_tmpoper;
481 dlink_node *ptr;
482 dlink_node *next_ptr;
484 if(conf_cur_block_name != NULL)
486 if(strlen(conf_cur_block_name) > OPERNICKLEN)
487 conf_cur_block_name[OPERNICKLEN] = '\0';
489 DupString(yy_oper->name, conf_cur_block_name);
492 if(EmptyString(yy_oper->name))
494 conf_report_error("Ignoring operator block -- missing name.");
495 return 0;
498 #ifdef HAVE_LIBCRYPTO
499 if(EmptyString(yy_oper->passwd) && EmptyString(yy_oper->rsa_pubkey_file))
500 #else
501 if(EmptyString(yy_oper->passwd))
502 #endif
504 conf_report_error("Ignoring operator block for %s -- missing password",
505 yy_oper->name);
506 return 0;
509 /* now, yy_oper_list contains a stack of oper_conf's with just user
510 * and host in, yy_oper contains the rest of the information which
511 * we need to copy into each element in yy_oper_list
513 DLINK_FOREACH_SAFE(ptr, next_ptr, yy_oper_list.head)
515 yy_tmpoper = ptr->data;
517 DupString(yy_tmpoper->name, yy_oper->name);
519 /* could be an rsa key instead.. */
520 if(!EmptyString(yy_oper->passwd))
521 DupString(yy_tmpoper->passwd, yy_oper->passwd);
523 yy_tmpoper->flags = yy_oper->flags;
524 yy_tmpoper->umodes = yy_oper->umodes;
526 #ifdef HAVE_LIBCRYPTO
527 if(yy_oper->rsa_pubkey_file)
529 BIO *file;
531 if((file = BIO_new_file(yy_oper->rsa_pubkey_file, "r")) == NULL)
533 conf_report_error("Ignoring operator block for %s -- "
534 "rsa_public_key_file cant be opened",
535 yy_tmpoper->name);
536 return 0;
539 yy_tmpoper->rsa_pubkey =
540 (RSA *) PEM_read_bio_RSA_PUBKEY(file, NULL, 0, NULL);
542 BIO_set_close(file, BIO_CLOSE);
543 BIO_free(file);
545 if(yy_tmpoper->rsa_pubkey == NULL)
547 conf_report_error("Ignoring operator block for %s -- "
548 "rsa_public_key_file key invalid; check syntax",
549 yy_tmpoper->name);
550 return 0;
553 #endif
555 /* all is ok, put it on oper_conf_list */
556 dlinkMoveNode(ptr, &yy_oper_list, &oper_conf_list);
559 free_oper_conf(yy_oper);
560 yy_oper = NULL;
562 return 0;
565 static void
566 conf_set_oper_flags(void *data)
568 conf_parm_t *args = data;
570 set_modes_from_table(&yy_oper->flags, "flag", flag_table, args);
573 static void
574 conf_set_oper_user(void *data)
576 struct oper_conf *yy_tmpoper;
577 char *p;
578 char *host = (char *) data;
580 yy_tmpoper = make_oper_conf();
582 if((p = strchr(host, '@')))
584 *p++ = '\0';
586 DupString(yy_tmpoper->username, host);
587 DupString(yy_tmpoper->host, p);
589 else
592 DupString(yy_tmpoper->username, "*");
593 DupString(yy_tmpoper->host, host);
596 if(EmptyString(yy_tmpoper->username) || EmptyString(yy_tmpoper->host))
598 conf_report_error("Ignoring user -- missing username/host");
599 free_oper_conf(yy_tmpoper);
600 return;
603 dlinkAddAlloc(yy_tmpoper, &yy_oper_list);
606 static void
607 conf_set_oper_password(void *data)
609 if(yy_oper->passwd)
611 memset(yy_oper->passwd, 0, strlen(yy_oper->passwd));
612 MyFree(yy_oper->passwd);
615 DupString(yy_oper->passwd, (char *) data);
618 static void
619 conf_set_oper_rsa_public_key_file(void *data)
621 #ifdef HAVE_LIBCRYPTO
622 MyFree(yy_oper->rsa_pubkey_file);
623 DupString(yy_oper->rsa_pubkey_file, (char *) data);
624 #else
625 conf_report_error("Warning -- ignoring rsa_public_key_file (OpenSSL support not available");
626 #endif
629 static void
630 conf_set_oper_umodes(void *data)
632 set_modes_from_table(&yy_oper->umodes, "umode", umode_table, data);
635 static int
636 conf_begin_class(struct TopConf *tc)
638 if(yy_class)
639 free_class(yy_class);
641 yy_class = make_class();
642 return 0;
645 static int
646 conf_end_class(struct TopConf *tc)
648 if(conf_cur_block_name != NULL)
649 DupString(yy_class->class_name, conf_cur_block_name);
651 if(EmptyString(yy_class->class_name))
653 conf_report_error("Ignoring connect block -- missing name.");
654 return 0;
657 add_class(yy_class);
658 yy_class = NULL;
659 return 0;
662 static void
663 conf_set_class_ping_time(void *data)
665 yy_class->ping_freq = *(unsigned int *) data;
668 static void
669 conf_set_class_cidr_bitlen(void *data)
671 #ifdef IPV6
672 unsigned int maxsize = 128;
673 #else
674 unsigned int maxsize = 32;
675 #endif
676 if(*(unsigned int *) data > maxsize)
677 conf_report_error
678 ("class::cidr_bitlen argument exceeds maxsize (%d > %d) - ignoring.",
679 *(unsigned int *) data, maxsize);
680 else
681 yy_class->cidr_bitlen = *(unsigned int *) data;
684 static void
685 conf_set_class_number_per_cidr(void *data)
687 yy_class->cidr_amount = *(unsigned int *) data;
690 static void
691 conf_set_class_number_per_ip(void *data)
693 yy_class->max_local = *(unsigned int *) data;
697 static void
698 conf_set_class_number_per_ip_global(void *data)
700 yy_class->max_global = *(unsigned int *) data;
703 static void
704 conf_set_class_number_per_ident(void *data)
706 yy_class->max_ident = *(unsigned int *) data;
709 static void
710 conf_set_class_connectfreq(void *data)
712 yy_class->con_freq = *(unsigned int *) data;
715 static void
716 conf_set_class_max_number(void *data)
718 yy_class->max_total = *(unsigned int *) data;
721 static void
722 conf_set_class_sendq(void *data)
724 yy_class->max_sendq = *(unsigned int *) data;
727 static char *listener_address;
729 static int
730 conf_begin_listen(struct TopConf *tc)
732 MyFree(listener_address);
733 listener_address = NULL;
734 return 0;
737 static int
738 conf_end_listen(struct TopConf *tc)
740 MyFree(listener_address);
741 listener_address = NULL;
742 return 0;
745 static void
746 conf_set_listen_port(void *data)
748 conf_parm_t *args = data;
749 for (; args; args = args->next)
751 if((args->type & CF_MTYPE) != CF_INT)
753 conf_report_error
754 ("listener::port argument is not an integer " "-- ignoring.");
755 continue;
757 if(listener_address == NULL)
759 add_listener(args->v.number, listener_address, AF_INET);
760 #ifdef IPV6
761 add_listener(args->v.number, listener_address, AF_INET6);
762 #endif
764 else
766 int family;
767 #ifdef IPV6
768 if(strchr(listener_address, ':') != NULL)
769 family = AF_INET6;
770 else
771 #endif
772 family = AF_INET;
774 add_listener(args->v.number, listener_address, family);
781 static void
782 conf_set_listen_address(void *data)
784 MyFree(listener_address);
785 DupString(listener_address, data);
788 static int
789 conf_begin_auth(struct TopConf *tc)
791 dlink_node *ptr;
792 dlink_node *next_ptr;
794 if(yy_aconf)
795 free_conf(yy_aconf);
797 MyFree(yy_aconf_class);
798 yy_aconf_class = NULL;
800 DLINK_FOREACH_SAFE(ptr, next_ptr, yy_aconf_list.head)
802 free_conf(ptr->data);
803 dlinkDestroy(ptr, &yy_aconf_list);
806 yy_aconf = make_conf();
807 yy_aconf->status = CONF_CLIENT;
809 return 0;
812 static int
813 conf_end_auth(struct TopConf *tc)
815 struct ConfItem *yy_tmp;
816 dlink_node *ptr;
817 dlink_node *next_ptr;
819 if(EmptyString(yy_aconf->name))
820 DupString(yy_aconf->name, "NOMATCH");
822 /* didnt even get one ->host? */
823 if(EmptyString(yy_aconf->host))
825 conf_report_error("Ignoring auth block -- missing user@host");
826 return 0;
829 /* so the stacking works in order.. */
830 collapse(yy_aconf->user);
831 collapse(yy_aconf->host);
832 conf_add_class_to_conf(yy_aconf, yy_aconf_class);
833 add_conf_by_address(yy_aconf->host, CONF_CLIENT, yy_aconf->user, yy_aconf);
835 DLINK_FOREACH_SAFE(ptr, next_ptr, yy_aconf_list.head)
837 yy_tmp = ptr->data;
839 if(yy_aconf->passwd)
840 DupString(yy_tmp->passwd, yy_aconf->passwd);
842 /* this will always exist.. */
843 DupString(yy_tmp->name, yy_aconf->name);
845 yy_tmp->flags = yy_aconf->flags;
846 yy_tmp->port = yy_aconf->port;
848 collapse(yy_tmp->user);
849 collapse(yy_tmp->host);
851 conf_add_class_to_conf(yy_tmp, yy_aconf_class);
853 add_conf_by_address(yy_tmp->host, CONF_CLIENT, yy_tmp->user, yy_tmp);
854 dlinkDestroy(ptr, &yy_aconf_list);
857 MyFree(yy_aconf_class);
858 yy_aconf = NULL;
859 yy_aconf_class = NULL;
861 return 0;
864 static void
865 conf_set_auth_user(void *data)
867 struct ConfItem *yy_tmp;
868 char *p;
870 /* The first user= line doesn't allocate a new conf */
871 if(!EmptyString(yy_aconf->host))
873 yy_tmp = make_conf();
874 yy_tmp->status = CONF_CLIENT;
876 else
877 yy_tmp = yy_aconf;
879 if((p = strchr(data, '@')))
881 *p++ = '\0';
883 DupString(yy_tmp->user, data);
884 DupString(yy_tmp->host, p);
886 else
888 DupString(yy_tmp->user, "*");
889 DupString(yy_tmp->host, data);
892 if(yy_aconf != yy_tmp)
893 dlinkAddAlloc(yy_tmp, &yy_aconf_list);
896 static void
897 conf_set_auth_passwd(void *data)
899 if(yy_aconf->passwd)
900 memset(yy_aconf->passwd, 0, strlen(yy_aconf->passwd));
901 MyFree(yy_aconf->passwd);
902 DupString(yy_aconf->passwd, data);
905 static void
906 conf_set_auth_spoof(void *data)
908 char *p;
909 char *user = NULL;
910 char *host = NULL;
912 host = data;
914 /* user@host spoof */
915 if((p = strchr(host, '@')) != NULL)
917 *p = '\0';
918 user = data;
919 host = p+1;
921 if(EmptyString(user))
923 conf_report_error("Warning -- spoof ident empty.");
924 return;
927 if(strlen(user) > USERLEN)
929 conf_report_error("Warning -- spoof ident length invalid.");
930 return;
933 if(!valid_username(user))
935 conf_report_error("Warning -- invalid spoof (ident).");
936 return;
939 /* this must be restored! */
940 *p = '@';
943 if(EmptyString(host))
945 conf_report_error("Warning -- spoof host empty.");
946 return;
949 if(strlen(host) > HOSTLEN)
951 conf_report_error("Warning -- spoof host length invalid.");
952 return;
955 if(!valid_hostname(host))
957 conf_report_error("Warning -- invalid spoof (host).");
958 return;
961 MyFree(yy_aconf->name);
962 DupString(yy_aconf->name, data);
963 yy_aconf->flags |= CONF_FLAGS_SPOOF_IP;
966 static void
967 conf_set_auth_flags(void *data)
969 conf_parm_t *args = data;
971 set_modes_from_table((int *) &yy_aconf->flags, "flag", auth_table, args);
974 static void
975 conf_set_auth_redir_serv(void *data)
977 yy_aconf->flags |= CONF_FLAGS_REDIR;
978 MyFree(yy_aconf->name);
979 DupString(yy_aconf->name, data);
982 static void
983 conf_set_auth_redir_port(void *data)
985 int port = *(unsigned int *) data;
987 yy_aconf->flags |= CONF_FLAGS_REDIR;
988 yy_aconf->port = port;
991 static void
992 conf_set_auth_class(void *data)
994 MyFree(yy_aconf_class);
995 DupString(yy_aconf_class, data);
998 /* ok, shared_oper handles the stacking, shared_flags handles adding
999 * things.. so all we need to do when we start and end a shared block, is
1000 * clean up anything thats been left over.
1002 static int
1003 conf_cleanup_shared(struct TopConf *tc)
1005 dlink_node *ptr, *next_ptr;
1007 DLINK_FOREACH_SAFE(ptr, next_ptr, yy_shared_list.head)
1009 free_remote_conf(ptr->data);
1010 dlinkDestroy(ptr, &yy_shared_list);
1013 if(yy_shared != NULL)
1015 free_remote_conf(yy_shared);
1016 yy_shared = NULL;
1019 return 0;
1022 static void
1023 conf_set_shared_oper(void *data)
1025 conf_parm_t *args = data;
1026 const char *username;
1027 char *p;
1029 if(yy_shared != NULL)
1030 free_remote_conf(yy_shared);
1032 yy_shared = make_remote_conf();
1034 if(args->next != NULL)
1036 if((args->type & CF_MTYPE) != CF_QSTRING)
1038 conf_report_error("Ignoring shared::oper -- server is not a qstring");
1039 return;
1042 DupString(yy_shared->server, args->v.string);
1043 args = args->next;
1045 else
1046 DupString(yy_shared->server, "*");
1048 if((args->type & CF_MTYPE) != CF_QSTRING)
1050 conf_report_error("Ignoring shared::oper -- oper is not a qstring");
1051 return;
1054 if((p = strchr(args->v.string, '@')) == NULL)
1056 conf_report_error("Ignoring shard::oper -- oper is not a user@host");
1057 return;
1060 username = args->v.string;
1061 *p++ = '\0';
1063 if(EmptyString(p))
1064 DupString(yy_shared->host, "*");
1065 else
1066 DupString(yy_shared->host, p);
1068 if(EmptyString(username))
1069 DupString(yy_shared->username, "*");
1070 else
1071 DupString(yy_shared->username, username);
1073 dlinkAddAlloc(yy_shared, &yy_shared_list);
1074 yy_shared = NULL;
1077 static void
1078 conf_set_shared_flags(void *data)
1080 conf_parm_t *args = data;
1081 int flags = 0;
1082 dlink_node *ptr, *next_ptr;
1084 if(yy_shared != NULL)
1085 free_remote_conf(yy_shared);
1087 set_modes_from_table(&flags, "flag", shared_table, args);
1089 DLINK_FOREACH_SAFE(ptr, next_ptr, yy_shared_list.head)
1091 yy_shared = ptr->data;
1093 yy_shared->flags = flags;
1094 dlinkDestroy(ptr, &yy_shared_list);
1095 dlinkAddTail(yy_shared, &yy_shared->node, &shared_conf_list);
1098 yy_shared = NULL;
1101 static int
1102 conf_begin_connect(struct TopConf *tc)
1104 if(yy_server)
1105 free_server_conf(yy_server);
1107 yy_server = make_server_conf();
1108 yy_server->port = PORTNUM;
1110 if(conf_cur_block_name != NULL)
1111 DupString(yy_server->name, conf_cur_block_name);
1113 return 0;
1116 static int
1117 conf_end_connect(struct TopConf *tc)
1119 if(EmptyString(yy_server->name))
1121 conf_report_error("Ignoring connect block -- missing name.");
1122 return 0;
1125 if(EmptyString(yy_server->passwd) || EmptyString(yy_server->spasswd))
1127 conf_report_error("Ignoring connect block for %s -- missing password.",
1128 yy_server->name);
1129 return 0;
1132 if(EmptyString(yy_server->host))
1134 conf_report_error("Ignoring connect block for %s -- missing host.",
1135 yy_server->name);
1136 return 0;
1139 #ifndef HAVE_LIBZ
1140 if(ServerConfCompressed(yy_server))
1142 conf_report_error("Ignoring connect::flags::compressed -- zlib not available.");
1143 yy_server->flags &= ~SERVER_COMPRESSED;
1145 #endif
1147 add_server_conf(yy_server);
1148 dlinkAdd(yy_server, &yy_server->node, &server_conf_list);
1150 yy_server = NULL;
1151 return 0;
1154 static void
1155 conf_set_connect_host(void *data)
1157 MyFree(yy_server->host);
1158 DupString(yy_server->host, data);
1161 static void
1162 conf_set_connect_vhost(void *data)
1164 if(inetpton_sock(data, (struct sockaddr *)&yy_server->my_ipnum) <= 0)
1166 conf_report_error("Invalid netmask for server vhost (%s)",
1167 (char *) data);
1168 return;
1171 yy_server->flags |= SERVER_VHOSTED;
1174 static void
1175 conf_set_connect_send_password(void *data)
1177 if(yy_server->spasswd)
1179 memset(yy_server->spasswd, 0, strlen(yy_server->spasswd));
1180 MyFree(yy_server->spasswd);
1183 DupString(yy_server->spasswd, data);
1186 static void
1187 conf_set_connect_accept_password(void *data)
1189 if(yy_server->passwd)
1191 memset(yy_server->passwd, 0, strlen(yy_server->passwd));
1192 MyFree(yy_server->passwd);
1194 DupString(yy_server->passwd, data);
1197 static void
1198 conf_set_connect_port(void *data)
1200 int port = *(unsigned int *) data;
1202 if(port < 1)
1203 port = PORTNUM;
1205 yy_server->port = port;
1208 static void
1209 conf_set_connect_aftype(void *data)
1211 char *aft = data;
1213 if(strcasecmp(aft, "ipv4") == 0)
1214 yy_server->ipnum.ss_family = AF_INET;
1215 #ifdef IPV6
1216 else if(strcasecmp(aft, "ipv6") == 0)
1217 yy_server->ipnum.ss_family = AF_INET6;
1218 #endif
1219 else
1220 conf_report_error("connect::aftype '%s' is unknown.", aft);
1223 static void
1224 conf_set_connect_flags(void *data)
1226 conf_parm_t *args = data;
1228 /* note, we allow them to set compressed, then remove it later if
1229 * they do and LIBZ isnt available
1231 set_modes_from_table(&yy_server->flags, "flag", connect_table, args);
1234 static void
1235 conf_set_connect_hub_mask(void *data)
1237 struct remote_conf *yy_hub;
1239 if(EmptyString(yy_server->name))
1240 return;
1242 yy_hub = make_remote_conf();
1243 yy_hub->flags = CONF_HUB;
1245 DupString(yy_hub->host, data);
1246 DupString(yy_hub->server, yy_server->name);
1247 dlinkAdd(yy_hub, &yy_hub->node, &hubleaf_conf_list);
1250 static void
1251 conf_set_connect_leaf_mask(void *data)
1253 struct remote_conf *yy_leaf;
1255 if(EmptyString(yy_server->name))
1256 return;
1258 yy_leaf = make_remote_conf();
1259 yy_leaf->flags = CONF_LEAF;
1261 DupString(yy_leaf->host, data);
1262 DupString(yy_leaf->server, yy_server->name);
1263 dlinkAdd(yy_leaf, &yy_leaf->node, &hubleaf_conf_list);
1266 static void
1267 conf_set_connect_class(void *data)
1269 MyFree(yy_server->class_name);
1270 DupString(yy_server->class_name, data);
1273 static void
1274 conf_set_exempt_ip(void *data)
1276 struct ConfItem *yy_tmp;
1278 if(parse_netmask(data, NULL, NULL) == HM_HOST)
1280 conf_report_error("Ignoring exempt -- invalid exempt::ip.");
1281 return;
1284 yy_tmp = make_conf();
1285 DupString(yy_tmp->passwd, "*");
1286 DupString(yy_tmp->host, data);
1287 yy_tmp->status = CONF_EXEMPTDLINE;
1288 add_conf_by_address(yy_tmp->host, CONF_EXEMPTDLINE, NULL, yy_tmp);
1291 static int
1292 conf_cleanup_cluster(struct TopConf *tc)
1294 dlink_node *ptr, *next_ptr;
1296 DLINK_FOREACH_SAFE(ptr, next_ptr, yy_cluster_list.head)
1298 free_remote_conf(ptr->data);
1299 dlinkDestroy(ptr, &yy_cluster_list);
1302 if(yy_shared != NULL)
1304 free_remote_conf(yy_shared);
1305 yy_shared = NULL;
1308 return 0;
1311 static void
1312 conf_set_cluster_name(void *data)
1314 if(yy_shared != NULL)
1315 free_remote_conf(yy_shared);
1317 yy_shared = make_remote_conf();
1318 DupString(yy_shared->server, data);
1319 dlinkAddAlloc(yy_shared, &yy_cluster_list);
1321 yy_shared = NULL;
1324 static void
1325 conf_set_cluster_flags(void *data)
1327 conf_parm_t *args = data;
1328 int flags = 0;
1329 dlink_node *ptr, *next_ptr;
1331 if(yy_shared != NULL)
1332 free_remote_conf(yy_shared);
1334 set_modes_from_table(&flags, "flag", cluster_table, args);
1336 DLINK_FOREACH_SAFE(ptr, next_ptr, yy_cluster_list.head)
1338 yy_shared = ptr->data;
1339 yy_shared->flags = flags;
1340 dlinkAddTail(yy_shared, &yy_shared->node, &cluster_conf_list);
1341 dlinkDestroy(ptr, &yy_cluster_list);
1344 yy_shared = NULL;
1347 static void
1348 conf_set_general_havent_read_conf(void *data)
1350 if(*(unsigned int *) data)
1352 conf_report_error("You haven't read your config file properly.");
1353 conf_report_error
1354 ("There is a line in the example conf that will kill your server if not removed.");
1355 conf_report_error
1356 ("Consider actually reading/editing the conf file, and removing this line.");
1357 if (!testing_conf)
1358 exit(0);
1362 static void
1363 conf_set_general_hide_error_messages(void *data)
1365 char *val = data;
1367 if(strcasecmp(val, "yes") == 0)
1368 ConfigFileEntry.hide_error_messages = 2;
1369 else if(strcasecmp(val, "opers") == 0)
1370 ConfigFileEntry.hide_error_messages = 1;
1371 else if(strcasecmp(val, "no") == 0)
1372 ConfigFileEntry.hide_error_messages = 0;
1373 else
1374 conf_report_error("Invalid setting '%s' for general::hide_error_messages.", val);
1377 static void
1378 conf_set_general_kline_delay(void *data)
1380 ConfigFileEntry.kline_delay = *(unsigned int *) data;
1382 /* THIS MUST BE HERE to stop us being unable to check klines */
1383 kline_queued = 0;
1386 static void
1387 conf_set_general_stats_k_oper_only(void *data)
1389 char *val = data;
1391 if(strcasecmp(val, "yes") == 0)
1392 ConfigFileEntry.stats_k_oper_only = 2;
1393 else if(strcasecmp(val, "masked") == 0)
1394 ConfigFileEntry.stats_k_oper_only = 1;
1395 else if(strcasecmp(val, "no") == 0)
1396 ConfigFileEntry.stats_k_oper_only = 0;
1397 else
1398 conf_report_error("Invalid setting '%s' for general::stats_k_oper_only.", val);
1401 static void
1402 conf_set_general_stats_i_oper_only(void *data)
1404 char *val = data;
1406 if(strcasecmp(val, "yes") == 0)
1407 ConfigFileEntry.stats_i_oper_only = 2;
1408 else if(strcasecmp(val, "masked") == 0)
1409 ConfigFileEntry.stats_i_oper_only = 1;
1410 else if(strcasecmp(val, "no") == 0)
1411 ConfigFileEntry.stats_i_oper_only = 0;
1412 else
1413 conf_report_error("Invalid setting '%s' for general::stats_i_oper_only.", val);
1416 static void
1417 conf_set_general_compression_level(void *data)
1419 #ifdef HAVE_LIBZ
1420 ConfigFileEntry.compression_level = *(unsigned int *) data;
1422 if((ConfigFileEntry.compression_level < 1) || (ConfigFileEntry.compression_level > 9))
1424 conf_report_error
1425 ("Invalid general::compression_level %d -- using default.",
1426 ConfigFileEntry.compression_level);
1427 ConfigFileEntry.compression_level = 0;
1429 #else
1430 conf_report_error("Ignoring general::compression_level -- zlib not available.");
1431 #endif
1434 static void
1435 conf_set_general_oper_umodes(void *data)
1437 set_modes_from_table(&ConfigFileEntry.oper_umodes, "umode", umode_table, data);
1440 static void
1441 conf_set_general_oper_only_umodes(void *data)
1443 set_modes_from_table(&ConfigFileEntry.oper_only_umodes, "umode", umode_table, data);
1446 static void
1447 conf_set_serverhide_links_delay(void *data)
1449 int val = *(unsigned int *) data;
1451 if((val > 0) && ConfigServerHide.links_disabled == 1)
1453 eventAddIsh("cache_links", cache_links, NULL, val);
1454 ConfigServerHide.links_disabled = 0;
1456 else if(val != ConfigServerHide.links_delay)
1457 eventUpdate("cache_links", val);
1459 ConfigServerHide.links_delay = val;
1462 #ifdef ENABLE_SERVICES
1463 static int
1464 conf_begin_service(struct TopConf *tc)
1466 struct Client *target_p;
1467 dlink_node *ptr;
1469 DLINK_FOREACH(ptr, global_serv_list.head)
1471 target_p = ptr->data;
1473 target_p->flags &= ~FLAGS_SERVICE;
1476 return 0;
1479 static void
1480 conf_set_service_name(void *data)
1482 struct Client *target_p;
1483 const char *s;
1484 char *tmp;
1485 int dots = 0;
1487 for(s = data; *s != '\0'; s++)
1489 if(!IsServChar(*s))
1491 conf_report_error("Ignoring service::name "
1492 "-- bogus servername.");
1493 return;
1495 else if(*s == '.')
1496 dots++;
1499 if(!dots)
1501 conf_report_error("Ignoring service::name -- must contain '.'");
1502 return;
1505 DupString(tmp, data);
1506 dlinkAddAlloc(tmp, &service_list);
1508 if((target_p = find_server(NULL, tmp)))
1509 target_p->flags |= FLAGS_SERVICE;
1511 #endif
1513 /* public functions */
1516 void
1517 conf_report_error(const char *fmt, ...)
1519 va_list ap;
1520 char msg[IRCD_BUFSIZE + 1] = { 0 };
1522 va_start(ap, fmt);
1523 ircvsnprintf(msg, IRCD_BUFSIZE, fmt, ap);
1524 va_end(ap);
1526 if (testing_conf)
1528 conf_parse_failure++;
1529 fprintf(stderr, "\"%s\", line %d: %s\n", current_file, lineno + 1, msg);
1530 return;
1533 ilog(L_MAIN, "\"%s\", line %d: %s", current_file, lineno + 1, msg);
1534 sendto_realops_flags(UMODE_ALL, L_ALL, "\"%s\", line %d: %s", current_file, lineno + 1, msg);
1538 conf_start_block(char *block, char *name)
1540 if((conf_cur_block = find_top_conf(block)) == NULL)
1542 conf_report_error("Configuration block '%s' is not defined.", block);
1543 return -1;
1546 if(name)
1547 DupString(conf_cur_block_name, name);
1548 else
1549 conf_cur_block_name = NULL;
1551 if(conf_cur_block->tc_sfunc)
1552 if(conf_cur_block->tc_sfunc(conf_cur_block) < 0)
1553 return -1;
1555 return 0;
1559 conf_end_block(struct TopConf *tc)
1561 if(tc->tc_efunc)
1562 return tc->tc_efunc(tc);
1564 MyFree(conf_cur_block_name);
1565 return 0;
1568 static void
1569 conf_set_generic_int(void *data, void *location)
1571 *((int *) location) = *((unsigned int *) data);
1574 static void
1575 conf_set_generic_string(void *data, int len, void *location)
1577 char **loc = location;
1578 char *input = data;
1580 if(len && strlen(input) > len)
1581 input[len] = '\0';
1583 MyFree(*loc);
1584 DupString(*loc, input);
1588 conf_call_set(struct TopConf *tc, char *item, conf_parm_t * value, int type)
1590 struct ConfEntry *cf;
1591 conf_parm_t *cp;
1593 if(!tc)
1594 return -1;
1596 if((cf = find_conf_item(tc, item)) == NULL)
1598 conf_report_error
1599 ("Non-existant configuration setting %s::%s.", tc->tc_name, (char *) item);
1600 return -1;
1603 /* if it takes one thing, make sure they only passed one thing,
1604 and handle as needed. */
1605 if(value->type & CF_FLIST && !cf->cf_type & CF_FLIST)
1607 conf_report_error
1608 ("Option %s::%s does not take a list of values.", tc->tc_name, item);
1609 return -1;
1612 cp = value->v.list;
1615 if(CF_TYPE(value->v.list->type) != CF_TYPE(cf->cf_type))
1617 /* if it expects a string value, but we got a yesno,
1618 * convert it back
1620 if((CF_TYPE(value->v.list->type) == CF_YESNO) &&
1621 (CF_TYPE(cf->cf_type) == CF_STRING))
1623 value->v.list->type = CF_STRING;
1625 if(cp->v.number == 1)
1626 DupString(cp->v.string, "yes");
1627 else
1628 DupString(cp->v.string, "no");
1631 /* maybe it's a CF_TIME and they passed CF_INT --
1632 should still be valid */
1633 else if(!((CF_TYPE(value->v.list->type) == CF_INT) &&
1634 (CF_TYPE(cf->cf_type) == CF_TIME)))
1636 conf_report_error
1637 ("Wrong type for %s::%s (expected %s, got %s)",
1638 tc->tc_name, (char *) item,
1639 conf_strtype(cf->cf_type), conf_strtype(value->v.list->type));
1640 return -1;
1644 if(cf->cf_type & CF_FLIST)
1646 #if 0
1647 if(cf->cf_arg)
1648 conf_set_generic_list(value->v.list, cf->cf_arg);
1649 else
1650 #endif
1651 /* just pass it the extended argument list */
1652 cf->cf_func(value->v.list);
1654 else
1656 /* it's old-style, needs only one arg */
1657 switch (cf->cf_type)
1659 case CF_INT:
1660 case CF_TIME:
1661 case CF_YESNO:
1662 if(cf->cf_arg)
1663 conf_set_generic_int(&cp->v.number, cf->cf_arg);
1664 else
1665 cf->cf_func(&cp->v.number);
1666 break;
1667 case CF_STRING:
1668 case CF_QSTRING:
1669 if(EmptyString(cp->v.string))
1670 conf_report_error("Ignoring %s::%s -- empty field",
1671 tc->tc_name, item);
1672 else if(cf->cf_arg)
1673 conf_set_generic_string(cp->v.string, cf->cf_len, cf->cf_arg);
1674 else
1675 cf->cf_func(cp->v.string);
1676 break;
1681 return 0;
1685 add_conf_item(const char *topconf, const char *name, int type, void (*func) (void *))
1687 struct TopConf *tc;
1688 struct ConfEntry *cf;
1690 if((tc = find_top_conf(topconf)) == NULL)
1691 return -1;
1693 if((cf = find_conf_item(tc, name)) != NULL)
1694 return -1;
1696 cf = MyMalloc(sizeof(struct ConfEntry));
1698 DupString(cf->cf_name, name);
1699 cf->cf_type = type;
1700 cf->cf_func = func;
1701 cf->cf_arg = NULL;
1703 dlinkAddAlloc(cf, &tc->tc_items);
1705 return 0;
1708 #if 0
1710 remove_conf_item(const char *topconf, const char *name)
1712 struct TopConf *tc;
1713 struct ConfEntry *cf;
1714 dlink_node *ptr;
1716 if((tc = find_top_conf(topconf)) == NULL)
1717 return -1;
1719 if((cf = find_conf_item(tc, name)) == NULL)
1720 return -1;
1722 if((ptr = dlinkFind(cf, &tc->tc_items)) == NULL)
1723 return -1;
1725 dlinkDestroy(ptr, &tc->tc_items);
1726 MyFree(cf->cf_name);
1727 MyFree(cf);
1729 return 0;
1731 #endif
1733 /* *INDENT-OFF* */
1734 static struct ConfEntry conf_serverinfo_table[] =
1736 { "description", CF_QSTRING, NULL, 0, &ServerInfo.description },
1737 { "network_desc", CF_QSTRING, NULL, 0, &ServerInfo.network_desc },
1738 { "hub", CF_YESNO, NULL, 0, &ServerInfo.hub },
1739 { "use_ts6", CF_YESNO, NULL, 0, &ServerInfo.use_ts6 },
1740 { "default_max_clients",CF_INT, NULL, 0, &ServerInfo.default_max_clients },
1742 { "network_name", CF_QSTRING, conf_set_serverinfo_network_name, 0, NULL },
1743 { "name", CF_QSTRING, conf_set_serverinfo_name, 0, NULL },
1744 { "sid", CF_QSTRING, conf_set_serverinfo_sid, 0, NULL },
1745 { "vhost", CF_QSTRING, conf_set_serverinfo_vhost, 0, NULL },
1746 { "vhost6", CF_QSTRING, conf_set_serverinfo_vhost6, 0, NULL },
1748 { "\0", 0, NULL, 0, NULL }
1751 static struct ConfEntry conf_admin_table[] =
1753 { "name", CF_QSTRING, NULL, 200, &AdminInfo.name },
1754 { "description",CF_QSTRING, NULL, 200, &AdminInfo.description },
1755 { "email", CF_QSTRING, NULL, 200, &AdminInfo.email },
1756 { "\0", 0, NULL, 0, NULL }
1759 static struct ConfEntry conf_log_table[] =
1761 { "fname_userlog", CF_QSTRING, NULL, MAXPATHLEN, &ConfigFileEntry.fname_userlog },
1762 { "fname_fuserlog", CF_QSTRING, NULL, MAXPATHLEN, &ConfigFileEntry.fname_fuserlog },
1763 { "fname_operlog", CF_QSTRING, NULL, MAXPATHLEN, &ConfigFileEntry.fname_operlog },
1764 { "fname_foperlog", CF_QSTRING, NULL, MAXPATHLEN, &ConfigFileEntry.fname_foperlog },
1765 { "fname_serverlog", CF_QSTRING, NULL, MAXPATHLEN, &ConfigFileEntry.fname_serverlog },
1766 { "fname_killlog", CF_QSTRING, NULL, MAXPATHLEN, &ConfigFileEntry.fname_killlog },
1767 { "fname_glinelog", CF_QSTRING, NULL, MAXPATHLEN, &ConfigFileEntry.fname_glinelog },
1768 { "fname_klinelog", CF_QSTRING, NULL, MAXPATHLEN, &ConfigFileEntry.fname_klinelog },
1769 { "fname_operspylog", CF_QSTRING, NULL, MAXPATHLEN, &ConfigFileEntry.fname_operspylog },
1770 { "fname_ioerrorlog", CF_QSTRING, NULL, MAXPATHLEN, &ConfigFileEntry.fname_ioerrorlog },
1771 { "\0", 0, NULL, 0, NULL }
1774 static struct ConfEntry conf_operator_table[] =
1776 { "rsa_public_key_file", CF_QSTRING, conf_set_oper_rsa_public_key_file, 0, NULL },
1777 { "flags", CF_STRING | CF_FLIST, conf_set_oper_flags, 0, NULL },
1778 { "umodes", CF_STRING | CF_FLIST, conf_set_oper_umodes, 0, NULL },
1779 { "user", CF_QSTRING, conf_set_oper_user, 0, NULL },
1780 { "password", CF_QSTRING, conf_set_oper_password, 0, NULL },
1781 { "\0", 0, NULL, 0, NULL }
1784 static struct ConfEntry conf_class_table[] =
1786 { "ping_time", CF_TIME, conf_set_class_ping_time, 0, NULL },
1787 { "cidr_bitlen", CF_INT, conf_set_class_cidr_bitlen, 0, NULL },
1788 { "number_per_cidr", CF_INT, conf_set_class_number_per_cidr, 0, NULL },
1789 { "number_per_ip", CF_INT, conf_set_class_number_per_ip, 0, NULL },
1790 { "number_per_ip_global", CF_INT,conf_set_class_number_per_ip_global, 0, NULL },
1791 { "number_per_ident", CF_INT, conf_set_class_number_per_ident, 0, NULL },
1792 { "connectfreq", CF_TIME, conf_set_class_connectfreq, 0, NULL },
1793 { "max_number", CF_INT, conf_set_class_max_number, 0, NULL },
1794 { "sendq", CF_TIME, conf_set_class_sendq, 0, NULL },
1795 { "\0", 0, NULL, 0, NULL }
1798 static struct ConfEntry conf_auth_table[] =
1800 { "user", CF_QSTRING, conf_set_auth_user, 0, NULL },
1801 { "password", CF_QSTRING, conf_set_auth_passwd, 0, NULL },
1802 { "class", CF_QSTRING, conf_set_auth_class, 0, NULL },
1803 { "spoof", CF_QSTRING, conf_set_auth_spoof, 0, NULL },
1804 { "redirserv", CF_QSTRING, conf_set_auth_redir_serv, 0, NULL },
1805 { "redirport", CF_INT, conf_set_auth_redir_port, 0, NULL },
1806 { "flags", CF_STRING | CF_FLIST, conf_set_auth_flags, 0, NULL },
1807 { "\0", 0, NULL, 0, NULL }
1810 static struct ConfEntry conf_connect_table[] =
1812 { "send_password", CF_QSTRING, conf_set_connect_send_password, 0, NULL },
1813 { "accept_password", CF_QSTRING, conf_set_connect_accept_password, 0, NULL },
1814 { "flags", CF_STRING | CF_FLIST, conf_set_connect_flags, 0, NULL },
1815 { "host", CF_QSTRING, conf_set_connect_host, 0, NULL },
1816 { "vhost", CF_QSTRING, conf_set_connect_vhost, 0, NULL },
1817 { "port", CF_INT, conf_set_connect_port, 0, NULL },
1818 { "aftype", CF_STRING, conf_set_connect_aftype, 0, NULL },
1819 { "hub_mask", CF_QSTRING, conf_set_connect_hub_mask, 0, NULL },
1820 { "leaf_mask", CF_QSTRING, conf_set_connect_leaf_mask, 0, NULL },
1821 { "class", CF_QSTRING, conf_set_connect_class, 0, NULL },
1822 { "\0", 0, NULL, 0, NULL }
1825 static struct ConfEntry conf_general_table[] =
1827 { "oper_only_umodes", CF_STRING | CF_FLIST, conf_set_general_oper_only_umodes, 0, NULL },
1828 { "oper_umodes", CF_STRING | CF_FLIST, conf_set_general_oper_umodes, 0, NULL },
1829 { "compression_level", CF_INT, conf_set_general_compression_level, 0, NULL },
1830 { "havent_read_conf", CF_YESNO, conf_set_general_havent_read_conf, 0, NULL },
1831 { "hide_error_messages",CF_STRING, conf_set_general_hide_error_messages,0, NULL },
1832 { "kline_delay", CF_TIME, conf_set_general_kline_delay, 0, NULL },
1833 { "stats_k_oper_only", CF_STRING, conf_set_general_stats_k_oper_only, 0, NULL },
1834 { "stats_i_oper_only", CF_STRING, conf_set_general_stats_i_oper_only, 0, NULL },
1836 { "default_operstring", CF_QSTRING, NULL, REALLEN, &ConfigFileEntry.default_operstring },
1837 { "default_adminstring",CF_QSTRING, NULL, REALLEN, &ConfigFileEntry.default_adminstring },
1838 { "egdpool_path", CF_QSTRING, NULL, MAXPATHLEN, &ConfigFileEntry.egdpool_path },
1839 { "kline_reason", CF_QSTRING, NULL, REALLEN, &ConfigFileEntry.kline_reason },
1840 { "servlink_path", CF_QSTRING, NULL, MAXPATHLEN, &ConfigFileEntry.servlink_path },
1842 { "anti_spam_exit_message_time", CF_TIME, NULL, 0, &ConfigFileEntry.anti_spam_exit_message_time },
1843 { "disable_fake_channels", CF_YESNO, NULL, 0, &ConfigFileEntry.disable_fake_channels },
1844 { "min_nonwildcard_simple", CF_INT, NULL, 0, &ConfigFileEntry.min_nonwildcard_simple },
1845 { "non_redundant_klines", CF_YESNO, NULL, 0, &ConfigFileEntry.non_redundant_klines },
1846 { "tkline_expire_notices", CF_YESNO, NULL, 0, &ConfigFileEntry.tkline_expire_notices },
1848 { "anti_nick_flood", CF_YESNO, NULL, 0, &ConfigFileEntry.anti_nick_flood },
1849 { "burst_away", CF_YESNO, NULL, 0, &ConfigFileEntry.burst_away },
1850 { "caller_id_wait", CF_TIME, NULL, 0, &ConfigFileEntry.caller_id_wait },
1851 { "client_exit", CF_YESNO, NULL, 0, &ConfigFileEntry.client_exit },
1852 { "client_flood", CF_INT, NULL, 0, &ConfigFileEntry.client_flood },
1853 { "connect_timeout", CF_TIME, NULL, 0, &ConfigFileEntry.connect_timeout },
1854 { "default_invisible", CF_YESNO, NULL, 0, &ConfigFileEntry.default_invisible },
1855 { "default_floodcount", CF_INT, NULL, 0, &ConfigFileEntry.default_floodcount },
1856 { "disable_auth", CF_YESNO, NULL, 0, &ConfigFileEntry.disable_auth },
1857 { "dot_in_ip6_addr", CF_YESNO, NULL, 0, &ConfigFileEntry.dot_in_ip6_addr },
1858 { "dots_in_ident", CF_INT, NULL, 0, &ConfigFileEntry.dots_in_ident },
1859 { "failed_oper_notice", CF_YESNO, NULL, 0, &ConfigFileEntry.failed_oper_notice },
1860 { "glines", CF_YESNO, NULL, 0, &ConfigFileEntry.glines },
1861 { "gline_min_cidr", CF_INT, NULL, 0, &ConfigFileEntry.gline_min_cidr },
1862 { "gline_min_cidr6", CF_INT, NULL, 0, &ConfigFileEntry.gline_min_cidr6 },
1863 { "gline_time", CF_TIME, NULL, 0, &ConfigFileEntry.gline_time },
1864 { "idletime", CF_TIME, NULL, 0, &ConfigFileEntry.idletime },
1865 { "hide_spoof_ips", CF_YESNO, NULL, 0, &ConfigFileEntry.hide_spoof_ips },
1866 { "dline_with_reason", CF_YESNO, NULL, 0, &ConfigFileEntry.dline_with_reason },
1867 { "kline_with_reason", CF_YESNO, NULL, 0, &ConfigFileEntry.kline_with_reason },
1868 { "map_oper_only", CF_YESNO, NULL, 0, &ConfigFileEntry.map_oper_only },
1869 { "max_accept", CF_INT, NULL, 0, &ConfigFileEntry.max_accept },
1870 { "max_monitor", CF_INT, NULL, 0, &ConfigFileEntry.max_monitor },
1871 { "max_nick_time", CF_TIME, NULL, 0, &ConfigFileEntry.max_nick_time },
1872 { "max_nick_changes", CF_INT, NULL, 0, &ConfigFileEntry.max_nick_changes },
1873 { "max_targets", CF_INT, NULL, 0, &ConfigFileEntry.max_targets },
1874 { "max_unknown_ip", CF_INT, NULL, 0, &ConfigFileEntry.max_unknown_ip },
1875 { "min_nonwildcard", CF_INT, NULL, 0, &ConfigFileEntry.min_nonwildcard },
1876 { "nick_delay", CF_TIME, NULL, 0, &ConfigFileEntry.nick_delay },
1877 { "no_oper_flood", CF_YESNO, NULL, 0, &ConfigFileEntry.no_oper_flood },
1878 { "operspy_admin_only", CF_YESNO, NULL, 0, &ConfigFileEntry.operspy_admin_only },
1879 { "pace_wait", CF_TIME, NULL, 0, &ConfigFileEntry.pace_wait },
1880 { "pace_wait_simple", CF_TIME, NULL, 0, &ConfigFileEntry.pace_wait_simple },
1881 { "ping_cookie", CF_YESNO, NULL, 0, &ConfigFileEntry.ping_cookie },
1882 { "reject_after_count", CF_INT, NULL, 0, &ConfigFileEntry.reject_after_count },
1883 { "reject_ban_time", CF_TIME, NULL, 0, &ConfigFileEntry.reject_ban_time },
1884 { "reject_duration", CF_TIME, NULL, 0, &ConfigFileEntry.reject_duration },
1885 { "short_motd", CF_YESNO, NULL, 0, &ConfigFileEntry.short_motd },
1886 { "stats_c_oper_only", CF_YESNO, NULL, 0, &ConfigFileEntry.stats_c_oper_only },
1887 { "stats_e_disabled", CF_YESNO, NULL, 0, &ConfigFileEntry.stats_e_disabled },
1888 { "stats_h_oper_only", CF_YESNO, NULL, 0, &ConfigFileEntry.stats_h_oper_only },
1889 { "stats_o_oper_only", CF_YESNO, NULL, 0, &ConfigFileEntry.stats_o_oper_only },
1890 { "stats_P_oper_only", CF_YESNO, NULL, 0, &ConfigFileEntry.stats_P_oper_only },
1891 { "stats_y_oper_only", CF_YESNO, NULL, 0, &ConfigFileEntry.stats_y_oper_only },
1892 { "target_change", CF_YESNO, NULL, 0, &ConfigFileEntry.target_change },
1893 { "ts_max_delta", CF_TIME, NULL, 0, &ConfigFileEntry.ts_max_delta },
1894 { "use_egd", CF_YESNO, NULL, 0, &ConfigFileEntry.use_egd },
1895 { "ts_warn_delta", CF_TIME, NULL, 0, &ConfigFileEntry.ts_warn_delta },
1896 { "use_whois_actually", CF_YESNO, NULL, 0, &ConfigFileEntry.use_whois_actually },
1897 { "warn_no_nline", CF_YESNO, NULL, 0, &ConfigFileEntry.warn_no_nline },
1898 { "\0", 0, NULL, 0, NULL }
1901 static struct ConfEntry conf_channel_table[] =
1903 { "default_split_user_count", CF_INT, NULL, 0, &ConfigChannel.default_split_user_count },
1904 { "default_split_server_count", CF_INT, NULL, 0, &ConfigChannel.default_split_server_count },
1905 { "burst_topicwho", CF_YESNO, NULL, 0, &ConfigChannel.burst_topicwho },
1906 { "invite_ops_only", CF_YESNO, NULL, 0, &ConfigChannel.invite_ops_only },
1907 { "knock_delay", CF_TIME, NULL, 0, &ConfigChannel.knock_delay },
1908 { "knock_delay_channel",CF_TIME, NULL, 0, &ConfigChannel.knock_delay_channel },
1909 { "max_bans", CF_INT, NULL, 0, &ConfigChannel.max_bans },
1910 { "max_chans_per_user", CF_INT, NULL, 0, &ConfigChannel.max_chans_per_user },
1911 { "no_create_on_split", CF_YESNO, NULL, 0, &ConfigChannel.no_create_on_split },
1912 { "no_join_on_split", CF_YESNO, NULL, 0, &ConfigChannel.no_join_on_split },
1913 { "quiet_on_ban", CF_YESNO, NULL, 0, &ConfigChannel.quiet_on_ban },
1914 { "use_except", CF_YESNO, NULL, 0, &ConfigChannel.use_except },
1915 { "use_invex", CF_YESNO, NULL, 0, &ConfigChannel.use_invex },
1916 { "use_knock", CF_YESNO, NULL, 0, &ConfigChannel.use_knock },
1917 { "\0", 0, NULL, 0, NULL }
1920 static struct ConfEntry conf_serverhide_table[] =
1922 { "disable_hidden", CF_YESNO, NULL, 0, &ConfigServerHide.disable_hidden },
1923 { "flatten_links", CF_YESNO, NULL, 0, &ConfigServerHide.flatten_links },
1924 { "hidden", CF_YESNO, NULL, 0, &ConfigServerHide.hidden },
1925 { "links_delay", CF_TIME, conf_set_serverhide_links_delay, 0, NULL },
1926 { "\0", 0, NULL, 0, NULL }
1928 /* *INDENT-ON* */
1930 void
1931 newconf_init()
1933 add_top_conf("modules", NULL, NULL, NULL);
1934 add_conf_item("modules", "path", CF_QSTRING, conf_set_modules_path);
1935 add_conf_item("modules", "module", CF_QSTRING, conf_set_modules_module);
1937 add_top_conf("serverinfo", NULL, NULL, conf_serverinfo_table);
1938 add_top_conf("admin", NULL, NULL, conf_admin_table);
1939 add_top_conf("log", NULL, NULL, conf_log_table);
1940 add_top_conf("operator", conf_begin_oper, conf_end_oper, conf_operator_table);
1941 add_top_conf("class", conf_begin_class, conf_end_class, conf_class_table);
1943 add_top_conf("listen", conf_begin_listen, conf_end_listen, NULL);
1944 add_conf_item("listen", "port", CF_INT | CF_FLIST, conf_set_listen_port);
1945 add_conf_item("listen", "ip", CF_QSTRING, conf_set_listen_address);
1946 add_conf_item("listen", "host", CF_QSTRING, conf_set_listen_address);
1948 add_top_conf("auth", conf_begin_auth, conf_end_auth, conf_auth_table);
1950 add_top_conf("shared", conf_cleanup_shared, conf_cleanup_shared, NULL);
1951 add_conf_item("shared", "oper", CF_QSTRING|CF_FLIST, conf_set_shared_oper);
1952 add_conf_item("shared", "flags", CF_STRING | CF_FLIST, conf_set_shared_flags);
1954 add_top_conf("connect", conf_begin_connect, conf_end_connect, conf_connect_table);
1956 add_top_conf("exempt", NULL, NULL, NULL);
1957 add_conf_item("exempt", "ip", CF_QSTRING, conf_set_exempt_ip);
1959 add_top_conf("cluster", conf_cleanup_cluster, conf_cleanup_cluster, NULL);
1960 add_conf_item("cluster", "name", CF_QSTRING, conf_set_cluster_name);
1961 add_conf_item("cluster", "flags", CF_STRING | CF_FLIST, conf_set_cluster_flags);
1963 add_top_conf("general", NULL, NULL, conf_general_table);
1964 add_top_conf("channel", NULL, NULL, conf_channel_table);
1965 add_top_conf("serverhide", NULL, NULL, conf_serverhide_table);
1967 #ifdef ENABLE_SERVICES
1968 add_top_conf("service", conf_begin_service, NULL, NULL);
1969 add_conf_item("service", "name", CF_QSTRING, conf_set_service_name);
1970 #endif