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 int yy_blacklist_ipv4
= 1;
58 static int yy_blacklist_ipv6
= 0;
60 static char *yy_privset_extends
= NULL
;
63 conf_strtype(int type
)
65 switch (type
& CF_MTYPE
)
68 return "integer value";
70 return "unquoted string";
72 return "yes/no value";
74 return "quoted string";
76 return "time/size value";
78 return "unknown type";
83 add_top_conf(const char *name
, int (*sfunc
) (struct TopConf
*),
84 int (*efunc
) (struct TopConf
*), struct ConfEntry
*items
)
88 tc
= rb_malloc(sizeof(struct TopConf
));
93 tc
->tc_entries
= items
;
95 rb_dlinkAddAlloc(tc
, &conf_items
);
100 find_top_conf(const char *name
)
105 RB_DLINK_FOREACH(d
, conf_items
.head
)
108 if(strcasecmp(tc
->tc_name
, name
) == 0)
117 find_conf_item(const struct TopConf
*top
, const char *name
)
119 struct ConfEntry
*cf
;
126 for(i
= 0; top
->tc_entries
[i
].cf_type
; i
++)
128 cf
= &top
->tc_entries
[i
];
130 if(!strcasecmp(cf
->cf_name
, name
))
135 RB_DLINK_FOREACH(d
, top
->tc_items
.head
)
138 if(strcasecmp(cf
->cf_name
, name
) == 0)
146 remove_top_conf(char *name
)
151 if((tc
= find_top_conf(name
)) == NULL
)
154 if((ptr
= rb_dlinkFind(tc
, &conf_items
)) == NULL
)
157 rb_dlinkDestroy(ptr
, &conf_items
);
164 conf_set_serverinfo_name(void *data
)
166 if(ServerInfo
.name
== NULL
)
171 for(s
= data
; *s
!= '\0'; s
++)
175 conf_report_error("Ignoring serverinfo::name "
176 "-- bogus servername.");
185 conf_report_error("Ignoring serverinfo::name -- must contain '.'");
193 conf_report_error("Ignoring serverinfo::name -- cannot begin with digit.");
197 /* the ircd will exit() in main() if we dont set one */
198 if(strlen(s
) <= HOSTLEN
)
199 ServerInfo
.name
= rb_strdup((char *) data
);
204 conf_set_serverinfo_sid(void *data
)
208 if(ServerInfo
.sid
[0] == '\0')
210 if(!IsDigit(sid
[0]) || !IsIdChar(sid
[1]) ||
211 !IsIdChar(sid
[2]) || sid
[3] != '\0')
213 conf_report_error("Ignoring serverinfo::sid "
218 strcpy(ServerInfo
.sid
, sid
);
223 conf_set_serverinfo_network_name(void *data
)
227 if((p
= strchr((char *) data
, ' ')))
230 rb_free(ServerInfo
.network_name
);
231 ServerInfo
.network_name
= rb_strdup((char *) data
);
235 conf_set_serverinfo_vhost(void *data
)
237 if(rb_inet_pton(AF_INET
, (char *) data
, &ServerInfo
.ip
.sin_addr
) <= 0)
239 conf_report_error("Invalid netmask for server IPv4 vhost (%s)", (char *) data
);
242 ServerInfo
.ip
.sin_family
= AF_INET
;
243 ServerInfo
.specific_ipv4_vhost
= 1;
247 conf_set_serverinfo_vhost6(void *data
)
250 if(rb_inet_pton(AF_INET6
, (char *) data
, &ServerInfo
.ip6
.sin6_addr
) <= 0)
252 conf_report_error("Invalid netmask for server IPv6 vhost (%s)", (char *) data
);
256 ServerInfo
.specific_ipv6_vhost
= 1;
257 ServerInfo
.ip6
.sin6_family
= AF_INET6
;
259 conf_report_error("Warning -- ignoring serverinfo::vhost6 -- IPv6 support not available.");
264 conf_set_modules_module(void *data
)
266 #ifndef STATIC_MODULES
269 m_bn
= rb_basename((char *) data
);
271 if(findmodule_byname(m_bn
) != -1)
274 load_one_module((char *) data
, 0);
278 conf_report_error("Ignoring modules::module -- loadable module support not present.");
283 conf_set_modules_path(void *data
)
285 #ifndef STATIC_MODULES
286 mod_add_path((char *) data
);
288 conf_report_error("Ignoring modules::path -- loadable module support not present.");
299 static struct mode_table umode_table
[] = {
300 {"callerid", UMODE_CALLERID
},
301 {"deaf", UMODE_DEAF
},
302 {"invisible", UMODE_INVISIBLE
},
303 {"locops", UMODE_LOCOPS
},
304 {"noforward", UMODE_NOFORWARD
},
305 {"regonlymsg", UMODE_REGONLYMSG
},
306 {"servnotice", UMODE_SERVNOTICE
},
307 {"wallop", UMODE_WALLOP
},
308 {"operwall", UMODE_OPERWALL
},
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",
602 if(!EmptyString(yy_oper
->certfp
))
603 yy_tmpoper
->certfp
= rb_strdup(yy_oper
->certfp
);
606 /* all is ok, put it on oper_conf_list */
607 rb_dlinkMoveNode(ptr
, &yy_oper_list
, &oper_conf_list
);
610 free_oper_conf(yy_oper
);
617 conf_set_oper_flags(void *data
)
619 conf_parm_t
*args
= data
;
621 set_modes_from_table(&yy_oper
->flags
, "flag", oper_table
, args
);
625 conf_set_oper_fingerprint(void *data
)
628 rb_free(yy_oper
->certfp
);
629 yy_oper
->certfp
= rb_strdup((char *) data
);
633 conf_set_oper_privset(void *data
)
635 yy_oper
->privset
= privilegeset_get((char *) data
);
639 conf_set_oper_user(void *data
)
641 struct oper_conf
*yy_tmpoper
;
643 char *host
= (char *) data
;
645 yy_tmpoper
= make_oper_conf();
647 if((p
= strchr(host
, '@')))
651 yy_tmpoper
->username
= rb_strdup(host
);
652 yy_tmpoper
->host
= rb_strdup(p
);
657 yy_tmpoper
->username
= rb_strdup("*");
658 yy_tmpoper
->host
= rb_strdup(host
);
661 if(EmptyString(yy_tmpoper
->username
) || EmptyString(yy_tmpoper
->host
))
663 conf_report_error("Ignoring user -- missing username/host");
664 free_oper_conf(yy_tmpoper
);
668 rb_dlinkAddAlloc(yy_tmpoper
, &yy_oper_list
);
672 conf_set_oper_password(void *data
)
676 memset(yy_oper
->passwd
, 0, strlen(yy_oper
->passwd
));
677 rb_free(yy_oper
->passwd
);
680 yy_oper
->passwd
= rb_strdup((char *) data
);
684 conf_set_oper_rsa_public_key_file(void *data
)
686 #ifdef HAVE_LIBCRYPTO
687 rb_free(yy_oper
->rsa_pubkey_file
);
688 yy_oper
->rsa_pubkey_file
= rb_strdup((char *) data
);
690 conf_report_error("Warning -- ignoring rsa_public_key_file (OpenSSL support not available");
695 conf_set_oper_umodes(void *data
)
697 set_modes_from_table(&yy_oper
->umodes
, "umode", umode_table
, data
);
701 conf_set_oper_snomask(void *data
)
703 yy_oper
->snomask
= parse_snobuf_to_mask(0, (const char *) data
);
707 conf_begin_class(struct TopConf
*tc
)
710 free_class(yy_class
);
712 yy_class
= make_class();
717 conf_end_class(struct TopConf
*tc
)
719 if(conf_cur_block_name
!= NULL
)
720 yy_class
->class_name
= rb_strdup(conf_cur_block_name
);
722 if(EmptyString(yy_class
->class_name
))
724 conf_report_error("Ignoring connect block -- missing name.");
734 conf_set_class_ping_time(void *data
)
736 yy_class
->ping_freq
= *(unsigned int *) data
;
740 conf_set_class_cidr_ipv4_bitlen(void *data
)
742 unsigned int maxsize
= 32;
743 if(*(unsigned int *) data
> maxsize
)
745 ("class::cidr_ipv4_bitlen argument exceeds maxsize (%d > %d) - ignoring.",
746 *(unsigned int *) data
, maxsize
);
748 yy_class
->cidr_ipv4_bitlen
= *(unsigned int *) data
;
754 conf_set_class_cidr_ipv6_bitlen(void *data
)
756 unsigned int maxsize
= 128;
757 if(*(unsigned int *) data
> maxsize
)
759 ("class::cidr_ipv6_bitlen argument exceeds maxsize (%d > %d) - ignoring.",
760 *(unsigned int *) data
, maxsize
);
762 yy_class
->cidr_ipv6_bitlen
= *(unsigned int *) data
;
768 conf_set_class_number_per_cidr(void *data
)
770 yy_class
->cidr_amount
= *(unsigned int *) data
;
774 conf_set_class_number_per_ip(void *data
)
776 yy_class
->max_local
= *(unsigned int *) data
;
781 conf_set_class_number_per_ip_global(void *data
)
783 yy_class
->max_global
= *(unsigned int *) data
;
787 conf_set_class_number_per_ident(void *data
)
789 yy_class
->max_ident
= *(unsigned int *) data
;
793 conf_set_class_connectfreq(void *data
)
795 yy_class
->con_freq
= *(unsigned int *) data
;
799 conf_set_class_max_number(void *data
)
801 yy_class
->max_total
= *(unsigned int *) data
;
805 conf_set_class_sendq(void *data
)
807 yy_class
->max_sendq
= *(unsigned int *) data
;
810 static char *listener_address
;
813 conf_begin_listen(struct TopConf
*tc
)
815 rb_free(listener_address
);
816 listener_address
= NULL
;
821 conf_end_listen(struct TopConf
*tc
)
823 rb_free(listener_address
);
824 listener_address
= NULL
;
831 conf_set_listen_port_both(void *data
, int ssl
)
833 conf_parm_t
*args
= data
;
834 for (; args
; args
= args
->next
)
836 if((args
->type
& CF_MTYPE
) != CF_INT
)
839 ("listener::port argument is not an integer " "-- ignoring.");
842 if(listener_address
== NULL
)
844 add_listener(args
->v
.number
, listener_address
, AF_INET
, ssl
);
846 add_listener(args
->v
.number
, listener_address
, AF_INET6
, ssl
);
853 if(strchr(listener_address
, ':') != NULL
)
859 add_listener(args
->v
.number
, listener_address
, family
, ssl
);
867 conf_set_listen_port(void *data
)
869 conf_set_listen_port_both(data
, 0);
873 conf_set_listen_sslport(void *data
)
875 conf_set_listen_port_both(data
, 1);
879 conf_set_listen_address(void *data
)
881 rb_free(listener_address
);
882 listener_address
= rb_strdup(data
);
886 conf_begin_auth(struct TopConf
*tc
)
889 rb_dlink_node
*next_ptr
;
894 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, yy_aconf_list
.head
)
896 free_conf(ptr
->data
);
897 rb_dlinkDestroy(ptr
, &yy_aconf_list
);
900 yy_aconf
= make_conf();
901 yy_aconf
->status
= CONF_CLIENT
;
907 conf_end_auth(struct TopConf
*tc
)
909 struct ConfItem
*yy_tmp
, *found_conf
;
911 rb_dlink_node
*next_ptr
;
913 if(EmptyString(yy_aconf
->info
.name
))
914 yy_aconf
->info
.name
= rb_strdup("NOMATCH");
916 /* didnt even get one ->host? */
917 if(EmptyString(yy_aconf
->host
))
919 conf_report_error("Ignoring auth block -- missing user@host");
923 /* so the stacking works in order.. */
924 collapse(yy_aconf
->user
);
925 collapse(yy_aconf
->host
);
926 conf_add_class_to_conf(yy_aconf
);
927 if ((found_conf
= find_exact_conf_by_address("*", CONF_CLIENT
, "*")) && found_conf
->spasswd
== NULL
)
928 conf_report_error("Ignoring redundant auth block (after *@*)");
929 else if ((found_conf
= find_exact_conf_by_address(yy_aconf
->host
, CONF_CLIENT
, yy_aconf
->user
)) &&
930 (!found_conf
->spasswd
|| (yy_aconf
->spasswd
&&
931 0 == irccmp(found_conf
->spasswd
, yy_aconf
->spasswd
))))
932 conf_report_error("Ignoring duplicate auth block for %s@%s",
933 yy_aconf
->user
, yy_aconf
->host
);
935 add_conf_by_address(yy_aconf
->host
, CONF_CLIENT
, yy_aconf
->user
, yy_aconf
->spasswd
, yy_aconf
);
937 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, yy_aconf_list
.head
)
942 yy_tmp
->passwd
= rb_strdup(yy_aconf
->passwd
);
944 if(yy_aconf
->spasswd
)
945 yy_tmp
->spasswd
= rb_strdup(yy_aconf
->spasswd
);
947 /* this will always exist.. */
948 yy_tmp
->info
.name
= rb_strdup(yy_aconf
->info
.name
);
950 if(yy_aconf
->className
)
951 yy_tmp
->className
= rb_strdup(yy_aconf
->className
);
953 yy_tmp
->flags
= yy_aconf
->flags
;
954 yy_tmp
->port
= yy_aconf
->port
;
956 collapse(yy_tmp
->user
);
957 collapse(yy_tmp
->host
);
959 conf_add_class_to_conf(yy_tmp
);
961 if (find_exact_conf_by_address("*", CONF_CLIENT
, "*"))
962 conf_report_error("Ignoring redundant auth block (after *@*)");
963 else if (find_exact_conf_by_address(yy_tmp
->host
, CONF_CLIENT
, yy_tmp
->user
))
964 conf_report_error("Ignoring duplicate auth block for %s@%s",
965 yy_tmp
->user
, yy_tmp
->host
);
967 add_conf_by_address(yy_tmp
->host
, CONF_CLIENT
, yy_tmp
->user
, yy_tmp
->spasswd
, yy_tmp
);
968 rb_dlinkDestroy(ptr
, &yy_aconf_list
);
976 conf_set_auth_user(void *data
)
978 struct ConfItem
*yy_tmp
;
981 /* The first user= line doesn't allocate a new conf */
982 if(!EmptyString(yy_aconf
->host
))
984 yy_tmp
= make_conf();
985 yy_tmp
->status
= CONF_CLIENT
;
990 if((p
= strchr(data
, '@')))
994 yy_tmp
->user
= rb_strdup(data
);
995 yy_tmp
->host
= rb_strdup(p
);
999 yy_tmp
->user
= rb_strdup("*");
1000 yy_tmp
->host
= rb_strdup(data
);
1003 if(yy_aconf
!= yy_tmp
)
1004 rb_dlinkAddAlloc(yy_tmp
, &yy_aconf_list
);
1008 conf_set_auth_auth_user(void *data
)
1010 if(yy_aconf
->spasswd
)
1011 memset(yy_aconf
->spasswd
, 0, strlen(yy_aconf
->spasswd
));
1012 rb_free(yy_aconf
->spasswd
);
1013 yy_aconf
->spasswd
= rb_strdup(data
);
1017 conf_set_auth_passwd(void *data
)
1019 if(yy_aconf
->passwd
)
1020 memset(yy_aconf
->passwd
, 0, strlen(yy_aconf
->passwd
));
1021 rb_free(yy_aconf
->passwd
);
1022 yy_aconf
->passwd
= rb_strdup(data
);
1026 conf_set_auth_spoof(void *data
)
1034 /* user@host spoof */
1035 if((p
= strchr(host
, '@')) != NULL
)
1041 if(EmptyString(user
))
1043 conf_report_error("Warning -- spoof ident empty.");
1047 if(strlen(user
) > USERLEN
)
1049 conf_report_error("Warning -- spoof ident length invalid.");
1053 if(!valid_username(user
))
1055 conf_report_error("Warning -- invalid spoof (ident).");
1059 /* this must be restored! */
1063 if(EmptyString(host
))
1065 conf_report_error("Warning -- spoof host empty.");
1069 if(strlen(host
) > HOSTLEN
)
1071 conf_report_error("Warning -- spoof host length invalid.");
1075 if(!valid_hostname(host
))
1077 conf_report_error("Warning -- invalid spoof (host).");
1081 rb_free(yy_aconf
->info
.name
);
1082 yy_aconf
->info
.name
= rb_strdup(data
);
1083 yy_aconf
->flags
|= CONF_FLAGS_SPOOF_IP
;
1087 conf_set_auth_flags(void *data
)
1089 conf_parm_t
*args
= data
;
1091 set_modes_from_table((int *) &yy_aconf
->flags
, "flag", auth_table
, args
);
1095 conf_set_auth_redir_serv(void *data
)
1097 yy_aconf
->flags
|= CONF_FLAGS_REDIR
;
1098 rb_free(yy_aconf
->info
.name
);
1099 yy_aconf
->info
.name
= rb_strdup(data
);
1103 conf_set_auth_redir_port(void *data
)
1105 int port
= *(unsigned int *) data
;
1107 yy_aconf
->flags
|= CONF_FLAGS_REDIR
;
1108 yy_aconf
->port
= port
;
1112 conf_set_auth_class(void *data
)
1114 rb_free(yy_aconf
->className
);
1115 yy_aconf
->className
= rb_strdup(data
);
1118 /* ok, shared_oper handles the stacking, shared_flags handles adding
1119 * things.. so all we need to do when we start and end a shared block, is
1120 * clean up anything thats been left over.
1123 conf_cleanup_shared(struct TopConf
*tc
)
1125 rb_dlink_node
*ptr
, *next_ptr
;
1127 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, yy_shared_list
.head
)
1129 free_remote_conf(ptr
->data
);
1130 rb_dlinkDestroy(ptr
, &yy_shared_list
);
1133 if(yy_shared
!= NULL
)
1135 free_remote_conf(yy_shared
);
1143 conf_set_shared_oper(void *data
)
1145 conf_parm_t
*args
= data
;
1146 const char *username
;
1149 if(yy_shared
!= NULL
)
1150 free_remote_conf(yy_shared
);
1152 yy_shared
= make_remote_conf();
1154 if(args
->next
!= NULL
)
1156 if((args
->type
& CF_MTYPE
) != CF_QSTRING
)
1158 conf_report_error("Ignoring shared::oper -- server is not a qstring");
1162 yy_shared
->server
= rb_strdup(args
->v
.string
);
1166 yy_shared
->server
= rb_strdup("*");
1168 if((args
->type
& CF_MTYPE
) != CF_QSTRING
)
1170 conf_report_error("Ignoring shared::oper -- oper is not a qstring");
1174 if((p
= strchr(args
->v
.string
, '@')) == NULL
)
1176 conf_report_error("Ignoring shard::oper -- oper is not a user@host");
1180 username
= args
->v
.string
;
1184 yy_shared
->host
= rb_strdup("*");
1186 yy_shared
->host
= rb_strdup(p
);
1188 if(EmptyString(username
))
1189 yy_shared
->username
= rb_strdup("*");
1191 yy_shared
->username
= rb_strdup(username
);
1193 rb_dlinkAddAlloc(yy_shared
, &yy_shared_list
);
1198 conf_set_shared_flags(void *data
)
1200 conf_parm_t
*args
= data
;
1202 rb_dlink_node
*ptr
, *next_ptr
;
1204 if(yy_shared
!= NULL
)
1205 free_remote_conf(yy_shared
);
1207 set_modes_from_table(&flags
, "flag", shared_table
, args
);
1209 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, yy_shared_list
.head
)
1211 yy_shared
= ptr
->data
;
1213 yy_shared
->flags
= flags
;
1214 rb_dlinkDestroy(ptr
, &yy_shared_list
);
1215 rb_dlinkAddTail(yy_shared
, &yy_shared
->node
, &shared_conf_list
);
1222 conf_begin_connect(struct TopConf
*tc
)
1225 free_server_conf(yy_server
);
1227 yy_server
= make_server_conf();
1228 yy_server
->port
= PORTNUM
;
1229 yy_server
->flags
|= SERVER_TB
;
1231 if(conf_cur_block_name
!= NULL
)
1232 yy_server
->name
= rb_strdup(conf_cur_block_name
);
1238 conf_end_connect(struct TopConf
*tc
)
1240 if(EmptyString(yy_server
->name
))
1242 conf_report_error("Ignoring connect block -- missing name.");
1246 if(ServerInfo
.name
!= NULL
&& !irccmp(ServerInfo
.name
, yy_server
->name
))
1248 conf_report_error("Ignoring connect block for %s -- name is equal to my own name.",
1253 if((EmptyString(yy_server
->passwd
) || EmptyString(yy_server
->spasswd
)) && EmptyString(yy_server
->certfp
))
1255 conf_report_error("Ignoring connect block for %s -- no fingerprint or password credentials provided.",
1260 if(EmptyString(yy_server
->host
))
1262 conf_report_error("Ignoring connect block for %s -- missing host.",
1268 if(ServerConfCompressed(yy_server
))
1270 conf_report_error("Ignoring connect::flags::compressed -- zlib not available.");
1271 yy_server
->flags
&= ~SERVER_COMPRESSED
;
1275 add_server_conf(yy_server
);
1276 rb_dlinkAdd(yy_server
, &yy_server
->node
, &server_conf_list
);
1283 conf_set_connect_host(void *data
)
1285 rb_free(yy_server
->host
);
1286 yy_server
->host
= rb_strdup(data
);
1287 if (strchr(yy_server
->host
, ':'))
1288 yy_server
->aftype
= AF_INET6
;
1292 conf_set_connect_vhost(void *data
)
1294 if(rb_inet_pton_sock(data
, (struct sockaddr
*)&yy_server
->my_ipnum
) <= 0)
1296 conf_report_error("Invalid netmask for server vhost (%s)",
1301 yy_server
->flags
|= SERVER_VHOSTED
;
1305 conf_set_connect_send_password(void *data
)
1307 if(yy_server
->spasswd
)
1309 memset(yy_server
->spasswd
, 0, strlen(yy_server
->spasswd
));
1310 rb_free(yy_server
->spasswd
);
1313 yy_server
->spasswd
= rb_strdup(data
);
1317 conf_set_connect_accept_password(void *data
)
1319 if(yy_server
->passwd
)
1321 memset(yy_server
->passwd
, 0, strlen(yy_server
->passwd
));
1322 rb_free(yy_server
->passwd
);
1324 yy_server
->passwd
= rb_strdup(data
);
1328 conf_set_connect_fingerprint(void *data
)
1330 if (yy_server
->certfp
)
1331 rb_free(yy_server
->certfp
);
1332 yy_server
->certfp
= rb_strdup((char *) data
);
1334 /* force SSL to be enabled if fingerprint is enabled. */
1335 yy_server
->flags
|= SERVER_SSL
;
1339 conf_set_connect_port(void *data
)
1341 int port
= *(unsigned int *) data
;
1346 yy_server
->port
= port
;
1350 conf_set_connect_aftype(void *data
)
1354 if(strcasecmp(aft
, "ipv4") == 0)
1355 yy_server
->aftype
= AF_INET
;
1357 else if(strcasecmp(aft
, "ipv6") == 0)
1358 yy_server
->aftype
= AF_INET6
;
1361 conf_report_error("connect::aftype '%s' is unknown.", aft
);
1365 conf_set_connect_flags(void *data
)
1367 conf_parm_t
*args
= data
;
1369 /* note, we allow them to set compressed, then remove it later if
1370 * they do and LIBZ isnt available
1372 set_modes_from_table(&yy_server
->flags
, "flag", connect_table
, args
);
1376 conf_set_connect_hub_mask(void *data
)
1378 struct remote_conf
*yy_hub
;
1380 if(EmptyString(yy_server
->name
))
1383 yy_hub
= make_remote_conf();
1384 yy_hub
->flags
= CONF_HUB
;
1386 yy_hub
->host
= rb_strdup(data
);
1387 yy_hub
->server
= rb_strdup(yy_server
->name
);
1388 rb_dlinkAdd(yy_hub
, &yy_hub
->node
, &hubleaf_conf_list
);
1392 conf_set_connect_leaf_mask(void *data
)
1394 struct remote_conf
*yy_leaf
;
1396 if(EmptyString(yy_server
->name
))
1399 yy_leaf
= make_remote_conf();
1400 yy_leaf
->flags
= CONF_LEAF
;
1402 yy_leaf
->host
= rb_strdup(data
);
1403 yy_leaf
->server
= rb_strdup(yy_server
->name
);
1404 rb_dlinkAdd(yy_leaf
, &yy_leaf
->node
, &hubleaf_conf_list
);
1408 conf_set_connect_class(void *data
)
1410 rb_free(yy_server
->class_name
);
1411 yy_server
->class_name
= rb_strdup(data
);
1415 conf_set_exempt_ip(void *data
)
1417 struct ConfItem
*yy_tmp
;
1419 if(parse_netmask(data
, NULL
, NULL
) == HM_HOST
)
1421 conf_report_error("Ignoring exempt -- invalid exempt::ip.");
1425 yy_tmp
= make_conf();
1426 yy_tmp
->passwd
= rb_strdup("*");
1427 yy_tmp
->host
= rb_strdup(data
);
1428 yy_tmp
->status
= CONF_EXEMPTDLINE
;
1429 add_conf_by_address(yy_tmp
->host
, CONF_EXEMPTDLINE
, NULL
, NULL
, yy_tmp
);
1433 conf_cleanup_cluster(struct TopConf
*tc
)
1435 rb_dlink_node
*ptr
, *next_ptr
;
1437 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, yy_cluster_list
.head
)
1439 free_remote_conf(ptr
->data
);
1440 rb_dlinkDestroy(ptr
, &yy_cluster_list
);
1443 if(yy_shared
!= NULL
)
1445 free_remote_conf(yy_shared
);
1453 conf_set_cluster_name(void *data
)
1455 if(yy_shared
!= NULL
)
1456 free_remote_conf(yy_shared
);
1458 yy_shared
= make_remote_conf();
1459 yy_shared
->server
= rb_strdup(data
);
1460 rb_dlinkAddAlloc(yy_shared
, &yy_cluster_list
);
1466 conf_set_cluster_flags(void *data
)
1468 conf_parm_t
*args
= data
;
1470 rb_dlink_node
*ptr
, *next_ptr
;
1472 if(yy_shared
!= NULL
)
1473 free_remote_conf(yy_shared
);
1475 set_modes_from_table(&flags
, "flag", cluster_table
, args
);
1477 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, yy_cluster_list
.head
)
1479 yy_shared
= ptr
->data
;
1480 yy_shared
->flags
= flags
;
1481 rb_dlinkAddTail(yy_shared
, &yy_shared
->node
, &cluster_conf_list
);
1482 rb_dlinkDestroy(ptr
, &yy_cluster_list
);
1489 conf_set_general_havent_read_conf(void *data
)
1491 if(*(unsigned int *) data
)
1493 conf_report_error("You haven't read your config file properly.");
1495 ("There is a line in the example conf that will kill your server if not removed.");
1497 ("Consider actually reading/editing the conf file, and removing this line.");
1504 conf_set_general_hide_error_messages(void *data
)
1508 if(strcasecmp(val
, "yes") == 0)
1509 ConfigFileEntry
.hide_error_messages
= 2;
1510 else if(strcasecmp(val
, "opers") == 0)
1511 ConfigFileEntry
.hide_error_messages
= 1;
1512 else if(strcasecmp(val
, "no") == 0)
1513 ConfigFileEntry
.hide_error_messages
= 0;
1515 conf_report_error("Invalid setting '%s' for general::hide_error_messages.", val
);
1519 conf_set_general_kline_delay(void *data
)
1521 ConfigFileEntry
.kline_delay
= *(unsigned int *) data
;
1523 /* THIS MUST BE HERE to stop us being unable to check klines */
1528 conf_set_general_stats_k_oper_only(void *data
)
1532 if(strcasecmp(val
, "yes") == 0)
1533 ConfigFileEntry
.stats_k_oper_only
= 2;
1534 else if(strcasecmp(val
, "masked") == 0)
1535 ConfigFileEntry
.stats_k_oper_only
= 1;
1536 else if(strcasecmp(val
, "no") == 0)
1537 ConfigFileEntry
.stats_k_oper_only
= 0;
1539 conf_report_error("Invalid setting '%s' for general::stats_k_oper_only.", val
);
1543 conf_set_general_stats_i_oper_only(void *data
)
1547 if(strcasecmp(val
, "yes") == 0)
1548 ConfigFileEntry
.stats_i_oper_only
= 2;
1549 else if(strcasecmp(val
, "masked") == 0)
1550 ConfigFileEntry
.stats_i_oper_only
= 1;
1551 else if(strcasecmp(val
, "no") == 0)
1552 ConfigFileEntry
.stats_i_oper_only
= 0;
1554 conf_report_error("Invalid setting '%s' for general::stats_i_oper_only.", val
);
1558 conf_set_general_compression_level(void *data
)
1561 ConfigFileEntry
.compression_level
= *(unsigned int *) data
;
1563 if((ConfigFileEntry
.compression_level
< 1) || (ConfigFileEntry
.compression_level
> 9))
1566 ("Invalid general::compression_level %d -- using default.",
1567 ConfigFileEntry
.compression_level
);
1568 ConfigFileEntry
.compression_level
= 0;
1571 conf_report_error("Ignoring general::compression_level -- zlib not available.");
1576 conf_set_general_default_umodes(void *data
)
1579 int what
= MODE_ADD
, flag
;
1581 ConfigFileEntry
.default_umodes
= 0;
1582 for (pm
= (char *) data
; *pm
; pm
++)
1593 /* don't allow +o */
1601 if ((flag
= user_modes
[(unsigned char) *pm
]))
1603 /* Proper value has probably not yet been set
1604 * so don't check oper_only_umodes -- jilles */
1605 if (what
== MODE_ADD
)
1606 ConfigFileEntry
.default_umodes
|= flag
;
1608 ConfigFileEntry
.default_umodes
&= ~flag
;
1616 conf_set_general_oper_umodes(void *data
)
1618 set_modes_from_table(&ConfigFileEntry
.oper_umodes
, "umode", umode_table
, data
);
1622 conf_set_general_oper_only_umodes(void *data
)
1624 set_modes_from_table(&ConfigFileEntry
.oper_only_umodes
, "umode", umode_table
, data
);
1628 conf_set_general_oper_snomask(void *data
)
1631 int what
= MODE_ADD
, flag
;
1633 ConfigFileEntry
.oper_snomask
= 0;
1634 for (pm
= (char *) data
; *pm
; pm
++)
1646 if ((flag
= snomask_modes
[(unsigned char) *pm
]))
1648 if (what
== MODE_ADD
)
1649 ConfigFileEntry
.oper_snomask
|= flag
;
1651 ConfigFileEntry
.oper_snomask
&= ~flag
;
1659 conf_set_serverhide_links_delay(void *data
)
1661 int val
= *(unsigned int *) data
;
1663 ConfigServerHide
.links_delay
= val
;
1667 conf_begin_service(struct TopConf
*tc
)
1669 struct Client
*target_p
;
1672 RB_DLINK_FOREACH(ptr
, global_serv_list
.head
)
1674 target_p
= ptr
->data
;
1676 target_p
->flags
&= ~FLAGS_SERVICE
;
1683 conf_set_service_name(void *data
)
1685 struct Client
*target_p
;
1690 for(s
= data
; *s
!= '\0'; s
++)
1694 conf_report_error("Ignoring service::name "
1695 "-- bogus servername.");
1704 conf_report_error("Ignoring service::name -- must contain '.'");
1708 tmp
= rb_strdup(data
);
1709 rb_dlinkAddAlloc(tmp
, &service_list
);
1711 if((target_p
= find_server(NULL
, tmp
)))
1712 target_p
->flags
|= FLAGS_SERVICE
;
1716 conf_begin_alias(struct TopConf
*tc
)
1718 yy_alias
= rb_malloc(sizeof(struct alias_entry
));
1720 if (conf_cur_block_name
!= NULL
)
1721 yy_alias
->name
= rb_strdup(conf_cur_block_name
);
1723 yy_alias
->flags
= 0;
1730 conf_end_alias(struct TopConf
*tc
)
1732 if (yy_alias
== NULL
)
1735 if (yy_alias
->name
== NULL
)
1737 conf_report_error("Ignoring alias -- must have a name.");
1744 if (yy_alias
->target
== NULL
)
1746 conf_report_error("Ignoring alias -- must have a target.");
1753 irc_dictionary_add(alias_dict
, yy_alias
->name
, yy_alias
);
1759 conf_set_alias_name(void *data
)
1761 if (data
== NULL
|| yy_alias
== NULL
) /* this shouldn't ever happen */
1764 yy_alias
->name
= rb_strdup(data
);
1768 conf_set_alias_target(void *data
)
1770 if (data
== NULL
|| yy_alias
== NULL
) /* this shouldn't ever happen */
1773 yy_alias
->target
= rb_strdup(data
);
1777 conf_set_blacklist_host(void *data
)
1779 yy_blacklist_host
= rb_strdup(data
);
1783 conf_set_blacklist_type(void *data
)
1785 conf_parm_t
*args
= data
;
1787 /* Don't assume we have either if we got here */
1788 yy_blacklist_ipv4
= 0;
1789 yy_blacklist_ipv6
= 0;
1791 for (; args
; args
= args
->next
)
1793 if (!strcasecmp(args
->v
.string
, "ipv4"))
1794 yy_blacklist_ipv4
= 1;
1795 else if (!strcasecmp(args
->v
.string
, "ipv6"))
1796 yy_blacklist_ipv6
= 1;
1798 conf_report_error("blacklist::type has unknown address family %s",
1802 /* If we have neither, just default to IPv4 */
1803 if (!yy_blacklist_ipv4
&& !yy_blacklist_ipv6
)
1805 conf_report_error("blacklist::type has neither IPv4 nor IPv6 (defaulting to IPv4)");
1806 yy_blacklist_ipv4
= 1;
1811 conf_set_blacklist_reason(void *data
)
1813 yy_blacklist_reason
= rb_strdup(data
);
1815 if (yy_blacklist_host
&& yy_blacklist_reason
)
1817 if (yy_blacklist_ipv6
)
1819 /* Make sure things fit (64 = alnum count + dots) */
1820 if ((64 + strlen(yy_blacklist_host
)) > IRCD_RES_HOSTLEN
)
1822 conf_report_error("blacklist::host %s results in IPv6 queries that are too long",
1827 /* Avoid doing redundant check, IPv6 is bigger than IPv4 --Elizabeth */
1828 if (yy_blacklist_ipv4
&& !yy_blacklist_ipv6
)
1830 /* Make sure things fit (16 = number of nums + dots) */
1831 if ((16 + strlen(yy_blacklist_host
)) > IRCD_RES_HOSTLEN
)
1833 conf_report_error("blacklist::host %s results in IPv4 queries that are too long",
1839 new_blacklist(yy_blacklist_host
, yy_blacklist_reason
, yy_blacklist_ipv4
, yy_blacklist_ipv6
);
1842 rb_free(yy_blacklist_host
);
1843 rb_free(yy_blacklist_reason
);
1844 yy_blacklist_host
= NULL
;
1845 yy_blacklist_reason
= NULL
;
1846 yy_blacklist_ipv4
= 1;
1847 yy_blacklist_ipv6
= 0;
1851 /* public functions */
1855 conf_report_error(const char *fmt
, ...)
1858 char msg
[IRCD_BUFSIZE
+ 1] = { 0 };
1861 rb_vsnprintf(msg
, IRCD_BUFSIZE
, fmt
, ap
);
1866 fprintf(stderr
, "\"%s\", line %d: %s\n", current_file
, lineno
+ 1, msg
);
1870 ierror("\"%s\", line %d: %s", current_file
, lineno
+ 1, msg
);
1871 sendto_realops_snomask(SNO_GENERAL
, L_ALL
, "\"%s\", line %d: %s", current_file
, lineno
+ 1, msg
);
1875 conf_start_block(char *block
, char *name
)
1877 if((conf_cur_block
= find_top_conf(block
)) == NULL
)
1879 conf_report_error("Configuration block '%s' is not defined.", block
);
1884 conf_cur_block_name
= rb_strdup(name
);
1886 conf_cur_block_name
= NULL
;
1888 if(conf_cur_block
->tc_sfunc
)
1889 if(conf_cur_block
->tc_sfunc(conf_cur_block
) < 0)
1896 conf_end_block(struct TopConf
*tc
)
1899 return tc
->tc_efunc(tc
);
1901 rb_free(conf_cur_block_name
);
1906 conf_set_generic_int(void *data
, void *location
)
1908 *((int *) location
) = *((unsigned int *) data
);
1912 conf_set_generic_string(void *data
, int len
, void *location
)
1914 char **loc
= location
;
1917 if(len
&& strlen(input
) > (unsigned int)len
)
1921 *loc
= rb_strdup(input
);
1925 conf_call_set(struct TopConf
*tc
, char *item
, conf_parm_t
* value
, int type
)
1927 struct ConfEntry
*cf
;
1933 if((cf
= find_conf_item(tc
, item
)) == NULL
)
1936 ("Non-existant configuration setting %s::%s.", tc
->tc_name
, (char *) item
);
1940 /* if it takes one thing, make sure they only passed one thing,
1941 and handle as needed. */
1942 if((value
->v
.list
->type
& CF_FLIST
) && !(cf
->cf_type
& CF_FLIST
))
1945 ("Option %s::%s does not take a list of values.", tc
->tc_name
, item
);
1952 if(CF_TYPE(value
->v
.list
->type
) != CF_TYPE(cf
->cf_type
))
1954 /* if it expects a string value, but we got a yesno,
1957 if((CF_TYPE(value
->v
.list
->type
) == CF_YESNO
) &&
1958 (CF_TYPE(cf
->cf_type
) == CF_STRING
))
1960 value
->v
.list
->type
= CF_STRING
;
1962 if(cp
->v
.number
== 1)
1963 cp
->v
.string
= rb_strdup("yes");
1965 cp
->v
.string
= rb_strdup("no");
1968 /* maybe it's a CF_TIME and they passed CF_INT --
1969 should still be valid */
1970 else if(!((CF_TYPE(value
->v
.list
->type
) == CF_INT
) &&
1971 (CF_TYPE(cf
->cf_type
) == CF_TIME
)))
1974 ("Wrong type for %s::%s (expected %s, got %s)",
1975 tc
->tc_name
, (char *) item
,
1976 conf_strtype(cf
->cf_type
), conf_strtype(value
->v
.list
->type
));
1981 if(cf
->cf_type
& CF_FLIST
)
1985 conf_set_generic_list(value
->v
.list
, cf
->cf_arg
);
1988 /* just pass it the extended argument list */
1989 cf
->cf_func(value
->v
.list
);
1993 /* it's old-style, needs only one arg */
1994 switch (cf
->cf_type
)
2000 conf_set_generic_int(&cp
->v
.number
, cf
->cf_arg
);
2002 cf
->cf_func(&cp
->v
.number
);
2006 if(EmptyString(cp
->v
.string
))
2007 conf_report_error("Ignoring %s::%s -- empty field",
2010 conf_set_generic_string(cp
->v
.string
, cf
->cf_len
, cf
->cf_arg
);
2012 cf
->cf_func(cp
->v
.string
);
2022 add_conf_item(const char *topconf
, const char *name
, int type
, void (*func
) (void *))
2025 struct ConfEntry
*cf
;
2027 if((tc
= find_top_conf(topconf
)) == NULL
)
2030 if((cf
= find_conf_item(tc
, name
)) != NULL
)
2033 cf
= rb_malloc(sizeof(struct ConfEntry
));
2040 rb_dlinkAddAlloc(cf
, &tc
->tc_items
);
2046 remove_conf_item(const char *topconf
, const char *name
)
2049 struct ConfEntry
*cf
;
2052 if((tc
= find_top_conf(topconf
)) == NULL
)
2055 if((cf
= find_conf_item(tc
, name
)) == NULL
)
2058 if((ptr
= rb_dlinkFind(cf
, &tc
->tc_items
)) == NULL
)
2061 rb_dlinkDestroy(ptr
, &tc
->tc_items
);
2068 static struct ConfEntry conf_serverinfo_table
[] =
2070 { "description", CF_QSTRING
, NULL
, 0, &ServerInfo
.description
},
2071 { "network_desc", CF_QSTRING
, NULL
, 0, &ServerInfo
.network_desc
},
2072 { "hub", CF_YESNO
, NULL
, 0, &ServerInfo
.hub
},
2074 { "network_name", CF_QSTRING
, conf_set_serverinfo_network_name
, 0, NULL
},
2075 { "name", CF_QSTRING
, conf_set_serverinfo_name
, 0, NULL
},
2076 { "sid", CF_QSTRING
, conf_set_serverinfo_sid
, 0, NULL
},
2077 { "vhost", CF_QSTRING
, conf_set_serverinfo_vhost
, 0, NULL
},
2078 { "vhost6", CF_QSTRING
, conf_set_serverinfo_vhost6
, 0, NULL
},
2080 { "ssl_private_key", CF_QSTRING
, NULL
, 0, &ServerInfo
.ssl_private_key
},
2081 { "ssl_ca_cert", CF_QSTRING
, NULL
, 0, &ServerInfo
.ssl_ca_cert
},
2082 { "ssl_cert", CF_QSTRING
, NULL
, 0, &ServerInfo
.ssl_cert
},
2083 { "ssl_dh_params", CF_QSTRING
, NULL
, 0, &ServerInfo
.ssl_dh_params
},
2084 { "ssld_count", CF_INT
, NULL
, 0, &ServerInfo
.ssld_count
},
2086 { "default_max_clients",CF_INT
, NULL
, 0, &ServerInfo
.default_max_clients
},
2088 { "\0", 0, NULL
, 0, NULL
}
2091 static struct ConfEntry conf_admin_table
[] =
2093 { "name", CF_QSTRING
, NULL
, 200, &AdminInfo
.name
},
2094 { "description",CF_QSTRING
, NULL
, 200, &AdminInfo
.description
},
2095 { "email", CF_QSTRING
, NULL
, 200, &AdminInfo
.email
},
2096 { "\0", 0, NULL
, 0, NULL
}
2099 static struct ConfEntry conf_log_table
[] =
2101 { "fname_userlog", CF_QSTRING
, NULL
, MAXPATHLEN
, &ConfigFileEntry
.fname_userlog
},
2102 { "fname_fuserlog", CF_QSTRING
, NULL
, MAXPATHLEN
, &ConfigFileEntry
.fname_fuserlog
},
2103 { "fname_operlog", CF_QSTRING
, NULL
, MAXPATHLEN
, &ConfigFileEntry
.fname_operlog
},
2104 { "fname_foperlog", CF_QSTRING
, NULL
, MAXPATHLEN
, &ConfigFileEntry
.fname_foperlog
},
2105 { "fname_serverlog", CF_QSTRING
, NULL
, MAXPATHLEN
, &ConfigFileEntry
.fname_serverlog
},
2106 { "fname_killlog", CF_QSTRING
, NULL
, MAXPATHLEN
, &ConfigFileEntry
.fname_killlog
},
2107 { "fname_klinelog", CF_QSTRING
, NULL
, MAXPATHLEN
, &ConfigFileEntry
.fname_klinelog
},
2108 { "fname_operspylog", CF_QSTRING
, NULL
, MAXPATHLEN
, &ConfigFileEntry
.fname_operspylog
},
2109 { "fname_ioerrorlog", CF_QSTRING
, NULL
, MAXPATHLEN
, &ConfigFileEntry
.fname_ioerrorlog
},
2110 { "\0", 0, NULL
, 0, NULL
}
2113 static struct ConfEntry conf_operator_table
[] =
2115 { "rsa_public_key_file", CF_QSTRING
, conf_set_oper_rsa_public_key_file
, 0, NULL
},
2116 { "flags", CF_STRING
| CF_FLIST
, conf_set_oper_flags
, 0, NULL
},
2117 { "umodes", CF_STRING
| CF_FLIST
, conf_set_oper_umodes
, 0, NULL
},
2118 { "privset", CF_QSTRING
, conf_set_oper_privset
, 0, NULL
},
2119 { "snomask", CF_QSTRING
, conf_set_oper_snomask
, 0, NULL
},
2120 { "user", CF_QSTRING
, conf_set_oper_user
, 0, NULL
},
2121 { "password", CF_QSTRING
, conf_set_oper_password
, 0, NULL
},
2122 { "fingerprint", CF_QSTRING
, conf_set_oper_fingerprint
, 0, NULL
},
2123 { "\0", 0, NULL
, 0, NULL
}
2126 static struct ConfEntry conf_privset_table
[] =
2128 { "extends", CF_QSTRING
, conf_set_privset_extends
, 0, NULL
},
2129 { "privs", CF_STRING
| CF_FLIST
, conf_set_privset_privs
, 0, NULL
},
2130 { "\0", 0, NULL
, 0, NULL
}
2133 static struct ConfEntry conf_class_table
[] =
2135 { "ping_time", CF_TIME
, conf_set_class_ping_time
, 0, NULL
},
2136 { "cidr_ipv4_bitlen", CF_INT
, conf_set_class_cidr_ipv4_bitlen
, 0, NULL
},
2138 { "cidr_ipv6_bitlen", CF_INT
, conf_set_class_cidr_ipv6_bitlen
, 0, NULL
},
2140 { "number_per_cidr", CF_INT
, conf_set_class_number_per_cidr
, 0, NULL
},
2141 { "number_per_ip", CF_INT
, conf_set_class_number_per_ip
, 0, NULL
},
2142 { "number_per_ip_global", CF_INT
,conf_set_class_number_per_ip_global
, 0, NULL
},
2143 { "number_per_ident", CF_INT
, conf_set_class_number_per_ident
, 0, NULL
},
2144 { "connectfreq", CF_TIME
, conf_set_class_connectfreq
, 0, NULL
},
2145 { "max_number", CF_INT
, conf_set_class_max_number
, 0, NULL
},
2146 { "sendq", CF_TIME
, conf_set_class_sendq
, 0, NULL
},
2147 { "\0", 0, NULL
, 0, NULL
}
2150 static struct ConfEntry conf_auth_table
[] =
2152 { "user", CF_QSTRING
, conf_set_auth_user
, 0, NULL
},
2153 { "auth_user", CF_QSTRING
, conf_set_auth_auth_user
, 0, NULL
},
2154 { "password", CF_QSTRING
, conf_set_auth_passwd
, 0, NULL
},
2155 { "class", CF_QSTRING
, conf_set_auth_class
, 0, NULL
},
2156 { "spoof", CF_QSTRING
, conf_set_auth_spoof
, 0, NULL
},
2157 { "redirserv", CF_QSTRING
, conf_set_auth_redir_serv
, 0, NULL
},
2158 { "redirport", CF_INT
, conf_set_auth_redir_port
, 0, NULL
},
2159 { "flags", CF_STRING
| CF_FLIST
, conf_set_auth_flags
, 0, NULL
},
2160 { "\0", 0, NULL
, 0, NULL
}
2163 static struct ConfEntry conf_connect_table
[] =
2165 { "send_password", CF_QSTRING
, conf_set_connect_send_password
, 0, NULL
},
2166 { "accept_password", CF_QSTRING
, conf_set_connect_accept_password
, 0, NULL
},
2167 { "fingerprint", CF_QSTRING
, conf_set_connect_fingerprint
, 0, NULL
},
2168 { "flags", CF_STRING
| CF_FLIST
, conf_set_connect_flags
, 0, NULL
},
2169 { "host", CF_QSTRING
, conf_set_connect_host
, 0, NULL
},
2170 { "vhost", CF_QSTRING
, conf_set_connect_vhost
, 0, NULL
},
2171 { "port", CF_INT
, conf_set_connect_port
, 0, NULL
},
2172 { "aftype", CF_STRING
, conf_set_connect_aftype
, 0, NULL
},
2173 { "hub_mask", CF_QSTRING
, conf_set_connect_hub_mask
, 0, NULL
},
2174 { "leaf_mask", CF_QSTRING
, conf_set_connect_leaf_mask
, 0, NULL
},
2175 { "class", CF_QSTRING
, conf_set_connect_class
, 0, NULL
},
2176 { "\0", 0, NULL
, 0, NULL
}
2179 static struct ConfEntry conf_general_table
[] =
2181 { "oper_only_umodes", CF_STRING
| CF_FLIST
, conf_set_general_oper_only_umodes
, 0, NULL
},
2182 { "oper_umodes", CF_STRING
| CF_FLIST
, conf_set_general_oper_umodes
, 0, NULL
},
2183 { "oper_snomask", CF_QSTRING
, conf_set_general_oper_snomask
, 0, NULL
},
2184 { "compression_level", CF_INT
, conf_set_general_compression_level
, 0, NULL
},
2185 { "havent_read_conf", CF_YESNO
, conf_set_general_havent_read_conf
, 0, NULL
},
2186 { "hide_error_messages",CF_STRING
, conf_set_general_hide_error_messages
,0, NULL
},
2187 { "kline_delay", CF_TIME
, conf_set_general_kline_delay
, 0, NULL
},
2188 { "stats_k_oper_only", CF_STRING
, conf_set_general_stats_k_oper_only
, 0, NULL
},
2189 { "stats_i_oper_only", CF_STRING
, conf_set_general_stats_i_oper_only
, 0, NULL
},
2190 { "default_umodes", CF_QSTRING
, conf_set_general_default_umodes
, 0, NULL
},
2192 { "default_operstring", CF_QSTRING
, NULL
, REALLEN
, &ConfigFileEntry
.default_operstring
},
2193 { "default_adminstring",CF_QSTRING
, NULL
, REALLEN
, &ConfigFileEntry
.default_adminstring
},
2194 { "servicestring", CF_QSTRING
, NULL
, REALLEN
, &ConfigFileEntry
.servicestring
},
2195 { "egdpool_path", CF_QSTRING
, NULL
, MAXPATHLEN
, &ConfigFileEntry
.egdpool_path
},
2196 { "kline_reason", CF_QSTRING
, NULL
, REALLEN
, &ConfigFileEntry
.kline_reason
},
2197 { "identify_service", CF_QSTRING
, NULL
, REALLEN
, &ConfigFileEntry
.identifyservice
},
2198 { "identify_command", CF_QSTRING
, NULL
, REALLEN
, &ConfigFileEntry
.identifycommand
},
2200 { "anti_spam_exit_message_time", CF_TIME
, NULL
, 0, &ConfigFileEntry
.anti_spam_exit_message_time
},
2201 { "disable_fake_channels", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.disable_fake_channels
},
2202 { "min_nonwildcard_simple", CF_INT
, NULL
, 0, &ConfigFileEntry
.min_nonwildcard_simple
},
2203 { "non_redundant_klines", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.non_redundant_klines
},
2204 { "tkline_expire_notices", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.tkline_expire_notices
},
2206 { "anti_nick_flood", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.anti_nick_flood
},
2207 { "burst_away", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.burst_away
},
2208 { "caller_id_wait", CF_TIME
, NULL
, 0, &ConfigFileEntry
.caller_id_wait
},
2209 { "client_exit", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.client_exit
},
2210 { "collision_fnc", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.collision_fnc
},
2211 { "connect_timeout", CF_TIME
, NULL
, 0, &ConfigFileEntry
.connect_timeout
},
2212 { "default_floodcount", CF_INT
, NULL
, 0, &ConfigFileEntry
.default_floodcount
},
2213 { "default_ident_timeout", CF_INT
, NULL
, 0, &ConfigFileEntry
.default_ident_timeout
},
2214 { "disable_auth", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.disable_auth
},
2215 { "dots_in_ident", CF_INT
, NULL
, 0, &ConfigFileEntry
.dots_in_ident
},
2216 { "failed_oper_notice", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.failed_oper_notice
},
2217 { "global_snotices", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.global_snotices
},
2218 { "hide_spoof_ips", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.hide_spoof_ips
},
2219 { "dline_with_reason", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.dline_with_reason
},
2220 { "kline_with_reason", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.kline_with_reason
},
2221 { "map_oper_only", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.map_oper_only
},
2222 { "max_accept", CF_INT
, NULL
, 0, &ConfigFileEntry
.max_accept
},
2223 { "max_monitor", CF_INT
, NULL
, 0, &ConfigFileEntry
.max_monitor
},
2224 { "max_nick_time", CF_TIME
, NULL
, 0, &ConfigFileEntry
.max_nick_time
},
2225 { "max_nick_changes", CF_INT
, NULL
, 0, &ConfigFileEntry
.max_nick_changes
},
2226 { "max_targets", CF_INT
, NULL
, 0, &ConfigFileEntry
.max_targets
},
2227 { "min_nonwildcard", CF_INT
, NULL
, 0, &ConfigFileEntry
.min_nonwildcard
},
2228 { "nick_delay", CF_TIME
, NULL
, 0, &ConfigFileEntry
.nick_delay
},
2229 { "no_oper_flood", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.no_oper_flood
},
2230 { "operspy_admin_only", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.operspy_admin_only
},
2231 { "operspy_dont_care_user_info", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.operspy_dont_care_user_info
},
2232 { "pace_wait", CF_TIME
, NULL
, 0, &ConfigFileEntry
.pace_wait
},
2233 { "pace_wait_simple", CF_TIME
, NULL
, 0, &ConfigFileEntry
.pace_wait_simple
},
2234 { "ping_cookie", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.ping_cookie
},
2235 { "reject_after_count", CF_INT
, NULL
, 0, &ConfigFileEntry
.reject_after_count
},
2236 { "reject_ban_time", CF_TIME
, NULL
, 0, &ConfigFileEntry
.reject_ban_time
},
2237 { "reject_duration", CF_TIME
, NULL
, 0, &ConfigFileEntry
.reject_duration
},
2238 { "throttle_count", CF_INT
, NULL
, 0, &ConfigFileEntry
.throttle_count
},
2239 { "throttle_duration", CF_TIME
, NULL
, 0, &ConfigFileEntry
.throttle_duration
},
2240 { "short_motd", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.short_motd
},
2241 { "stats_c_oper_only", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.stats_c_oper_only
},
2242 { "stats_e_disabled", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.stats_e_disabled
},
2243 { "stats_h_oper_only", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.stats_h_oper_only
},
2244 { "stats_o_oper_only", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.stats_o_oper_only
},
2245 { "stats_P_oper_only", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.stats_P_oper_only
},
2246 { "stats_y_oper_only", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.stats_y_oper_only
},
2247 { "target_change", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.target_change
},
2248 { "ts_max_delta", CF_TIME
, NULL
, 0, &ConfigFileEntry
.ts_max_delta
},
2249 { "use_egd", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.use_egd
},
2250 { "ts_warn_delta", CF_TIME
, NULL
, 0, &ConfigFileEntry
.ts_warn_delta
},
2251 { "use_whois_actually", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.use_whois_actually
},
2252 { "warn_no_nline", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.warn_no_nline
},
2253 { "use_propagated_bans",CF_YESNO
, NULL
, 0, &ConfigFileEntry
.use_propagated_bans
},
2254 { "client_flood_max_lines", CF_INT
, NULL
, 0, &ConfigFileEntry
.client_flood_max_lines
},
2255 { "client_flood_burst_rate", CF_INT
, NULL
, 0, &ConfigFileEntry
.client_flood_burst_rate
},
2256 { "client_flood_burst_max", CF_INT
, NULL
, 0, &ConfigFileEntry
.client_flood_burst_max
},
2257 { "client_flood_message_num", CF_INT
, NULL
, 0, &ConfigFileEntry
.client_flood_message_num
},
2258 { "client_flood_message_time", CF_INT
, NULL
, 0, &ConfigFileEntry
.client_flood_message_time
},
2259 { "\0", 0, NULL
, 0, NULL
}
2262 static struct ConfEntry conf_channel_table
[] =
2264 { "default_split_user_count", CF_INT
, NULL
, 0, &ConfigChannel
.default_split_user_count
},
2265 { "default_split_server_count", CF_INT
, NULL
, 0, &ConfigChannel
.default_split_server_count
},
2266 { "burst_topicwho", CF_YESNO
, NULL
, 0, &ConfigChannel
.burst_topicwho
},
2267 { "kick_on_split_riding", CF_YESNO
, NULL
, 0, &ConfigChannel
.kick_on_split_riding
},
2268 { "knock_delay", CF_TIME
, NULL
, 0, &ConfigChannel
.knock_delay
},
2269 { "knock_delay_channel",CF_TIME
, NULL
, 0, &ConfigChannel
.knock_delay_channel
},
2270 { "max_bans", CF_INT
, NULL
, 0, &ConfigChannel
.max_bans
},
2271 { "max_bans_large", CF_INT
, NULL
, 0, &ConfigChannel
.max_bans_large
},
2272 { "max_chans_per_user", CF_INT
, NULL
, 0, &ConfigChannel
.max_chans_per_user
},
2273 { "no_create_on_split", CF_YESNO
, NULL
, 0, &ConfigChannel
.no_create_on_split
},
2274 { "no_join_on_split", CF_YESNO
, NULL
, 0, &ConfigChannel
.no_join_on_split
},
2275 { "only_ascii_channels", CF_YESNO
, NULL
, 0, &ConfigChannel
.only_ascii_channels
},
2276 { "use_except", CF_YESNO
, NULL
, 0, &ConfigChannel
.use_except
},
2277 { "use_invex", CF_YESNO
, NULL
, 0, &ConfigChannel
.use_invex
},
2278 { "use_knock", CF_YESNO
, NULL
, 0, &ConfigChannel
.use_knock
},
2279 { "use_forward", CF_YESNO
, NULL
, 0, &ConfigChannel
.use_forward
},
2280 { "resv_forcepart", CF_YESNO
, NULL
, 0, &ConfigChannel
.resv_forcepart
},
2281 { "channel_target_change", CF_YESNO
, NULL
, 0, &ConfigChannel
.channel_target_change
},
2282 { "disable_local_channels", CF_YESNO
, NULL
, 0, &ConfigChannel
.disable_local_channels
},
2283 { "\0", 0, NULL
, 0, NULL
}
2286 static struct ConfEntry conf_serverhide_table
[] =
2288 { "disable_hidden", CF_YESNO
, NULL
, 0, &ConfigServerHide
.disable_hidden
},
2289 { "flatten_links", CF_YESNO
, NULL
, 0, &ConfigServerHide
.flatten_links
},
2290 { "hidden", CF_YESNO
, NULL
, 0, &ConfigServerHide
.hidden
},
2291 { "links_delay", CF_TIME
, conf_set_serverhide_links_delay
, 0, NULL
},
2292 { "\0", 0, NULL
, 0, NULL
}
2299 add_top_conf("modules", NULL
, NULL
, NULL
);
2300 add_conf_item("modules", "path", CF_QSTRING
, conf_set_modules_path
);
2301 add_conf_item("modules", "module", CF_QSTRING
, conf_set_modules_module
);
2303 add_top_conf("serverinfo", NULL
, NULL
, conf_serverinfo_table
);
2304 add_top_conf("admin", NULL
, NULL
, conf_admin_table
);
2305 add_top_conf("log", NULL
, NULL
, conf_log_table
);
2306 add_top_conf("operator", conf_begin_oper
, conf_end_oper
, conf_operator_table
);
2307 add_top_conf("class", conf_begin_class
, conf_end_class
, conf_class_table
);
2308 add_top_conf("privset", NULL
, NULL
, conf_privset_table
);
2310 add_top_conf("listen", conf_begin_listen
, conf_end_listen
, NULL
);
2311 add_conf_item("listen", "port", CF_INT
| CF_FLIST
, conf_set_listen_port
);
2312 add_conf_item("listen", "sslport", CF_INT
| CF_FLIST
, conf_set_listen_sslport
);
2313 add_conf_item("listen", "ip", CF_QSTRING
, conf_set_listen_address
);
2314 add_conf_item("listen", "host", CF_QSTRING
, conf_set_listen_address
);
2316 add_top_conf("auth", conf_begin_auth
, conf_end_auth
, conf_auth_table
);
2318 add_top_conf("shared", conf_cleanup_shared
, conf_cleanup_shared
, NULL
);
2319 add_conf_item("shared", "oper", CF_QSTRING
|CF_FLIST
, conf_set_shared_oper
);
2320 add_conf_item("shared", "flags", CF_STRING
| CF_FLIST
, conf_set_shared_flags
);
2322 add_top_conf("connect", conf_begin_connect
, conf_end_connect
, conf_connect_table
);
2324 add_top_conf("exempt", NULL
, NULL
, NULL
);
2325 add_conf_item("exempt", "ip", CF_QSTRING
, conf_set_exempt_ip
);
2327 add_top_conf("cluster", conf_cleanup_cluster
, conf_cleanup_cluster
, NULL
);
2328 add_conf_item("cluster", "name", CF_QSTRING
, conf_set_cluster_name
);
2329 add_conf_item("cluster", "flags", CF_STRING
| CF_FLIST
, conf_set_cluster_flags
);
2331 add_top_conf("general", NULL
, NULL
, conf_general_table
);
2332 add_top_conf("channel", NULL
, NULL
, conf_channel_table
);
2333 add_top_conf("serverhide", NULL
, NULL
, conf_serverhide_table
);
2335 add_top_conf("service", conf_begin_service
, NULL
, NULL
);
2336 add_conf_item("service", "name", CF_QSTRING
, conf_set_service_name
);
2338 add_top_conf("alias", conf_begin_alias
, conf_end_alias
, NULL
);
2339 add_conf_item("alias", "name", CF_QSTRING
, conf_set_alias_name
);
2340 add_conf_item("alias", "target", CF_QSTRING
, conf_set_alias_target
);
2342 add_top_conf("blacklist", NULL
, NULL
, NULL
);
2343 add_conf_item("blacklist", "host", CF_QSTRING
, conf_set_blacklist_host
);
2344 add_conf_item("blacklist", "type", CF_STRING
| CF_FLIST
, conf_set_blacklist_type
);
2345 add_conf_item("blacklist", "reject_reason", CF_QSTRING
, conf_set_blacklist_reason
);