1 /* This code is in the public domain.
2 * $Id: newconf.c 3550 2007-08-09 06:47:26Z nenolod $
8 #include <openssl/pem.h>
9 #include <openssl/rsa.h>
13 #include "ircd_defs.h"
18 #include "s_newconf.h"
29 #include "blacklist.h"
31 #include "privilege.h"
33 #define CF_TYPE(x) ((x) & CF_MTYPE)
35 struct TopConf
*conf_cur_block
;
36 static char *conf_cur_block_name
;
38 static rb_dlink_list conf_items
;
40 static struct ConfItem
*yy_aconf
= NULL
;
42 static struct Class
*yy_class
= NULL
;
44 static struct remote_conf
*yy_shared
= NULL
;
45 static struct server_conf
*yy_server
= NULL
;
47 static rb_dlink_list yy_aconf_list
;
48 static rb_dlink_list yy_oper_list
;
49 static rb_dlink_list yy_shared_list
;
50 static rb_dlink_list yy_cluster_list
;
51 static struct oper_conf
*yy_oper
= NULL
;
53 static struct alias_entry
*yy_alias
= NULL
;
55 static char *yy_blacklist_host
= NULL
;
56 static char *yy_blacklist_reason
= NULL
;
57 static char *yy_privset_extends
= NULL
;
60 conf_strtype(int type
)
62 switch (type
& CF_MTYPE
)
65 return "integer value";
67 return "unquoted string";
69 return "yes/no value";
71 return "quoted string";
73 return "time/size value";
75 return "unknown type";
80 add_top_conf(const char *name
, int (*sfunc
) (struct TopConf
*),
81 int (*efunc
) (struct TopConf
*), struct ConfEntry
*items
)
85 tc
= rb_malloc(sizeof(struct TopConf
));
90 tc
->tc_entries
= items
;
92 rb_dlinkAddAlloc(tc
, &conf_items
);
97 find_top_conf(const char *name
)
102 RB_DLINK_FOREACH(d
, conf_items
.head
)
105 if(strcasecmp(tc
->tc_name
, name
) == 0)
114 find_conf_item(const struct TopConf
*top
, const char *name
)
116 struct ConfEntry
*cf
;
123 for(i
= 0; top
->tc_entries
[i
].cf_type
; i
++)
125 cf
= &top
->tc_entries
[i
];
127 if(!strcasecmp(cf
->cf_name
, name
))
132 RB_DLINK_FOREACH(d
, top
->tc_items
.head
)
135 if(strcasecmp(cf
->cf_name
, name
) == 0)
143 remove_top_conf(char *name
)
148 if((tc
= find_top_conf(name
)) == NULL
)
151 if((ptr
= rb_dlinkFind(tc
, &conf_items
)) == NULL
)
154 rb_dlinkDestroy(ptr
, &conf_items
);
161 conf_set_serverinfo_name(void *data
)
163 if(ServerInfo
.name
== NULL
)
168 for(s
= data
; *s
!= '\0'; s
++)
172 conf_report_error("Ignoring serverinfo::name "
173 "-- bogus servername.");
182 conf_report_error("Ignoring serverinfo::name -- must contain '.'");
190 conf_report_error("Ignoring serverinfo::name -- cannot begin with digit.");
194 /* the ircd will exit() in main() if we dont set one */
195 if(strlen(s
) <= HOSTLEN
)
196 ServerInfo
.name
= rb_strdup((char *) data
);
201 conf_set_serverinfo_sid(void *data
)
205 if(ServerInfo
.sid
[0] == '\0')
207 if(!IsDigit(sid
[0]) || !IsIdChar(sid
[1]) ||
208 !IsIdChar(sid
[2]) || sid
[3] != '\0')
210 conf_report_error("Ignoring serverinfo::sid "
215 strcpy(ServerInfo
.sid
, sid
);
220 conf_set_serverinfo_network_name(void *data
)
224 if((p
= strchr((char *) data
, ' ')))
227 rb_free(ServerInfo
.network_name
);
228 ServerInfo
.network_name
= rb_strdup((char *) data
);
232 conf_set_serverinfo_vhost(void *data
)
234 if(rb_inet_pton(AF_INET
, (char *) data
, &ServerInfo
.ip
.sin_addr
) <= 0)
236 conf_report_error("Invalid netmask for server IPv4 vhost (%s)", (char *) data
);
239 ServerInfo
.ip
.sin_family
= AF_INET
;
240 ServerInfo
.specific_ipv4_vhost
= 1;
244 conf_set_serverinfo_vhost6(void *data
)
247 if(rb_inet_pton(AF_INET6
, (char *) data
, &ServerInfo
.ip6
.sin6_addr
) <= 0)
249 conf_report_error("Invalid netmask for server IPv6 vhost (%s)", (char *) data
);
253 ServerInfo
.specific_ipv6_vhost
= 1;
254 ServerInfo
.ip6
.sin6_family
= AF_INET6
;
256 conf_report_error("Warning -- ignoring serverinfo::vhost6 -- IPv6 support not available.");
261 conf_set_modules_module(void *data
)
263 #ifndef STATIC_MODULES
266 m_bn
= rb_basename((char *) data
);
268 if(findmodule_byname(m_bn
) != -1)
271 load_one_module((char *) data
, 0);
275 conf_report_error("Ignoring modules::module -- loadable module support not present.");
280 conf_set_modules_path(void *data
)
282 #ifndef STATIC_MODULES
283 mod_add_path((char *) data
);
285 conf_report_error("Ignoring modules::path -- loadable module support not present.");
296 static struct mode_table umode_table
[] = {
297 {"callerid", UMODE_CALLERID
},
298 {"deaf", UMODE_DEAF
},
299 {"invisible", UMODE_INVISIBLE
},
300 {"locops", UMODE_LOCOPS
},
301 {"noforward", UMODE_NOFORWARD
},
302 {"regonlymsg", UMODE_REGONLYMSG
},
303 {"servnotice", UMODE_SERVNOTICE
},
304 {"wallop", UMODE_WALLOP
},
305 {"operwall", UMODE_OPERWALL
},
309 static struct mode_table oper_table
[] = {
310 {"encrypted", OPER_ENCRYPTED
},
311 {"need_ssl", OPER_NEEDSSL
},
315 static struct mode_table auth_table
[] = {
316 {"encrypted", CONF_FLAGS_ENCRYPTED
},
317 {"spoof_notice", CONF_FLAGS_SPOOF_NOTICE
},
318 {"exceed_limit", CONF_FLAGS_NOLIMIT
},
319 {"dnsbl_exempt", CONF_FLAGS_EXEMPTDNSBL
},
320 {"kline_exempt", CONF_FLAGS_EXEMPTKLINE
},
321 {"flood_exempt", CONF_FLAGS_EXEMPTFLOOD
},
322 {"spambot_exempt", CONF_FLAGS_EXEMPTSPAMBOT
},
323 {"shide_exempt", CONF_FLAGS_EXEMPTSHIDE
},
324 {"jupe_exempt", CONF_FLAGS_EXEMPTJUPE
},
325 {"resv_exempt", CONF_FLAGS_EXEMPTRESV
},
326 {"no_tilde", CONF_FLAGS_NO_TILDE
},
327 {"need_ident", CONF_FLAGS_NEED_IDENTD
},
328 {"have_ident", CONF_FLAGS_NEED_IDENTD
},
329 {"need_ssl", CONF_FLAGS_NEED_SSL
},
330 {"need_sasl", CONF_FLAGS_NEED_SASL
},
334 static struct mode_table connect_table
[] = {
335 { "autoconn", SERVER_AUTOCONN
},
336 { "compressed", SERVER_COMPRESSED
},
337 { "encrypted", SERVER_ENCRYPTED
},
338 { "topicburst", SERVER_TB
},
339 { "ssl", SERVER_SSL
},
343 static struct mode_table cluster_table
[] = {
344 { "kline", SHARED_PKLINE
},
345 { "tkline", SHARED_TKLINE
},
346 { "unkline", SHARED_UNKLINE
},
347 { "locops", SHARED_LOCOPS
},
348 { "xline", SHARED_PXLINE
},
349 { "txline", SHARED_TXLINE
},
350 { "unxline", SHARED_UNXLINE
},
351 { "resv", SHARED_PRESV
},
352 { "tresv", SHARED_TRESV
},
353 { "unresv", SHARED_UNRESV
},
354 { "all", CLUSTER_ALL
},
358 static struct mode_table shared_table
[] =
360 { "kline", SHARED_PKLINE
|SHARED_TKLINE
},
361 { "xline", SHARED_PXLINE
|SHARED_TXLINE
},
362 { "resv", SHARED_PRESV
|SHARED_TRESV
},
363 { "dline", SHARED_PDLINE
|SHARED_TDLINE
},
364 { "tdline", SHARED_TDLINE
},
365 { "pdline", SHARED_PDLINE
},
366 { "undline", SHARED_UNDLINE
},
367 { "tkline", SHARED_TKLINE
},
368 { "unkline", SHARED_UNKLINE
},
369 { "txline", SHARED_TXLINE
},
370 { "unxline", SHARED_UNXLINE
},
371 { "tresv", SHARED_TRESV
},
372 { "unresv", SHARED_UNRESV
},
373 { "locops", SHARED_LOCOPS
},
374 { "rehash", SHARED_REHASH
},
375 { "all", SHARED_ALL
},
382 find_umode(struct mode_table
*tab
, const char *name
)
386 for (i
= 0; tab
[i
].name
; i
++)
388 if(strcmp(tab
[i
].name
, name
) == 0)
396 set_modes_from_table(int *modes
, const char *whatis
, struct mode_table
*tab
, conf_parm_t
* args
)
398 for (; args
; args
= args
->next
)
404 if((args
->type
& CF_MTYPE
) != CF_STRING
)
406 conf_report_error("Warning -- %s is not a string; ignoring.", whatis
);
410 umode
= args
->v
.string
;
418 mode
= find_umode(tab
, umode
);
422 conf_report_error("Warning -- unknown %s %s.", whatis
, args
->v
.string
);
439 conf_set_privset_extends(void *data
)
441 yy_privset_extends
= rb_strdup((char *) data
);
445 conf_set_privset_privs(void *data
)
448 conf_parm_t
*args
= data
;
450 for (; args
; args
= args
->next
)
453 privs
= rb_strdup(args
->v
.string
);
456 char *privs_old
= privs
;
458 privs
= rb_malloc(strlen(privs_old
) + 1 + strlen(args
->v
.string
) + 1);
459 strcpy(privs
, privs_old
);
461 strcat(privs
, args
->v
.string
);
469 if (yy_privset_extends
)
471 struct PrivilegeSet
*set
= privilegeset_get(yy_privset_extends
);
475 conf_report_error("Warning -- unknown parent privilege set %s for %s; assuming defaults", yy_privset_extends
, conf_cur_block_name
);
477 set
= privilegeset_get("default");
480 privilegeset_extend(set
, conf_cur_block_name
!= NULL
? conf_cur_block_name
: "<unknown>", privs
, 0);
482 rb_free(yy_privset_extends
);
483 yy_privset_extends
= NULL
;
486 privilegeset_set_new(conf_cur_block_name
!= NULL
? conf_cur_block_name
: "<unknown>", privs
, 0);
493 conf_begin_oper(struct TopConf
*tc
)
496 rb_dlink_node
*next_ptr
;
500 free_oper_conf(yy_oper
);
504 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, yy_oper_list
.head
)
506 free_oper_conf(ptr
->data
);
507 rb_dlinkDestroy(ptr
, &yy_oper_list
);
510 yy_oper
= make_oper_conf();
511 yy_oper
->flags
|= OPER_ENCRYPTED
;
517 conf_end_oper(struct TopConf
*tc
)
519 struct oper_conf
*yy_tmpoper
;
521 rb_dlink_node
*next_ptr
;
523 if(conf_cur_block_name
!= NULL
)
525 if(strlen(conf_cur_block_name
) > OPERNICKLEN
)
526 conf_cur_block_name
[OPERNICKLEN
] = '\0';
528 yy_oper
->name
= rb_strdup(conf_cur_block_name
);
531 if(EmptyString(yy_oper
->name
))
533 conf_report_error("Ignoring operator block -- missing name.");
537 #ifdef HAVE_LIBCRYPTO
538 if(EmptyString(yy_oper
->passwd
) && EmptyString(yy_oper
->rsa_pubkey_file
))
540 if(EmptyString(yy_oper
->passwd
))
543 conf_report_error("Ignoring operator block for %s -- missing password",
549 if (!yy_oper
->privset
)
550 yy_oper
->privset
= privilegeset_get("default");
552 /* now, yy_oper_list contains a stack of oper_conf's with just user
553 * and host in, yy_oper contains the rest of the information which
554 * we need to copy into each element in yy_oper_list
556 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, yy_oper_list
.head
)
558 yy_tmpoper
= ptr
->data
;
560 yy_tmpoper
->name
= rb_strdup(yy_oper
->name
);
562 /* could be an rsa key instead.. */
563 if(!EmptyString(yy_oper
->passwd
))
564 yy_tmpoper
->passwd
= rb_strdup(yy_oper
->passwd
);
566 yy_tmpoper
->flags
= yy_oper
->flags
;
567 yy_tmpoper
->umodes
= yy_oper
->umodes
;
568 yy_tmpoper
->snomask
= yy_oper
->snomask
;
569 yy_tmpoper
->privset
= yy_oper
->privset
;
571 #ifdef HAVE_LIBCRYPTO
572 if(yy_oper
->rsa_pubkey_file
)
576 if((file
= BIO_new_file(yy_oper
->rsa_pubkey_file
, "r")) == NULL
)
578 conf_report_error("Ignoring operator block for %s -- "
579 "rsa_public_key_file cant be opened",
584 yy_tmpoper
->rsa_pubkey
=
585 (RSA
*) PEM_read_bio_RSA_PUBKEY(file
, NULL
, 0, NULL
);
587 (void)BIO_set_close(file
, BIO_CLOSE
);
590 if(yy_tmpoper
->rsa_pubkey
== NULL
)
592 conf_report_error("Ignoring operator block for %s -- "
593 "rsa_public_key_file key invalid; check syntax",
599 if(!EmptyString(yy_oper
->certfp
))
600 yy_tmpoper
->certfp
= rb_strdup(yy_oper
->certfp
);
603 /* all is ok, put it on oper_conf_list */
604 rb_dlinkMoveNode(ptr
, &yy_oper_list
, &oper_conf_list
);
607 free_oper_conf(yy_oper
);
614 conf_set_oper_flags(void *data
)
616 conf_parm_t
*args
= data
;
618 set_modes_from_table(&yy_oper
->flags
, "flag", oper_table
, args
);
622 conf_set_oper_fingerprint(void *data
)
625 rb_free(yy_oper
->certfp
);
626 yy_oper
->certfp
= rb_strdup((char *) data
);
630 conf_set_oper_privset(void *data
)
632 yy_oper
->privset
= privilegeset_get((char *) data
);
636 conf_set_oper_user(void *data
)
638 struct oper_conf
*yy_tmpoper
;
640 char *host
= (char *) data
;
642 yy_tmpoper
= make_oper_conf();
644 if((p
= strchr(host
, '@')))
648 yy_tmpoper
->username
= rb_strdup(host
);
649 yy_tmpoper
->host
= rb_strdup(p
);
654 yy_tmpoper
->username
= rb_strdup("*");
655 yy_tmpoper
->host
= rb_strdup(host
);
658 if(EmptyString(yy_tmpoper
->username
) || EmptyString(yy_tmpoper
->host
))
660 conf_report_error("Ignoring user -- missing username/host");
661 free_oper_conf(yy_tmpoper
);
665 rb_dlinkAddAlloc(yy_tmpoper
, &yy_oper_list
);
669 conf_set_oper_password(void *data
)
673 memset(yy_oper
->passwd
, 0, strlen(yy_oper
->passwd
));
674 rb_free(yy_oper
->passwd
);
677 yy_oper
->passwd
= rb_strdup((char *) data
);
681 conf_set_oper_rsa_public_key_file(void *data
)
683 #ifdef HAVE_LIBCRYPTO
684 rb_free(yy_oper
->rsa_pubkey_file
);
685 yy_oper
->rsa_pubkey_file
= rb_strdup((char *) data
);
687 conf_report_error("Warning -- ignoring rsa_public_key_file (OpenSSL support not available");
692 conf_set_oper_umodes(void *data
)
694 set_modes_from_table(&yy_oper
->umodes
, "umode", umode_table
, data
);
698 conf_set_oper_snomask(void *data
)
700 yy_oper
->snomask
= parse_snobuf_to_mask(0, (const char *) data
);
704 conf_begin_class(struct TopConf
*tc
)
707 free_class(yy_class
);
709 yy_class
= make_class();
714 conf_end_class(struct TopConf
*tc
)
716 if(conf_cur_block_name
!= NULL
)
717 yy_class
->class_name
= rb_strdup(conf_cur_block_name
);
719 if(EmptyString(yy_class
->class_name
))
721 conf_report_error("Ignoring connect block -- missing name.");
731 conf_set_class_ping_time(void *data
)
733 yy_class
->ping_freq
= *(unsigned int *) data
;
737 conf_set_class_cidr_ipv4_bitlen(void *data
)
739 unsigned int maxsize
= 32;
740 if(*(unsigned int *) data
> maxsize
)
742 ("class::cidr_ipv4_bitlen argument exceeds maxsize (%d > %d) - ignoring.",
743 *(unsigned int *) data
, maxsize
);
745 yy_class
->cidr_ipv4_bitlen
= *(unsigned int *) data
;
751 conf_set_class_cidr_ipv6_bitlen(void *data
)
753 unsigned int maxsize
= 128;
754 if(*(unsigned int *) data
> maxsize
)
756 ("class::cidr_ipv6_bitlen argument exceeds maxsize (%d > %d) - ignoring.",
757 *(unsigned int *) data
, maxsize
);
759 yy_class
->cidr_ipv6_bitlen
= *(unsigned int *) data
;
765 conf_set_class_number_per_cidr(void *data
)
767 yy_class
->cidr_amount
= *(unsigned int *) data
;
771 conf_set_class_number_per_ip(void *data
)
773 yy_class
->max_local
= *(unsigned int *) data
;
778 conf_set_class_number_per_ip_global(void *data
)
780 yy_class
->max_global
= *(unsigned int *) data
;
784 conf_set_class_number_per_ident(void *data
)
786 yy_class
->max_ident
= *(unsigned int *) data
;
790 conf_set_class_connectfreq(void *data
)
792 yy_class
->con_freq
= *(unsigned int *) data
;
796 conf_set_class_max_number(void *data
)
798 yy_class
->max_total
= *(unsigned int *) data
;
802 conf_set_class_sendq(void *data
)
804 yy_class
->max_sendq
= *(unsigned int *) data
;
807 static char *listener_address
;
810 conf_begin_listen(struct TopConf
*tc
)
812 rb_free(listener_address
);
813 listener_address
= NULL
;
818 conf_end_listen(struct TopConf
*tc
)
820 rb_free(listener_address
);
821 listener_address
= NULL
;
828 conf_set_listen_port_both(void *data
, int ssl
)
830 conf_parm_t
*args
= data
;
831 for (; args
; args
= args
->next
)
833 if((args
->type
& CF_MTYPE
) != CF_INT
)
836 ("listener::port argument is not an integer " "-- ignoring.");
839 if(listener_address
== NULL
)
841 add_listener(args
->v
.number
, listener_address
, AF_INET
, ssl
);
843 add_listener(args
->v
.number
, listener_address
, AF_INET6
, ssl
);
850 if(strchr(listener_address
, ':') != NULL
)
856 add_listener(args
->v
.number
, listener_address
, family
, ssl
);
864 conf_set_listen_port(void *data
)
866 conf_set_listen_port_both(data
, 0);
870 conf_set_listen_sslport(void *data
)
872 conf_set_listen_port_both(data
, 1);
876 conf_set_listen_address(void *data
)
878 rb_free(listener_address
);
879 listener_address
= rb_strdup(data
);
883 conf_begin_auth(struct TopConf
*tc
)
886 rb_dlink_node
*next_ptr
;
891 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, yy_aconf_list
.head
)
893 free_conf(ptr
->data
);
894 rb_dlinkDestroy(ptr
, &yy_aconf_list
);
897 yy_aconf
= make_conf();
898 yy_aconf
->status
= CONF_CLIENT
;
904 conf_end_auth(struct TopConf
*tc
)
906 struct ConfItem
*yy_tmp
, *found_conf
;
908 rb_dlink_node
*next_ptr
;
910 if(EmptyString(yy_aconf
->info
.name
))
911 yy_aconf
->info
.name
= rb_strdup("NOMATCH");
913 /* didnt even get one ->host? */
914 if(EmptyString(yy_aconf
->host
))
916 conf_report_error("Ignoring auth block -- missing user@host");
920 /* so the stacking works in order.. */
921 collapse(yy_aconf
->user
);
922 collapse(yy_aconf
->host
);
923 conf_add_class_to_conf(yy_aconf
);
924 if ((found_conf
= find_exact_conf_by_address("*", CONF_CLIENT
, "*")) && found_conf
->spasswd
== NULL
)
925 conf_report_error("Ignoring redundant auth block (after *@*)");
926 else if ((found_conf
= find_exact_conf_by_address(yy_aconf
->host
, CONF_CLIENT
, yy_aconf
->user
)) &&
927 (!found_conf
->spasswd
|| (yy_aconf
->spasswd
&&
928 0 == irccmp(found_conf
->spasswd
, yy_aconf
->spasswd
))))
929 conf_report_error("Ignoring duplicate auth block for %s@%s",
930 yy_aconf
->user
, yy_aconf
->host
);
932 add_conf_by_address(yy_aconf
->host
, CONF_CLIENT
, yy_aconf
->user
, yy_aconf
->spasswd
, yy_aconf
);
934 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, yy_aconf_list
.head
)
939 yy_tmp
->passwd
= rb_strdup(yy_aconf
->passwd
);
941 if(yy_aconf
->spasswd
)
942 yy_tmp
->spasswd
= rb_strdup(yy_aconf
->spasswd
);
944 /* this will always exist.. */
945 yy_tmp
->info
.name
= rb_strdup(yy_aconf
->info
.name
);
947 if(yy_aconf
->className
)
948 yy_tmp
->className
= rb_strdup(yy_aconf
->className
);
950 yy_tmp
->flags
= yy_aconf
->flags
;
951 yy_tmp
->port
= yy_aconf
->port
;
953 collapse(yy_tmp
->user
);
954 collapse(yy_tmp
->host
);
956 conf_add_class_to_conf(yy_tmp
);
958 if (find_exact_conf_by_address("*", CONF_CLIENT
, "*"))
959 conf_report_error("Ignoring redundant auth block (after *@*)");
960 else if (find_exact_conf_by_address(yy_tmp
->host
, CONF_CLIENT
, yy_tmp
->user
))
961 conf_report_error("Ignoring duplicate auth block for %s@%s",
962 yy_tmp
->user
, yy_tmp
->host
);
964 add_conf_by_address(yy_tmp
->host
, CONF_CLIENT
, yy_tmp
->user
, yy_tmp
->spasswd
, yy_tmp
);
965 rb_dlinkDestroy(ptr
, &yy_aconf_list
);
973 conf_set_auth_user(void *data
)
975 struct ConfItem
*yy_tmp
;
978 /* The first user= line doesn't allocate a new conf */
979 if(!EmptyString(yy_aconf
->host
))
981 yy_tmp
= make_conf();
982 yy_tmp
->status
= CONF_CLIENT
;
987 if((p
= strchr(data
, '@')))
991 yy_tmp
->user
= rb_strdup(data
);
992 yy_tmp
->host
= rb_strdup(p
);
996 yy_tmp
->user
= rb_strdup("*");
997 yy_tmp
->host
= rb_strdup(data
);
1000 if(yy_aconf
!= yy_tmp
)
1001 rb_dlinkAddAlloc(yy_tmp
, &yy_aconf_list
);
1005 conf_set_auth_auth_user(void *data
)
1007 if(yy_aconf
->spasswd
)
1008 memset(yy_aconf
->spasswd
, 0, strlen(yy_aconf
->spasswd
));
1009 rb_free(yy_aconf
->spasswd
);
1010 yy_aconf
->spasswd
= rb_strdup(data
);
1014 conf_set_auth_passwd(void *data
)
1016 if(yy_aconf
->passwd
)
1017 memset(yy_aconf
->passwd
, 0, strlen(yy_aconf
->passwd
));
1018 rb_free(yy_aconf
->passwd
);
1019 yy_aconf
->passwd
= rb_strdup(data
);
1023 conf_set_auth_spoof(void *data
)
1031 /* user@host spoof */
1032 if((p
= strchr(host
, '@')) != NULL
)
1038 if(EmptyString(user
))
1040 conf_report_error("Warning -- spoof ident empty.");
1044 if(strlen(user
) > USERLEN
)
1046 conf_report_error("Warning -- spoof ident length invalid.");
1050 if(!valid_username(user
))
1052 conf_report_error("Warning -- invalid spoof (ident).");
1056 /* this must be restored! */
1060 if(EmptyString(host
))
1062 conf_report_error("Warning -- spoof host empty.");
1066 if(strlen(host
) > HOSTLEN
)
1068 conf_report_error("Warning -- spoof host length invalid.");
1072 if(!valid_hostname(host
))
1074 conf_report_error("Warning -- invalid spoof (host).");
1078 rb_free(yy_aconf
->info
.name
);
1079 yy_aconf
->info
.name
= rb_strdup(data
);
1080 yy_aconf
->flags
|= CONF_FLAGS_SPOOF_IP
;
1084 conf_set_auth_flags(void *data
)
1086 conf_parm_t
*args
= data
;
1088 set_modes_from_table((int *) &yy_aconf
->flags
, "flag", auth_table
, args
);
1092 conf_set_auth_redir_serv(void *data
)
1094 yy_aconf
->flags
|= CONF_FLAGS_REDIR
;
1095 rb_free(yy_aconf
->info
.name
);
1096 yy_aconf
->info
.name
= rb_strdup(data
);
1100 conf_set_auth_redir_port(void *data
)
1102 int port
= *(unsigned int *) data
;
1104 yy_aconf
->flags
|= CONF_FLAGS_REDIR
;
1105 yy_aconf
->port
= port
;
1109 conf_set_auth_class(void *data
)
1111 rb_free(yy_aconf
->className
);
1112 yy_aconf
->className
= rb_strdup(data
);
1115 /* ok, shared_oper handles the stacking, shared_flags handles adding
1116 * things.. so all we need to do when we start and end a shared block, is
1117 * clean up anything thats been left over.
1120 conf_cleanup_shared(struct TopConf
*tc
)
1122 rb_dlink_node
*ptr
, *next_ptr
;
1124 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, yy_shared_list
.head
)
1126 free_remote_conf(ptr
->data
);
1127 rb_dlinkDestroy(ptr
, &yy_shared_list
);
1130 if(yy_shared
!= NULL
)
1132 free_remote_conf(yy_shared
);
1140 conf_set_shared_oper(void *data
)
1142 conf_parm_t
*args
= data
;
1143 const char *username
;
1146 if(yy_shared
!= NULL
)
1147 free_remote_conf(yy_shared
);
1149 yy_shared
= make_remote_conf();
1151 if(args
->next
!= NULL
)
1153 if((args
->type
& CF_MTYPE
) != CF_QSTRING
)
1155 conf_report_error("Ignoring shared::oper -- server is not a qstring");
1159 yy_shared
->server
= rb_strdup(args
->v
.string
);
1163 yy_shared
->server
= rb_strdup("*");
1165 if((args
->type
& CF_MTYPE
) != CF_QSTRING
)
1167 conf_report_error("Ignoring shared::oper -- oper is not a qstring");
1171 if((p
= strchr(args
->v
.string
, '@')) == NULL
)
1173 conf_report_error("Ignoring shard::oper -- oper is not a user@host");
1177 username
= args
->v
.string
;
1181 yy_shared
->host
= rb_strdup("*");
1183 yy_shared
->host
= rb_strdup(p
);
1185 if(EmptyString(username
))
1186 yy_shared
->username
= rb_strdup("*");
1188 yy_shared
->username
= rb_strdup(username
);
1190 rb_dlinkAddAlloc(yy_shared
, &yy_shared_list
);
1195 conf_set_shared_flags(void *data
)
1197 conf_parm_t
*args
= data
;
1199 rb_dlink_node
*ptr
, *next_ptr
;
1201 if(yy_shared
!= NULL
)
1202 free_remote_conf(yy_shared
);
1204 set_modes_from_table(&flags
, "flag", shared_table
, args
);
1206 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, yy_shared_list
.head
)
1208 yy_shared
= ptr
->data
;
1210 yy_shared
->flags
= flags
;
1211 rb_dlinkDestroy(ptr
, &yy_shared_list
);
1212 rb_dlinkAddTail(yy_shared
, &yy_shared
->node
, &shared_conf_list
);
1219 conf_begin_connect(struct TopConf
*tc
)
1222 free_server_conf(yy_server
);
1224 yy_server
= make_server_conf();
1225 yy_server
->port
= PORTNUM
;
1226 yy_server
->flags
|= SERVER_TB
;
1228 if(conf_cur_block_name
!= NULL
)
1229 yy_server
->name
= rb_strdup(conf_cur_block_name
);
1235 conf_end_connect(struct TopConf
*tc
)
1237 if(EmptyString(yy_server
->name
))
1239 conf_report_error("Ignoring connect block -- missing name.");
1243 if(ServerInfo
.name
!= NULL
&& !irccmp(ServerInfo
.name
, yy_server
->name
))
1245 conf_report_error("Ignoring connect block for %s -- name is equal to my own name.",
1250 if((EmptyString(yy_server
->passwd
) || EmptyString(yy_server
->spasswd
)) && EmptyString(yy_server
->certfp
))
1252 conf_report_error("Ignoring connect block for %s -- no fingerprint or password credentials provided.",
1257 if(EmptyString(yy_server
->host
))
1259 conf_report_error("Ignoring connect block for %s -- missing host.",
1265 if(ServerConfCompressed(yy_server
))
1267 conf_report_error("Ignoring connect::flags::compressed -- zlib not available.");
1268 yy_server
->flags
&= ~SERVER_COMPRESSED
;
1272 add_server_conf(yy_server
);
1273 rb_dlinkAdd(yy_server
, &yy_server
->node
, &server_conf_list
);
1280 conf_set_connect_host(void *data
)
1282 rb_free(yy_server
->host
);
1283 yy_server
->host
= rb_strdup(data
);
1284 if (strchr(yy_server
->host
, ':'))
1285 yy_server
->aftype
= AF_INET6
;
1289 conf_set_connect_vhost(void *data
)
1291 if(rb_inet_pton_sock(data
, (struct sockaddr
*)&yy_server
->my_ipnum
) <= 0)
1293 conf_report_error("Invalid netmask for server vhost (%s)",
1298 yy_server
->flags
|= SERVER_VHOSTED
;
1302 conf_set_connect_send_password(void *data
)
1304 if(yy_server
->spasswd
)
1306 memset(yy_server
->spasswd
, 0, strlen(yy_server
->spasswd
));
1307 rb_free(yy_server
->spasswd
);
1310 yy_server
->spasswd
= rb_strdup(data
);
1314 conf_set_connect_accept_password(void *data
)
1316 if(yy_server
->passwd
)
1318 memset(yy_server
->passwd
, 0, strlen(yy_server
->passwd
));
1319 rb_free(yy_server
->passwd
);
1321 yy_server
->passwd
= rb_strdup(data
);
1325 conf_set_connect_fingerprint(void *data
)
1327 if (yy_server
->certfp
)
1328 rb_free(yy_server
->certfp
);
1329 yy_server
->certfp
= rb_strdup((char *) data
);
1331 /* force SSL to be enabled if fingerprint is enabled. */
1332 yy_server
->flags
|= SERVER_SSL
;
1336 conf_set_connect_port(void *data
)
1338 int port
= *(unsigned int *) data
;
1343 yy_server
->port
= port
;
1347 conf_set_connect_aftype(void *data
)
1351 if(strcasecmp(aft
, "ipv4") == 0)
1352 yy_server
->aftype
= AF_INET
;
1354 else if(strcasecmp(aft
, "ipv6") == 0)
1355 yy_server
->aftype
= AF_INET6
;
1358 conf_report_error("connect::aftype '%s' is unknown.", aft
);
1362 conf_set_connect_flags(void *data
)
1364 conf_parm_t
*args
= data
;
1366 /* note, we allow them to set compressed, then remove it later if
1367 * they do and LIBZ isnt available
1369 set_modes_from_table(&yy_server
->flags
, "flag", connect_table
, args
);
1373 conf_set_connect_hub_mask(void *data
)
1375 struct remote_conf
*yy_hub
;
1377 if(EmptyString(yy_server
->name
))
1380 yy_hub
= make_remote_conf();
1381 yy_hub
->flags
= CONF_HUB
;
1383 yy_hub
->host
= rb_strdup(data
);
1384 yy_hub
->server
= rb_strdup(yy_server
->name
);
1385 rb_dlinkAdd(yy_hub
, &yy_hub
->node
, &hubleaf_conf_list
);
1389 conf_set_connect_leaf_mask(void *data
)
1391 struct remote_conf
*yy_leaf
;
1393 if(EmptyString(yy_server
->name
))
1396 yy_leaf
= make_remote_conf();
1397 yy_leaf
->flags
= CONF_LEAF
;
1399 yy_leaf
->host
= rb_strdup(data
);
1400 yy_leaf
->server
= rb_strdup(yy_server
->name
);
1401 rb_dlinkAdd(yy_leaf
, &yy_leaf
->node
, &hubleaf_conf_list
);
1405 conf_set_connect_class(void *data
)
1407 rb_free(yy_server
->class_name
);
1408 yy_server
->class_name
= rb_strdup(data
);
1412 conf_set_exempt_ip(void *data
)
1414 struct ConfItem
*yy_tmp
;
1416 if(parse_netmask(data
, NULL
, NULL
) == HM_HOST
)
1418 conf_report_error("Ignoring exempt -- invalid exempt::ip.");
1422 yy_tmp
= make_conf();
1423 yy_tmp
->passwd
= rb_strdup("*");
1424 yy_tmp
->host
= rb_strdup(data
);
1425 yy_tmp
->status
= CONF_EXEMPTDLINE
;
1426 add_conf_by_address(yy_tmp
->host
, CONF_EXEMPTDLINE
, NULL
, NULL
, yy_tmp
);
1430 conf_cleanup_cluster(struct TopConf
*tc
)
1432 rb_dlink_node
*ptr
, *next_ptr
;
1434 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, yy_cluster_list
.head
)
1436 free_remote_conf(ptr
->data
);
1437 rb_dlinkDestroy(ptr
, &yy_cluster_list
);
1440 if(yy_shared
!= NULL
)
1442 free_remote_conf(yy_shared
);
1450 conf_set_cluster_name(void *data
)
1452 if(yy_shared
!= NULL
)
1453 free_remote_conf(yy_shared
);
1455 yy_shared
= make_remote_conf();
1456 yy_shared
->server
= rb_strdup(data
);
1457 rb_dlinkAddAlloc(yy_shared
, &yy_cluster_list
);
1463 conf_set_cluster_flags(void *data
)
1465 conf_parm_t
*args
= data
;
1467 rb_dlink_node
*ptr
, *next_ptr
;
1469 if(yy_shared
!= NULL
)
1470 free_remote_conf(yy_shared
);
1472 set_modes_from_table(&flags
, "flag", cluster_table
, args
);
1474 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, yy_cluster_list
.head
)
1476 yy_shared
= ptr
->data
;
1477 yy_shared
->flags
= flags
;
1478 rb_dlinkAddTail(yy_shared
, &yy_shared
->node
, &cluster_conf_list
);
1479 rb_dlinkDestroy(ptr
, &yy_cluster_list
);
1486 conf_set_general_havent_read_conf(void *data
)
1488 if(*(unsigned int *) data
)
1490 conf_report_error("You haven't read your config file properly.");
1492 ("There is a line in the example conf that will kill your server if not removed.");
1494 ("Consider actually reading/editing the conf file, and removing this line.");
1501 conf_set_general_hide_error_messages(void *data
)
1505 if(strcasecmp(val
, "yes") == 0)
1506 ConfigFileEntry
.hide_error_messages
= 2;
1507 else if(strcasecmp(val
, "opers") == 0)
1508 ConfigFileEntry
.hide_error_messages
= 1;
1509 else if(strcasecmp(val
, "no") == 0)
1510 ConfigFileEntry
.hide_error_messages
= 0;
1512 conf_report_error("Invalid setting '%s' for general::hide_error_messages.", val
);
1516 conf_set_general_kline_delay(void *data
)
1518 ConfigFileEntry
.kline_delay
= *(unsigned int *) data
;
1520 /* THIS MUST BE HERE to stop us being unable to check klines */
1525 conf_set_general_stats_k_oper_only(void *data
)
1529 if(strcasecmp(val
, "yes") == 0)
1530 ConfigFileEntry
.stats_k_oper_only
= 2;
1531 else if(strcasecmp(val
, "masked") == 0)
1532 ConfigFileEntry
.stats_k_oper_only
= 1;
1533 else if(strcasecmp(val
, "no") == 0)
1534 ConfigFileEntry
.stats_k_oper_only
= 0;
1536 conf_report_error("Invalid setting '%s' for general::stats_k_oper_only.", val
);
1540 conf_set_general_stats_i_oper_only(void *data
)
1544 if(strcasecmp(val
, "yes") == 0)
1545 ConfigFileEntry
.stats_i_oper_only
= 2;
1546 else if(strcasecmp(val
, "masked") == 0)
1547 ConfigFileEntry
.stats_i_oper_only
= 1;
1548 else if(strcasecmp(val
, "no") == 0)
1549 ConfigFileEntry
.stats_i_oper_only
= 0;
1551 conf_report_error("Invalid setting '%s' for general::stats_i_oper_only.", val
);
1555 conf_set_general_compression_level(void *data
)
1558 ConfigFileEntry
.compression_level
= *(unsigned int *) data
;
1560 if((ConfigFileEntry
.compression_level
< 1) || (ConfigFileEntry
.compression_level
> 9))
1563 ("Invalid general::compression_level %d -- using default.",
1564 ConfigFileEntry
.compression_level
);
1565 ConfigFileEntry
.compression_level
= 0;
1568 conf_report_error("Ignoring general::compression_level -- zlib not available.");
1573 conf_set_general_default_umodes(void *data
)
1576 int what
= MODE_ADD
, flag
;
1578 ConfigFileEntry
.default_umodes
= 0;
1579 for (pm
= (char *) data
; *pm
; pm
++)
1590 /* don't allow +o */
1597 if ((flag
= user_modes
[(unsigned char) *pm
]))
1599 /* Proper value has probably not yet been set
1600 * so don't check oper_only_umodes -- jilles */
1601 if (what
== MODE_ADD
)
1602 ConfigFileEntry
.default_umodes
|= flag
;
1604 ConfigFileEntry
.default_umodes
&= ~flag
;
1612 conf_set_general_oper_umodes(void *data
)
1614 set_modes_from_table(&ConfigFileEntry
.oper_umodes
, "umode", umode_table
, data
);
1618 conf_set_general_oper_only_umodes(void *data
)
1620 set_modes_from_table(&ConfigFileEntry
.oper_only_umodes
, "umode", umode_table
, data
);
1624 conf_set_general_oper_snomask(void *data
)
1627 int what
= MODE_ADD
, flag
;
1629 ConfigFileEntry
.oper_snomask
= 0;
1630 for (pm
= (char *) data
; *pm
; pm
++)
1642 if ((flag
= snomask_modes
[(unsigned char) *pm
]))
1644 if (what
== MODE_ADD
)
1645 ConfigFileEntry
.oper_snomask
|= flag
;
1647 ConfigFileEntry
.oper_snomask
&= ~flag
;
1655 conf_set_serverhide_links_delay(void *data
)
1657 int val
= *(unsigned int *) data
;
1659 ConfigServerHide
.links_delay
= val
;
1663 conf_begin_service(struct TopConf
*tc
)
1665 struct Client
*target_p
;
1668 RB_DLINK_FOREACH(ptr
, global_serv_list
.head
)
1670 target_p
= ptr
->data
;
1672 target_p
->flags
&= ~FLAGS_SERVICE
;
1679 conf_set_service_name(void *data
)
1681 struct Client
*target_p
;
1686 for(s
= data
; *s
!= '\0'; s
++)
1690 conf_report_error("Ignoring service::name "
1691 "-- bogus servername.");
1700 conf_report_error("Ignoring service::name -- must contain '.'");
1704 tmp
= rb_strdup(data
);
1705 rb_dlinkAddAlloc(tmp
, &service_list
);
1707 if((target_p
= find_server(NULL
, tmp
)))
1708 target_p
->flags
|= FLAGS_SERVICE
;
1712 conf_begin_alias(struct TopConf
*tc
)
1714 yy_alias
= rb_malloc(sizeof(struct alias_entry
));
1716 if (conf_cur_block_name
!= NULL
)
1717 yy_alias
->name
= rb_strdup(conf_cur_block_name
);
1719 yy_alias
->flags
= 0;
1726 conf_end_alias(struct TopConf
*tc
)
1728 if (yy_alias
== NULL
)
1731 if (yy_alias
->name
== NULL
)
1733 conf_report_error("Ignoring alias -- must have a name.");
1740 if (yy_alias
->target
== NULL
)
1742 conf_report_error("Ignoring alias -- must have a target.");
1749 irc_dictionary_add(alias_dict
, yy_alias
->name
, yy_alias
);
1755 conf_set_alias_name(void *data
)
1757 if (data
== NULL
|| yy_alias
== NULL
) /* this shouldn't ever happen */
1760 yy_alias
->name
= rb_strdup(data
);
1764 conf_set_alias_target(void *data
)
1766 if (data
== NULL
|| yy_alias
== NULL
) /* this shouldn't ever happen */
1769 yy_alias
->target
= rb_strdup(data
);
1773 conf_set_blacklist_host(void *data
)
1775 yy_blacklist_host
= rb_strdup(data
);
1779 conf_set_blacklist_reason(void *data
)
1781 yy_blacklist_reason
= rb_strdup(data
);
1783 if (yy_blacklist_host
&& yy_blacklist_reason
)
1785 new_blacklist(yy_blacklist_host
, yy_blacklist_reason
);
1786 rb_free(yy_blacklist_host
);
1787 rb_free(yy_blacklist_reason
);
1788 yy_blacklist_host
= NULL
;
1789 yy_blacklist_reason
= NULL
;
1793 /* public functions */
1797 conf_report_error(const char *fmt
, ...)
1800 char msg
[IRCD_BUFSIZE
+ 1] = { 0 };
1803 rb_vsnprintf(msg
, IRCD_BUFSIZE
, fmt
, ap
);
1808 fprintf(stderr
, "\"%s\", line %d: %s\n", current_file
, lineno
+ 1, msg
);
1812 ierror("\"%s\", line %d: %s", current_file
, lineno
+ 1, msg
);
1813 sendto_realops_snomask(SNO_GENERAL
, L_ALL
, "\"%s\", line %d: %s", current_file
, lineno
+ 1, msg
);
1817 conf_start_block(char *block
, char *name
)
1819 if((conf_cur_block
= find_top_conf(block
)) == NULL
)
1821 conf_report_error("Configuration block '%s' is not defined.", block
);
1826 conf_cur_block_name
= rb_strdup(name
);
1828 conf_cur_block_name
= NULL
;
1830 if(conf_cur_block
->tc_sfunc
)
1831 if(conf_cur_block
->tc_sfunc(conf_cur_block
) < 0)
1838 conf_end_block(struct TopConf
*tc
)
1841 return tc
->tc_efunc(tc
);
1843 rb_free(conf_cur_block_name
);
1848 conf_set_generic_int(void *data
, void *location
)
1850 *((int *) location
) = *((unsigned int *) data
);
1854 conf_set_generic_string(void *data
, int len
, void *location
)
1856 char **loc
= location
;
1859 if(len
&& strlen(input
) > (unsigned int)len
)
1863 *loc
= rb_strdup(input
);
1867 conf_call_set(struct TopConf
*tc
, char *item
, conf_parm_t
* value
, int type
)
1869 struct ConfEntry
*cf
;
1875 if((cf
= find_conf_item(tc
, item
)) == NULL
)
1878 ("Non-existant configuration setting %s::%s.", tc
->tc_name
, (char *) item
);
1882 /* if it takes one thing, make sure they only passed one thing,
1883 and handle as needed. */
1884 if((value
->v
.list
->type
& CF_FLIST
) && !(cf
->cf_type
& CF_FLIST
))
1887 ("Option %s::%s does not take a list of values.", tc
->tc_name
, item
);
1894 if(CF_TYPE(value
->v
.list
->type
) != CF_TYPE(cf
->cf_type
))
1896 /* if it expects a string value, but we got a yesno,
1899 if((CF_TYPE(value
->v
.list
->type
) == CF_YESNO
) &&
1900 (CF_TYPE(cf
->cf_type
) == CF_STRING
))
1902 value
->v
.list
->type
= CF_STRING
;
1904 if(cp
->v
.number
== 1)
1905 cp
->v
.string
= rb_strdup("yes");
1907 cp
->v
.string
= rb_strdup("no");
1910 /* maybe it's a CF_TIME and they passed CF_INT --
1911 should still be valid */
1912 else if(!((CF_TYPE(value
->v
.list
->type
) == CF_INT
) &&
1913 (CF_TYPE(cf
->cf_type
) == CF_TIME
)))
1916 ("Wrong type for %s::%s (expected %s, got %s)",
1917 tc
->tc_name
, (char *) item
,
1918 conf_strtype(cf
->cf_type
), conf_strtype(value
->v
.list
->type
));
1923 if(cf
->cf_type
& CF_FLIST
)
1927 conf_set_generic_list(value
->v
.list
, cf
->cf_arg
);
1930 /* just pass it the extended argument list */
1931 cf
->cf_func(value
->v
.list
);
1935 /* it's old-style, needs only one arg */
1936 switch (cf
->cf_type
)
1942 conf_set_generic_int(&cp
->v
.number
, cf
->cf_arg
);
1944 cf
->cf_func(&cp
->v
.number
);
1948 if(EmptyString(cp
->v
.string
))
1949 conf_report_error("Ignoring %s::%s -- empty field",
1952 conf_set_generic_string(cp
->v
.string
, cf
->cf_len
, cf
->cf_arg
);
1954 cf
->cf_func(cp
->v
.string
);
1964 add_conf_item(const char *topconf
, const char *name
, int type
, void (*func
) (void *))
1967 struct ConfEntry
*cf
;
1969 if((tc
= find_top_conf(topconf
)) == NULL
)
1972 if((cf
= find_conf_item(tc
, name
)) != NULL
)
1975 cf
= rb_malloc(sizeof(struct ConfEntry
));
1982 rb_dlinkAddAlloc(cf
, &tc
->tc_items
);
1988 remove_conf_item(const char *topconf
, const char *name
)
1991 struct ConfEntry
*cf
;
1994 if((tc
= find_top_conf(topconf
)) == NULL
)
1997 if((cf
= find_conf_item(tc
, name
)) == NULL
)
2000 if((ptr
= rb_dlinkFind(cf
, &tc
->tc_items
)) == NULL
)
2003 rb_dlinkDestroy(ptr
, &tc
->tc_items
);
2010 static struct ConfEntry conf_serverinfo_table
[] =
2012 { "description", CF_QSTRING
, NULL
, 0, &ServerInfo
.description
},
2013 { "network_desc", CF_QSTRING
, NULL
, 0, &ServerInfo
.network_desc
},
2014 { "hub", CF_YESNO
, NULL
, 0, &ServerInfo
.hub
},
2016 { "network_name", CF_QSTRING
, conf_set_serverinfo_network_name
, 0, NULL
},
2017 { "name", CF_QSTRING
, conf_set_serverinfo_name
, 0, NULL
},
2018 { "sid", CF_QSTRING
, conf_set_serverinfo_sid
, 0, NULL
},
2019 { "vhost", CF_QSTRING
, conf_set_serverinfo_vhost
, 0, NULL
},
2020 { "vhost6", CF_QSTRING
, conf_set_serverinfo_vhost6
, 0, NULL
},
2022 { "ssl_private_key", CF_QSTRING
, NULL
, 0, &ServerInfo
.ssl_private_key
},
2023 { "ssl_ca_cert", CF_QSTRING
, NULL
, 0, &ServerInfo
.ssl_ca_cert
},
2024 { "ssl_cert", CF_QSTRING
, NULL
, 0, &ServerInfo
.ssl_cert
},
2025 { "ssl_dh_params", CF_QSTRING
, NULL
, 0, &ServerInfo
.ssl_dh_params
},
2026 { "ssld_count", CF_INT
, NULL
, 0, &ServerInfo
.ssld_count
},
2028 { "default_max_clients",CF_INT
, NULL
, 0, &ServerInfo
.default_max_clients
},
2030 { "\0", 0, NULL
, 0, NULL
}
2033 static struct ConfEntry conf_admin_table
[] =
2035 { "name", CF_QSTRING
, NULL
, 200, &AdminInfo
.name
},
2036 { "description",CF_QSTRING
, NULL
, 200, &AdminInfo
.description
},
2037 { "email", CF_QSTRING
, NULL
, 200, &AdminInfo
.email
},
2038 { "\0", 0, NULL
, 0, NULL
}
2041 static struct ConfEntry conf_log_table
[] =
2043 { "fname_userlog", CF_QSTRING
, NULL
, MAXPATHLEN
, &ConfigFileEntry
.fname_userlog
},
2044 { "fname_fuserlog", CF_QSTRING
, NULL
, MAXPATHLEN
, &ConfigFileEntry
.fname_fuserlog
},
2045 { "fname_operlog", CF_QSTRING
, NULL
, MAXPATHLEN
, &ConfigFileEntry
.fname_operlog
},
2046 { "fname_foperlog", CF_QSTRING
, NULL
, MAXPATHLEN
, &ConfigFileEntry
.fname_foperlog
},
2047 { "fname_serverlog", CF_QSTRING
, NULL
, MAXPATHLEN
, &ConfigFileEntry
.fname_serverlog
},
2048 { "fname_killlog", CF_QSTRING
, NULL
, MAXPATHLEN
, &ConfigFileEntry
.fname_killlog
},
2049 { "fname_klinelog", CF_QSTRING
, NULL
, MAXPATHLEN
, &ConfigFileEntry
.fname_klinelog
},
2050 { "fname_operspylog", CF_QSTRING
, NULL
, MAXPATHLEN
, &ConfigFileEntry
.fname_operspylog
},
2051 { "fname_ioerrorlog", CF_QSTRING
, NULL
, MAXPATHLEN
, &ConfigFileEntry
.fname_ioerrorlog
},
2052 { "\0", 0, NULL
, 0, NULL
}
2055 static struct ConfEntry conf_operator_table
[] =
2057 { "rsa_public_key_file", CF_QSTRING
, conf_set_oper_rsa_public_key_file
, 0, NULL
},
2058 { "flags", CF_STRING
| CF_FLIST
, conf_set_oper_flags
, 0, NULL
},
2059 { "umodes", CF_STRING
| CF_FLIST
, conf_set_oper_umodes
, 0, NULL
},
2060 { "privset", CF_QSTRING
, conf_set_oper_privset
, 0, NULL
},
2061 { "snomask", CF_QSTRING
, conf_set_oper_snomask
, 0, NULL
},
2062 { "user", CF_QSTRING
, conf_set_oper_user
, 0, NULL
},
2063 { "password", CF_QSTRING
, conf_set_oper_password
, 0, NULL
},
2064 { "fingerprint", CF_QSTRING
, conf_set_oper_fingerprint
, 0, NULL
},
2065 { "\0", 0, NULL
, 0, NULL
}
2068 static struct ConfEntry conf_privset_table
[] =
2070 { "extends", CF_QSTRING
, conf_set_privset_extends
, 0, NULL
},
2071 { "privs", CF_STRING
| CF_FLIST
, conf_set_privset_privs
, 0, NULL
},
2072 { "\0", 0, NULL
, 0, NULL
}
2075 static struct ConfEntry conf_class_table
[] =
2077 { "ping_time", CF_TIME
, conf_set_class_ping_time
, 0, NULL
},
2078 { "cidr_ipv4_bitlen", CF_INT
, conf_set_class_cidr_ipv4_bitlen
, 0, NULL
},
2080 { "cidr_ipv6_bitlen", CF_INT
, conf_set_class_cidr_ipv6_bitlen
, 0, NULL
},
2082 { "number_per_cidr", CF_INT
, conf_set_class_number_per_cidr
, 0, NULL
},
2083 { "number_per_ip", CF_INT
, conf_set_class_number_per_ip
, 0, NULL
},
2084 { "number_per_ip_global", CF_INT
,conf_set_class_number_per_ip_global
, 0, NULL
},
2085 { "number_per_ident", CF_INT
, conf_set_class_number_per_ident
, 0, NULL
},
2086 { "connectfreq", CF_TIME
, conf_set_class_connectfreq
, 0, NULL
},
2087 { "max_number", CF_INT
, conf_set_class_max_number
, 0, NULL
},
2088 { "sendq", CF_TIME
, conf_set_class_sendq
, 0, NULL
},
2089 { "\0", 0, NULL
, 0, NULL
}
2092 static struct ConfEntry conf_auth_table
[] =
2094 { "user", CF_QSTRING
, conf_set_auth_user
, 0, NULL
},
2095 { "auth_user", CF_QSTRING
, conf_set_auth_auth_user
, 0, NULL
},
2096 { "password", CF_QSTRING
, conf_set_auth_passwd
, 0, NULL
},
2097 { "class", CF_QSTRING
, conf_set_auth_class
, 0, NULL
},
2098 { "spoof", CF_QSTRING
, conf_set_auth_spoof
, 0, NULL
},
2099 { "redirserv", CF_QSTRING
, conf_set_auth_redir_serv
, 0, NULL
},
2100 { "redirport", CF_INT
, conf_set_auth_redir_port
, 0, NULL
},
2101 { "flags", CF_STRING
| CF_FLIST
, conf_set_auth_flags
, 0, NULL
},
2102 { "\0", 0, NULL
, 0, NULL
}
2105 static struct ConfEntry conf_connect_table
[] =
2107 { "send_password", CF_QSTRING
, conf_set_connect_send_password
, 0, NULL
},
2108 { "accept_password", CF_QSTRING
, conf_set_connect_accept_password
, 0, NULL
},
2109 { "fingerprint", CF_QSTRING
, conf_set_connect_fingerprint
, 0, NULL
},
2110 { "flags", CF_STRING
| CF_FLIST
, conf_set_connect_flags
, 0, NULL
},
2111 { "host", CF_QSTRING
, conf_set_connect_host
, 0, NULL
},
2112 { "vhost", CF_QSTRING
, conf_set_connect_vhost
, 0, NULL
},
2113 { "port", CF_INT
, conf_set_connect_port
, 0, NULL
},
2114 { "aftype", CF_STRING
, conf_set_connect_aftype
, 0, NULL
},
2115 { "hub_mask", CF_QSTRING
, conf_set_connect_hub_mask
, 0, NULL
},
2116 { "leaf_mask", CF_QSTRING
, conf_set_connect_leaf_mask
, 0, NULL
},
2117 { "class", CF_QSTRING
, conf_set_connect_class
, 0, NULL
},
2118 { "\0", 0, NULL
, 0, NULL
}
2121 static struct ConfEntry conf_general_table
[] =
2123 { "oper_only_umodes", CF_STRING
| CF_FLIST
, conf_set_general_oper_only_umodes
, 0, NULL
},
2124 { "oper_umodes", CF_STRING
| CF_FLIST
, conf_set_general_oper_umodes
, 0, NULL
},
2125 { "oper_snomask", CF_QSTRING
, conf_set_general_oper_snomask
, 0, NULL
},
2126 { "compression_level", CF_INT
, conf_set_general_compression_level
, 0, NULL
},
2127 { "havent_read_conf", CF_YESNO
, conf_set_general_havent_read_conf
, 0, NULL
},
2128 { "hide_error_messages",CF_STRING
, conf_set_general_hide_error_messages
,0, NULL
},
2129 { "kline_delay", CF_TIME
, conf_set_general_kline_delay
, 0, NULL
},
2130 { "stats_k_oper_only", CF_STRING
, conf_set_general_stats_k_oper_only
, 0, NULL
},
2131 { "stats_i_oper_only", CF_STRING
, conf_set_general_stats_i_oper_only
, 0, NULL
},
2132 { "default_umodes", CF_QSTRING
, conf_set_general_default_umodes
, 0, NULL
},
2134 { "default_operstring", CF_QSTRING
, NULL
, REALLEN
, &ConfigFileEntry
.default_operstring
},
2135 { "default_adminstring",CF_QSTRING
, NULL
, REALLEN
, &ConfigFileEntry
.default_adminstring
},
2136 { "servicestring", CF_QSTRING
, NULL
, REALLEN
, &ConfigFileEntry
.servicestring
},
2137 { "egdpool_path", CF_QSTRING
, NULL
, MAXPATHLEN
, &ConfigFileEntry
.egdpool_path
},
2138 { "kline_reason", CF_QSTRING
, NULL
, REALLEN
, &ConfigFileEntry
.kline_reason
},
2139 { "identify_service", CF_QSTRING
, NULL
, REALLEN
, &ConfigFileEntry
.identifyservice
},
2140 { "identify_command", CF_QSTRING
, NULL
, REALLEN
, &ConfigFileEntry
.identifycommand
},
2142 { "anti_spam_exit_message_time", CF_TIME
, NULL
, 0, &ConfigFileEntry
.anti_spam_exit_message_time
},
2143 { "disable_fake_channels", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.disable_fake_channels
},
2144 { "min_nonwildcard_simple", CF_INT
, NULL
, 0, &ConfigFileEntry
.min_nonwildcard_simple
},
2145 { "non_redundant_klines", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.non_redundant_klines
},
2146 { "tkline_expire_notices", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.tkline_expire_notices
},
2148 { "anti_nick_flood", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.anti_nick_flood
},
2149 { "burst_away", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.burst_away
},
2150 { "caller_id_wait", CF_TIME
, NULL
, 0, &ConfigFileEntry
.caller_id_wait
},
2151 { "client_exit", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.client_exit
},
2152 { "client_flood", CF_INT
, NULL
, 0, &ConfigFileEntry
.client_flood
},
2153 { "collision_fnc", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.collision_fnc
},
2154 { "connect_timeout", CF_TIME
, NULL
, 0, &ConfigFileEntry
.connect_timeout
},
2155 { "default_floodcount", CF_INT
, NULL
, 0, &ConfigFileEntry
.default_floodcount
},
2156 { "default_ident_timeout", CF_INT
, NULL
, 0, &ConfigFileEntry
.default_ident_timeout
},
2157 { "disable_auth", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.disable_auth
},
2158 { "dots_in_ident", CF_INT
, NULL
, 0, &ConfigFileEntry
.dots_in_ident
},
2159 { "failed_oper_notice", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.failed_oper_notice
},
2160 { "global_snotices", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.global_snotices
},
2161 { "hide_spoof_ips", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.hide_spoof_ips
},
2162 { "dline_with_reason", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.dline_with_reason
},
2163 { "kline_with_reason", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.kline_with_reason
},
2164 { "map_oper_only", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.map_oper_only
},
2165 { "max_accept", CF_INT
, NULL
, 0, &ConfigFileEntry
.max_accept
},
2166 { "max_monitor", CF_INT
, NULL
, 0, &ConfigFileEntry
.max_monitor
},
2167 { "max_nick_time", CF_TIME
, NULL
, 0, &ConfigFileEntry
.max_nick_time
},
2168 { "max_nick_changes", CF_INT
, NULL
, 0, &ConfigFileEntry
.max_nick_changes
},
2169 { "max_targets", CF_INT
, NULL
, 0, &ConfigFileEntry
.max_targets
},
2170 { "min_nonwildcard", CF_INT
, NULL
, 0, &ConfigFileEntry
.min_nonwildcard
},
2171 { "nick_delay", CF_TIME
, NULL
, 0, &ConfigFileEntry
.nick_delay
},
2172 { "no_oper_flood", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.no_oper_flood
},
2173 { "operspy_admin_only", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.operspy_admin_only
},
2174 { "operspy_dont_care_user_info", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.operspy_dont_care_user_info
},
2175 { "pace_wait", CF_TIME
, NULL
, 0, &ConfigFileEntry
.pace_wait
},
2176 { "pace_wait_simple", CF_TIME
, NULL
, 0, &ConfigFileEntry
.pace_wait_simple
},
2177 { "ping_cookie", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.ping_cookie
},
2178 { "reject_after_count", CF_INT
, NULL
, 0, &ConfigFileEntry
.reject_after_count
},
2179 { "reject_ban_time", CF_TIME
, NULL
, 0, &ConfigFileEntry
.reject_ban_time
},
2180 { "reject_duration", CF_TIME
, NULL
, 0, &ConfigFileEntry
.reject_duration
},
2181 { "throttle_count", CF_INT
, NULL
, 0, &ConfigFileEntry
.throttle_count
},
2182 { "throttle_duration", CF_TIME
, NULL
, 0, &ConfigFileEntry
.throttle_duration
},
2183 { "short_motd", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.short_motd
},
2184 { "stats_c_oper_only", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.stats_c_oper_only
},
2185 { "stats_e_disabled", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.stats_e_disabled
},
2186 { "stats_h_oper_only", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.stats_h_oper_only
},
2187 { "stats_o_oper_only", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.stats_o_oper_only
},
2188 { "stats_P_oper_only", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.stats_P_oper_only
},
2189 { "stats_y_oper_only", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.stats_y_oper_only
},
2190 { "target_change", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.target_change
},
2191 { "ts_max_delta", CF_TIME
, NULL
, 0, &ConfigFileEntry
.ts_max_delta
},
2192 { "use_egd", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.use_egd
},
2193 { "ts_warn_delta", CF_TIME
, NULL
, 0, &ConfigFileEntry
.ts_warn_delta
},
2194 { "use_whois_actually", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.use_whois_actually
},
2195 { "warn_no_nline", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.warn_no_nline
},
2196 { "use_propagated_bans",CF_YESNO
, NULL
, 0, &ConfigFileEntry
.use_propagated_bans
},
2197 { "\0", 0, NULL
, 0, NULL
}
2200 static struct ConfEntry conf_channel_table
[] =
2202 { "default_split_user_count", CF_INT
, NULL
, 0, &ConfigChannel
.default_split_user_count
},
2203 { "default_split_server_count", CF_INT
, NULL
, 0, &ConfigChannel
.default_split_server_count
},
2204 { "burst_topicwho", CF_YESNO
, NULL
, 0, &ConfigChannel
.burst_topicwho
},
2205 { "kick_on_split_riding", CF_YESNO
, NULL
, 0, &ConfigChannel
.kick_on_split_riding
},
2206 { "knock_delay", CF_TIME
, NULL
, 0, &ConfigChannel
.knock_delay
},
2207 { "knock_delay_channel",CF_TIME
, NULL
, 0, &ConfigChannel
.knock_delay_channel
},
2208 { "max_bans", CF_INT
, NULL
, 0, &ConfigChannel
.max_bans
},
2209 { "max_bans_large", CF_INT
, NULL
, 0, &ConfigChannel
.max_bans_large
},
2210 { "max_chans_per_user", CF_INT
, NULL
, 0, &ConfigChannel
.max_chans_per_user
},
2211 { "no_create_on_split", CF_YESNO
, NULL
, 0, &ConfigChannel
.no_create_on_split
},
2212 { "no_join_on_split", CF_YESNO
, NULL
, 0, &ConfigChannel
.no_join_on_split
},
2213 { "only_ascii_channels", CF_YESNO
, NULL
, 0, &ConfigChannel
.only_ascii_channels
},
2214 { "use_except", CF_YESNO
, NULL
, 0, &ConfigChannel
.use_except
},
2215 { "use_invex", CF_YESNO
, NULL
, 0, &ConfigChannel
.use_invex
},
2216 { "use_knock", CF_YESNO
, NULL
, 0, &ConfigChannel
.use_knock
},
2217 { "use_forward", CF_YESNO
, NULL
, 0, &ConfigChannel
.use_forward
},
2218 { "resv_forcepart", CF_YESNO
, NULL
, 0, &ConfigChannel
.resv_forcepart
},
2219 { "channel_target_change", CF_YESNO
, NULL
, 0, &ConfigChannel
.channel_target_change
},
2220 { "disable_local_channels", CF_YESNO
, NULL
, 0, &ConfigChannel
.disable_local_channels
},
2221 { "\0", 0, NULL
, 0, NULL
}
2224 static struct ConfEntry conf_serverhide_table
[] =
2226 { "disable_hidden", CF_YESNO
, NULL
, 0, &ConfigServerHide
.disable_hidden
},
2227 { "flatten_links", CF_YESNO
, NULL
, 0, &ConfigServerHide
.flatten_links
},
2228 { "hidden", CF_YESNO
, NULL
, 0, &ConfigServerHide
.hidden
},
2229 { "links_delay", CF_TIME
, conf_set_serverhide_links_delay
, 0, NULL
},
2230 { "\0", 0, NULL
, 0, NULL
}
2237 add_top_conf("modules", NULL
, NULL
, NULL
);
2238 add_conf_item("modules", "path", CF_QSTRING
, conf_set_modules_path
);
2239 add_conf_item("modules", "module", CF_QSTRING
, conf_set_modules_module
);
2241 add_top_conf("serverinfo", NULL
, NULL
, conf_serverinfo_table
);
2242 add_top_conf("admin", NULL
, NULL
, conf_admin_table
);
2243 add_top_conf("log", NULL
, NULL
, conf_log_table
);
2244 add_top_conf("operator", conf_begin_oper
, conf_end_oper
, conf_operator_table
);
2245 add_top_conf("class", conf_begin_class
, conf_end_class
, conf_class_table
);
2246 add_top_conf("privset", NULL
, NULL
, conf_privset_table
);
2248 add_top_conf("listen", conf_begin_listen
, conf_end_listen
, NULL
);
2249 add_conf_item("listen", "port", CF_INT
| CF_FLIST
, conf_set_listen_port
);
2250 add_conf_item("listen", "sslport", CF_INT
| CF_FLIST
, conf_set_listen_sslport
);
2251 add_conf_item("listen", "ip", CF_QSTRING
, conf_set_listen_address
);
2252 add_conf_item("listen", "host", CF_QSTRING
, conf_set_listen_address
);
2254 add_top_conf("auth", conf_begin_auth
, conf_end_auth
, conf_auth_table
);
2256 add_top_conf("shared", conf_cleanup_shared
, conf_cleanup_shared
, NULL
);
2257 add_conf_item("shared", "oper", CF_QSTRING
|CF_FLIST
, conf_set_shared_oper
);
2258 add_conf_item("shared", "flags", CF_STRING
| CF_FLIST
, conf_set_shared_flags
);
2260 add_top_conf("connect", conf_begin_connect
, conf_end_connect
, conf_connect_table
);
2262 add_top_conf("exempt", NULL
, NULL
, NULL
);
2263 add_conf_item("exempt", "ip", CF_QSTRING
, conf_set_exempt_ip
);
2265 add_top_conf("cluster", conf_cleanup_cluster
, conf_cleanup_cluster
, NULL
);
2266 add_conf_item("cluster", "name", CF_QSTRING
, conf_set_cluster_name
);
2267 add_conf_item("cluster", "flags", CF_STRING
| CF_FLIST
, conf_set_cluster_flags
);
2269 add_top_conf("general", NULL
, NULL
, conf_general_table
);
2270 add_top_conf("channel", NULL
, NULL
, conf_channel_table
);
2271 add_top_conf("serverhide", NULL
, NULL
, conf_serverhide_table
);
2273 add_top_conf("service", conf_begin_service
, NULL
, NULL
);
2274 add_conf_item("service", "name", CF_QSTRING
, conf_set_service_name
);
2276 add_top_conf("alias", conf_begin_alias
, conf_end_alias
, NULL
);
2277 add_conf_item("alias", "name", CF_QSTRING
, conf_set_alias_name
);
2278 add_conf_item("alias", "target", CF_QSTRING
, conf_set_alias_target
);
2280 add_top_conf("blacklist", NULL
, NULL
, NULL
);
2281 add_conf_item("blacklist", "host", CF_QSTRING
, conf_set_blacklist_host
);
2282 add_conf_item("blacklist", "reject_reason", CF_QSTRING
, conf_set_blacklist_reason
);