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
},
306 {"noctcp", UMODE_NOCTCP
},
307 {"noinvite", UMODE_NOINVITE
},
312 static struct mode_table oper_table
[] = {
313 {"encrypted", OPER_ENCRYPTED
},
314 {"need_ssl", OPER_NEEDSSL
},
318 static struct mode_table auth_table
[] = {
319 {"encrypted", CONF_FLAGS_ENCRYPTED
},
320 {"spoof_notice", CONF_FLAGS_SPOOF_NOTICE
},
321 {"exceed_limit", CONF_FLAGS_NOLIMIT
},
322 {"dnsbl_exempt", CONF_FLAGS_EXEMPTDNSBL
},
323 {"kline_exempt", CONF_FLAGS_EXEMPTKLINE
},
324 {"flood_exempt", CONF_FLAGS_EXEMPTFLOOD
},
325 {"spambot_exempt", CONF_FLAGS_EXEMPTSPAMBOT
},
326 {"shide_exempt", CONF_FLAGS_EXEMPTSHIDE
},
327 {"jupe_exempt", CONF_FLAGS_EXEMPTJUPE
},
328 {"resv_exempt", CONF_FLAGS_EXEMPTRESV
},
329 {"no_tilde", CONF_FLAGS_NO_TILDE
},
330 {"need_ident", CONF_FLAGS_NEED_IDENTD
},
331 {"have_ident", CONF_FLAGS_NEED_IDENTD
},
332 {"need_ssl", CONF_FLAGS_NEED_SSL
},
333 {"need_sasl", CONF_FLAGS_NEED_SASL
},
337 static struct mode_table connect_table
[] = {
338 { "autoconn", SERVER_AUTOCONN
},
339 { "compressed", SERVER_COMPRESSED
},
340 { "encrypted", SERVER_ENCRYPTED
},
341 { "topicburst", SERVER_TB
},
342 { "ssl", SERVER_SSL
},
346 static struct mode_table cluster_table
[] = {
347 { "kline", SHARED_PKLINE
},
348 { "tkline", SHARED_TKLINE
},
349 { "unkline", SHARED_UNKLINE
},
350 { "locops", SHARED_LOCOPS
},
351 { "xline", SHARED_PXLINE
},
352 { "txline", SHARED_TXLINE
},
353 { "unxline", SHARED_UNXLINE
},
354 { "resv", SHARED_PRESV
},
355 { "tresv", SHARED_TRESV
},
356 { "unresv", SHARED_UNRESV
},
357 { "all", CLUSTER_ALL
},
361 static struct mode_table shared_table
[] =
363 { "kline", SHARED_PKLINE
|SHARED_TKLINE
},
364 { "xline", SHARED_PXLINE
|SHARED_TXLINE
},
365 { "resv", SHARED_PRESV
|SHARED_TRESV
},
366 { "dline", SHARED_PDLINE
|SHARED_TDLINE
},
367 { "tdline", SHARED_TDLINE
},
368 { "pdline", SHARED_PDLINE
},
369 { "undline", SHARED_UNDLINE
},
370 { "tkline", SHARED_TKLINE
},
371 { "unkline", SHARED_UNKLINE
},
372 { "txline", SHARED_TXLINE
},
373 { "unxline", SHARED_UNXLINE
},
374 { "tresv", SHARED_TRESV
},
375 { "unresv", SHARED_UNRESV
},
376 { "locops", SHARED_LOCOPS
},
377 { "rehash", SHARED_REHASH
},
378 { "all", SHARED_ALL
},
385 find_umode(struct mode_table
*tab
, const char *name
)
389 for (i
= 0; tab
[i
].name
; i
++)
391 if(strcmp(tab
[i
].name
, name
) == 0)
399 set_modes_from_table(int *modes
, const char *whatis
, struct mode_table
*tab
, conf_parm_t
* args
)
401 for (; args
; args
= args
->next
)
407 if((args
->type
& CF_MTYPE
) != CF_STRING
)
409 conf_report_error("Warning -- %s is not a string; ignoring.", whatis
);
413 umode
= args
->v
.string
;
421 mode
= find_umode(tab
, umode
);
425 conf_report_error("Warning -- unknown %s %s.", whatis
, args
->v
.string
);
442 conf_set_privset_extends(void *data
)
444 yy_privset_extends
= rb_strdup((char *) data
);
448 conf_set_privset_privs(void *data
)
451 conf_parm_t
*args
= data
;
453 for (; args
; args
= args
->next
)
456 privs
= rb_strdup(args
->v
.string
);
459 char *privs_old
= privs
;
461 privs
= rb_malloc(strlen(privs_old
) + 1 + strlen(args
->v
.string
) + 1);
462 strcpy(privs
, privs_old
);
464 strcat(privs
, args
->v
.string
);
472 if (yy_privset_extends
)
474 struct PrivilegeSet
*set
= privilegeset_get(yy_privset_extends
);
478 conf_report_error("Warning -- unknown parent privilege set %s for %s; assuming defaults", yy_privset_extends
, conf_cur_block_name
);
480 set
= privilegeset_get("default");
483 privilegeset_extend(set
, conf_cur_block_name
!= NULL
? conf_cur_block_name
: "<unknown>", privs
, 0);
485 rb_free(yy_privset_extends
);
486 yy_privset_extends
= NULL
;
489 privilegeset_set_new(conf_cur_block_name
!= NULL
? conf_cur_block_name
: "<unknown>", privs
, 0);
496 conf_begin_oper(struct TopConf
*tc
)
499 rb_dlink_node
*next_ptr
;
503 free_oper_conf(yy_oper
);
507 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, yy_oper_list
.head
)
509 free_oper_conf(ptr
->data
);
510 rb_dlinkDestroy(ptr
, &yy_oper_list
);
513 yy_oper
= make_oper_conf();
514 yy_oper
->flags
|= OPER_ENCRYPTED
;
520 conf_end_oper(struct TopConf
*tc
)
522 struct oper_conf
*yy_tmpoper
;
524 rb_dlink_node
*next_ptr
;
526 if(conf_cur_block_name
!= NULL
)
528 if(strlen(conf_cur_block_name
) > OPERNICKLEN
)
529 conf_cur_block_name
[OPERNICKLEN
] = '\0';
531 yy_oper
->name
= rb_strdup(conf_cur_block_name
);
534 if(EmptyString(yy_oper
->name
))
536 conf_report_error("Ignoring operator block -- missing name.");
540 #ifdef HAVE_LIBCRYPTO
541 if(EmptyString(yy_oper
->passwd
) && EmptyString(yy_oper
->rsa_pubkey_file
))
543 if(EmptyString(yy_oper
->passwd
))
546 conf_report_error("Ignoring operator block for %s -- missing password",
552 if (!yy_oper
->privset
)
553 yy_oper
->privset
= privilegeset_get("default");
555 /* now, yy_oper_list contains a stack of oper_conf's with just user
556 * and host in, yy_oper contains the rest of the information which
557 * we need to copy into each element in yy_oper_list
559 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, yy_oper_list
.head
)
561 yy_tmpoper
= ptr
->data
;
563 yy_tmpoper
->name
= rb_strdup(yy_oper
->name
);
565 /* could be an rsa key instead.. */
566 if(!EmptyString(yy_oper
->passwd
))
567 yy_tmpoper
->passwd
= rb_strdup(yy_oper
->passwd
);
569 yy_tmpoper
->flags
= yy_oper
->flags
;
570 yy_tmpoper
->umodes
= yy_oper
->umodes
;
571 yy_tmpoper
->snomask
= yy_oper
->snomask
;
572 yy_tmpoper
->privset
= yy_oper
->privset
;
574 #ifdef HAVE_LIBCRYPTO
575 if(yy_oper
->rsa_pubkey_file
)
579 if((file
= BIO_new_file(yy_oper
->rsa_pubkey_file
, "r")) == NULL
)
581 conf_report_error("Ignoring operator block for %s -- "
582 "rsa_public_key_file cant be opened",
587 yy_tmpoper
->rsa_pubkey
=
588 (RSA
*) PEM_read_bio_RSA_PUBKEY(file
, NULL
, 0, NULL
);
590 (void)BIO_set_close(file
, BIO_CLOSE
);
593 if(yy_tmpoper
->rsa_pubkey
== NULL
)
595 conf_report_error("Ignoring operator block for %s -- "
596 "rsa_public_key_file key invalid; check syntax",
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
)
624 yy_oper
->certfp
= rb_strdup((char *) data
);
628 conf_set_oper_privset(void *data
)
630 yy_oper
->privset
= privilegeset_get((char *) data
);
634 conf_set_oper_user(void *data
)
636 struct oper_conf
*yy_tmpoper
;
638 char *host
= (char *) data
;
640 yy_tmpoper
= make_oper_conf();
642 if((p
= strchr(host
, '@')))
646 yy_tmpoper
->username
= rb_strdup(host
);
647 yy_tmpoper
->host
= rb_strdup(p
);
652 yy_tmpoper
->username
= rb_strdup("*");
653 yy_tmpoper
->host
= rb_strdup(host
);
656 if(EmptyString(yy_tmpoper
->username
) || EmptyString(yy_tmpoper
->host
))
658 conf_report_error("Ignoring user -- missing username/host");
659 free_oper_conf(yy_tmpoper
);
663 rb_dlinkAddAlloc(yy_tmpoper
, &yy_oper_list
);
667 conf_set_oper_password(void *data
)
671 memset(yy_oper
->passwd
, 0, strlen(yy_oper
->passwd
));
672 rb_free(yy_oper
->passwd
);
675 yy_oper
->passwd
= rb_strdup((char *) data
);
679 conf_set_oper_rsa_public_key_file(void *data
)
681 #ifdef HAVE_LIBCRYPTO
682 rb_free(yy_oper
->rsa_pubkey_file
);
683 yy_oper
->rsa_pubkey_file
= rb_strdup((char *) data
);
685 conf_report_error("Warning -- ignoring rsa_public_key_file (OpenSSL support not available");
690 conf_set_oper_umodes(void *data
)
692 set_modes_from_table(&yy_oper
->umodes
, "umode", umode_table
, data
);
696 conf_set_oper_snomask(void *data
)
698 yy_oper
->snomask
= parse_snobuf_to_mask(0, (const char *) data
);
702 conf_begin_class(struct TopConf
*tc
)
705 free_class(yy_class
);
707 yy_class
= make_class();
712 conf_end_class(struct TopConf
*tc
)
714 if(conf_cur_block_name
!= NULL
)
715 yy_class
->class_name
= rb_strdup(conf_cur_block_name
);
717 if(EmptyString(yy_class
->class_name
))
719 conf_report_error("Ignoring connect block -- missing name.");
729 conf_set_class_ping_time(void *data
)
731 yy_class
->ping_freq
= *(unsigned int *) data
;
735 conf_set_class_cidr_ipv4_bitlen(void *data
)
737 unsigned int maxsize
= 32;
738 if(*(unsigned int *) data
> maxsize
)
740 ("class::cidr_ipv4_bitlen argument exceeds maxsize (%d > %d) - ignoring.",
741 *(unsigned int *) data
, maxsize
);
743 yy_class
->cidr_ipv4_bitlen
= *(unsigned int *) data
;
749 conf_set_class_cidr_ipv6_bitlen(void *data
)
751 unsigned int maxsize
= 128;
752 if(*(unsigned int *) data
> maxsize
)
754 ("class::cidr_ipv6_bitlen argument exceeds maxsize (%d > %d) - ignoring.",
755 *(unsigned int *) data
, maxsize
);
757 yy_class
->cidr_ipv6_bitlen
= *(unsigned int *) data
;
763 conf_set_class_number_per_cidr(void *data
)
765 yy_class
->cidr_amount
= *(unsigned int *) data
;
769 conf_set_class_number_per_ip(void *data
)
771 yy_class
->max_local
= *(unsigned int *) data
;
776 conf_set_class_number_per_ip_global(void *data
)
778 yy_class
->max_global
= *(unsigned int *) data
;
782 conf_set_class_number_per_ident(void *data
)
784 yy_class
->max_ident
= *(unsigned int *) data
;
788 conf_set_class_connectfreq(void *data
)
790 yy_class
->con_freq
= *(unsigned int *) data
;
794 conf_set_class_max_number(void *data
)
796 yy_class
->max_total
= *(unsigned int *) data
;
800 conf_set_class_sendq(void *data
)
802 yy_class
->max_sendq
= *(unsigned int *) data
;
805 static char *listener_address
;
808 conf_begin_listen(struct TopConf
*tc
)
810 rb_free(listener_address
);
811 listener_address
= NULL
;
816 conf_end_listen(struct TopConf
*tc
)
818 rb_free(listener_address
);
819 listener_address
= NULL
;
826 conf_set_listen_port_both(void *data
, int ssl
)
828 conf_parm_t
*args
= data
;
829 for (; args
; args
= args
->next
)
831 if((args
->type
& CF_MTYPE
) != CF_INT
)
834 ("listener::port argument is not an integer " "-- ignoring.");
837 if(listener_address
== NULL
)
839 add_listener(args
->v
.number
, listener_address
, AF_INET
, ssl
);
841 add_listener(args
->v
.number
, listener_address
, AF_INET6
, ssl
);
848 if(strchr(listener_address
, ':') != NULL
)
854 add_listener(args
->v
.number
, listener_address
, family
, ssl
);
862 conf_set_listen_port(void *data
)
864 conf_set_listen_port_both(data
, 0);
868 conf_set_listen_sslport(void *data
)
870 conf_set_listen_port_both(data
, 1);
874 conf_set_listen_address(void *data
)
876 rb_free(listener_address
);
877 listener_address
= rb_strdup(data
);
881 conf_begin_auth(struct TopConf
*tc
)
884 rb_dlink_node
*next_ptr
;
889 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, yy_aconf_list
.head
)
891 free_conf(ptr
->data
);
892 rb_dlinkDestroy(ptr
, &yy_aconf_list
);
895 yy_aconf
= make_conf();
896 yy_aconf
->status
= CONF_CLIENT
;
902 conf_end_auth(struct TopConf
*tc
)
904 struct ConfItem
*yy_tmp
, *found_conf
;
906 rb_dlink_node
*next_ptr
;
908 if(EmptyString(yy_aconf
->name
))
909 yy_aconf
->name
= rb_strdup("NOMATCH");
911 /* didnt even get one ->host? */
912 if(EmptyString(yy_aconf
->host
))
914 conf_report_error("Ignoring auth block -- missing user@host");
918 /* so the stacking works in order.. */
919 collapse(yy_aconf
->user
);
920 collapse(yy_aconf
->host
);
921 conf_add_class_to_conf(yy_aconf
);
922 if ((found_conf
= find_exact_conf_by_address("*", CONF_CLIENT
, "*")) && found_conf
->spasswd
== NULL
)
923 conf_report_error("Ignoring redundant auth block (after *@*)");
924 else if ((found_conf
= find_exact_conf_by_address(yy_aconf
->host
, CONF_CLIENT
, yy_aconf
->user
)) &&
925 (!found_conf
->spasswd
|| (yy_aconf
->spasswd
&&
926 0 == irccmp(found_conf
->spasswd
, yy_aconf
->spasswd
))))
927 conf_report_error("Ignoring duplicate auth block for %s@%s",
928 yy_aconf
->user
, yy_aconf
->host
);
930 add_conf_by_address(yy_aconf
->host
, CONF_CLIENT
, yy_aconf
->user
, yy_aconf
->spasswd
, yy_aconf
);
932 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, yy_aconf_list
.head
)
937 yy_tmp
->passwd
= rb_strdup(yy_aconf
->passwd
);
939 if(yy_aconf
->spasswd
)
940 yy_tmp
->spasswd
= rb_strdup(yy_aconf
->spasswd
);
942 /* this will always exist.. */
943 yy_tmp
->name
= rb_strdup(yy_aconf
->name
);
945 if(yy_aconf
->className
)
946 yy_tmp
->className
= rb_strdup(yy_aconf
->className
);
948 yy_tmp
->flags
= yy_aconf
->flags
;
949 yy_tmp
->port
= yy_aconf
->port
;
951 collapse(yy_tmp
->user
);
952 collapse(yy_tmp
->host
);
954 conf_add_class_to_conf(yy_tmp
);
956 if (find_exact_conf_by_address("*", CONF_CLIENT
, "*"))
957 conf_report_error("Ignoring redundant auth block (after *@*)");
958 else if (find_exact_conf_by_address(yy_tmp
->host
, CONF_CLIENT
, yy_tmp
->user
))
959 conf_report_error("Ignoring duplicate auth block for %s@%s",
960 yy_tmp
->user
, yy_tmp
->host
);
962 add_conf_by_address(yy_tmp
->host
, CONF_CLIENT
, yy_tmp
->user
, yy_tmp
->spasswd
, yy_tmp
);
963 rb_dlinkDestroy(ptr
, &yy_aconf_list
);
971 conf_set_auth_user(void *data
)
973 struct ConfItem
*yy_tmp
;
976 /* The first user= line doesn't allocate a new conf */
977 if(!EmptyString(yy_aconf
->host
))
979 yy_tmp
= make_conf();
980 yy_tmp
->status
= CONF_CLIENT
;
985 if((p
= strchr(data
, '@')))
989 yy_tmp
->user
= rb_strdup(data
);
990 yy_tmp
->host
= rb_strdup(p
);
994 yy_tmp
->user
= rb_strdup("*");
995 yy_tmp
->host
= rb_strdup(data
);
998 if(yy_aconf
!= yy_tmp
)
999 rb_dlinkAddAlloc(yy_tmp
, &yy_aconf_list
);
1003 conf_set_auth_auth_user(void *data
)
1005 if(yy_aconf
->spasswd
)
1006 memset(yy_aconf
->spasswd
, 0, strlen(yy_aconf
->spasswd
));
1007 rb_free(yy_aconf
->spasswd
);
1008 yy_aconf
->spasswd
= rb_strdup(data
);
1012 conf_set_auth_passwd(void *data
)
1014 if(yy_aconf
->passwd
)
1015 memset(yy_aconf
->passwd
, 0, strlen(yy_aconf
->passwd
));
1016 rb_free(yy_aconf
->passwd
);
1017 yy_aconf
->passwd
= rb_strdup(data
);
1021 conf_set_auth_autojoin(void *data
)
1023 if(yy_aconf
->autojoin
)
1024 memset(yy_aconf
->autojoin
, 0, strlen(yy_aconf
->autojoin
));
1025 rb_free(yy_aconf
->autojoin
);
1026 yy_aconf
->autojoin
= rb_strdup(data
);
1030 conf_set_auth_spoof(void *data
)
1038 /* user@host spoof */
1039 if((p
= strchr(host
, '@')) != NULL
)
1045 if(EmptyString(user
))
1047 conf_report_error("Warning -- spoof ident empty.");
1051 if(strlen(user
) > USERLEN
)
1053 conf_report_error("Warning -- spoof ident length invalid.");
1057 if(!valid_username(user
))
1059 conf_report_error("Warning -- invalid spoof (ident).");
1063 /* this must be restored! */
1067 if(EmptyString(host
))
1069 conf_report_error("Warning -- spoof host empty.");
1073 if(strlen(host
) > HOSTLEN
)
1075 conf_report_error("Warning -- spoof host length invalid.");
1079 if(!valid_hostname(host
))
1081 conf_report_error("Warning -- invalid spoof (host).");
1085 rb_free(yy_aconf
->name
);
1086 yy_aconf
->name
= rb_strdup(data
);
1087 yy_aconf
->flags
|= CONF_FLAGS_SPOOF_IP
;
1091 conf_set_auth_flags(void *data
)
1093 conf_parm_t
*args
= data
;
1095 set_modes_from_table((int *) &yy_aconf
->flags
, "flag", auth_table
, args
);
1099 conf_set_auth_redir_serv(void *data
)
1101 yy_aconf
->flags
|= CONF_FLAGS_REDIR
;
1102 rb_free(yy_aconf
->name
);
1103 yy_aconf
->name
= rb_strdup(data
);
1107 conf_set_auth_redir_port(void *data
)
1109 int port
= *(unsigned int *) data
;
1111 yy_aconf
->flags
|= CONF_FLAGS_REDIR
;
1112 yy_aconf
->port
= port
;
1116 conf_set_auth_class(void *data
)
1118 rb_free(yy_aconf
->className
);
1119 yy_aconf
->className
= rb_strdup(data
);
1122 /* ok, shared_oper handles the stacking, shared_flags handles adding
1123 * things.. so all we need to do when we start and end a shared block, is
1124 * clean up anything thats been left over.
1127 conf_cleanup_shared(struct TopConf
*tc
)
1129 rb_dlink_node
*ptr
, *next_ptr
;
1131 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, yy_shared_list
.head
)
1133 free_remote_conf(ptr
->data
);
1134 rb_dlinkDestroy(ptr
, &yy_shared_list
);
1137 if(yy_shared
!= NULL
)
1139 free_remote_conf(yy_shared
);
1147 conf_set_shared_oper(void *data
)
1149 conf_parm_t
*args
= data
;
1150 const char *username
;
1153 if(yy_shared
!= NULL
)
1154 free_remote_conf(yy_shared
);
1156 yy_shared
= make_remote_conf();
1158 if(args
->next
!= NULL
)
1160 if((args
->type
& CF_MTYPE
) != CF_QSTRING
)
1162 conf_report_error("Ignoring shared::oper -- server is not a qstring");
1166 yy_shared
->server
= rb_strdup(args
->v
.string
);
1170 yy_shared
->server
= rb_strdup("*");
1172 if((args
->type
& CF_MTYPE
) != CF_QSTRING
)
1174 conf_report_error("Ignoring shared::oper -- oper is not a qstring");
1178 if((p
= strchr(args
->v
.string
, '@')) == NULL
)
1180 conf_report_error("Ignoring shard::oper -- oper is not a user@host");
1184 username
= args
->v
.string
;
1188 yy_shared
->host
= rb_strdup("*");
1190 yy_shared
->host
= rb_strdup(p
);
1192 if(EmptyString(username
))
1193 yy_shared
->username
= rb_strdup("*");
1195 yy_shared
->username
= rb_strdup(username
);
1197 rb_dlinkAddAlloc(yy_shared
, &yy_shared_list
);
1202 conf_set_shared_flags(void *data
)
1204 conf_parm_t
*args
= data
;
1206 rb_dlink_node
*ptr
, *next_ptr
;
1208 if(yy_shared
!= NULL
)
1209 free_remote_conf(yy_shared
);
1211 set_modes_from_table(&flags
, "flag", shared_table
, args
);
1213 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, yy_shared_list
.head
)
1215 yy_shared
= ptr
->data
;
1217 yy_shared
->flags
= flags
;
1218 rb_dlinkDestroy(ptr
, &yy_shared_list
);
1219 rb_dlinkAddTail(yy_shared
, &yy_shared
->node
, &shared_conf_list
);
1226 conf_begin_connect(struct TopConf
*tc
)
1229 free_server_conf(yy_server
);
1231 yy_server
= make_server_conf();
1232 yy_server
->port
= PORTNUM
;
1233 yy_server
->flags
|= SERVER_TB
;
1235 if(conf_cur_block_name
!= NULL
)
1236 yy_server
->name
= rb_strdup(conf_cur_block_name
);
1242 conf_end_connect(struct TopConf
*tc
)
1244 if(EmptyString(yy_server
->name
))
1246 conf_report_error("Ignoring connect block -- missing name.");
1250 if(ServerInfo
.name
!= NULL
&& !irccmp(ServerInfo
.name
, yy_server
->name
))
1252 conf_report_error("Ignoring connect block for %s -- name is equal to my own name.",
1257 if(EmptyString(yy_server
->passwd
) || EmptyString(yy_server
->spasswd
))
1259 conf_report_error("Ignoring connect block for %s -- missing password.",
1264 if(EmptyString(yy_server
->host
))
1266 conf_report_error("Ignoring connect block for %s -- missing host.",
1272 if(ServerConfCompressed(yy_server
))
1274 conf_report_error("Ignoring connect::flags::compressed -- zlib not available.");
1275 yy_server
->flags
&= ~SERVER_COMPRESSED
;
1279 add_server_conf(yy_server
);
1280 rb_dlinkAdd(yy_server
, &yy_server
->node
, &server_conf_list
);
1287 conf_set_connect_host(void *data
)
1289 rb_free(yy_server
->host
);
1290 yy_server
->host
= rb_strdup(data
);
1291 if (strchr(yy_server
->host
, ':'))
1292 yy_server
->aftype
= AF_INET6
;
1296 conf_set_connect_vhost(void *data
)
1298 if(rb_inet_pton_sock(data
, (struct sockaddr
*)&yy_server
->my_ipnum
) <= 0)
1300 conf_report_error("Invalid netmask for server vhost (%s)",
1305 yy_server
->flags
|= SERVER_VHOSTED
;
1309 conf_set_connect_send_password(void *data
)
1311 if(yy_server
->spasswd
)
1313 memset(yy_server
->spasswd
, 0, strlen(yy_server
->spasswd
));
1314 rb_free(yy_server
->spasswd
);
1317 yy_server
->spasswd
= rb_strdup(data
);
1321 conf_set_connect_accept_password(void *data
)
1323 if(yy_server
->passwd
)
1325 memset(yy_server
->passwd
, 0, strlen(yy_server
->passwd
));
1326 rb_free(yy_server
->passwd
);
1328 yy_server
->passwd
= rb_strdup(data
);
1332 conf_set_connect_port(void *data
)
1334 int port
= *(unsigned int *) data
;
1339 yy_server
->port
= port
;
1343 conf_set_connect_aftype(void *data
)
1347 if(strcasecmp(aft
, "ipv4") == 0)
1348 yy_server
->aftype
= AF_INET
;
1350 else if(strcasecmp(aft
, "ipv6") == 0)
1351 yy_server
->aftype
= AF_INET6
;
1354 conf_report_error("connect::aftype '%s' is unknown.", aft
);
1358 conf_set_connect_flags(void *data
)
1360 conf_parm_t
*args
= data
;
1362 /* note, we allow them to set compressed, then remove it later if
1363 * they do and LIBZ isnt available
1365 set_modes_from_table(&yy_server
->flags
, "flag", connect_table
, args
);
1369 conf_set_connect_hub_mask(void *data
)
1371 struct remote_conf
*yy_hub
;
1373 if(EmptyString(yy_server
->name
))
1376 yy_hub
= make_remote_conf();
1377 yy_hub
->flags
= CONF_HUB
;
1379 yy_hub
->host
= rb_strdup(data
);
1380 yy_hub
->server
= rb_strdup(yy_server
->name
);
1381 rb_dlinkAdd(yy_hub
, &yy_hub
->node
, &hubleaf_conf_list
);
1385 conf_set_connect_leaf_mask(void *data
)
1387 struct remote_conf
*yy_leaf
;
1389 if(EmptyString(yy_server
->name
))
1392 yy_leaf
= make_remote_conf();
1393 yy_leaf
->flags
= CONF_LEAF
;
1395 yy_leaf
->host
= rb_strdup(data
);
1396 yy_leaf
->server
= rb_strdup(yy_server
->name
);
1397 rb_dlinkAdd(yy_leaf
, &yy_leaf
->node
, &hubleaf_conf_list
);
1401 conf_set_connect_class(void *data
)
1403 rb_free(yy_server
->class_name
);
1404 yy_server
->class_name
= rb_strdup(data
);
1408 conf_set_exempt_ip(void *data
)
1410 struct ConfItem
*yy_tmp
;
1412 if(parse_netmask(data
, NULL
, NULL
) == HM_HOST
)
1414 conf_report_error("Ignoring exempt -- invalid exempt::ip.");
1418 yy_tmp
= make_conf();
1419 yy_tmp
->passwd
= rb_strdup("*");
1420 yy_tmp
->host
= rb_strdup(data
);
1421 yy_tmp
->status
= CONF_EXEMPTDLINE
;
1422 add_conf_by_address(yy_tmp
->host
, CONF_EXEMPTDLINE
, NULL
, NULL
, yy_tmp
);
1426 conf_cleanup_cluster(struct TopConf
*tc
)
1428 rb_dlink_node
*ptr
, *next_ptr
;
1430 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, yy_cluster_list
.head
)
1432 free_remote_conf(ptr
->data
);
1433 rb_dlinkDestroy(ptr
, &yy_cluster_list
);
1436 if(yy_shared
!= NULL
)
1438 free_remote_conf(yy_shared
);
1446 conf_set_cluster_name(void *data
)
1448 if(yy_shared
!= NULL
)
1449 free_remote_conf(yy_shared
);
1451 yy_shared
= make_remote_conf();
1452 yy_shared
->server
= rb_strdup(data
);
1453 rb_dlinkAddAlloc(yy_shared
, &yy_cluster_list
);
1459 conf_set_cluster_flags(void *data
)
1461 conf_parm_t
*args
= data
;
1463 rb_dlink_node
*ptr
, *next_ptr
;
1465 if(yy_shared
!= NULL
)
1466 free_remote_conf(yy_shared
);
1468 set_modes_from_table(&flags
, "flag", cluster_table
, args
);
1470 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, yy_cluster_list
.head
)
1472 yy_shared
= ptr
->data
;
1473 yy_shared
->flags
= flags
;
1474 rb_dlinkAddTail(yy_shared
, &yy_shared
->node
, &cluster_conf_list
);
1475 rb_dlinkDestroy(ptr
, &yy_cluster_list
);
1482 conf_set_general_havent_read_conf(void *data
)
1484 if(*(unsigned int *) data
)
1486 conf_report_error("You haven't read your config file properly.");
1488 ("There is a line in the example conf that will kill your server if not removed.");
1490 ("Consider actually reading/editing the conf file, and removing this line.");
1497 conf_set_general_hide_error_messages(void *data
)
1501 if(strcasecmp(val
, "yes") == 0)
1502 ConfigFileEntry
.hide_error_messages
= 2;
1503 else if(strcasecmp(val
, "opers") == 0)
1504 ConfigFileEntry
.hide_error_messages
= 1;
1505 else if(strcasecmp(val
, "no") == 0)
1506 ConfigFileEntry
.hide_error_messages
= 0;
1508 conf_report_error("Invalid setting '%s' for general::hide_error_messages.", val
);
1512 conf_set_general_kline_delay(void *data
)
1514 ConfigFileEntry
.kline_delay
= *(unsigned int *) data
;
1516 /* THIS MUST BE HERE to stop us being unable to check klines */
1521 conf_set_general_stats_k_oper_only(void *data
)
1525 if(strcasecmp(val
, "yes") == 0)
1526 ConfigFileEntry
.stats_k_oper_only
= 2;
1527 else if(strcasecmp(val
, "masked") == 0)
1528 ConfigFileEntry
.stats_k_oper_only
= 1;
1529 else if(strcasecmp(val
, "no") == 0)
1530 ConfigFileEntry
.stats_k_oper_only
= 0;
1532 conf_report_error("Invalid setting '%s' for general::stats_k_oper_only.", val
);
1536 conf_set_general_stats_i_oper_only(void *data
)
1540 if(strcasecmp(val
, "yes") == 0)
1541 ConfigFileEntry
.stats_i_oper_only
= 2;
1542 else if(strcasecmp(val
, "masked") == 0)
1543 ConfigFileEntry
.stats_i_oper_only
= 1;
1544 else if(strcasecmp(val
, "no") == 0)
1545 ConfigFileEntry
.stats_i_oper_only
= 0;
1547 conf_report_error("Invalid setting '%s' for general::stats_i_oper_only.", val
);
1551 conf_set_general_compression_level(void *data
)
1554 ConfigFileEntry
.compression_level
= *(unsigned int *) data
;
1556 if((ConfigFileEntry
.compression_level
< 1) || (ConfigFileEntry
.compression_level
> 9))
1559 ("Invalid general::compression_level %d -- using default.",
1560 ConfigFileEntry
.compression_level
);
1561 ConfigFileEntry
.compression_level
= 0;
1564 conf_report_error("Ignoring general::compression_level -- zlib not available.");
1569 conf_set_general_default_umodes(void *data
)
1572 int what
= MODE_ADD
, flag
;
1574 ConfigFileEntry
.default_umodes
= 0;
1575 for (pm
= (char *) data
; *pm
; pm
++)
1586 /* don't allow +o */
1593 if ((flag
= user_modes
[(unsigned char) *pm
]))
1595 /* Proper value has probably not yet been set
1596 * so don't check oper_only_umodes -- jilles */
1597 if (what
== MODE_ADD
)
1598 ConfigFileEntry
.default_umodes
|= flag
;
1600 ConfigFileEntry
.default_umodes
&= ~flag
;
1608 conf_set_general_oper_umodes(void *data
)
1610 set_modes_from_table(&ConfigFileEntry
.oper_umodes
, "umode", umode_table
, data
);
1614 conf_set_general_oper_only_umodes(void *data
)
1616 set_modes_from_table(&ConfigFileEntry
.oper_only_umodes
, "umode", umode_table
, data
);
1620 conf_set_general_oper_snomask(void *data
)
1623 int what
= MODE_ADD
, flag
;
1625 ConfigFileEntry
.oper_snomask
= 0;
1626 for (pm
= (char *) data
; *pm
; pm
++)
1638 if ((flag
= snomask_modes
[(unsigned char) *pm
]))
1640 if (what
== MODE_ADD
)
1641 ConfigFileEntry
.oper_snomask
|= flag
;
1643 ConfigFileEntry
.oper_snomask
&= ~flag
;
1651 conf_set_serverhide_links_delay(void *data
)
1653 int val
= *(unsigned int *) data
;
1655 ConfigServerHide
.links_delay
= val
;
1659 conf_begin_service(struct TopConf
*tc
)
1661 struct Client
*target_p
;
1664 RB_DLINK_FOREACH(ptr
, global_serv_list
.head
)
1666 target_p
= ptr
->data
;
1668 target_p
->flags
&= ~FLAGS_SERVICE
;
1675 conf_set_service_name(void *data
)
1677 struct Client
*target_p
;
1682 for(s
= data
; *s
!= '\0'; s
++)
1686 conf_report_error("Ignoring service::name "
1687 "-- bogus servername.");
1696 conf_report_error("Ignoring service::name -- must contain '.'");
1700 tmp
= rb_strdup(data
);
1701 rb_dlinkAddAlloc(tmp
, &service_list
);
1703 if((target_p
= find_server(NULL
, tmp
)))
1704 target_p
->flags
|= FLAGS_SERVICE
;
1708 conf_begin_alias(struct TopConf
*tc
)
1710 yy_alias
= rb_malloc(sizeof(struct alias_entry
));
1712 if (conf_cur_block_name
!= NULL
)
1713 yy_alias
->name
= rb_strdup(conf_cur_block_name
);
1715 yy_alias
->flags
= 0;
1722 conf_end_alias(struct TopConf
*tc
)
1724 if (yy_alias
== NULL
)
1727 if (yy_alias
->name
== NULL
)
1729 conf_report_error("Ignoring alias -- must have a name.");
1736 if (yy_alias
->target
== NULL
)
1738 conf_report_error("Ignoring alias -- must have a target.");
1745 irc_dictionary_add(alias_dict
, yy_alias
->name
, yy_alias
);
1751 conf_set_alias_name(void *data
)
1753 if (data
== NULL
|| yy_alias
== NULL
) /* this shouldn't ever happen */
1756 yy_alias
->name
= rb_strdup(data
);
1760 conf_set_alias_target(void *data
)
1762 if (data
== NULL
|| yy_alias
== NULL
) /* this shouldn't ever happen */
1765 yy_alias
->target
= rb_strdup(data
);
1769 conf_set_blacklist_host(void *data
)
1771 yy_blacklist_host
= rb_strdup(data
);
1775 conf_set_blacklist_reason(void *data
)
1777 yy_blacklist_reason
= rb_strdup(data
);
1779 if (yy_blacklist_host
&& yy_blacklist_reason
)
1781 new_blacklist(yy_blacklist_host
, yy_blacklist_reason
);
1782 rb_free(yy_blacklist_host
);
1783 rb_free(yy_blacklist_reason
);
1784 yy_blacklist_host
= NULL
;
1785 yy_blacklist_reason
= NULL
;
1789 /* public functions */
1793 conf_report_error(const char *fmt
, ...)
1796 char msg
[IRCD_BUFSIZE
+ 1] = { 0 };
1799 rb_vsnprintf(msg
, IRCD_BUFSIZE
, fmt
, ap
);
1804 fprintf(stderr
, "\"%s\", line %d: %s\n", current_file
, lineno
+ 1, msg
);
1808 ierror("\"%s\", line %d: %s", current_file
, lineno
+ 1, msg
);
1809 sendto_realops_snomask(SNO_GENERAL
, L_ALL
, "\"%s\", line %d: %s", current_file
, lineno
+ 1, msg
);
1813 conf_start_block(char *block
, char *name
)
1815 if((conf_cur_block
= find_top_conf(block
)) == NULL
)
1817 conf_report_error("Configuration block '%s' is not defined.", block
);
1822 conf_cur_block_name
= rb_strdup(name
);
1824 conf_cur_block_name
= NULL
;
1826 if(conf_cur_block
->tc_sfunc
)
1827 if(conf_cur_block
->tc_sfunc(conf_cur_block
) < 0)
1834 conf_end_block(struct TopConf
*tc
)
1837 return tc
->tc_efunc(tc
);
1839 rb_free(conf_cur_block_name
);
1844 conf_set_generic_int(void *data
, void *location
)
1846 *((int *) location
) = *((unsigned int *) data
);
1850 conf_set_generic_string(void *data
, int len
, void *location
)
1852 char **loc
= location
;
1855 if(len
&& strlen(input
) > (unsigned int)len
)
1859 *loc
= rb_strdup(input
);
1863 conf_call_set(struct TopConf
*tc
, char *item
, conf_parm_t
* value
, int type
)
1865 struct ConfEntry
*cf
;
1871 if((cf
= find_conf_item(tc
, item
)) == NULL
)
1874 ("Non-existant configuration setting %s::%s.", tc
->tc_name
, (char *) item
);
1878 /* if it takes one thing, make sure they only passed one thing,
1879 and handle as needed. */
1880 if(value
->type
& CF_FLIST
&& !cf
->cf_type
& CF_FLIST
)
1883 ("Option %s::%s does not take a list of values.", tc
->tc_name
, item
);
1890 if(CF_TYPE(value
->v
.list
->type
) != CF_TYPE(cf
->cf_type
))
1892 /* if it expects a string value, but we got a yesno,
1895 if((CF_TYPE(value
->v
.list
->type
) == CF_YESNO
) &&
1896 (CF_TYPE(cf
->cf_type
) == CF_STRING
))
1898 value
->v
.list
->type
= CF_STRING
;
1900 if(cp
->v
.number
== 1)
1901 cp
->v
.string
= rb_strdup("yes");
1903 cp
->v
.string
= rb_strdup("no");
1906 /* maybe it's a CF_TIME and they passed CF_INT --
1907 should still be valid */
1908 else if(!((CF_TYPE(value
->v
.list
->type
) == CF_INT
) &&
1909 (CF_TYPE(cf
->cf_type
) == CF_TIME
)))
1912 ("Wrong type for %s::%s (expected %s, got %s)",
1913 tc
->tc_name
, (char *) item
,
1914 conf_strtype(cf
->cf_type
), conf_strtype(value
->v
.list
->type
));
1919 if(cf
->cf_type
& CF_FLIST
)
1923 conf_set_generic_list(value
->v
.list
, cf
->cf_arg
);
1926 /* just pass it the extended argument list */
1927 cf
->cf_func(value
->v
.list
);
1931 /* it's old-style, needs only one arg */
1932 switch (cf
->cf_type
)
1938 conf_set_generic_int(&cp
->v
.number
, cf
->cf_arg
);
1940 cf
->cf_func(&cp
->v
.number
);
1944 if(EmptyString(cp
->v
.string
))
1945 conf_report_error("Ignoring %s::%s -- empty field",
1948 conf_set_generic_string(cp
->v
.string
, cf
->cf_len
, cf
->cf_arg
);
1950 cf
->cf_func(cp
->v
.string
);
1960 add_conf_item(const char *topconf
, const char *name
, int type
, void (*func
) (void *))
1963 struct ConfEntry
*cf
;
1965 if((tc
= find_top_conf(topconf
)) == NULL
)
1968 if((cf
= find_conf_item(tc
, name
)) != NULL
)
1971 cf
= rb_malloc(sizeof(struct ConfEntry
));
1978 rb_dlinkAddAlloc(cf
, &tc
->tc_items
);
1984 remove_conf_item(const char *topconf
, const char *name
)
1987 struct ConfEntry
*cf
;
1990 if((tc
= find_top_conf(topconf
)) == NULL
)
1993 if((cf
= find_conf_item(tc
, name
)) == NULL
)
1996 if((ptr
= rb_dlinkFind(cf
, &tc
->tc_items
)) == NULL
)
1999 rb_dlinkDestroy(ptr
, &tc
->tc_items
);
2006 static struct ConfEntry conf_serverinfo_table
[] =
2008 { "description", CF_QSTRING
, NULL
, 0, &ServerInfo
.description
},
2009 { "network_desc", CF_QSTRING
, NULL
, 0, &ServerInfo
.network_desc
},
2010 { "hub", CF_YESNO
, NULL
, 0, &ServerInfo
.hub
},
2012 { "network_name", CF_QSTRING
, conf_set_serverinfo_network_name
, 0, NULL
},
2013 { "name", CF_QSTRING
, conf_set_serverinfo_name
, 0, NULL
},
2014 { "sid", CF_QSTRING
, conf_set_serverinfo_sid
, 0, NULL
},
2015 { "vhost", CF_QSTRING
, conf_set_serverinfo_vhost
, 0, NULL
},
2016 { "vhost6", CF_QSTRING
, conf_set_serverinfo_vhost6
, 0, NULL
},
2018 { "ssl_private_key", CF_QSTRING
, NULL
, 0, &ServerInfo
.ssl_private_key
},
2019 { "ssl_ca_cert", CF_QSTRING
, NULL
, 0, &ServerInfo
.ssl_ca_cert
},
2020 { "ssl_cert", CF_QSTRING
, NULL
, 0, &ServerInfo
.ssl_cert
},
2021 { "ssl_dh_params", CF_QSTRING
, NULL
, 0, &ServerInfo
.ssl_dh_params
},
2022 { "ssld_count", CF_INT
, NULL
, 0, &ServerInfo
.ssld_count
},
2024 { "default_max_clients",CF_INT
, NULL
, 0, &ServerInfo
.default_max_clients
},
2026 { "\0", 0, NULL
, 0, NULL
}
2029 static struct ConfEntry conf_admin_table
[] =
2031 { "name", CF_QSTRING
, NULL
, 200, &AdminInfo
.name
},
2032 { "description",CF_QSTRING
, NULL
, 200, &AdminInfo
.description
},
2033 { "email", CF_QSTRING
, NULL
, 200, &AdminInfo
.email
},
2034 { "\0", 0, NULL
, 0, NULL
}
2037 static struct ConfEntry conf_log_table
[] =
2039 { "fname_userlog", CF_QSTRING
, NULL
, MAXPATHLEN
, &ConfigFileEntry
.fname_userlog
},
2040 { "fname_fuserlog", CF_QSTRING
, NULL
, MAXPATHLEN
, &ConfigFileEntry
.fname_fuserlog
},
2041 { "fname_operlog", CF_QSTRING
, NULL
, MAXPATHLEN
, &ConfigFileEntry
.fname_operlog
},
2042 { "fname_foperlog", CF_QSTRING
, NULL
, MAXPATHLEN
, &ConfigFileEntry
.fname_foperlog
},
2043 { "fname_serverlog", CF_QSTRING
, NULL
, MAXPATHLEN
, &ConfigFileEntry
.fname_serverlog
},
2044 { "fname_killlog", CF_QSTRING
, NULL
, MAXPATHLEN
, &ConfigFileEntry
.fname_killlog
},
2045 { "fname_klinelog", CF_QSTRING
, NULL
, MAXPATHLEN
, &ConfigFileEntry
.fname_klinelog
},
2046 { "fname_operspylog", CF_QSTRING
, NULL
, MAXPATHLEN
, &ConfigFileEntry
.fname_operspylog
},
2047 { "fname_ioerrorlog", CF_QSTRING
, NULL
, MAXPATHLEN
, &ConfigFileEntry
.fname_ioerrorlog
},
2048 { "\0", 0, NULL
, 0, NULL
}
2051 static struct ConfEntry conf_operator_table
[] =
2053 { "rsa_public_key_file", CF_QSTRING
, conf_set_oper_rsa_public_key_file
, 0, NULL
},
2054 { "flags", CF_STRING
| CF_FLIST
, conf_set_oper_flags
, 0, NULL
},
2055 { "umodes", CF_STRING
| CF_FLIST
, conf_set_oper_umodes
, 0, NULL
},
2056 { "privset", CF_QSTRING
, conf_set_oper_privset
, 0, NULL
},
2057 { "snomask", CF_QSTRING
, conf_set_oper_snomask
, 0, NULL
},
2058 { "user", CF_QSTRING
, conf_set_oper_user
, 0, NULL
},
2059 { "password", CF_QSTRING
, conf_set_oper_password
, 0, NULL
},
2060 { "fingerprint", CF_QSTRING
, conf_set_oper_fingerprint
, 0, NULL
},
2061 { "\0", 0, NULL
, 0, NULL
}
2064 static struct ConfEntry conf_privset_table
[] =
2066 { "extends", CF_QSTRING
, conf_set_privset_extends
, 0, NULL
},
2067 { "privs", CF_STRING
| CF_FLIST
, conf_set_privset_privs
, 0, NULL
},
2068 { "\0", 0, NULL
, 0, NULL
}
2071 static struct ConfEntry conf_class_table
[] =
2073 { "ping_time", CF_TIME
, conf_set_class_ping_time
, 0, NULL
},
2074 { "cidr_ipv4_bitlen", CF_INT
, conf_set_class_cidr_ipv4_bitlen
, 0, NULL
},
2076 { "cidr_ipv6_bitlen", CF_INT
, conf_set_class_cidr_ipv6_bitlen
, 0, NULL
},
2078 { "number_per_cidr", CF_INT
, conf_set_class_number_per_cidr
, 0, NULL
},
2079 { "number_per_ip", CF_INT
, conf_set_class_number_per_ip
, 0, NULL
},
2080 { "number_per_ip_global", CF_INT
,conf_set_class_number_per_ip_global
, 0, NULL
},
2081 { "number_per_ident", CF_INT
, conf_set_class_number_per_ident
, 0, NULL
},
2082 { "connectfreq", CF_TIME
, conf_set_class_connectfreq
, 0, NULL
},
2083 { "max_number", CF_INT
, conf_set_class_max_number
, 0, NULL
},
2084 { "sendq", CF_TIME
, conf_set_class_sendq
, 0, NULL
},
2085 { "\0", 0, NULL
, 0, NULL
}
2088 static struct ConfEntry conf_auth_table
[] =
2090 { "user", CF_QSTRING
, conf_set_auth_user
, 0, NULL
},
2091 { "auth_user", CF_QSTRING
, conf_set_auth_auth_user
, 0, NULL
},
2092 { "password", CF_QSTRING
, conf_set_auth_passwd
, 0, NULL
},
2093 { "class", CF_QSTRING
, conf_set_auth_class
, 0, NULL
},
2094 { "spoof", CF_QSTRING
, conf_set_auth_spoof
, 0, NULL
},
2095 { "autojoin", CF_QSTRING
, conf_set_auth_autojoin
, 0, NULL
},
2096 { "redirserv", CF_QSTRING
, conf_set_auth_redir_serv
, 0, NULL
},
2097 { "redirport", CF_INT
, conf_set_auth_redir_port
, 0, NULL
},
2098 { "flags", CF_STRING
| CF_FLIST
, conf_set_auth_flags
, 0, NULL
},
2099 { "\0", 0, NULL
, 0, NULL
}
2102 static struct ConfEntry conf_connect_table
[] =
2104 { "send_password", CF_QSTRING
, conf_set_connect_send_password
, 0, NULL
},
2105 { "accept_password", CF_QSTRING
, conf_set_connect_accept_password
, 0, NULL
},
2106 { "flags", CF_STRING
| CF_FLIST
, conf_set_connect_flags
, 0, NULL
},
2107 { "host", CF_QSTRING
, conf_set_connect_host
, 0, NULL
},
2108 { "vhost", CF_QSTRING
, conf_set_connect_vhost
, 0, NULL
},
2109 { "port", CF_INT
, conf_set_connect_port
, 0, NULL
},
2110 { "aftype", CF_STRING
, conf_set_connect_aftype
, 0, NULL
},
2111 { "hub_mask", CF_QSTRING
, conf_set_connect_hub_mask
, 0, NULL
},
2112 { "leaf_mask", CF_QSTRING
, conf_set_connect_leaf_mask
, 0, NULL
},
2113 { "class", CF_QSTRING
, conf_set_connect_class
, 0, NULL
},
2114 { "\0", 0, NULL
, 0, NULL
}
2117 static struct ConfEntry conf_general_table
[] =
2119 { "oper_only_umodes", CF_STRING
| CF_FLIST
, conf_set_general_oper_only_umodes
, 0, NULL
},
2120 { "oper_umodes", CF_STRING
| CF_FLIST
, conf_set_general_oper_umodes
, 0, NULL
},
2121 { "oper_snomask", CF_QSTRING
, conf_set_general_oper_snomask
, 0, NULL
},
2122 { "compression_level", CF_INT
, conf_set_general_compression_level
, 0, NULL
},
2123 { "havent_read_conf", CF_YESNO
, conf_set_general_havent_read_conf
, 0, NULL
},
2124 { "hide_error_messages",CF_STRING
, conf_set_general_hide_error_messages
,0, NULL
},
2125 { "kline_delay", CF_TIME
, conf_set_general_kline_delay
, 0, NULL
},
2126 { "stats_k_oper_only", CF_STRING
, conf_set_general_stats_k_oper_only
, 0, NULL
},
2127 { "stats_i_oper_only", CF_STRING
, conf_set_general_stats_i_oper_only
, 0, NULL
},
2128 { "default_umodes", CF_QSTRING
, conf_set_general_default_umodes
, 0, NULL
},
2130 { "default_operstring", CF_QSTRING
, NULL
, REALLEN
, &ConfigFileEntry
.default_operstring
},
2131 { "default_adminstring",CF_QSTRING
, NULL
, REALLEN
, &ConfigFileEntry
.default_adminstring
},
2132 { "servicestring", CF_QSTRING
, NULL
, REALLEN
, &ConfigFileEntry
.servicestring
},
2133 { "egdpool_path", CF_QSTRING
, NULL
, MAXPATHLEN
, &ConfigFileEntry
.egdpool_path
},
2134 { "kline_reason", CF_QSTRING
, NULL
, REALLEN
, &ConfigFileEntry
.kline_reason
},
2135 { "identify_service", CF_QSTRING
, NULL
, REALLEN
, &ConfigFileEntry
.identifyservice
},
2136 { "identify_command", CF_QSTRING
, NULL
, REALLEN
, &ConfigFileEntry
.identifycommand
},
2138 { "anti_spam_exit_message_time", CF_TIME
, NULL
, 0, &ConfigFileEntry
.anti_spam_exit_message_time
},
2139 { "disable_fake_channels", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.disable_fake_channels
},
2140 { "min_nonwildcard_simple", CF_INT
, NULL
, 0, &ConfigFileEntry
.min_nonwildcard_simple
},
2141 { "non_redundant_klines", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.non_redundant_klines
},
2142 { "tkline_expire_notices", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.tkline_expire_notices
},
2144 { "anti_nick_flood", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.anti_nick_flood
},
2145 { "burst_away", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.burst_away
},
2146 { "caller_id_wait", CF_TIME
, NULL
, 0, &ConfigFileEntry
.caller_id_wait
},
2147 { "client_exit", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.client_exit
},
2148 { "client_flood", CF_INT
, NULL
, 0, &ConfigFileEntry
.client_flood
},
2149 { "collision_fnc", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.collision_fnc
},
2150 { "connect_timeout", CF_TIME
, NULL
, 0, &ConfigFileEntry
.connect_timeout
},
2151 { "default_floodcount", CF_INT
, NULL
, 0, &ConfigFileEntry
.default_floodcount
},
2152 { "disable_auth", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.disable_auth
},
2153 { "dots_in_ident", CF_INT
, NULL
, 0, &ConfigFileEntry
.dots_in_ident
},
2154 { "failed_oper_notice", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.failed_oper_notice
},
2155 { "global_snotices", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.global_snotices
},
2156 { "hide_spoof_ips", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.hide_spoof_ips
},
2157 { "dline_with_reason", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.dline_with_reason
},
2158 { "kline_with_reason", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.kline_with_reason
},
2159 { "map_oper_only", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.map_oper_only
},
2160 { "max_accept", CF_INT
, NULL
, 0, &ConfigFileEntry
.max_accept
},
2161 { "max_monitor", CF_INT
, NULL
, 0, &ConfigFileEntry
.max_monitor
},
2162 { "max_nick_time", CF_TIME
, NULL
, 0, &ConfigFileEntry
.max_nick_time
},
2163 { "max_nick_changes", CF_INT
, NULL
, 0, &ConfigFileEntry
.max_nick_changes
},
2164 { "max_targets", CF_INT
, NULL
, 0, &ConfigFileEntry
.max_targets
},
2165 { "min_nonwildcard", CF_INT
, NULL
, 0, &ConfigFileEntry
.min_nonwildcard
},
2166 { "nick_delay", CF_TIME
, NULL
, 0, &ConfigFileEntry
.nick_delay
},
2167 { "no_oper_flood", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.no_oper_flood
},
2168 { "operspy_admin_only", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.operspy_admin_only
},
2169 { "operspy_dont_care_user_info", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.operspy_dont_care_user_info
},
2170 { "pace_wait", CF_TIME
, NULL
, 0, &ConfigFileEntry
.pace_wait
},
2171 { "pace_wait_simple", CF_TIME
, NULL
, 0, &ConfigFileEntry
.pace_wait_simple
},
2172 { "ping_cookie", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.ping_cookie
},
2173 { "reject_after_count", CF_INT
, NULL
, 0, &ConfigFileEntry
.reject_after_count
},
2174 { "reject_ban_time", CF_TIME
, NULL
, 0, &ConfigFileEntry
.reject_ban_time
},
2175 { "reject_duration", CF_TIME
, NULL
, 0, &ConfigFileEntry
.reject_duration
},
2176 { "throttle_count", CF_INT
, NULL
, 0, &ConfigFileEntry
.throttle_count
},
2177 { "throttle_duration", CF_TIME
, NULL
, 0, &ConfigFileEntry
.throttle_duration
},
2178 { "short_motd", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.short_motd
},
2179 { "stats_c_oper_only", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.stats_c_oper_only
},
2180 { "stats_e_disabled", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.stats_e_disabled
},
2181 { "stats_h_oper_only", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.stats_h_oper_only
},
2182 { "stats_o_oper_only", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.stats_o_oper_only
},
2183 { "stats_P_oper_only", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.stats_P_oper_only
},
2184 { "stats_y_oper_only", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.stats_y_oper_only
},
2185 { "target_change", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.target_change
},
2186 { "ts_max_delta", CF_TIME
, NULL
, 0, &ConfigFileEntry
.ts_max_delta
},
2187 { "use_egd", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.use_egd
},
2188 { "ts_warn_delta", CF_TIME
, NULL
, 0, &ConfigFileEntry
.ts_warn_delta
},
2189 { "use_whois_actually", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.use_whois_actually
},
2190 { "warn_no_nline", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.warn_no_nline
},
2191 { "\0", 0, NULL
, 0, NULL
}
2194 static struct ConfEntry conf_channel_table
[] =
2196 { "default_split_user_count", CF_INT
, NULL
, 0, &ConfigChannel
.default_split_user_count
},
2197 { "default_split_server_count", CF_INT
, NULL
, 0, &ConfigChannel
.default_split_server_count
},
2198 { "burst_topicwho", CF_YESNO
, NULL
, 0, &ConfigChannel
.burst_topicwho
},
2199 { "kick_on_split_riding", CF_YESNO
, NULL
, 0, &ConfigChannel
.kick_on_split_riding
},
2200 { "knock_delay", CF_TIME
, NULL
, 0, &ConfigChannel
.knock_delay
},
2201 { "knock_delay_channel",CF_TIME
, NULL
, 0, &ConfigChannel
.knock_delay_channel
},
2202 { "max_bans", CF_INT
, NULL
, 0, &ConfigChannel
.max_bans
},
2203 { "max_bans_large", CF_INT
, NULL
, 0, &ConfigChannel
.max_bans_large
},
2204 { "max_chans_per_user", CF_INT
, NULL
, 0, &ConfigChannel
.max_chans_per_user
},
2205 { "no_create_on_split", CF_YESNO
, NULL
, 0, &ConfigChannel
.no_create_on_split
},
2206 { "no_join_on_split", CF_YESNO
, NULL
, 0, &ConfigChannel
.no_join_on_split
},
2207 { "only_ascii_channels", CF_YESNO
, NULL
, 0, &ConfigChannel
.only_ascii_channels
},
2208 { "use_except", CF_YESNO
, NULL
, 0, &ConfigChannel
.use_except
},
2209 { "use_invex", CF_YESNO
, NULL
, 0, &ConfigChannel
.use_invex
},
2210 { "use_knock", CF_YESNO
, NULL
, 0, &ConfigChannel
.use_knock
},
2211 { "use_forward", CF_YESNO
, NULL
, 0, &ConfigChannel
.use_forward
},
2212 { "resv_forcepart", CF_YESNO
, NULL
, 0, &ConfigChannel
.resv_forcepart
},
2213 { "\0", 0, NULL
, 0, NULL
}
2216 static struct ConfEntry conf_serverhide_table
[] =
2218 { "disable_hidden", CF_YESNO
, NULL
, 0, &ConfigServerHide
.disable_hidden
},
2219 { "flatten_links", CF_YESNO
, NULL
, 0, &ConfigServerHide
.flatten_links
},
2220 { "hidden", CF_YESNO
, NULL
, 0, &ConfigServerHide
.hidden
},
2221 { "links_delay", CF_TIME
, conf_set_serverhide_links_delay
, 0, NULL
},
2222 { "\0", 0, NULL
, 0, NULL
}
2229 add_top_conf("modules", NULL
, NULL
, NULL
);
2230 add_conf_item("modules", "path", CF_QSTRING
, conf_set_modules_path
);
2231 add_conf_item("modules", "module", CF_QSTRING
, conf_set_modules_module
);
2233 add_top_conf("serverinfo", NULL
, NULL
, conf_serverinfo_table
);
2234 add_top_conf("admin", NULL
, NULL
, conf_admin_table
);
2235 add_top_conf("log", NULL
, NULL
, conf_log_table
);
2236 add_top_conf("operator", conf_begin_oper
, conf_end_oper
, conf_operator_table
);
2237 add_top_conf("class", conf_begin_class
, conf_end_class
, conf_class_table
);
2238 add_top_conf("privset", NULL
, NULL
, conf_privset_table
);
2240 add_top_conf("listen", conf_begin_listen
, conf_end_listen
, NULL
);
2241 add_conf_item("listen", "port", CF_INT
| CF_FLIST
, conf_set_listen_port
);
2242 add_conf_item("listen", "sslport", CF_INT
| CF_FLIST
, conf_set_listen_sslport
);
2243 add_conf_item("listen", "ip", CF_QSTRING
, conf_set_listen_address
);
2244 add_conf_item("listen", "host", CF_QSTRING
, conf_set_listen_address
);
2246 add_top_conf("auth", conf_begin_auth
, conf_end_auth
, conf_auth_table
);
2248 add_top_conf("shared", conf_cleanup_shared
, conf_cleanup_shared
, NULL
);
2249 add_conf_item("shared", "oper", CF_QSTRING
|CF_FLIST
, conf_set_shared_oper
);
2250 add_conf_item("shared", "flags", CF_STRING
| CF_FLIST
, conf_set_shared_flags
);
2252 add_top_conf("connect", conf_begin_connect
, conf_end_connect
, conf_connect_table
);
2254 add_top_conf("exempt", NULL
, NULL
, NULL
);
2255 add_conf_item("exempt", "ip", CF_QSTRING
, conf_set_exempt_ip
);
2257 add_top_conf("cluster", conf_cleanup_cluster
, conf_cleanup_cluster
, NULL
);
2258 add_conf_item("cluster", "name", CF_QSTRING
, conf_set_cluster_name
);
2259 add_conf_item("cluster", "flags", CF_STRING
| CF_FLIST
, conf_set_cluster_flags
);
2261 add_top_conf("general", NULL
, NULL
, conf_general_table
);
2262 add_top_conf("channel", NULL
, NULL
, conf_channel_table
);
2263 add_top_conf("serverhide", NULL
, NULL
, conf_serverhide_table
);
2265 add_top_conf("service", conf_begin_service
, NULL
, NULL
);
2266 add_conf_item("service", "name", CF_QSTRING
, conf_set_service_name
);
2268 add_top_conf("alias", conf_begin_alias
, conf_end_alias
, NULL
);
2269 add_conf_item("alias", "name", CF_QSTRING
, conf_set_alias_name
);
2270 add_conf_item("alias", "target", CF_QSTRING
, conf_set_alias_target
);
2272 add_top_conf("blacklist", NULL
, NULL
, NULL
);
2273 add_conf_item("blacklist", "host", CF_QSTRING
, conf_set_blacklist_host
);
2274 add_conf_item("blacklist", "reject_reason", CF_QSTRING
, conf_set_blacklist_reason
);