1 /* This code is in the public domain.
7 #include <openssl/evp.h>
8 #include <openssl/pem.h>
9 #include <openssl/rsa.h>
10 #if (OPENSSL_VERSION_NUMBER >= 0x30000000L)
11 #include <openssl/decoder.h>
12 #include <openssl/core.h>
17 #include "ircd_defs.h"
21 #include "s_newconf.h"
34 #include "privilege.h"
38 #define CF_TYPE(x) ((x) & CF_MTYPE)
40 static int yy_defer_accept
= 1;
41 static int yy_wsock
= 0;
43 struct TopConf
*conf_cur_block
;
44 static char *conf_cur_block_name
= NULL
;
46 static rb_dlink_list conf_items
;
48 static struct ConfItem
*yy_aconf
= NULL
;
50 static struct Class
*yy_class
= NULL
;
52 static struct remote_conf
*yy_shared
= NULL
;
53 static struct server_conf
*yy_server
= NULL
;
55 static rb_dlink_list yy_aconf_list
;
56 static rb_dlink_list yy_oper_list
;
57 static rb_dlink_list yy_cluster_list
;
58 static struct oper_conf
*yy_oper
= NULL
;
60 static struct alias_entry
*yy_alias
= NULL
;
62 static char *yy_dnsbl_entry_host
= NULL
;
63 static char *yy_dnsbl_entry_reason
= NULL
;
64 static uint8_t yy_dnsbl_entry_iptype
= 0;
65 static rb_dlink_list yy_dnsbl_entry_filters
= { NULL
, NULL
, 0 };
67 static char *yy_opm_address_ipv4
= NULL
;
68 static char *yy_opm_address_ipv6
= NULL
;
69 static uint16_t yy_opm_port_ipv4
= 0;
70 static uint16_t yy_opm_port_ipv6
= 0;
71 static int yy_opm_timeout
= 0;
72 static rb_dlink_list yy_opm_scanner_list
;
74 static char *yy_privset_extends
= NULL
;
77 conf_strtype(int type
)
79 switch (CF_TYPE(type
))
82 return "integer value";
84 return "unquoted string";
86 return "yes/no value";
88 return "quoted string";
90 return "time/size value";
92 return "unknown type";
97 add_top_conf(const char *name
, int (*sfunc
) (struct TopConf
*),
98 int (*efunc
) (struct TopConf
*), struct ConfEntry
*items
)
102 tc
= rb_malloc(sizeof(struct TopConf
));
105 tc
->tc_sfunc
= sfunc
;
106 tc
->tc_efunc
= efunc
;
107 tc
->tc_entries
= items
;
109 rb_dlinkAddAlloc(tc
, &conf_items
);
114 find_top_conf(const char *name
)
119 RB_DLINK_FOREACH(d
, conf_items
.head
)
122 if(rb_strcasecmp(tc
->tc_name
, name
) == 0)
131 find_conf_item(const struct TopConf
*top
, const char *name
)
133 struct ConfEntry
*cf
;
140 for(i
= 0; top
->tc_entries
[i
].cf_type
; i
++)
142 cf
= &top
->tc_entries
[i
];
144 if(!rb_strcasecmp(cf
->cf_name
, name
))
149 RB_DLINK_FOREACH(d
, top
->tc_items
.head
)
152 if(rb_strcasecmp(cf
->cf_name
, name
) == 0)
160 remove_top_conf(char *name
)
165 if((tc
= find_top_conf(name
)) == NULL
)
168 if((ptr
= rb_dlinkFind(tc
, &conf_items
)) == NULL
)
171 rb_dlinkDestroy(ptr
, &conf_items
);
178 conf_set_serverinfo_name(void *data
)
180 if(ServerInfo
.name
== NULL
)
185 for(s
= data
; *s
!= '\0'; s
++)
189 conf_report_error("Ignoring serverinfo::name "
190 "-- bogus servername.");
199 conf_report_error("Ignoring serverinfo::name -- must contain '.'");
207 conf_report_error("Ignoring serverinfo::name -- cannot begin with digit.");
211 /* the ircd will exit() in main() if we dont set one */
212 if(strlen(s
) <= HOSTLEN
)
213 ServerInfo
.name
= rb_strdup((char *) data
);
218 conf_set_serverinfo_sid(void *data
)
222 if(ServerInfo
.sid
[0] == '\0')
224 if(!IsDigit(sid
[0]) || !IsIdChar(sid
[1]) ||
225 !IsIdChar(sid
[2]) || sid
[3] != '\0')
227 conf_report_error("Ignoring serverinfo::sid "
232 rb_strlcpy(ServerInfo
.sid
, sid
, sizeof(ServerInfo
.sid
));
237 conf_set_serverinfo_network_name(void *data
)
241 if((p
= strchr((char *) data
, ' ')))
244 rb_free(ServerInfo
.network_name
);
245 ServerInfo
.network_name
= rb_strdup((char *) data
);
249 conf_set_serverinfo_vhost(void *data
)
251 struct rb_sockaddr_storage addr
;
253 if(rb_inet_pton_sock(data
, &addr
) <= 0 || GET_SS_FAMILY(&addr
) != AF_INET
)
255 conf_report_error("Invalid IPv4 address for server vhost (%s)", (char *) data
);
259 ServerInfo
.bind4
= addr
;
263 conf_set_serverinfo_vhost6(void *data
)
266 struct rb_sockaddr_storage addr
;
268 if(rb_inet_pton_sock(data
, &addr
) <= 0 || GET_SS_FAMILY(&addr
) != AF_INET6
)
270 conf_report_error("Invalid IPv6 address for server vhost (%s)", (char *) data
);
274 ServerInfo
.bind6
= addr
;
278 conf_set_serverinfo_nicklen(void *data
)
280 ConfigFileEntry
.nicklen
= (*(unsigned int *) data
) + 1;
282 if (ConfigFileEntry
.nicklen
> NICKLEN
)
284 conf_report_error("Warning -- ignoring serverinfo::nicklen -- provided nicklen (%u) is greater than allowed nicklen (%u)",
285 ConfigFileEntry
.nicklen
- 1, NICKLEN
- 1);
286 ConfigFileEntry
.nicklen
= NICKLEN
;
288 else if (ConfigFileEntry
.nicklen
< 9 + 1)
290 conf_report_error("Warning -- serverinfo::nicklen is too low (%u) -- forcing 9",
291 ConfigFileEntry
.nicklen
- 1);
292 ConfigFileEntry
.nicklen
= 9 + 1;
297 conf_set_modules_module(void *data
)
301 m_bn
= rb_basename((char *) data
);
303 if(findmodule_byname(m_bn
) == NULL
)
304 load_one_module((char *) data
, MAPI_ORIGIN_EXTENSION
, false);
310 conf_set_modules_path(void *data
)
312 mod_add_path((char *) data
);
322 static struct mode_table umode_table
[] = {
323 {"deaf", UMODE_DEAF
},
324 {"invisible", UMODE_INVISIBLE
},
325 {"locops", UMODE_LOCOPS
},
326 {"noforward", UMODE_NOFORWARD
},
327 {"servnotice", UMODE_SERVNOTICE
},
328 {"wallop", UMODE_WALLOP
},
329 {"operwall", UMODE_OPERWALL
},
333 static struct mode_table oper_table
[] = {
334 {"encrypted", OPER_ENCRYPTED
},
335 {"need_ssl", OPER_NEEDSSL
},
339 static struct mode_table auth_table
[] = {
340 {"encrypted", CONF_FLAGS_ENCRYPTED
},
341 {"spoof_notice", CONF_FLAGS_SPOOF_NOTICE
},
342 {"exceed_limit", CONF_FLAGS_NOLIMIT
},
343 {"dnsbl_exempt", CONF_FLAGS_EXEMPTDNSBL
},
344 {"proxy_exempt", CONF_FLAGS_EXEMPTPROXY
},
345 {"kline_exempt", CONF_FLAGS_EXEMPTKLINE
},
346 {"flood_exempt", CONF_FLAGS_EXEMPTFLOOD
},
347 {"spambot_exempt", CONF_FLAGS_EXEMPTSPAMBOT
},
348 {"shide_exempt", CONF_FLAGS_EXEMPTSHIDE
},
349 {"jupe_exempt", CONF_FLAGS_EXEMPTJUPE
},
350 {"resv_exempt", CONF_FLAGS_EXEMPTRESV
},
351 {"no_tilde", CONF_FLAGS_NO_TILDE
},
352 {"need_ident", CONF_FLAGS_NEED_IDENTD
},
353 {"have_ident", CONF_FLAGS_NEED_IDENTD
},
354 {"need_ssl", CONF_FLAGS_NEED_SSL
},
355 {"need_sasl", CONF_FLAGS_NEED_SASL
},
356 {"extend_chans", CONF_FLAGS_EXTEND_CHANS
},
357 {"allow_sctp", CONF_FLAGS_ALLOW_SCTP
},
358 {"kline_spoof_ip", CONF_FLAGS_KLINE_SPOOF
},
362 static struct mode_table connect_table
[] = {
363 { "autoconn", SERVER_AUTOCONN
},
365 { "encrypted", SERVER_ENCRYPTED
},
366 { "topicburst", SERVER_TB
},
367 { "sctp", SERVER_SCTP
},
368 { "ssl", SERVER_SSL
},
369 { "no-export", SERVER_NO_EXPORT
},
373 static struct mode_table cluster_table
[] = {
374 { "kline", SHARED_PKLINE
},
375 { "tkline", SHARED_TKLINE
},
376 { "unkline", SHARED_UNKLINE
},
377 { "locops", SHARED_LOCOPS
},
378 { "xline", SHARED_PXLINE
},
379 { "txline", SHARED_TXLINE
},
380 { "unxline", SHARED_UNXLINE
},
381 { "resv", SHARED_PRESV
},
382 { "tresv", SHARED_TRESV
},
383 { "unresv", SHARED_UNRESV
},
384 { "all", CLUSTER_ALL
},
390 find_umode(struct mode_table
*tab
, const char *name
)
394 for (i
= 0; tab
[i
].name
; i
++)
396 if(strcmp(tab
[i
].name
, name
) == 0)
404 set_modes_from_table(int *modes
, const char *whatis
, struct mode_table
*tab
, conf_parm_t
* args
)
406 for (; args
; args
= args
->next
)
412 if(CF_TYPE(args
->type
) != CF_STRING
)
414 conf_report_error("Warning -- %s is not a string; ignoring.", whatis
);
418 umode
= args
->v
.string
;
426 mode
= find_umode(tab
, umode
);
430 conf_report_error("Warning -- unknown %s %s.", whatis
, args
->v
.string
);
447 parse_umodes(const char *pm
, int *values
, int *mask
)
449 int what
= MODE_ADD
, flag
;
475 flag
= user_modes
[(unsigned char) *pm
];
478 /* Proper value has probably not yet been set
479 * so don't check oper_only_umodes -- jilles */
480 if (what
== MODE_ADD
)
494 conf_set_privset_extends(void *data
)
496 yy_privset_extends
= rb_strdup((char *) data
);
500 conf_set_privset_privs(void *data
)
503 conf_parm_t
*args
= data
;
505 for (; args
; args
= args
->next
)
508 privs
= rb_strdup(args
->v
.string
);
511 char *privs_old
= privs
;
513 privs
= rb_malloc(strlen(privs_old
) + 1 + strlen(args
->v
.string
) + 1);
514 strcpy(privs
, privs_old
);
516 strcat(privs
, args
->v
.string
);
524 if (yy_privset_extends
)
526 struct PrivilegeSet
*set
= privilegeset_get(yy_privset_extends
);
530 conf_report_error("Warning -- unknown parent privilege set %s for %s; assuming defaults", yy_privset_extends
, conf_cur_block_name
);
532 set
= privilegeset_get("default");
535 privilegeset_extend(set
, conf_cur_block_name
!= NULL
? conf_cur_block_name
: "<unknown>", privs
, 0);
537 rb_free(yy_privset_extends
);
538 yy_privset_extends
= NULL
;
541 privilegeset_set_new(conf_cur_block_name
!= NULL
? conf_cur_block_name
: "<unknown>", privs
, 0);
548 conf_begin_oper(struct TopConf
*tc
)
551 rb_dlink_node
*next_ptr
;
555 free_oper_conf(yy_oper
);
559 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, yy_oper_list
.head
)
561 free_oper_conf(ptr
->data
);
562 rb_dlinkDestroy(ptr
, &yy_oper_list
);
565 yy_oper
= make_oper_conf();
566 yy_oper
->flags
|= OPER_ENCRYPTED
;
572 conf_end_oper(struct TopConf
*tc
)
574 struct oper_conf
*yy_tmpoper
;
576 rb_dlink_node
*next_ptr
;
578 if(conf_cur_block_name
!= NULL
)
580 if(strlen(conf_cur_block_name
) > OPERNICKLEN
)
581 conf_cur_block_name
[OPERNICKLEN
] = '\0';
583 yy_oper
->name
= rb_strdup(conf_cur_block_name
);
586 if(EmptyString(yy_oper
->name
))
588 conf_report_error("Ignoring operator block -- missing name.");
592 #ifdef HAVE_LIBCRYPTO
593 if(EmptyString(yy_oper
->passwd
) && EmptyString(yy_oper
->rsa_pubkey_file
))
595 if(EmptyString(yy_oper
->passwd
))
598 conf_report_error("Ignoring operator block for %s -- missing password",
604 if (!yy_oper
->privset
)
605 yy_oper
->privset
= privilegeset_get("default");
607 /* now, yy_oper_list contains a stack of oper_conf's with just user
608 * and host in, yy_oper contains the rest of the information which
609 * we need to copy into each element in yy_oper_list
611 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, yy_oper_list
.head
)
613 yy_tmpoper
= ptr
->data
;
615 yy_tmpoper
->name
= rb_strdup(yy_oper
->name
);
617 /* could be an rsa key instead.. */
618 if(!EmptyString(yy_oper
->passwd
))
619 yy_tmpoper
->passwd
= rb_strdup(yy_oper
->passwd
);
621 yy_tmpoper
->flags
= yy_oper
->flags
;
622 yy_tmpoper
->umodes
= yy_oper
->umodes
;
623 yy_tmpoper
->snomask
= yy_oper
->snomask
;
624 yy_tmpoper
->privset
= yy_oper
->privset
;
626 #ifdef HAVE_LIBCRYPTO
627 if(yy_oper
->rsa_pubkey_file
)
631 if((file
= BIO_new_file(yy_oper
->rsa_pubkey_file
, "r")) == NULL
)
633 conf_report_error("Ignoring operator block for %s -- "
634 "rsa_public_key_file cant be opened",
639 #if (OPENSSL_VERSION_NUMBER >= 0x30000000L)
640 OSSL_DECODER_CTX
*const ctx
= OSSL_DECODER_CTX_new_for_pkey(
641 &yy_tmpoper
->rsa_pubkey
, "PEM", NULL
, "RSA",
642 OSSL_KEYMGMT_SELECT_PUBLIC_KEY
, NULL
, NULL
);
646 if(OSSL_DECODER_CTX_get_num_decoders(ctx
) < 1 ||
647 OSSL_DECODER_from_bio(ctx
, file
) < 1)
649 EVP_PKEY_free(yy_tmpoper
->rsa_pubkey
);
650 yy_tmpoper
->rsa_pubkey
= NULL
;
653 OSSL_DECODER_CTX_free(ctx
);
656 yy_tmpoper
->rsa_pubkey
=
657 (RSA
*) PEM_read_bio_RSA_PUBKEY(file
, NULL
, 0, NULL
);
660 (void)BIO_set_close(file
, BIO_CLOSE
);
663 if(yy_tmpoper
->rsa_pubkey
== NULL
)
665 conf_report_error("Ignoring operator block for %s -- "
666 "rsa_public_key_file key invalid; check syntax",
672 if(!EmptyString(yy_oper
->certfp
))
673 yy_tmpoper
->certfp
= rb_strdup(yy_oper
->certfp
);
676 /* all is ok, put it on oper_conf_list */
677 rb_dlinkMoveNode(ptr
, &yy_oper_list
, &oper_conf_list
);
680 free_oper_conf(yy_oper
);
687 conf_set_oper_flags(void *data
)
689 conf_parm_t
*args
= data
;
691 set_modes_from_table(&yy_oper
->flags
, "flag", oper_table
, args
);
695 conf_set_oper_fingerprint(void *data
)
698 rb_free(yy_oper
->certfp
);
699 yy_oper
->certfp
= rb_strdup((char *) data
);
703 conf_set_oper_privset(void *data
)
705 yy_oper
->privset
= privilegeset_get((char *) data
);
709 conf_set_oper_user(void *data
)
711 struct oper_conf
*yy_tmpoper
;
713 char *host
= (char *) data
;
715 yy_tmpoper
= make_oper_conf();
717 if((p
= strchr(host
, '@')))
721 yy_tmpoper
->username
= rb_strdup(host
);
722 yy_tmpoper
->host
= rb_strdup(p
);
727 yy_tmpoper
->username
= rb_strdup("*");
728 yy_tmpoper
->host
= rb_strdup(host
);
731 if(EmptyString(yy_tmpoper
->username
) || EmptyString(yy_tmpoper
->host
))
733 conf_report_error("Ignoring user -- missing username/host");
734 free_oper_conf(yy_tmpoper
);
738 rb_dlinkAddAlloc(yy_tmpoper
, &yy_oper_list
);
742 conf_set_oper_password(void *data
)
746 memset(yy_oper
->passwd
, 0, strlen(yy_oper
->passwd
));
747 rb_free(yy_oper
->passwd
);
750 yy_oper
->passwd
= rb_strdup((char *) data
);
754 conf_set_oper_rsa_public_key_file(void *data
)
756 #ifdef HAVE_LIBCRYPTO
757 rb_free(yy_oper
->rsa_pubkey_file
);
758 yy_oper
->rsa_pubkey_file
= rb_strdup((char *) data
);
760 conf_report_error("Warning -- ignoring rsa_public_key_file (OpenSSL support not available");
765 conf_set_oper_umodes(void *data
)
767 set_modes_from_table(&yy_oper
->umodes
, "umode", umode_table
, data
);
771 conf_set_oper_snomask(void *data
)
773 yy_oper
->snomask
= parse_snobuf_to_mask(0, (const char *) data
);
777 conf_begin_class(struct TopConf
*tc
)
780 free_class(yy_class
);
782 yy_class
= make_class();
787 conf_end_class(struct TopConf
*tc
)
789 if(conf_cur_block_name
!= NULL
)
790 yy_class
->class_name
= rb_strdup(conf_cur_block_name
);
792 if(EmptyString(yy_class
->class_name
))
794 conf_report_error("Ignoring class block -- missing name.");
804 conf_set_class_ping_time(void *data
)
806 yy_class
->ping_freq
= *(unsigned int *) data
;
810 conf_set_class_cidr_ipv4_bitlen(void *data
)
812 unsigned int maxsize
= 32;
813 if(*(unsigned int *) data
> maxsize
)
815 ("class::cidr_ipv4_bitlen argument exceeds maxsize (%d > %d) - ignoring.",
816 *(unsigned int *) data
, maxsize
);
818 yy_class
->cidr_ipv4_bitlen
= *(unsigned int *) data
;
823 conf_set_class_cidr_ipv6_bitlen(void *data
)
825 unsigned int maxsize
= 128;
826 if(*(unsigned int *) data
> maxsize
)
828 ("class::cidr_ipv6_bitlen argument exceeds maxsize (%d > %d) - ignoring.",
829 *(unsigned int *) data
, maxsize
);
831 yy_class
->cidr_ipv6_bitlen
= *(unsigned int *) data
;
836 conf_set_class_number_per_cidr(void *data
)
838 yy_class
->cidr_amount
= *(unsigned int *) data
;
842 conf_set_class_number_per_ip(void *data
)
844 yy_class
->max_local
= *(unsigned int *) data
;
849 conf_set_class_number_per_ip_global(void *data
)
851 yy_class
->max_global
= *(unsigned int *) data
;
855 conf_set_class_number_per_ident(void *data
)
857 yy_class
->max_ident
= *(unsigned int *) data
;
861 conf_set_class_connectfreq(void *data
)
863 yy_class
->con_freq
= *(unsigned int *) data
;
867 conf_set_class_max_number(void *data
)
869 yy_class
->max_total
= *(unsigned int *) data
;
873 conf_set_class_max_autoconn(void *data
)
875 yy_class
->max_autoconn
= *(unsigned int *) data
;
879 conf_set_class_sendq(void *data
)
881 yy_class
->max_sendq
= *(unsigned int *) data
;
884 static char *listener_address
[2];
887 conf_begin_listen(struct TopConf
*tc
)
889 for (int i
= 0; i
< ARRAY_SIZE(listener_address
); i
++) {
890 rb_free(listener_address
[i
]);
891 listener_address
[i
] = NULL
;
899 conf_end_listen(struct TopConf
*tc
)
901 for (int i
= 0; i
< ARRAY_SIZE(listener_address
); i
++) {
902 rb_free(listener_address
[i
]);
903 listener_address
[i
] = NULL
;
911 conf_set_listen_defer_accept(void *data
)
913 yy_defer_accept
= *(unsigned int *) data
;
917 conf_set_listen_wsock(void *data
)
919 yy_wsock
= *(unsigned int *) data
;
923 conf_set_listen_port_both(void *data
, int ssl
, int sctp
)
925 conf_parm_t
*args
= data
;
926 for (; args
; args
= args
->next
)
928 if(CF_TYPE(args
->type
) != CF_INT
)
930 conf_report_error("listener::port argument is not an integer -- ignoring.");
933 if(listener_address
[0] == NULL
)
936 conf_report_error("listener::sctp_port has no addresses -- ignoring.");
938 add_tcp_listener(args
->v
.number
, NULL
, AF_INET
, ssl
, ssl
|| yy_defer_accept
, yy_wsock
);
939 add_tcp_listener(args
->v
.number
, NULL
, AF_INET6
, ssl
, ssl
|| yy_defer_accept
, yy_wsock
);
945 if(strchr(listener_address
[0], ':') != NULL
)
952 add_sctp_listener(args
->v
.number
, listener_address
[0], listener_address
[1], ssl
, yy_wsock
);
954 conf_report_error("Warning -- ignoring listener::sctp_port -- SCTP support not available.");
957 add_tcp_listener(args
->v
.number
, listener_address
[0], family
, ssl
, ssl
|| yy_defer_accept
, yy_wsock
);
964 conf_set_listen_port(void *data
)
966 conf_set_listen_port_both(data
, 0, 0);
970 conf_set_listen_sslport(void *data
)
972 conf_set_listen_port_both(data
, 1, 0 );
976 conf_set_listen_sctp_port(void *data
)
978 conf_set_listen_port_both(data
, 0, 1);
982 conf_set_listen_sctp_sslport(void *data
)
984 conf_set_listen_port_both(data
, 1, 1);
988 conf_set_listen_address(void *data
)
990 rb_free(listener_address
[1]);
991 listener_address
[1] = listener_address
[0];
992 listener_address
[0] = rb_strdup(data
);
996 conf_begin_auth(struct TopConf
*tc
)
999 rb_dlink_node
*next_ptr
;
1002 free_conf(yy_aconf
);
1004 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, yy_aconf_list
.head
)
1006 free_conf(ptr
->data
);
1007 rb_dlinkDestroy(ptr
, &yy_aconf_list
);
1010 yy_aconf
= make_conf();
1011 yy_aconf
->status
= CONF_CLIENT
;
1017 conf_end_auth(struct TopConf
*tc
)
1019 struct ConfItem
*yy_tmp
, *found_conf
;
1021 rb_dlink_node
*next_ptr
;
1023 if(EmptyString(yy_aconf
->info
.name
))
1024 yy_aconf
->info
.name
= rb_strdup("NOMATCH");
1026 /* didnt even get one ->host? */
1027 if(EmptyString(yy_aconf
->host
))
1029 conf_report_error("Ignoring auth block -- missing user@host");
1033 /* so the stacking works in order.. */
1034 collapse(yy_aconf
->user
);
1035 collapse(yy_aconf
->host
);
1036 conf_add_class_to_conf(yy_aconf
);
1037 if ((found_conf
= find_exact_conf_by_address("*", CONF_CLIENT
, "*")) && found_conf
->spasswd
== NULL
)
1038 conf_report_error("Ignoring redundant auth block (after *@*)");
1039 else if ((found_conf
= find_exact_conf_by_address(yy_aconf
->host
, CONF_CLIENT
, yy_aconf
->user
)) &&
1040 (!found_conf
->spasswd
|| (yy_aconf
->spasswd
&&
1041 0 == irccmp(found_conf
->spasswd
, yy_aconf
->spasswd
))))
1042 conf_report_error("Ignoring duplicate auth block for %s@%s",
1043 yy_aconf
->user
, yy_aconf
->host
);
1045 add_conf_by_address(yy_aconf
->host
, CONF_CLIENT
, yy_aconf
->user
, yy_aconf
->spasswd
, yy_aconf
);
1047 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, yy_aconf_list
.head
)
1051 if(yy_aconf
->passwd
)
1052 yy_tmp
->passwd
= rb_strdup(yy_aconf
->passwd
);
1054 if(yy_aconf
->spasswd
)
1055 yy_tmp
->spasswd
= rb_strdup(yy_aconf
->spasswd
);
1057 /* this will always exist.. */
1058 yy_tmp
->info
.name
= rb_strdup(yy_aconf
->info
.name
);
1060 if(yy_aconf
->className
)
1061 yy_tmp
->className
= rb_strdup(yy_aconf
->className
);
1064 yy_tmp
->desc
= rb_strdup(yy_aconf
->desc
);
1066 yy_tmp
->flags
= yy_aconf
->flags
;
1067 yy_tmp
->port
= yy_aconf
->port
;
1069 collapse(yy_tmp
->user
);
1070 collapse(yy_tmp
->host
);
1072 conf_add_class_to_conf(yy_tmp
);
1074 if ((found_conf
= find_exact_conf_by_address("*", CONF_CLIENT
, "*")) && found_conf
->spasswd
== NULL
)
1075 conf_report_error("Ignoring redundant auth block (after *@*)");
1076 else if ((found_conf
= find_exact_conf_by_address(yy_tmp
->host
, CONF_CLIENT
, yy_tmp
->user
)) &&
1077 (!found_conf
->spasswd
|| (yy_tmp
->spasswd
&&
1078 0 == irccmp(found_conf
->spasswd
, yy_tmp
->spasswd
))))
1079 conf_report_error("Ignoring duplicate auth block for %s@%s",
1080 yy_tmp
->user
, yy_tmp
->host
);
1082 add_conf_by_address(yy_tmp
->host
, CONF_CLIENT
, yy_tmp
->user
, yy_tmp
->spasswd
, yy_tmp
);
1083 rb_dlinkDestroy(ptr
, &yy_aconf_list
);
1091 conf_set_auth_user(void *data
)
1093 struct ConfItem
*yy_tmp
;
1096 /* The first user= line doesn't allocate a new conf */
1097 if(!EmptyString(yy_aconf
->host
))
1099 yy_tmp
= make_conf();
1100 yy_tmp
->status
= CONF_CLIENT
;
1105 if((p
= strchr(data
, '@')))
1109 yy_tmp
->user
= rb_strdup(data
);
1110 yy_tmp
->host
= rb_strdup(p
);
1114 yy_tmp
->user
= rb_strdup("*");
1115 yy_tmp
->host
= rb_strdup(data
);
1118 if(yy_aconf
!= yy_tmp
)
1119 rb_dlinkAddAlloc(yy_tmp
, &yy_aconf_list
);
1123 conf_set_auth_auth_user(void *data
)
1125 if(yy_aconf
->spasswd
)
1126 memset(yy_aconf
->spasswd
, 0, strlen(yy_aconf
->spasswd
));
1127 rb_free(yy_aconf
->spasswd
);
1128 yy_aconf
->spasswd
= rb_strdup(data
);
1132 conf_set_auth_passwd(void *data
)
1134 if(yy_aconf
->passwd
)
1135 memset(yy_aconf
->passwd
, 0, strlen(yy_aconf
->passwd
));
1136 rb_free(yy_aconf
->passwd
);
1137 yy_aconf
->passwd
= rb_strdup(data
);
1141 conf_set_auth_spoof(void *data
)
1149 /* user@host spoof */
1150 if((p
= strchr(host
, '@')) != NULL
)
1156 if(EmptyString(user
))
1158 conf_report_error("Warning -- spoof ident empty.");
1162 if(strlen(user
) > USERLEN
)
1164 conf_report_error("Warning -- spoof ident length invalid.");
1168 if(!valid_username(user
))
1170 conf_report_error("Warning -- invalid spoof (ident).");
1174 /* this must be restored! */
1178 if(EmptyString(host
))
1180 conf_report_error("Warning -- spoof host empty.");
1184 if(strlen(host
) > HOSTLEN
)
1186 conf_report_error("Warning -- spoof host length invalid.");
1190 if(!valid_hostname(host
))
1192 conf_report_error("Warning -- invalid spoof (host).");
1196 rb_free(yy_aconf
->info
.name
);
1197 yy_aconf
->info
.name
= rb_strdup(data
);
1198 yy_aconf
->flags
|= CONF_FLAGS_SPOOF_IP
;
1202 conf_set_auth_desc(void *data
)
1204 rb_free(yy_aconf
->desc
);
1205 yy_aconf
->desc
= rb_strdup(data
);
1209 conf_set_auth_flags(void *data
)
1211 conf_parm_t
*args
= data
;
1213 set_modes_from_table((int *) &yy_aconf
->flags
, "flag", auth_table
, args
);
1217 conf_set_auth_redir_serv(void *data
)
1219 yy_aconf
->flags
|= CONF_FLAGS_REDIR
;
1220 rb_free(yy_aconf
->info
.name
);
1221 yy_aconf
->info
.name
= rb_strdup(data
);
1225 conf_set_auth_redir_port(void *data
)
1227 int port
= *(unsigned int *) data
;
1229 yy_aconf
->flags
|= CONF_FLAGS_REDIR
;
1230 yy_aconf
->port
= port
;
1234 conf_set_auth_class(void *data
)
1236 rb_free(yy_aconf
->className
);
1237 yy_aconf
->className
= rb_strdup(data
);
1241 conf_set_auth_umodes(void *data
)
1243 char *umodes
= data
;
1245 parse_umodes(umodes
, &yy_aconf
->umodes
, &yy_aconf
->umodes_mask
);
1249 conf_begin_connect(struct TopConf
*tc
)
1252 free_server_conf(yy_server
);
1254 yy_server
= make_server_conf();
1255 yy_server
->port
= PORTNUM
;
1256 yy_server
->flags
|= SERVER_TB
;
1258 if(conf_cur_block_name
!= NULL
)
1259 yy_server
->name
= rb_strdup(conf_cur_block_name
);
1265 conf_end_connect(struct TopConf
*tc
)
1267 if (EmptyString(yy_server
->name
))
1269 conf_report_error("Ignoring connect block -- missing name.");
1273 if (ServerInfo
.name
!= NULL
&& !irccmp(ServerInfo
.name
, yy_server
->name
))
1275 conf_report_error("Ignoring connect block for %s -- name is "
1276 "equal to my own name.", yy_server
->name
);
1280 if ((EmptyString(yy_server
->passwd
) || EmptyString(yy_server
->spasswd
))
1281 && EmptyString(yy_server
->certfp
))
1283 conf_report_error("Ignoring connect block for %s -- no "
1284 "fingerprint or password credentials "
1285 "provided.", yy_server
->name
);
1289 if ((yy_server
->flags
& SERVER_SSL
) && EmptyString(yy_server
->certfp
))
1291 conf_report_error("Ignoring connect block for %s -- no "
1292 "fingerprint provided for SSL "
1293 "connection.", yy_server
->name
);
1297 if (! (yy_server
->flags
& SERVER_SSL
) && ! EmptyString(yy_server
->certfp
))
1299 conf_report_error("Ignoring connect block for %s -- "
1300 "fingerprint authentication has "
1301 "been requested; but the ssl flag "
1302 "is not set.", yy_server
->name
);
1306 if (EmptyString(yy_server
->connect_host
)
1307 && GET_SS_FAMILY(&yy_server
->connect4
) != AF_INET
1308 && GET_SS_FAMILY(&yy_server
->connect6
) != AF_INET6
)
1310 conf_report_error("Ignoring connect block for %s -- missing "
1311 "host.", yy_server
->name
);
1315 add_server_conf(yy_server
);
1316 rb_dlinkAdd(yy_server
, &yy_server
->node
, &server_conf_list
);
1323 conf_set_connect_host(void *data
)
1325 struct rb_sockaddr_storage addr
;
1327 if(rb_inet_pton_sock(data
, &addr
) <= 0)
1329 rb_free(yy_server
->connect_host
);
1330 yy_server
->connect_host
= rb_strdup(data
);
1332 else if(GET_SS_FAMILY(&addr
) == AF_INET
)
1334 yy_server
->connect4
= addr
;
1336 else if(GET_SS_FAMILY(&addr
) == AF_INET6
)
1338 yy_server
->connect6
= addr
;
1342 conf_report_error("Unsupported IP address for server connect host (%s)",
1349 conf_set_connect_vhost(void *data
)
1351 struct rb_sockaddr_storage addr
;
1353 if(rb_inet_pton_sock(data
, &addr
) <= 0)
1355 rb_free(yy_server
->bind_host
);
1356 yy_server
->bind_host
= rb_strdup(data
);
1358 else if(GET_SS_FAMILY(&addr
) == AF_INET
)
1360 yy_server
->bind4
= addr
;
1362 else if(GET_SS_FAMILY(&addr
) == AF_INET6
)
1364 yy_server
->bind6
= addr
;
1368 conf_report_error("Unsupported IP address for server connect vhost (%s)",
1375 conf_set_connect_send_password(void *data
)
1377 if(yy_server
->spasswd
)
1379 memset(yy_server
->spasswd
, 0, strlen(yy_server
->spasswd
));
1380 rb_free(yy_server
->spasswd
);
1383 if (EmptyString((const char *) data
))
1385 yy_server
->spasswd
= NULL
;
1386 conf_report_warning("Invalid send_password for connect "
1387 "block; must not be empty if provided");
1389 else if (strpbrk(data
, " :"))
1391 yy_server
->spasswd
= NULL
;
1392 conf_report_error("Invalid send_password for connect "
1393 "block; cannot contain spaces or colons");
1396 yy_server
->spasswd
= rb_strdup(data
);
1400 conf_set_connect_accept_password(void *data
)
1402 if(yy_server
->passwd
)
1404 memset(yy_server
->passwd
, 0, strlen(yy_server
->passwd
));
1405 rb_free(yy_server
->passwd
);
1408 if (EmptyString((const char *) data
))
1410 yy_server
->passwd
= NULL
;
1411 conf_report_warning("Invalid accept_password for connect "
1412 "block; must not be empty if provided");
1414 else if (strpbrk(data
, " :"))
1416 yy_server
->passwd
= NULL
;
1417 conf_report_error("Invalid accept_password for connect "
1418 "block; cannot contain spaces or colons");
1421 yy_server
->passwd
= rb_strdup(data
);
1425 conf_set_connect_fingerprint(void *data
)
1427 if (yy_server
->certfp
)
1428 rb_free(yy_server
->certfp
);
1429 yy_server
->certfp
= rb_strdup((char *) data
);
1431 /* force SSL to be enabled if fingerprint is enabled. */
1432 yy_server
->flags
|= SERVER_SSL
;
1436 conf_set_connect_port(void *data
)
1438 int port
= *(unsigned int *) data
;
1443 yy_server
->port
= port
;
1447 conf_set_connect_aftype(void *data
)
1451 if(rb_strcasecmp(aft
, "ipv4") == 0)
1452 yy_server
->aftype
= AF_INET
;
1453 else if(rb_strcasecmp(aft
, "ipv6") == 0)
1454 yy_server
->aftype
= AF_INET6
;
1456 conf_report_error("connect::aftype '%s' is unknown.", aft
);
1460 conf_set_connect_flags(void *data
)
1462 conf_parm_t
*args
= data
;
1464 set_modes_from_table(&yy_server
->flags
, "flag", connect_table
, args
);
1468 conf_set_connect_class(void *data
)
1470 rb_free(yy_server
->class_name
);
1471 yy_server
->class_name
= rb_strdup(data
);
1475 conf_set_exempt_ip(void *data
)
1477 struct ConfItem
*yy_tmp
;
1478 int masktype
= parse_netmask_strict(data
, NULL
, NULL
);
1480 if(masktype
!= HM_IPV4
&& masktype
!= HM_IPV6
)
1482 conf_report_error("Ignoring exempt -- invalid exempt::ip.");
1486 yy_tmp
= make_conf();
1487 yy_tmp
->passwd
= rb_strdup("*");
1488 yy_tmp
->host
= rb_strdup(data
);
1489 yy_tmp
->status
= CONF_EXEMPTDLINE
;
1490 add_conf_by_address(yy_tmp
->host
, CONF_EXEMPTDLINE
, NULL
, NULL
, yy_tmp
);
1494 conf_set_secure_ip(void *data
)
1496 struct ConfItem
*yy_tmp
;
1497 int masktype
= parse_netmask_strict(data
, NULL
, NULL
);
1499 if(masktype
!= HM_IPV4
&& masktype
!= HM_IPV6
)
1501 conf_report_error("Ignoring secure -- invalid secure::ip.");
1505 yy_tmp
= make_conf();
1506 yy_tmp
->passwd
= rb_strdup("*");
1507 yy_tmp
->host
= rb_strdup(data
);
1508 yy_tmp
->status
= CONF_SECURE
;
1509 add_conf_by_address(yy_tmp
->host
, CONF_SECURE
, NULL
, NULL
, yy_tmp
);
1513 conf_cleanup_cluster(struct TopConf
*tc
)
1515 rb_dlink_node
*ptr
, *next_ptr
;
1517 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, yy_cluster_list
.head
)
1519 free_remote_conf(ptr
->data
);
1520 rb_dlinkDestroy(ptr
, &yy_cluster_list
);
1523 if(yy_shared
!= NULL
)
1525 free_remote_conf(yy_shared
);
1533 conf_set_cluster_name(void *data
)
1535 if(yy_shared
!= NULL
)
1536 free_remote_conf(yy_shared
);
1538 yy_shared
= make_remote_conf();
1539 yy_shared
->server
= rb_strdup(data
);
1540 rb_dlinkAddAlloc(yy_shared
, &yy_cluster_list
);
1546 conf_set_cluster_flags(void *data
)
1548 conf_parm_t
*args
= data
;
1550 rb_dlink_node
*ptr
, *next_ptr
;
1552 if(yy_shared
!= NULL
)
1553 free_remote_conf(yy_shared
);
1555 set_modes_from_table(&flags
, "flag", cluster_table
, args
);
1557 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, yy_cluster_list
.head
)
1559 yy_shared
= ptr
->data
;
1560 yy_shared
->flags
= flags
;
1561 rb_dlinkAddTail(yy_shared
, &yy_shared
->node
, &cluster_conf_list
);
1562 rb_dlinkDestroy(ptr
, &yy_cluster_list
);
1569 conf_set_general_havent_read_conf(void *data
)
1571 if(*(unsigned int *) data
)
1573 conf_report_error("You haven't read your config file properly.");
1575 ("There is a line in the example conf that will kill your server if not removed.");
1577 ("Consider actually reading/editing the conf file, and removing this line.");
1584 conf_set_general_hide_error_messages(void *data
)
1588 if(rb_strcasecmp(val
, "yes") == 0)
1589 ConfigFileEntry
.hide_error_messages
= 2;
1590 else if(rb_strcasecmp(val
, "opers") == 0)
1591 ConfigFileEntry
.hide_error_messages
= 1;
1592 else if(rb_strcasecmp(val
, "no") == 0)
1593 ConfigFileEntry
.hide_error_messages
= 0;
1595 conf_report_error("Invalid setting '%s' for general::hide_error_messages.", val
);
1599 conf_set_general_stats_k_oper_only(void *data
)
1603 if(rb_strcasecmp(val
, "yes") == 0)
1604 ConfigFileEntry
.stats_k_oper_only
= 2;
1605 else if(rb_strcasecmp(val
, "masked") == 0)
1606 ConfigFileEntry
.stats_k_oper_only
= 1;
1607 else if(rb_strcasecmp(val
, "no") == 0)
1608 ConfigFileEntry
.stats_k_oper_only
= 0;
1610 conf_report_error("Invalid setting '%s' for general::stats_k_oper_only.", val
);
1614 conf_set_general_stats_i_oper_only(void *data
)
1618 if(rb_strcasecmp(val
, "yes") == 0)
1619 ConfigFileEntry
.stats_i_oper_only
= 2;
1620 else if(rb_strcasecmp(val
, "masked") == 0)
1621 ConfigFileEntry
.stats_i_oper_only
= 1;
1622 else if(rb_strcasecmp(val
, "no") == 0)
1623 ConfigFileEntry
.stats_i_oper_only
= 0;
1625 conf_report_error("Invalid setting '%s' for general::stats_i_oper_only.", val
);
1629 conf_set_general_stats_l_oper_only(void *data
)
1633 if(rb_strcasecmp(val
, "yes") == 0)
1634 ConfigFileEntry
.stats_l_oper_only
= STATS_L_OPER_ONLY_YES
;
1635 else if(rb_strcasecmp(val
, "self") == 0)
1636 ConfigFileEntry
.stats_l_oper_only
= STATS_L_OPER_ONLY_SELF
;
1637 else if(rb_strcasecmp(val
, "no") == 0)
1638 ConfigFileEntry
.stats_l_oper_only
= STATS_L_OPER_ONLY_NO
;
1640 conf_report_error("Invalid setting '%s' for general::stats_l_oper_only.", val
);
1644 conf_set_general_default_umodes(void *data
)
1646 char *umodes
= data
;
1648 parse_umodes(umodes
, &ConfigFileEntry
.default_umodes
, NULL
);
1652 conf_set_general_oper_umodes(void *data
)
1654 set_modes_from_table(&ConfigFileEntry
.oper_umodes
, "umode", umode_table
, data
);
1658 conf_set_general_certfp_method(void *data
)
1660 char *method
= data
;
1662 if (!rb_strcasecmp(method
, CERTFP_NAME_CERT_SHA1
))
1663 ConfigFileEntry
.certfp_method
= RB_SSL_CERTFP_METH_CERT_SHA1
;
1664 else if (!rb_strcasecmp(method
, CERTFP_NAME_CERT_SHA256
))
1665 ConfigFileEntry
.certfp_method
= RB_SSL_CERTFP_METH_CERT_SHA256
;
1666 else if (!rb_strcasecmp(method
, CERTFP_NAME_CERT_SHA512
))
1667 ConfigFileEntry
.certfp_method
= RB_SSL_CERTFP_METH_CERT_SHA512
;
1668 else if (!rb_strcasecmp(method
, CERTFP_NAME_SPKI_SHA256
))
1669 ConfigFileEntry
.certfp_method
= RB_SSL_CERTFP_METH_SPKI_SHA256
;
1670 else if (!rb_strcasecmp(method
, CERTFP_NAME_SPKI_SHA512
))
1671 ConfigFileEntry
.certfp_method
= RB_SSL_CERTFP_METH_SPKI_SHA512
;
1674 ConfigFileEntry
.certfp_method
= RB_SSL_CERTFP_METH_CERT_SHA1
;
1675 conf_report_error("Ignoring general::certfp_method -- bogus certfp method %s", method
);
1680 conf_set_general_oper_only_umodes(void *data
)
1682 set_modes_from_table(&ConfigFileEntry
.oper_only_umodes
, "umode", umode_table
, data
);
1686 conf_set_general_oper_snomask(void *data
)
1689 int what
= MODE_ADD
, flag
;
1691 ConfigFileEntry
.oper_snomask
= 0;
1692 for (pm
= (char *) data
; *pm
; pm
++)
1704 if ((flag
= snomask_modes
[(unsigned char) *pm
]))
1706 if (what
== MODE_ADD
)
1707 ConfigFileEntry
.oper_snomask
|= flag
;
1709 ConfigFileEntry
.oper_snomask
&= ~flag
;
1717 conf_set_general_hidden_caps(void *data
)
1721 for (conf_parm_t
*arg
= data
; arg
; arg
= arg
->next
)
1724 if (ConfigFileEntry
.hidden_caps
!= NULL
)
1726 for (n
= 0; ConfigFileEntry
.hidden_caps
[n
] != NULL
; n
++)
1727 rb_free(ConfigFileEntry
.hidden_caps
[n
]);
1728 rb_free(ConfigFileEntry
.hidden_caps
);
1730 ConfigFileEntry
.hidden_caps
= rb_malloc(sizeof *ConfigFileEntry
.hidden_caps
* (n
+ 1));
1733 for (conf_parm_t
*arg
= data
; arg
; arg
= arg
->next
)
1735 ConfigFileEntry
.hidden_caps
[n
++] = rb_strdup(arg
->v
.string
);
1737 ConfigFileEntry
.hidden_caps
[n
] = NULL
;
1741 conf_set_serverhide_links_delay(void *data
)
1743 int val
= *(unsigned int *) data
;
1745 ConfigServerHide
.links_delay
= val
;
1749 conf_set_service_name(void *data
)
1755 for(s
= data
; *s
!= '\0'; s
++)
1759 conf_report_error("Ignoring service::name "
1760 "-- bogus servername.");
1769 conf_report_error("Ignoring service::name -- must contain '.'");
1773 tmp
= rb_strdup(data
);
1774 rb_dlinkAddAlloc(tmp
, &service_list
);
1778 conf_begin_alias(struct TopConf
*tc
)
1780 yy_alias
= rb_malloc(sizeof(struct alias_entry
));
1782 if (conf_cur_block_name
!= NULL
)
1783 yy_alias
->name
= rb_strdup(conf_cur_block_name
);
1785 yy_alias
->flags
= 0;
1791 conf_end_alias(struct TopConf
*tc
)
1793 if (yy_alias
== NULL
)
1796 if (yy_alias
->name
== NULL
)
1798 conf_report_error("Ignoring alias -- must have a name.");
1805 if (yy_alias
->target
== NULL
)
1807 conf_report_error("Ignoring alias -- must have a target.");
1814 rb_dictionary_add(alias_dict
, yy_alias
->name
, yy_alias
);
1820 conf_set_alias_name(void *data
)
1822 if (data
== NULL
|| yy_alias
== NULL
) /* this shouldn't ever happen */
1825 yy_alias
->name
= rb_strdup(data
);
1829 conf_set_alias_target(void *data
)
1831 if (data
== NULL
|| yy_alias
== NULL
) /* this shouldn't ever happen */
1834 yy_alias
->target
= rb_strdup(data
);
1838 conf_set_channel_autochanmodes(void *data
)
1841 int what
= MODE_ADD
;
1843 ConfigChannel
.autochanmodes
= 0;
1844 for (pm
= (char *) data
; *pm
; pm
++)
1856 if (chmode_table
[(unsigned char) *pm
].set_func
== chm_simple
)
1858 if (what
== MODE_ADD
)
1859 ConfigChannel
.autochanmodes
|= chmode_table
[(unsigned char) *pm
].mode_type
;
1861 ConfigChannel
.autochanmodes
&= ~chmode_table
[(unsigned char) *pm
].mode_type
;
1865 conf_report_error("channel::autochanmodes -- Invalid channel mode %c", *pm
);
1874 static void conf_set_dnsbl_entry_reason(void *data
);
1876 #define IPTYPE_IPV4 1
1877 #define IPTYPE_IPV6 2
1880 conf_warn_blacklist_deprecation(struct TopConf
*tc
)
1882 conf_report_error("blacklist{} blocks have been deprecated -- use dnsbl{} blocks instead.");
1887 conf_set_dnsbl_entry_host(void *data
)
1889 if (yy_dnsbl_entry_host
)
1891 conf_report_error("dnsbl::host %s overlaps existing host %s",
1892 (char *)data
, yy_dnsbl_entry_host
);
1895 conf_set_dnsbl_entry_reason(NULL
);
1899 yy_dnsbl_entry_iptype
|= IPTYPE_IPV4
;
1900 yy_dnsbl_entry_host
= rb_strdup(data
);
1904 conf_set_dnsbl_entry_type(void *data
)
1906 conf_parm_t
*args
= data
;
1908 /* Don't assume we have either if we got here */
1909 yy_dnsbl_entry_iptype
= 0;
1911 for (; args
; args
= args
->next
)
1913 if (!rb_strcasecmp(args
->v
.string
, "ipv4"))
1914 yy_dnsbl_entry_iptype
|= IPTYPE_IPV4
;
1915 else if (!rb_strcasecmp(args
->v
.string
, "ipv6"))
1916 yy_dnsbl_entry_iptype
|= IPTYPE_IPV6
;
1918 conf_report_error("dnsbl::type has unknown address family %s",
1922 /* If we have neither, just default to IPv4 */
1923 if (!yy_dnsbl_entry_iptype
)
1925 conf_report_warning("dnsbl::type has neither IPv4 nor IPv6 (defaulting to IPv4)");
1926 yy_dnsbl_entry_iptype
= IPTYPE_IPV4
;
1931 conf_set_dnsbl_entry_matches(void *data
)
1933 conf_parm_t
*args
= data
;
1934 enum filter_t
{ FILTER_NONE
, FILTER_ALL
, FILTER_LAST
};
1936 for (; args
; args
= args
->next
)
1938 char *str
= args
->v
.string
;
1940 enum filter_t type
= FILTER_LAST
;
1942 if (CF_TYPE(args
->type
) != CF_QSTRING
)
1944 conf_report_error("dnsbl::matches -- must be quoted string");
1950 conf_report_error("dnsbl::matches -- invalid entry");
1954 if (strlen(str
) > HOSTIPLEN
)
1956 conf_report_error("dnsbl::matches has an entry too long: %s",
1961 for (p
= str
; *p
!= '\0'; p
++)
1963 /* Check for validity */
1966 else if (!isdigit((unsigned char)*p
))
1968 conf_report_error("dnsbl::matches has invalid IP match entry %s",
1975 if (type
== FILTER_ALL
)
1977 /* Basic IP sanity check */
1978 struct rb_sockaddr_storage tmp
;
1979 if (rb_inet_pton(AF_INET
, str
, &tmp
) <= 0)
1981 conf_report_error("dnsbl::matches has invalid IP match entry %s",
1986 else if (type
== FILTER_LAST
)
1988 /* Verify it's the correct length */
1989 if (strlen(str
) > 3)
1991 conf_report_error("dnsbl::matches has invalid octet match entry %s",
1998 continue; /* Invalid entry */
2001 rb_dlinkAddAlloc(rb_strdup(str
), &yy_dnsbl_entry_filters
);
2006 conf_set_dnsbl_entry_reason(void *data
)
2008 rb_dlink_node
*ptr
, *nptr
;
2010 if (yy_dnsbl_entry_host
&& data
)
2012 yy_dnsbl_entry_reason
= rb_strdup(data
);
2013 if (yy_dnsbl_entry_iptype
& IPTYPE_IPV6
)
2015 /* Make sure things fit (magic number 64 = alnum count + dots)
2016 * Example: 1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa
2018 if ((64 + strlen(yy_dnsbl_entry_host
)) > IRCD_RES_HOSTLEN
)
2020 conf_report_error("dnsbl::host %s results in IPv6 queries that are too long",
2021 yy_dnsbl_entry_host
);
2025 /* Avoid doing redundant check, IPv6 is bigger than IPv4 --Elizabeth */
2026 if ((yy_dnsbl_entry_iptype
& IPTYPE_IPV4
) && !(yy_dnsbl_entry_iptype
& IPTYPE_IPV6
))
2028 /* Make sure things fit for worst case (magic number 16 = number of nums + dots)
2029 * Example: 127.127.127.127.in-addr.arpa
2031 if ((16 + strlen(yy_dnsbl_entry_host
)) > IRCD_RES_HOSTLEN
)
2033 conf_report_error("dnsbl::host %s results in IPv4 queries that are too long",
2034 yy_dnsbl_entry_host
);
2039 add_dnsbl_entry(yy_dnsbl_entry_host
, yy_dnsbl_entry_reason
, yy_dnsbl_entry_iptype
, &yy_dnsbl_entry_filters
);
2043 RB_DLINK_FOREACH_SAFE(ptr
, nptr
, yy_dnsbl_entry_filters
.head
)
2046 rb_dlinkDestroy(ptr
, &yy_dnsbl_entry_filters
);
2049 yy_dnsbl_entry_filters
= (rb_dlink_list
){ NULL
, NULL
, 0 };
2051 rb_free(yy_dnsbl_entry_host
);
2052 rb_free(yy_dnsbl_entry_reason
);
2053 yy_dnsbl_entry_host
= NULL
;
2054 yy_dnsbl_entry_reason
= NULL
;
2055 yy_dnsbl_entry_iptype
= 0;
2068 conf_begin_opm(struct TopConf
*tc
)
2070 yy_opm_address_ipv4
= yy_opm_address_ipv6
= NULL
;
2071 yy_opm_port_ipv4
= yy_opm_port_ipv6
= yy_opm_timeout
= 0;
2072 delete_opm_proxy_scanner_all();
2073 delete_opm_listener_all();
2078 conf_end_opm(struct TopConf
*tc
)
2080 rb_dlink_node
*ptr
, *nptr
;
2083 if(rb_dlink_list_length(&yy_opm_scanner_list
) == 0)
2085 conf_report_error("No opm scanners configured -- disabling opm.");
2090 if(yy_opm_port_ipv4
> 0)
2092 if(yy_opm_address_ipv4
!= NULL
)
2093 conf_create_opm_listener(yy_opm_address_ipv4
, yy_opm_port_ipv4
);
2097 if(!rb_inet_ntop_sock((struct sockaddr
*)&ServerInfo
.bind4
, ip
, sizeof(ip
)))
2098 conf_report_error("No opm::listen_ipv4 nor serverinfo::vhost directive; cannot listen on IPv4");
2100 conf_create_opm_listener(ip
, yy_opm_port_ipv4
);
2104 if(yy_opm_port_ipv6
> 0)
2106 if(yy_opm_address_ipv6
!= NULL
)
2107 conf_create_opm_listener(yy_opm_address_ipv6
, yy_opm_port_ipv6
);
2111 if(!rb_inet_ntop_sock((struct sockaddr
*)&ServerInfo
.bind6
, ip
, sizeof(ip
)))
2112 conf_report_error("No opm::listen_ipv6 nor serverinfo::vhost directive; cannot listen on IPv6");
2114 conf_create_opm_listener(ip
, yy_opm_port_ipv6
);
2118 /* If there's no listeners... */
2119 fail
= (yy_opm_port_ipv4
== 0 || yy_opm_port_ipv6
== 0);
2120 if(!fail
&& yy_opm_timeout
> 0 && yy_opm_timeout
< 60)
2122 set_authd_timeout("opm_timeout", yy_opm_timeout
);
2124 conf_report_error("No opm listeners -- disabling");
2125 else if(yy_opm_timeout
<= 0 || yy_opm_timeout
>= 60)
2126 conf_report_error("opm::timeout value is invalid -- ignoring");
2129 RB_DLINK_FOREACH_SAFE(ptr
, nptr
, yy_opm_scanner_list
.head
)
2131 struct opm_scanner
*scanner
= ptr
->data
;
2134 create_opm_proxy_scanner(scanner
->type
, scanner
->port
);
2136 rb_dlinkDelete(&scanner
->node
, &yy_opm_scanner_list
);
2141 opm_check_enable(true);
2143 rb_free(yy_opm_address_ipv4
);
2144 rb_free(yy_opm_address_ipv6
);
2149 conf_set_opm_timeout(void *data
)
2151 int timeout
= *((int *)data
);
2153 if(timeout
<= 0 || timeout
> 60)
2155 conf_report_error("opm::timeout value %d is bogus, ignoring", timeout
);
2159 yy_opm_timeout
= timeout
;
2163 conf_set_opm_listen_address_both(void *data
, bool ipv6
)
2165 struct rb_sockaddr_storage addr
;
2166 const char *confstr
= (ipv6
? "opm::listen_ipv6" : "opm::listen_ipv4");
2169 if(!rb_inet_pton_sock(ip
, &addr
))
2171 conf_report_error("%s is an invalid address: %s", confstr
, ip
);
2177 if(GET_SS_FAMILY(&addr
) != AF_INET6
)
2179 conf_report_error("%s is of the wrong address type: %s", confstr
, ip
);
2183 if(yy_opm_address_ipv6
!= NULL
)
2185 conf_report_error("%s overwrites previous address %s", confstr
, ip
);
2189 yy_opm_address_ipv6
= rb_strdup(ip
);
2193 if(GET_SS_FAMILY(&addr
) != AF_INET
)
2195 conf_report_error("%s is of the wrong address type: %s", confstr
, ip
);
2199 if(yy_opm_address_ipv4
!= NULL
)
2201 conf_report_error("%s overwrites previous address %s", confstr
, ip
);
2205 yy_opm_address_ipv4
= rb_strdup(ip
);
2210 conf_set_opm_listen_address_ipv4(void *data
)
2212 conf_set_opm_listen_address_both(data
, false);
2216 conf_set_opm_listen_address_ipv6(void *data
)
2218 conf_set_opm_listen_address_both(data
, true);
2222 conf_set_opm_listen_port_both(void *data
, bool ipv6
)
2224 int port
= *((int *)data
);
2225 const char *confstr
= (ipv6
? "opm::port_ipv6" : "opm::port_ipv4");
2227 if(port
> 65535 || port
<= 0)
2229 conf_report_error("%s is out of range: %d", confstr
, port
);
2235 if(yy_opm_port_ipv4
)
2237 conf_report_error("%s overwrites existing port %hu",
2238 confstr
, yy_opm_port_ipv4
);
2242 yy_opm_port_ipv4
= port
;
2246 if(yy_opm_port_ipv6
)
2248 conf_report_error("%s overwrites existing port %hu",
2249 confstr
, yy_opm_port_ipv6
);
2253 yy_opm_port_ipv6
= port
;
2258 conf_set_opm_listen_port_ipv4(void *data
)
2260 conf_set_opm_listen_port_both(data
, false);
2264 conf_set_opm_listen_port_ipv6(void *data
)
2266 conf_set_opm_listen_port_both(data
, true);
2270 conf_set_opm_listen_port(void *data
)
2272 conf_set_opm_listen_port_both(data
, true);
2273 conf_set_opm_listen_port_both(data
, false);
2277 conf_set_opm_scan_ports_all(void *data
, const char *node
, const char *type
)
2279 conf_parm_t
*args
= data
;
2280 for (; args
; args
= args
->next
)
2285 if(CF_TYPE(args
->type
) != CF_INT
)
2287 conf_report_error("%s argument is not an integer -- ignoring.", node
);
2291 if(args
->v
.number
> 65535 || args
->v
.number
<= 0)
2293 conf_report_error("%s argument is not an integer between 1 and 65535 -- ignoring.", node
);
2297 /* Check for duplicates */
2298 RB_DLINK_FOREACH(ptr
, yy_opm_scanner_list
.head
)
2300 struct opm_scanner
*scanner
= ptr
->data
;
2302 if(scanner
->port
== args
->v
.number
&& strcmp(type
, scanner
->type
) == 0)
2304 conf_report_error("%s argument is duplicate", node
);
2312 struct opm_scanner
*scanner
= rb_malloc(sizeof(struct opm_scanner
));
2313 scanner
->port
= args
->v
.number
;
2314 scanner
->type
= type
;
2315 rb_dlinkAdd(scanner
, &scanner
->node
, &yy_opm_scanner_list
);
2321 conf_set_opm_scan_ports_socks4(void *data
)
2323 conf_set_opm_scan_ports_all(data
, "opm::socks4_ports", "socks4");
2327 conf_set_opm_scan_ports_socks5(void *data
)
2329 conf_set_opm_scan_ports_all(data
, "opm::socks5_ports", "socks5");
2333 conf_set_opm_scan_ports_httpconnect(void *data
)
2335 conf_set_opm_scan_ports_all(data
, "opm::httpconnect_ports", "httpconnect");
2339 conf_set_opm_scan_ports_httpsconnect(void *data
)
2341 conf_set_opm_scan_ports_all(data
, "opm::httpsconnect_ports", "httpsconnect");
2344 /* public functions */
2348 conf_report_error(const char *fmt
, ...)
2351 char msg
[BUFSIZE
+ 1] = { 0 };
2354 vsnprintf(msg
, sizeof msg
, fmt
, ap
);
2359 fprintf(stderr
, "\"%s\", line %d: %s\n", current_file
, lineno
+ 1, msg
);
2363 ierror("\"%s\", line %d: %s", current_file
, lineno
+ 1, msg
);
2364 sendto_realops_snomask(SNO_GENERAL
, L_NETWIDE
, "error: \"%s\", line %d: %s", current_file
, lineno
+ 1, msg
);
2368 conf_report_warning(const char *fmt
, ...)
2371 char msg
[BUFSIZE
+ 1] = { 0 };
2374 vsnprintf(msg
, sizeof msg
, fmt
, ap
);
2379 fprintf(stderr
, "\"%s\", line %d: %s\n", current_file
, lineno
+ 1, msg
);
2383 iwarn("\"%s\", line %d: %s", current_file
, lineno
+ 1, msg
);
2384 sendto_realops_snomask(SNO_GENERAL
, L_NETWIDE
, "warning: \"%s\", line %d: %s", current_file
, lineno
+ 1, msg
);
2388 conf_start_block(char *block
, char *name
)
2390 if((conf_cur_block
= find_top_conf(block
)) == NULL
)
2392 conf_report_error("Configuration block '%s' is not defined.", block
);
2397 conf_cur_block_name
= rb_strdup(name
);
2399 conf_cur_block_name
= NULL
;
2401 if(conf_cur_block
->tc_sfunc
)
2402 if(conf_cur_block
->tc_sfunc(conf_cur_block
) < 0)
2409 conf_end_block(struct TopConf
*tc
)
2413 ret
= tc
->tc_efunc(tc
);
2415 rb_free(conf_cur_block_name
);
2416 conf_cur_block_name
= NULL
;
2421 conf_set_generic_int(void *data
, void *location
)
2423 *((int *) location
) = *((unsigned int *) data
);
2427 conf_set_generic_string(void *data
, int len
, void *location
)
2429 char **loc
= location
;
2432 if(len
&& strlen(input
) > (unsigned int)len
)
2436 *loc
= rb_strdup(input
);
2440 conf_call_set(struct TopConf
*tc
, char *item
, conf_parm_t
* value
)
2442 struct ConfEntry
*cf
;
2448 if((cf
= find_conf_item(tc
, item
)) == NULL
)
2451 ("Non-existent configuration setting %s::%s.", tc
->tc_name
, (char *) item
);
2455 /* if it takes one thing, make sure they only passed one thing,
2456 and handle as needed. */
2457 if((value
->v
.list
->type
& CF_FLIST
) && !(cf
->cf_type
& CF_FLIST
))
2460 ("Option %s::%s does not take a list of values.", tc
->tc_name
, item
);
2467 if(CF_TYPE(value
->v
.list
->type
) != CF_TYPE(cf
->cf_type
))
2469 /* if it expects a string value, but we got a yesno,
2472 if((CF_TYPE(value
->v
.list
->type
) == CF_YESNO
) &&
2473 (CF_TYPE(cf
->cf_type
) == CF_STRING
))
2475 value
->v
.list
->type
= CF_STRING
;
2477 if(cp
->v
.number
== 1)
2478 cp
->v
.string
= rb_strdup("yes");
2480 cp
->v
.string
= rb_strdup("no");
2483 /* maybe it's a CF_TIME and they passed CF_INT --
2484 should still be valid */
2485 else if(!((CF_TYPE(value
->v
.list
->type
) == CF_INT
) &&
2486 (CF_TYPE(cf
->cf_type
) == CF_TIME
)))
2489 ("Wrong type for %s::%s (expected %s, got %s)",
2490 tc
->tc_name
, (char *) item
,
2491 conf_strtype(cf
->cf_type
), conf_strtype(value
->v
.list
->type
));
2496 if(cf
->cf_type
& CF_FLIST
)
2500 conf_set_generic_list(value
->v
.list
, cf
->cf_arg
);
2503 /* just pass it the extended argument list */
2504 cf
->cf_func(value
->v
.list
);
2508 /* it's old-style, needs only one arg */
2509 switch (cf
->cf_type
)
2515 conf_set_generic_int(&cp
->v
.number
, cf
->cf_arg
);
2517 cf
->cf_func(&cp
->v
.number
);
2521 if(EmptyString(cp
->v
.string
))
2522 conf_report_error("Ignoring %s::%s -- empty field",
2525 conf_set_generic_string(cp
->v
.string
, cf
->cf_len
, cf
->cf_arg
);
2527 cf
->cf_func(cp
->v
.string
);
2537 add_conf_item(const char *topconf
, const char *name
, int type
, void (*func
) (void *))
2540 struct ConfEntry
*cf
;
2542 if((tc
= find_top_conf(topconf
)) == NULL
)
2545 if(find_conf_item(tc
, name
) != NULL
)
2548 cf
= rb_malloc(sizeof(struct ConfEntry
));
2555 rb_dlinkAddAlloc(cf
, &tc
->tc_items
);
2561 remove_conf_item(const char *topconf
, const char *name
)
2564 struct ConfEntry
*cf
;
2567 if((tc
= find_top_conf(topconf
)) == NULL
)
2570 if((cf
= find_conf_item(tc
, name
)) == NULL
)
2573 if((ptr
= rb_dlinkFind(cf
, &tc
->tc_items
)) == NULL
)
2576 rb_dlinkDestroy(ptr
, &tc
->tc_items
);
2583 static struct ConfEntry conf_serverinfo_table
[] =
2585 { "description", CF_QSTRING
, NULL
, 0, &ServerInfo
.description
},
2587 { "network_name", CF_QSTRING
, conf_set_serverinfo_network_name
, 0, NULL
},
2588 { "name", CF_QSTRING
, conf_set_serverinfo_name
, 0, NULL
},
2589 { "sid", CF_QSTRING
, conf_set_serverinfo_sid
, 0, NULL
},
2590 { "vhost", CF_QSTRING
, conf_set_serverinfo_vhost
, 0, NULL
},
2591 { "vhost6", CF_QSTRING
, conf_set_serverinfo_vhost6
, 0, NULL
},
2593 { "ssl_private_key", CF_QSTRING
, NULL
, 0, &ServerInfo
.ssl_private_key
},
2594 { "ssl_ca_cert", CF_QSTRING
, NULL
, 0, &ServerInfo
.ssl_ca_cert
},
2595 { "ssl_cert", CF_QSTRING
, NULL
, 0, &ServerInfo
.ssl_cert
},
2596 { "ssl_dh_params", CF_QSTRING
, NULL
, 0, &ServerInfo
.ssl_dh_params
},
2597 { "ssl_cipher_list", CF_QSTRING
, NULL
, 0, &ServerInfo
.ssl_cipher_list
},
2598 { "ssld_count", CF_INT
, NULL
, 0, &ServerInfo
.ssld_count
},
2600 { "default_max_clients",CF_INT
, NULL
, 0, &ServerInfo
.default_max_clients
},
2602 { "nicklen", CF_INT
, conf_set_serverinfo_nicklen
, 0, NULL
},
2604 { "\0", 0, NULL
, 0, NULL
}
2607 static struct ConfEntry conf_admin_table
[] =
2609 { "name", CF_QSTRING
, NULL
, 200, &AdminInfo
.name
},
2610 { "description",CF_QSTRING
, NULL
, 200, &AdminInfo
.description
},
2611 { "email", CF_QSTRING
, NULL
, 200, &AdminInfo
.email
},
2612 { "\0", 0, NULL
, 0, NULL
}
2615 static struct ConfEntry conf_log_table
[] =
2617 { "fname_userlog", CF_QSTRING
, NULL
, PATH_MAX
, &ConfigFileEntry
.fname_userlog
},
2618 { "fname_fuserlog", CF_QSTRING
, NULL
, PATH_MAX
, &ConfigFileEntry
.fname_fuserlog
},
2619 { "fname_operlog", CF_QSTRING
, NULL
, PATH_MAX
, &ConfigFileEntry
.fname_operlog
},
2620 { "fname_foperlog", CF_QSTRING
, NULL
, PATH_MAX
, &ConfigFileEntry
.fname_foperlog
},
2621 { "fname_serverlog", CF_QSTRING
, NULL
, PATH_MAX
, &ConfigFileEntry
.fname_serverlog
},
2622 { "fname_killlog", CF_QSTRING
, NULL
, PATH_MAX
, &ConfigFileEntry
.fname_killlog
},
2623 { "fname_klinelog", CF_QSTRING
, NULL
, PATH_MAX
, &ConfigFileEntry
.fname_klinelog
},
2624 { "fname_operspylog", CF_QSTRING
, NULL
, PATH_MAX
, &ConfigFileEntry
.fname_operspylog
},
2625 { "fname_ioerrorlog", CF_QSTRING
, NULL
, PATH_MAX
, &ConfigFileEntry
.fname_ioerrorlog
},
2626 { "\0", 0, NULL
, 0, NULL
}
2629 static struct ConfEntry conf_operator_table
[] =
2631 { "rsa_public_key_file", CF_QSTRING
, conf_set_oper_rsa_public_key_file
, 0, NULL
},
2632 { "flags", CF_STRING
| CF_FLIST
, conf_set_oper_flags
, 0, NULL
},
2633 { "umodes", CF_STRING
| CF_FLIST
, conf_set_oper_umodes
, 0, NULL
},
2634 { "privset", CF_QSTRING
, conf_set_oper_privset
, 0, NULL
},
2635 { "snomask", CF_QSTRING
, conf_set_oper_snomask
, 0, NULL
},
2636 { "user", CF_QSTRING
, conf_set_oper_user
, 0, NULL
},
2637 { "password", CF_QSTRING
, conf_set_oper_password
, 0, NULL
},
2638 { "fingerprint", CF_QSTRING
, conf_set_oper_fingerprint
, 0, NULL
},
2639 { "\0", 0, NULL
, 0, NULL
}
2642 static struct ConfEntry conf_privset_table
[] =
2644 { "extends", CF_QSTRING
, conf_set_privset_extends
, 0, NULL
},
2645 { "privs", CF_STRING
| CF_FLIST
, conf_set_privset_privs
, 0, NULL
},
2646 { "\0", 0, NULL
, 0, NULL
}
2649 static struct ConfEntry conf_class_table
[] =
2651 { "ping_time", CF_TIME
, conf_set_class_ping_time
, 0, NULL
},
2652 { "cidr_ipv4_bitlen", CF_INT
, conf_set_class_cidr_ipv4_bitlen
, 0, NULL
},
2653 { "cidr_ipv6_bitlen", CF_INT
, conf_set_class_cidr_ipv6_bitlen
, 0, NULL
},
2654 { "number_per_cidr", CF_INT
, conf_set_class_number_per_cidr
, 0, NULL
},
2655 { "number_per_ip", CF_INT
, conf_set_class_number_per_ip
, 0, NULL
},
2656 { "number_per_ip_global", CF_INT
,conf_set_class_number_per_ip_global
, 0, NULL
},
2657 { "number_per_ident", CF_INT
, conf_set_class_number_per_ident
, 0, NULL
},
2658 { "connectfreq", CF_TIME
, conf_set_class_connectfreq
, 0, NULL
},
2659 { "max_number", CF_INT
, conf_set_class_max_number
, 0, NULL
},
2660 { "max_autoconn", CF_INT
, conf_set_class_max_autoconn
, 0, NULL
},
2661 { "sendq", CF_TIME
, conf_set_class_sendq
, 0, NULL
},
2662 { "\0", 0, NULL
, 0, NULL
}
2665 static struct ConfEntry conf_auth_table
[] =
2667 { "user", CF_QSTRING
, conf_set_auth_user
, 0, NULL
},
2668 { "auth_user", CF_QSTRING
, conf_set_auth_auth_user
, 0, NULL
},
2669 { "password", CF_QSTRING
, conf_set_auth_passwd
, 0, NULL
},
2670 { "class", CF_QSTRING
, conf_set_auth_class
, 0, NULL
},
2671 { "spoof", CF_QSTRING
, conf_set_auth_spoof
, 0, NULL
},
2672 { "redirserv", CF_QSTRING
, conf_set_auth_redir_serv
, 0, NULL
},
2673 { "redirport", CF_INT
, conf_set_auth_redir_port
, 0, NULL
},
2674 { "flags", CF_STRING
| CF_FLIST
, conf_set_auth_flags
, 0, NULL
},
2675 { "umodes", CF_QSTRING
, conf_set_auth_umodes
, 0, NULL
},
2676 { "description",CF_QSTRING
, conf_set_auth_desc
, 0, NULL
},
2677 { "\0", 0, NULL
, 0, NULL
}
2680 static struct ConfEntry conf_connect_table
[] =
2682 { "send_password", CF_QSTRING
, conf_set_connect_send_password
, 0, NULL
},
2683 { "accept_password", CF_QSTRING
, conf_set_connect_accept_password
, 0, NULL
},
2684 { "fingerprint", CF_QSTRING
, conf_set_connect_fingerprint
, 0, NULL
},
2685 { "flags", CF_STRING
| CF_FLIST
, conf_set_connect_flags
, 0, NULL
},
2686 { "host", CF_QSTRING
, conf_set_connect_host
, 0, NULL
},
2687 { "vhost", CF_QSTRING
, conf_set_connect_vhost
, 0, NULL
},
2688 { "port", CF_INT
, conf_set_connect_port
, 0, NULL
},
2689 { "aftype", CF_STRING
, conf_set_connect_aftype
, 0, NULL
},
2690 { "class", CF_QSTRING
, conf_set_connect_class
, 0, NULL
},
2691 { "\0", 0, NULL
, 0, NULL
}
2694 static struct ConfEntry conf_general_table
[] =
2696 { "oper_only_umodes", CF_STRING
| CF_FLIST
, conf_set_general_oper_only_umodes
, 0, NULL
},
2697 { "oper_umodes", CF_STRING
| CF_FLIST
, conf_set_general_oper_umodes
, 0, NULL
},
2698 { "oper_snomask", CF_QSTRING
, conf_set_general_oper_snomask
, 0, NULL
},
2699 { "havent_read_conf", CF_YESNO
, conf_set_general_havent_read_conf
, 0, NULL
},
2700 { "hide_error_messages",CF_STRING
, conf_set_general_hide_error_messages
,0, NULL
},
2701 { "stats_i_oper_only", CF_STRING
, conf_set_general_stats_i_oper_only
, 0, NULL
},
2702 { "stats_k_oper_only", CF_STRING
, conf_set_general_stats_k_oper_only
, 0, NULL
},
2703 { "stats_l_oper_only", CF_STRING
, conf_set_general_stats_l_oper_only
, 0, NULL
},
2704 { "default_umodes", CF_QSTRING
, conf_set_general_default_umodes
, 0, NULL
},
2706 { "default_operstring", CF_QSTRING
, NULL
, REALLEN
, &ConfigFileEntry
.default_operstring
},
2707 { "default_adminstring",CF_QSTRING
, NULL
, REALLEN
, &ConfigFileEntry
.default_adminstring
},
2708 { "servicestring", CF_QSTRING
, NULL
, REALLEN
, &ConfigFileEntry
.servicestring
},
2709 { "kline_reason", CF_QSTRING
, NULL
, REALLEN
, &ConfigFileEntry
.kline_reason
},
2710 { "identify_service", CF_QSTRING
, NULL
, REALLEN
, &ConfigFileEntry
.identifyservice
},
2711 { "identify_command", CF_QSTRING
, NULL
, REALLEN
, &ConfigFileEntry
.identifycommand
},
2712 { "sasl_service", CF_QSTRING
, NULL
, REALLEN
, &ConfigFileEntry
.sasl_service
},
2714 { "anti_spam_exit_message_time", CF_TIME
, NULL
, 0, &ConfigFileEntry
.anti_spam_exit_message_time
},
2715 { "disable_fake_channels", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.disable_fake_channels
},
2716 { "min_nonwildcard_simple", CF_INT
, NULL
, 0, &ConfigFileEntry
.min_nonwildcard_simple
},
2717 { "non_redundant_klines", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.non_redundant_klines
},
2718 { "tkline_expire_notices", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.tkline_expire_notices
},
2720 { "hidden_caps", CF_QSTRING
| CF_FLIST
, conf_set_general_hidden_caps
, 0, NULL
},
2722 { "anti_nick_flood", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.anti_nick_flood
},
2723 { "burst_away", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.burst_away
},
2724 { "caller_id_wait", CF_TIME
, NULL
, 0, &ConfigFileEntry
.caller_id_wait
},
2725 { "client_exit", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.client_exit
},
2726 { "collision_fnc", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.collision_fnc
},
2727 { "resv_fnc", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.resv_fnc
},
2728 { "post_registration_delay", CF_TIME
, NULL
, 0, &ConfigFileEntry
.post_registration_delay
},
2729 { "connect_timeout", CF_TIME
, NULL
, 0, &ConfigFileEntry
.connect_timeout
},
2730 { "default_floodcount", CF_INT
, NULL
, 0, &ConfigFileEntry
.default_floodcount
},
2731 { "default_ident_timeout", CF_INT
, NULL
, 0, &ConfigFileEntry
.default_ident_timeout
},
2732 { "disable_auth", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.disable_auth
},
2733 { "dots_in_ident", CF_INT
, NULL
, 0, &ConfigFileEntry
.dots_in_ident
},
2734 { "failed_oper_notice", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.failed_oper_notice
},
2735 { "global_snotices", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.global_snotices
},
2736 { "hide_spoof_ips", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.hide_spoof_ips
},
2737 { "dline_with_reason", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.dline_with_reason
},
2738 { "kline_with_reason", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.kline_with_reason
},
2739 { "hide_tkdline_duration", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.hide_tkdline_duration
},
2740 { "map_oper_only", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.map_oper_only
},
2741 { "max_accept", CF_INT
, NULL
, 0, &ConfigFileEntry
.max_accept
},
2742 { "max_monitor", CF_INT
, NULL
, 0, &ConfigFileEntry
.max_monitor
},
2743 { "max_nick_time", CF_TIME
, NULL
, 0, &ConfigFileEntry
.max_nick_time
},
2744 { "max_nick_changes", CF_INT
, NULL
, 0, &ConfigFileEntry
.max_nick_changes
},
2745 { "max_targets", CF_INT
, NULL
, 0, &ConfigFileEntry
.max_targets
},
2746 { "min_nonwildcard", CF_INT
, NULL
, 0, &ConfigFileEntry
.min_nonwildcard
},
2747 { "nick_delay", CF_TIME
, NULL
, 0, &ConfigFileEntry
.nick_delay
},
2748 { "no_oper_flood", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.no_oper_flood
},
2749 { "operspy_admin_only", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.operspy_admin_only
},
2750 { "operspy_dont_care_user_info", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.operspy_dont_care_user_info
},
2751 { "pace_wait", CF_TIME
, NULL
, 0, &ConfigFileEntry
.pace_wait
},
2752 { "pace_wait_simple", CF_TIME
, NULL
, 0, &ConfigFileEntry
.pace_wait_simple
},
2753 { "ping_cookie", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.ping_cookie
},
2754 { "reject_after_count", CF_INT
, NULL
, 0, &ConfigFileEntry
.reject_after_count
},
2755 { "reject_ban_time", CF_TIME
, NULL
, 0, &ConfigFileEntry
.reject_ban_time
},
2756 { "reject_duration", CF_TIME
, NULL
, 0, &ConfigFileEntry
.reject_duration
},
2757 { "throttle_count", CF_INT
, NULL
, 0, &ConfigFileEntry
.throttle_count
},
2758 { "throttle_duration", CF_TIME
, NULL
, 0, &ConfigFileEntry
.throttle_duration
},
2759 { "short_motd", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.short_motd
},
2760 { "stats_c_oper_only", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.stats_c_oper_only
},
2761 { "stats_e_disabled", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.stats_e_disabled
},
2762 { "stats_o_oper_only", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.stats_o_oper_only
},
2763 { "stats_P_oper_only", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.stats_P_oper_only
},
2764 { "stats_y_oper_only", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.stats_y_oper_only
},
2765 { "target_change", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.target_change
},
2766 { "ts_max_delta", CF_TIME
, NULL
, 0, &ConfigFileEntry
.ts_max_delta
},
2767 { "ts_warn_delta", CF_TIME
, NULL
, 0, &ConfigFileEntry
.ts_warn_delta
},
2768 { "use_whois_actually", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.use_whois_actually
},
2769 { "warn_no_nline", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.warn_no_nline
},
2770 { "use_propagated_bans",CF_YESNO
, NULL
, 0, &ConfigFileEntry
.use_propagated_bans
},
2771 { "client_flood_max_lines", CF_INT
, NULL
, 0, &ConfigFileEntry
.client_flood_max_lines
},
2772 { "client_flood_burst_rate", CF_INT
, NULL
, 0, &ConfigFileEntry
.client_flood_burst_rate
},
2773 { "client_flood_burst_max", CF_INT
, NULL
, 0, &ConfigFileEntry
.client_flood_burst_max
},
2774 { "client_flood_message_num", CF_INT
, NULL
, 0, &ConfigFileEntry
.client_flood_message_num
},
2775 { "client_flood_message_time", CF_INT
, NULL
, 0, &ConfigFileEntry
.client_flood_message_time
},
2776 { "max_ratelimit_tokens", CF_INT
, NULL
, 0, &ConfigFileEntry
.max_ratelimit_tokens
},
2777 { "away_interval", CF_INT
, NULL
, 0, &ConfigFileEntry
.away_interval
},
2778 { "hide_opers_in_whois", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.hide_opers_in_whois
},
2779 { "hide_opers", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.hide_opers
},
2780 { "certfp_method", CF_STRING
, conf_set_general_certfp_method
, 0, NULL
},
2781 { "drain_reason", CF_QSTRING
, NULL
, BUFSIZE
, &ConfigFileEntry
.drain_reason
},
2782 { "sasl_only_client_message", CF_QSTRING
, NULL
, BUFSIZE
, &ConfigFileEntry
.sasl_only_client_message
},
2783 { "identd_only_client_message", CF_QSTRING
, NULL
, BUFSIZE
, &ConfigFileEntry
.identd_only_client_message
},
2784 { "sctp_forbidden_client_message", CF_QSTRING
, NULL
, BUFSIZE
, &ConfigFileEntry
.sctp_forbidden_client_message
},
2785 { "ssltls_only_client_message", CF_QSTRING
, NULL
, BUFSIZE
, &ConfigFileEntry
.ssltls_only_client_message
},
2786 { "not_authorised_client_message", CF_QSTRING
, NULL
, BUFSIZE
, &ConfigFileEntry
.not_authorised_client_message
},
2787 { "illegal_hostname_client_message", CF_QSTRING
, NULL
, BUFSIZE
, &ConfigFileEntry
.not_authorised_client_message
},
2788 { "server_full_client_message", CF_QSTRING
, NULL
, BUFSIZE
, &ConfigFileEntry
.server_full_client_message
},
2789 { "illegal_name_long_client_message", CF_QSTRING
, NULL
, BUFSIZE
, &ConfigFileEntry
.illegal_name_long_client_message
},
2790 { "illegal_name_short_client_message", CF_QSTRING
, NULL
, BUFSIZE
, &ConfigFileEntry
.illegal_name_short_client_message
},
2791 { "tls_ciphers_oper_only", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.tls_ciphers_oper_only
},
2792 { "oper_secure_only", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.oper_secure_only
},
2793 { "\0", 0, NULL
, 0, NULL
}
2796 static struct ConfEntry conf_channel_table
[] =
2798 { "default_split_user_count", CF_INT
, NULL
, 0, &ConfigChannel
.default_split_user_count
},
2799 { "default_split_server_count", CF_INT
, NULL
, 0, &ConfigChannel
.default_split_server_count
},
2800 { "burst_topicwho", CF_YESNO
, NULL
, 0, &ConfigChannel
.burst_topicwho
},
2801 { "kick_on_split_riding", CF_YESNO
, NULL
, 0, &ConfigChannel
.kick_on_split_riding
},
2802 { "knock_delay", CF_TIME
, NULL
, 0, &ConfigChannel
.knock_delay
},
2803 { "knock_delay_channel",CF_TIME
, NULL
, 0, &ConfigChannel
.knock_delay_channel
},
2804 { "max_bans", CF_INT
, NULL
, 0, &ConfigChannel
.max_bans
},
2805 { "max_bans_large", CF_INT
, NULL
, 0, &ConfigChannel
.max_bans_large
},
2806 { "max_chans_per_user", CF_INT
, NULL
, 0, &ConfigChannel
.max_chans_per_user
},
2807 { "max_chans_per_user_large", CF_INT
, NULL
, 0, &ConfigChannel
.max_chans_per_user_large
},
2808 { "no_create_on_split", CF_YESNO
, NULL
, 0, &ConfigChannel
.no_create_on_split
},
2809 { "no_join_on_split", CF_YESNO
, NULL
, 0, &ConfigChannel
.no_join_on_split
},
2810 { "only_ascii_channels", CF_YESNO
, NULL
, 0, &ConfigChannel
.only_ascii_channels
},
2811 { "use_except", CF_YESNO
, NULL
, 0, &ConfigChannel
.use_except
},
2812 { "use_invex", CF_YESNO
, NULL
, 0, &ConfigChannel
.use_invex
},
2813 { "use_forward", CF_YESNO
, NULL
, 0, &ConfigChannel
.use_forward
},
2814 { "use_knock", CF_YESNO
, NULL
, 0, &ConfigChannel
.use_knock
},
2815 { "resv_forcepart", CF_YESNO
, NULL
, 0, &ConfigChannel
.resv_forcepart
},
2816 { "channel_target_change", CF_YESNO
, NULL
, 0, &ConfigChannel
.channel_target_change
},
2817 { "disable_local_channels", CF_YESNO
, NULL
, 0, &ConfigChannel
.disable_local_channels
},
2818 { "autochanmodes", CF_QSTRING
, conf_set_channel_autochanmodes
, 0, NULL
},
2819 { "displayed_usercount", CF_INT
, NULL
, 0, &ConfigChannel
.displayed_usercount
},
2820 { "strip_topic_colors", CF_YESNO
, NULL
, 0, &ConfigChannel
.strip_topic_colors
},
2821 { "opmod_send_statusmsg", CF_YESNO
, NULL
, 0, &ConfigChannel
.opmod_send_statusmsg
},
2822 { "ip_bans_through_vhost", CF_YESNO
, NULL
, 0, &ConfigChannel
.ip_bans_through_vhost
},
2823 { "\0", 0, NULL
, 0, NULL
}
2826 static struct ConfEntry conf_serverhide_table
[] =
2828 { "disable_hidden", CF_YESNO
, NULL
, 0, &ConfigServerHide
.disable_hidden
},
2829 { "flatten_links", CF_YESNO
, NULL
, 0, &ConfigServerHide
.flatten_links
},
2830 { "hidden", CF_YESNO
, NULL
, 0, &ConfigServerHide
.hidden
},
2831 { "links_delay", CF_TIME
, conf_set_serverhide_links_delay
, 0, NULL
},
2832 { "\0", 0, NULL
, 0, NULL
}
2839 add_top_conf("modules", NULL
, NULL
, NULL
);
2840 add_conf_item("modules", "path", CF_QSTRING
, conf_set_modules_path
);
2841 add_conf_item("modules", "module", CF_QSTRING
, conf_set_modules_module
);
2843 add_top_conf("serverinfo", NULL
, NULL
, conf_serverinfo_table
);
2844 add_top_conf("admin", NULL
, NULL
, conf_admin_table
);
2845 add_top_conf("log", NULL
, NULL
, conf_log_table
);
2846 add_top_conf("operator", conf_begin_oper
, conf_end_oper
, conf_operator_table
);
2847 add_top_conf("class", conf_begin_class
, conf_end_class
, conf_class_table
);
2848 add_top_conf("privset", NULL
, NULL
, conf_privset_table
);
2850 add_top_conf("listen", conf_begin_listen
, conf_end_listen
, NULL
);
2851 add_conf_item("listen", "defer_accept", CF_YESNO
, conf_set_listen_defer_accept
);
2852 add_conf_item("listen", "wsock", CF_YESNO
, conf_set_listen_wsock
);
2853 add_conf_item("listen", "port", CF_INT
| CF_FLIST
, conf_set_listen_port
);
2854 add_conf_item("listen", "sslport", CF_INT
| CF_FLIST
, conf_set_listen_sslport
);
2855 add_conf_item("listen", "sctp_port", CF_INT
| CF_FLIST
, conf_set_listen_sctp_port
);
2856 add_conf_item("listen", "sctp_sslport", CF_INT
| CF_FLIST
, conf_set_listen_sctp_sslport
);
2857 add_conf_item("listen", "ip", CF_QSTRING
, conf_set_listen_address
);
2858 add_conf_item("listen", "host", CF_QSTRING
, conf_set_listen_address
);
2860 add_top_conf("auth", conf_begin_auth
, conf_end_auth
, conf_auth_table
);
2862 add_top_conf("connect", conf_begin_connect
, conf_end_connect
, conf_connect_table
);
2864 add_top_conf("exempt", NULL
, NULL
, NULL
);
2865 add_conf_item("exempt", "ip", CF_QSTRING
, conf_set_exempt_ip
);
2867 add_top_conf("secure", NULL
, NULL
, NULL
);
2868 add_conf_item("secure", "ip", CF_QSTRING
, conf_set_secure_ip
);
2870 add_top_conf("cluster", conf_cleanup_cluster
, conf_cleanup_cluster
, NULL
);
2871 add_conf_item("cluster", "name", CF_QSTRING
, conf_set_cluster_name
);
2872 add_conf_item("cluster", "flags", CF_STRING
| CF_FLIST
, conf_set_cluster_flags
);
2874 add_top_conf("general", NULL
, NULL
, conf_general_table
);
2875 add_top_conf("channel", NULL
, NULL
, conf_channel_table
);
2876 add_top_conf("serverhide", NULL
, NULL
, conf_serverhide_table
);
2878 add_top_conf("service", NULL
, NULL
, NULL
);
2879 add_conf_item("service", "name", CF_QSTRING
, conf_set_service_name
);
2881 add_top_conf("alias", conf_begin_alias
, conf_end_alias
, NULL
);
2882 add_conf_item("alias", "name", CF_QSTRING
, conf_set_alias_name
);
2883 add_conf_item("alias", "target", CF_QSTRING
, conf_set_alias_target
);
2885 add_top_conf("dnsbl", NULL
, NULL
, NULL
);
2886 add_conf_item("dnsbl", "host", CF_QSTRING
, conf_set_dnsbl_entry_host
);
2887 add_conf_item("dnsbl", "type", CF_STRING
| CF_FLIST
, conf_set_dnsbl_entry_type
);
2888 add_conf_item("dnsbl", "matches", CF_QSTRING
| CF_FLIST
, conf_set_dnsbl_entry_matches
);
2889 add_conf_item("dnsbl", "reject_reason", CF_QSTRING
, conf_set_dnsbl_entry_reason
);
2891 add_top_conf("blacklist", conf_warn_blacklist_deprecation
, NULL
, NULL
);
2892 add_conf_item("blacklist", "host", CF_QSTRING
, conf_set_dnsbl_entry_host
);
2893 add_conf_item("blacklist", "type", CF_STRING
| CF_FLIST
, conf_set_dnsbl_entry_type
);
2894 add_conf_item("blacklist", "matches", CF_QSTRING
| CF_FLIST
, conf_set_dnsbl_entry_matches
);
2895 add_conf_item("blacklist", "reject_reason", CF_QSTRING
, conf_set_dnsbl_entry_reason
);
2897 add_top_conf("opm", conf_begin_opm
, conf_end_opm
, NULL
);
2898 add_conf_item("opm", "timeout", CF_INT
, conf_set_opm_timeout
);
2899 add_conf_item("opm", "listen_ipv4", CF_QSTRING
, conf_set_opm_listen_address_ipv4
);
2900 add_conf_item("opm", "listen_ipv6", CF_QSTRING
, conf_set_opm_listen_address_ipv6
);
2901 add_conf_item("opm", "port_v4", CF_INT
, conf_set_opm_listen_port_ipv4
);
2902 add_conf_item("opm", "port_v6", CF_INT
, conf_set_opm_listen_port_ipv6
);
2903 add_conf_item("opm", "listen_port", CF_INT
, conf_set_opm_listen_port
);
2904 add_conf_item("opm", "socks4_ports", CF_INT
| CF_FLIST
, conf_set_opm_scan_ports_socks4
);
2905 add_conf_item("opm", "socks5_ports", CF_INT
| CF_FLIST
, conf_set_opm_scan_ports_socks5
);
2906 add_conf_item("opm", "httpconnect_ports", CF_INT
| CF_FLIST
, conf_set_opm_scan_ports_httpconnect
);
2907 add_conf_item("opm", "httpsconnect_ports", CF_INT
| CF_FLIST
, conf_set_opm_scan_ports_httpsconnect
);