1 /* This code is in the public domain.
7 #include <openssl/pem.h>
8 #include <openssl/rsa.h>
12 #include "ircd_defs.h"
16 #include "s_newconf.h"
29 #include "privilege.h"
32 #define CF_TYPE(x) ((x) & CF_MTYPE)
34 static int yy_defer_accept
= 1;
35 static int yy_wsock
= 0;
37 struct TopConf
*conf_cur_block
;
38 static char *conf_cur_block_name
= NULL
;
40 static rb_dlink_list conf_items
;
42 static struct ConfItem
*yy_aconf
= NULL
;
44 static struct Class
*yy_class
= NULL
;
46 static struct remote_conf
*yy_shared
= NULL
;
47 static struct server_conf
*yy_server
= NULL
;
49 static rb_dlink_list yy_aconf_list
;
50 static rb_dlink_list yy_oper_list
;
51 static rb_dlink_list yy_shared_list
;
52 static rb_dlink_list yy_cluster_list
;
53 static struct oper_conf
*yy_oper
= NULL
;
55 static struct alias_entry
*yy_alias
= NULL
;
57 static char *yy_blacklist_host
= NULL
;
58 static char *yy_blacklist_reason
= NULL
;
59 static uint8_t yy_blacklist_iptype
= 0;
60 static rb_dlink_list yy_blacklist_filters
= { NULL
, NULL
, 0 };
62 static char *yy_opm_address_ipv4
= NULL
;
63 static char *yy_opm_address_ipv6
= NULL
;
64 static uint16_t yy_opm_port_ipv4
= 0;
65 static uint16_t yy_opm_port_ipv6
= 0;
66 static rb_dlink_list yy_opm_scanner_list
;
68 static char *yy_privset_extends
= NULL
;
71 conf_strtype(int type
)
73 switch (CF_TYPE(type
))
76 return "integer value";
78 return "unquoted string";
80 return "yes/no value";
82 return "quoted string";
84 return "time/size value";
86 return "unknown type";
91 add_top_conf(const char *name
, int (*sfunc
) (struct TopConf
*),
92 int (*efunc
) (struct TopConf
*), struct ConfEntry
*items
)
96 tc
= rb_malloc(sizeof(struct TopConf
));
100 tc
->tc_efunc
= efunc
;
101 tc
->tc_entries
= items
;
103 rb_dlinkAddAlloc(tc
, &conf_items
);
108 find_top_conf(const char *name
)
113 RB_DLINK_FOREACH(d
, conf_items
.head
)
116 if(strcasecmp(tc
->tc_name
, name
) == 0)
125 find_conf_item(const struct TopConf
*top
, const char *name
)
127 struct ConfEntry
*cf
;
134 for(i
= 0; top
->tc_entries
[i
].cf_type
; i
++)
136 cf
= &top
->tc_entries
[i
];
138 if(!strcasecmp(cf
->cf_name
, name
))
143 RB_DLINK_FOREACH(d
, top
->tc_items
.head
)
146 if(strcasecmp(cf
->cf_name
, name
) == 0)
154 remove_top_conf(char *name
)
159 if((tc
= find_top_conf(name
)) == NULL
)
162 if((ptr
= rb_dlinkFind(tc
, &conf_items
)) == NULL
)
165 rb_dlinkDestroy(ptr
, &conf_items
);
172 conf_set_serverinfo_name(void *data
)
174 if(ServerInfo
.name
== NULL
)
179 for(s
= data
; *s
!= '\0'; s
++)
183 conf_report_error("Ignoring serverinfo::name "
184 "-- bogus servername.");
193 conf_report_error("Ignoring serverinfo::name -- must contain '.'");
201 conf_report_error("Ignoring serverinfo::name -- cannot begin with digit.");
205 /* the ircd will exit() in main() if we dont set one */
206 if(strlen(s
) <= HOSTLEN
)
207 ServerInfo
.name
= rb_strdup((char *) data
);
212 conf_set_serverinfo_sid(void *data
)
216 if(ServerInfo
.sid
[0] == '\0')
218 if(!IsDigit(sid
[0]) || !IsIdChar(sid
[1]) ||
219 !IsIdChar(sid
[2]) || sid
[3] != '\0')
221 conf_report_error("Ignoring serverinfo::sid "
226 strcpy(ServerInfo
.sid
, sid
);
231 conf_set_serverinfo_network_name(void *data
)
235 if((p
= strchr((char *) data
, ' ')))
238 rb_free(ServerInfo
.network_name
);
239 ServerInfo
.network_name
= rb_strdup((char *) data
);
243 conf_set_serverinfo_vhost(void *data
)
245 if(rb_inet_pton(AF_INET
, (char *) data
, &ServerInfo
.ip
.sin_addr
) <= 0)
247 conf_report_error("Invalid IPv4 address for server vhost (%s)", (char *) data
);
250 ServerInfo
.ip
.sin_family
= AF_INET
;
251 ServerInfo
.specific_ipv4_vhost
= 1;
255 conf_set_serverinfo_vhost6(void *data
)
258 if(rb_inet_pton(AF_INET6
, (char *) data
, &ServerInfo
.ip6
.sin6_addr
) <= 0)
260 conf_report_error("Invalid IPv6 address for server vhost (%s)", (char *) data
);
264 ServerInfo
.specific_ipv6_vhost
= 1;
265 ServerInfo
.ip6
.sin6_family
= AF_INET6
;
267 conf_report_error("Warning -- ignoring serverinfo::vhost6 -- IPv6 support not available.");
272 conf_set_serverinfo_nicklen(void *data
)
274 ConfigFileEntry
.nicklen
= (*(unsigned int *) data
) + 1;
276 if (ConfigFileEntry
.nicklen
> NICKLEN
)
278 conf_report_error("Warning -- ignoring serverinfo::nicklen -- provided nicklen (%u) is greater than allowed nicklen (%u)",
279 ConfigFileEntry
.nicklen
- 1, NICKLEN
- 1);
280 ConfigFileEntry
.nicklen
= NICKLEN
;
282 else if (ConfigFileEntry
.nicklen
< 9 + 1)
284 conf_report_error("Warning -- serverinfo::nicklen is too low (%u) -- forcing 9",
285 ConfigFileEntry
.nicklen
- 1);
286 ConfigFileEntry
.nicklen
= 9 + 1;
291 conf_set_modules_module(void *data
)
295 m_bn
= rb_basename((char *) data
);
297 if(findmodule_byname(m_bn
) == -1)
298 load_one_module((char *) data
, MAPI_ORIGIN_EXTENSION
, 0);
304 conf_set_modules_path(void *data
)
306 mod_add_path((char *) data
);
316 static struct mode_table umode_table
[] = {
317 {"callerid", UMODE_CALLERID
},
318 {"deaf", UMODE_DEAF
},
319 {"invisible", UMODE_INVISIBLE
},
320 {"locops", UMODE_LOCOPS
},
321 {"noforward", UMODE_NOFORWARD
},
322 {"regonlymsg", UMODE_REGONLYMSG
},
323 {"servnotice", UMODE_SERVNOTICE
},
324 {"wallop", UMODE_WALLOP
},
325 {"operwall", UMODE_OPERWALL
},
329 static struct mode_table oper_table
[] = {
330 {"encrypted", OPER_ENCRYPTED
},
331 {"need_ssl", OPER_NEEDSSL
},
335 static struct mode_table auth_table
[] = {
336 {"encrypted", CONF_FLAGS_ENCRYPTED
},
337 {"spoof_notice", CONF_FLAGS_SPOOF_NOTICE
},
338 {"exceed_limit", CONF_FLAGS_NOLIMIT
},
339 {"dnsbl_exempt", CONF_FLAGS_EXEMPTDNSBL
},
340 {"proxy_exempt", CONF_FLAGS_EXEMPTPROXY
},
341 {"kline_exempt", CONF_FLAGS_EXEMPTKLINE
},
342 {"flood_exempt", CONF_FLAGS_EXEMPTFLOOD
},
343 {"spambot_exempt", CONF_FLAGS_EXEMPTSPAMBOT
},
344 {"shide_exempt", CONF_FLAGS_EXEMPTSHIDE
},
345 {"jupe_exempt", CONF_FLAGS_EXEMPTJUPE
},
346 {"resv_exempt", CONF_FLAGS_EXEMPTRESV
},
347 {"no_tilde", CONF_FLAGS_NO_TILDE
},
348 {"need_ident", CONF_FLAGS_NEED_IDENTD
},
349 {"have_ident", CONF_FLAGS_NEED_IDENTD
},
350 {"need_ssl", CONF_FLAGS_NEED_SSL
},
351 {"need_sasl", CONF_FLAGS_NEED_SASL
},
352 {"extend_chans", CONF_FLAGS_EXTEND_CHANS
},
356 static struct mode_table connect_table
[] = {
357 { "autoconn", SERVER_AUTOCONN
},
358 { "compressed", SERVER_COMPRESSED
},
359 { "encrypted", SERVER_ENCRYPTED
},
360 { "topicburst", SERVER_TB
},
361 { "ssl", SERVER_SSL
},
365 static struct mode_table cluster_table
[] = {
366 { "kline", SHARED_PKLINE
},
367 { "tkline", SHARED_TKLINE
},
368 { "unkline", SHARED_UNKLINE
},
369 { "locops", SHARED_LOCOPS
},
370 { "xline", SHARED_PXLINE
},
371 { "txline", SHARED_TXLINE
},
372 { "unxline", SHARED_UNXLINE
},
373 { "resv", SHARED_PRESV
},
374 { "tresv", SHARED_TRESV
},
375 { "unresv", SHARED_UNRESV
},
376 { "all", CLUSTER_ALL
},
380 static struct mode_table shared_table
[] =
382 { "kline", SHARED_PKLINE
|SHARED_TKLINE
},
383 { "xline", SHARED_PXLINE
|SHARED_TXLINE
},
384 { "resv", SHARED_PRESV
|SHARED_TRESV
},
385 { "dline", SHARED_PDLINE
|SHARED_TDLINE
},
386 { "tdline", SHARED_TDLINE
},
387 { "pdline", SHARED_PDLINE
},
388 { "undline", SHARED_UNDLINE
},
389 { "tkline", SHARED_TKLINE
},
390 { "unkline", SHARED_UNKLINE
},
391 { "txline", SHARED_TXLINE
},
392 { "unxline", SHARED_UNXLINE
},
393 { "tresv", SHARED_TRESV
},
394 { "unresv", SHARED_UNRESV
},
395 { "locops", SHARED_LOCOPS
},
396 { "rehash", SHARED_REHASH
},
397 { "grant", SHARED_GRANT
},
398 { "die", SHARED_DIE
},
399 { "module", SHARED_MODULE
},
400 { "all", SHARED_ALL
},
407 find_umode(struct mode_table
*tab
, const char *name
)
411 for (i
= 0; tab
[i
].name
; i
++)
413 if(strcmp(tab
[i
].name
, name
) == 0)
421 set_modes_from_table(int *modes
, const char *whatis
, struct mode_table
*tab
, conf_parm_t
* args
)
423 for (; args
; args
= args
->next
)
429 if(CF_TYPE(args
->type
) != CF_STRING
)
431 conf_report_error("Warning -- %s is not a string; ignoring.", whatis
);
435 umode
= args
->v
.string
;
443 mode
= find_umode(tab
, umode
);
447 conf_report_error("Warning -- unknown %s %s.", whatis
, args
->v
.string
);
464 conf_set_privset_extends(void *data
)
466 yy_privset_extends
= rb_strdup((char *) data
);
470 conf_set_privset_privs(void *data
)
473 conf_parm_t
*args
= data
;
475 for (; args
; args
= args
->next
)
478 privs
= rb_strdup(args
->v
.string
);
481 char *privs_old
= privs
;
483 privs
= rb_malloc(strlen(privs_old
) + 1 + strlen(args
->v
.string
) + 1);
484 strcpy(privs
, privs_old
);
486 strcat(privs
, args
->v
.string
);
494 if (yy_privset_extends
)
496 struct PrivilegeSet
*set
= privilegeset_get(yy_privset_extends
);
500 conf_report_error("Warning -- unknown parent privilege set %s for %s; assuming defaults", yy_privset_extends
, conf_cur_block_name
);
502 set
= privilegeset_get("default");
505 privilegeset_extend(set
, conf_cur_block_name
!= NULL
? conf_cur_block_name
: "<unknown>", privs
, 0);
507 rb_free(yy_privset_extends
);
508 yy_privset_extends
= NULL
;
511 privilegeset_set_new(conf_cur_block_name
!= NULL
? conf_cur_block_name
: "<unknown>", privs
, 0);
518 conf_begin_oper(struct TopConf
*tc
)
521 rb_dlink_node
*next_ptr
;
525 free_oper_conf(yy_oper
);
529 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, yy_oper_list
.head
)
531 free_oper_conf(ptr
->data
);
532 rb_dlinkDestroy(ptr
, &yy_oper_list
);
535 yy_oper
= make_oper_conf();
536 yy_oper
->flags
|= OPER_ENCRYPTED
;
542 conf_end_oper(struct TopConf
*tc
)
544 struct oper_conf
*yy_tmpoper
;
546 rb_dlink_node
*next_ptr
;
548 if(conf_cur_block_name
!= NULL
)
550 if(strlen(conf_cur_block_name
) > OPERNICKLEN
)
551 conf_cur_block_name
[OPERNICKLEN
] = '\0';
553 yy_oper
->name
= rb_strdup(conf_cur_block_name
);
556 if(EmptyString(yy_oper
->name
))
558 conf_report_error("Ignoring operator block -- missing name.");
562 #ifdef HAVE_LIBCRYPTO
563 if(EmptyString(yy_oper
->passwd
) && EmptyString(yy_oper
->rsa_pubkey_file
))
565 if(EmptyString(yy_oper
->passwd
))
568 conf_report_error("Ignoring operator block for %s -- missing password",
574 if (!yy_oper
->privset
)
575 yy_oper
->privset
= privilegeset_get("default");
577 /* now, yy_oper_list contains a stack of oper_conf's with just user
578 * and host in, yy_oper contains the rest of the information which
579 * we need to copy into each element in yy_oper_list
581 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, yy_oper_list
.head
)
583 yy_tmpoper
= ptr
->data
;
585 yy_tmpoper
->name
= rb_strdup(yy_oper
->name
);
587 /* could be an rsa key instead.. */
588 if(!EmptyString(yy_oper
->passwd
))
589 yy_tmpoper
->passwd
= rb_strdup(yy_oper
->passwd
);
591 yy_tmpoper
->flags
= yy_oper
->flags
;
592 yy_tmpoper
->umodes
= yy_oper
->umodes
;
593 yy_tmpoper
->snomask
= yy_oper
->snomask
;
594 yy_tmpoper
->privset
= yy_oper
->privset
;
596 #ifdef HAVE_LIBCRYPTO
597 if(yy_oper
->rsa_pubkey_file
)
601 if((file
= BIO_new_file(yy_oper
->rsa_pubkey_file
, "r")) == NULL
)
603 conf_report_error("Ignoring operator block for %s -- "
604 "rsa_public_key_file cant be opened",
609 yy_tmpoper
->rsa_pubkey
=
610 (RSA
*) PEM_read_bio_RSA_PUBKEY(file
, NULL
, 0, NULL
);
612 (void)BIO_set_close(file
, BIO_CLOSE
);
615 if(yy_tmpoper
->rsa_pubkey
== NULL
)
617 conf_report_error("Ignoring operator block for %s -- "
618 "rsa_public_key_file key invalid; check syntax",
624 if(!EmptyString(yy_oper
->certfp
))
625 yy_tmpoper
->certfp
= rb_strdup(yy_oper
->certfp
);
628 /* all is ok, put it on oper_conf_list */
629 rb_dlinkMoveNode(ptr
, &yy_oper_list
, &oper_conf_list
);
632 free_oper_conf(yy_oper
);
639 conf_set_oper_flags(void *data
)
641 conf_parm_t
*args
= data
;
643 set_modes_from_table(&yy_oper
->flags
, "flag", oper_table
, args
);
647 conf_set_oper_fingerprint(void *data
)
650 rb_free(yy_oper
->certfp
);
651 yy_oper
->certfp
= rb_strdup((char *) data
);
655 conf_set_oper_privset(void *data
)
657 yy_oper
->privset
= privilegeset_get((char *) data
);
661 conf_set_oper_user(void *data
)
663 struct oper_conf
*yy_tmpoper
;
665 char *host
= (char *) data
;
667 yy_tmpoper
= make_oper_conf();
669 if((p
= strchr(host
, '@')))
673 yy_tmpoper
->username
= rb_strdup(host
);
674 yy_tmpoper
->host
= rb_strdup(p
);
679 yy_tmpoper
->username
= rb_strdup("*");
680 yy_tmpoper
->host
= rb_strdup(host
);
683 if(EmptyString(yy_tmpoper
->username
) || EmptyString(yy_tmpoper
->host
))
685 conf_report_error("Ignoring user -- missing username/host");
686 free_oper_conf(yy_tmpoper
);
690 rb_dlinkAddAlloc(yy_tmpoper
, &yy_oper_list
);
694 conf_set_oper_password(void *data
)
698 memset(yy_oper
->passwd
, 0, strlen(yy_oper
->passwd
));
699 rb_free(yy_oper
->passwd
);
702 yy_oper
->passwd
= rb_strdup((char *) data
);
706 conf_set_oper_rsa_public_key_file(void *data
)
708 #ifdef HAVE_LIBCRYPTO
709 rb_free(yy_oper
->rsa_pubkey_file
);
710 yy_oper
->rsa_pubkey_file
= rb_strdup((char *) data
);
712 conf_report_error("Warning -- ignoring rsa_public_key_file (OpenSSL support not available");
717 conf_set_oper_umodes(void *data
)
719 set_modes_from_table(&yy_oper
->umodes
, "umode", umode_table
, data
);
723 conf_set_oper_snomask(void *data
)
725 yy_oper
->snomask
= parse_snobuf_to_mask(0, (const char *) data
);
729 conf_begin_class(struct TopConf
*tc
)
732 free_class(yy_class
);
734 yy_class
= make_class();
739 conf_end_class(struct TopConf
*tc
)
741 if(conf_cur_block_name
!= NULL
)
742 yy_class
->class_name
= rb_strdup(conf_cur_block_name
);
744 if(EmptyString(yy_class
->class_name
))
746 conf_report_error("Ignoring connect block -- missing name.");
756 conf_set_class_ping_time(void *data
)
758 yy_class
->ping_freq
= *(unsigned int *) data
;
762 conf_set_class_cidr_ipv4_bitlen(void *data
)
764 unsigned int maxsize
= 32;
765 if(*(unsigned int *) data
> maxsize
)
767 ("class::cidr_ipv4_bitlen argument exceeds maxsize (%d > %d) - ignoring.",
768 *(unsigned int *) data
, maxsize
);
770 yy_class
->cidr_ipv4_bitlen
= *(unsigned int *) data
;
776 conf_set_class_cidr_ipv6_bitlen(void *data
)
778 unsigned int maxsize
= 128;
779 if(*(unsigned int *) data
> maxsize
)
781 ("class::cidr_ipv6_bitlen argument exceeds maxsize (%d > %d) - ignoring.",
782 *(unsigned int *) data
, maxsize
);
784 yy_class
->cidr_ipv6_bitlen
= *(unsigned int *) data
;
790 conf_set_class_number_per_cidr(void *data
)
792 yy_class
->cidr_amount
= *(unsigned int *) data
;
796 conf_set_class_number_per_ip(void *data
)
798 yy_class
->max_local
= *(unsigned int *) data
;
803 conf_set_class_number_per_ip_global(void *data
)
805 yy_class
->max_global
= *(unsigned int *) data
;
809 conf_set_class_number_per_ident(void *data
)
811 yy_class
->max_ident
= *(unsigned int *) data
;
815 conf_set_class_connectfreq(void *data
)
817 yy_class
->con_freq
= *(unsigned int *) data
;
821 conf_set_class_max_number(void *data
)
823 yy_class
->max_total
= *(unsigned int *) data
;
827 conf_set_class_sendq(void *data
)
829 yy_class
->max_sendq
= *(unsigned int *) data
;
832 static char *listener_address
;
835 conf_begin_listen(struct TopConf
*tc
)
837 rb_free(listener_address
);
838 listener_address
= NULL
;
843 conf_end_listen(struct TopConf
*tc
)
845 rb_free(listener_address
);
846 listener_address
= NULL
;
851 conf_set_listen_defer_accept(void *data
)
853 yy_defer_accept
= *(unsigned int *) data
;
857 conf_set_listen_wsock(void *data
)
859 yy_wsock
= *(unsigned int *) data
;
863 conf_set_listen_port_both(void *data
, int ssl
)
865 conf_parm_t
*args
= data
;
866 for (; args
; args
= args
->next
)
868 if(CF_TYPE(args
->type
) != CF_INT
)
871 ("listener::port argument is not an integer " "-- ignoring.");
874 if(listener_address
== NULL
)
878 conf_report_warning("listener 'ANY/%d': support for plaintext listeners may be removed in a future release per RFC 7194. "
879 "It is suggested that users be migrated to SSL/TLS connections.", args
->v
.number
);
881 add_listener(args
->v
.number
, listener_address
, AF_INET
, ssl
, ssl
|| yy_defer_accept
, yy_wsock
);
883 add_listener(args
->v
.number
, listener_address
, AF_INET6
, ssl
, ssl
|| yy_defer_accept
, yy_wsock
);
890 if(strchr(listener_address
, ':') != NULL
)
898 conf_report_warning("listener '%s/%d': support for plaintext listeners may be removed in a future release per RFC 7194. "
899 "It is suggested that users be migrated to SSL/TLS connections.", listener_address
, args
->v
.number
);
902 add_listener(args
->v
.number
, listener_address
, family
, ssl
, ssl
|| yy_defer_accept
, yy_wsock
);
908 conf_set_listen_port(void *data
)
910 conf_set_listen_port_both(data
, 0);
914 conf_set_listen_sslport(void *data
)
916 conf_set_listen_port_both(data
, 1);
920 conf_set_listen_address(void *data
)
922 rb_free(listener_address
);
923 listener_address
= rb_strdup(data
);
927 conf_begin_auth(struct TopConf
*tc
)
930 rb_dlink_node
*next_ptr
;
935 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, yy_aconf_list
.head
)
937 free_conf(ptr
->data
);
938 rb_dlinkDestroy(ptr
, &yy_aconf_list
);
941 yy_aconf
= make_conf();
942 yy_aconf
->status
= CONF_CLIENT
;
948 conf_end_auth(struct TopConf
*tc
)
950 struct ConfItem
*yy_tmp
, *found_conf
;
952 rb_dlink_node
*next_ptr
;
954 if(EmptyString(yy_aconf
->info
.name
))
955 yy_aconf
->info
.name
= rb_strdup("NOMATCH");
957 /* didnt even get one ->host? */
958 if(EmptyString(yy_aconf
->host
))
960 conf_report_error("Ignoring auth block -- missing user@host");
964 /* so the stacking works in order.. */
965 collapse(yy_aconf
->user
);
966 collapse(yy_aconf
->host
);
967 conf_add_class_to_conf(yy_aconf
);
968 if ((found_conf
= find_exact_conf_by_address("*", CONF_CLIENT
, "*")) && found_conf
->spasswd
== NULL
)
969 conf_report_error("Ignoring redundant auth block (after *@*)");
970 else if ((found_conf
= find_exact_conf_by_address(yy_aconf
->host
, CONF_CLIENT
, yy_aconf
->user
)) &&
971 (!found_conf
->spasswd
|| (yy_aconf
->spasswd
&&
972 0 == irccmp(found_conf
->spasswd
, yy_aconf
->spasswd
))))
973 conf_report_error("Ignoring duplicate auth block for %s@%s",
974 yy_aconf
->user
, yy_aconf
->host
);
976 add_conf_by_address(yy_aconf
->host
, CONF_CLIENT
, yy_aconf
->user
, yy_aconf
->spasswd
, yy_aconf
);
978 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, yy_aconf_list
.head
)
983 yy_tmp
->passwd
= rb_strdup(yy_aconf
->passwd
);
985 if(yy_aconf
->spasswd
)
986 yy_tmp
->spasswd
= rb_strdup(yy_aconf
->spasswd
);
988 /* this will always exist.. */
989 yy_tmp
->info
.name
= rb_strdup(yy_aconf
->info
.name
);
991 if(yy_aconf
->className
)
992 yy_tmp
->className
= rb_strdup(yy_aconf
->className
);
994 yy_tmp
->flags
= yy_aconf
->flags
;
995 yy_tmp
->port
= yy_aconf
->port
;
997 collapse(yy_tmp
->user
);
998 collapse(yy_tmp
->host
);
1000 conf_add_class_to_conf(yy_tmp
);
1002 if ((found_conf
= find_exact_conf_by_address("*", CONF_CLIENT
, "*")) && found_conf
->spasswd
== NULL
)
1003 conf_report_error("Ignoring redundant auth block (after *@*)");
1004 else if ((found_conf
= find_exact_conf_by_address(yy_tmp
->host
, CONF_CLIENT
, yy_tmp
->user
)) &&
1005 (!found_conf
->spasswd
|| (yy_tmp
->spasswd
&&
1006 0 == irccmp(found_conf
->spasswd
, yy_tmp
->spasswd
))))
1007 conf_report_error("Ignoring duplicate auth block for %s@%s",
1008 yy_tmp
->user
, yy_tmp
->host
);
1010 add_conf_by_address(yy_tmp
->host
, CONF_CLIENT
, yy_tmp
->user
, yy_tmp
->spasswd
, yy_tmp
);
1011 rb_dlinkDestroy(ptr
, &yy_aconf_list
);
1019 conf_set_auth_user(void *data
)
1021 struct ConfItem
*yy_tmp
;
1024 /* The first user= line doesn't allocate a new conf */
1025 if(!EmptyString(yy_aconf
->host
))
1027 yy_tmp
= make_conf();
1028 yy_tmp
->status
= CONF_CLIENT
;
1033 if((p
= strchr(data
, '@')))
1037 yy_tmp
->user
= rb_strdup(data
);
1038 yy_tmp
->host
= rb_strdup(p
);
1042 yy_tmp
->user
= rb_strdup("*");
1043 yy_tmp
->host
= rb_strdup(data
);
1046 if(yy_aconf
!= yy_tmp
)
1047 rb_dlinkAddAlloc(yy_tmp
, &yy_aconf_list
);
1051 conf_set_auth_auth_user(void *data
)
1053 if(yy_aconf
->spasswd
)
1054 memset(yy_aconf
->spasswd
, 0, strlen(yy_aconf
->spasswd
));
1055 rb_free(yy_aconf
->spasswd
);
1056 yy_aconf
->spasswd
= rb_strdup(data
);
1060 conf_set_auth_passwd(void *data
)
1062 if(yy_aconf
->passwd
)
1063 memset(yy_aconf
->passwd
, 0, strlen(yy_aconf
->passwd
));
1064 rb_free(yy_aconf
->passwd
);
1065 yy_aconf
->passwd
= rb_strdup(data
);
1069 conf_set_auth_spoof(void *data
)
1077 /* user@host spoof */
1078 if((p
= strchr(host
, '@')) != NULL
)
1084 if(EmptyString(user
))
1086 conf_report_error("Warning -- spoof ident empty.");
1090 if(strlen(user
) > USERLEN
)
1092 conf_report_error("Warning -- spoof ident length invalid.");
1096 if(!valid_username(user
))
1098 conf_report_error("Warning -- invalid spoof (ident).");
1102 /* this must be restored! */
1106 if(EmptyString(host
))
1108 conf_report_error("Warning -- spoof host empty.");
1112 if(strlen(host
) > HOSTLEN
)
1114 conf_report_error("Warning -- spoof host length invalid.");
1118 if(!valid_hostname(host
))
1120 conf_report_error("Warning -- invalid spoof (host).");
1124 rb_free(yy_aconf
->info
.name
);
1125 yy_aconf
->info
.name
= rb_strdup(data
);
1126 yy_aconf
->flags
|= CONF_FLAGS_SPOOF_IP
;
1130 conf_set_auth_flags(void *data
)
1132 conf_parm_t
*args
= data
;
1134 set_modes_from_table((int *) &yy_aconf
->flags
, "flag", auth_table
, args
);
1138 conf_set_auth_redir_serv(void *data
)
1140 yy_aconf
->flags
|= CONF_FLAGS_REDIR
;
1141 rb_free(yy_aconf
->info
.name
);
1142 yy_aconf
->info
.name
= rb_strdup(data
);
1146 conf_set_auth_redir_port(void *data
)
1148 int port
= *(unsigned int *) data
;
1150 yy_aconf
->flags
|= CONF_FLAGS_REDIR
;
1151 yy_aconf
->port
= port
;
1155 conf_set_auth_class(void *data
)
1157 rb_free(yy_aconf
->className
);
1158 yy_aconf
->className
= rb_strdup(data
);
1161 /* ok, shared_oper handles the stacking, shared_flags handles adding
1162 * things.. so all we need to do when we start and end a shared block, is
1163 * clean up anything thats been left over.
1166 conf_cleanup_shared(struct TopConf
*tc
)
1168 rb_dlink_node
*ptr
, *next_ptr
;
1170 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, yy_shared_list
.head
)
1172 free_remote_conf(ptr
->data
);
1173 rb_dlinkDestroy(ptr
, &yy_shared_list
);
1176 if(yy_shared
!= NULL
)
1178 free_remote_conf(yy_shared
);
1186 conf_set_shared_oper(void *data
)
1188 conf_parm_t
*args
= data
;
1189 const char *username
;
1192 if(yy_shared
!= NULL
)
1193 free_remote_conf(yy_shared
);
1195 yy_shared
= make_remote_conf();
1197 if(args
->next
!= NULL
)
1199 if(CF_TYPE(args
->type
) != CF_QSTRING
)
1201 conf_report_error("Ignoring shared::oper -- server is not a qstring");
1205 yy_shared
->server
= rb_strdup(args
->v
.string
);
1209 yy_shared
->server
= rb_strdup("*");
1211 if(CF_TYPE(args
->type
) != CF_QSTRING
)
1213 conf_report_error("Ignoring shared::oper -- oper is not a qstring");
1217 if((p
= strchr(args
->v
.string
, '@')) == NULL
)
1219 conf_report_error("Ignoring shard::oper -- oper is not a user@host");
1223 username
= args
->v
.string
;
1227 yy_shared
->host
= rb_strdup("*");
1229 yy_shared
->host
= rb_strdup(p
);
1231 if(EmptyString(username
))
1232 yy_shared
->username
= rb_strdup("*");
1234 yy_shared
->username
= rb_strdup(username
);
1236 rb_dlinkAddAlloc(yy_shared
, &yy_shared_list
);
1241 conf_set_shared_flags(void *data
)
1243 conf_parm_t
*args
= data
;
1245 rb_dlink_node
*ptr
, *next_ptr
;
1247 if(yy_shared
!= NULL
)
1248 free_remote_conf(yy_shared
);
1250 set_modes_from_table(&flags
, "flag", shared_table
, args
);
1252 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, yy_shared_list
.head
)
1254 yy_shared
= ptr
->data
;
1256 yy_shared
->flags
= flags
;
1257 rb_dlinkDestroy(ptr
, &yy_shared_list
);
1258 rb_dlinkAddTail(yy_shared
, &yy_shared
->node
, &shared_conf_list
);
1265 conf_begin_connect(struct TopConf
*tc
)
1268 free_server_conf(yy_server
);
1270 yy_server
= make_server_conf();
1271 yy_server
->port
= PORTNUM
;
1272 yy_server
->flags
|= SERVER_TB
;
1274 if(conf_cur_block_name
!= NULL
)
1275 yy_server
->name
= rb_strdup(conf_cur_block_name
);
1281 conf_end_connect(struct TopConf
*tc
)
1283 if(EmptyString(yy_server
->name
))
1285 conf_report_error("Ignoring connect block -- missing name.");
1289 if(ServerInfo
.name
!= NULL
&& !irccmp(ServerInfo
.name
, yy_server
->name
))
1291 conf_report_error("Ignoring connect block for %s -- name is equal to my own name.",
1296 if((EmptyString(yy_server
->passwd
) || EmptyString(yy_server
->spasswd
)) && EmptyString(yy_server
->certfp
))
1298 conf_report_error("Ignoring connect block for %s -- no fingerprint or password credentials provided.",
1303 if(EmptyString(yy_server
->host
))
1305 conf_report_error("Ignoring connect block for %s -- missing host.",
1311 if(ServerConfCompressed(yy_server
))
1313 conf_report_error("Ignoring connect::flags::compressed -- zlib not available.");
1314 yy_server
->flags
&= ~SERVER_COMPRESSED
;
1318 add_server_conf(yy_server
);
1319 rb_dlinkAdd(yy_server
, &yy_server
->node
, &server_conf_list
);
1326 conf_set_connect_host(void *data
)
1328 rb_free(yy_server
->host
);
1329 yy_server
->host
= rb_strdup(data
);
1330 if (strchr(yy_server
->host
, ':'))
1331 yy_server
->aftype
= AF_INET6
;
1335 conf_set_connect_vhost(void *data
)
1337 if(rb_inet_pton_sock(data
, (struct sockaddr
*)&yy_server
->my_ipnum
) <= 0)
1339 conf_report_error("Invalid IP address for server connect vhost (%s)",
1344 yy_server
->flags
|= SERVER_VHOSTED
;
1348 conf_set_connect_send_password(void *data
)
1350 if(yy_server
->spasswd
)
1352 memset(yy_server
->spasswd
, 0, strlen(yy_server
->spasswd
));
1353 rb_free(yy_server
->spasswd
);
1356 yy_server
->spasswd
= rb_strdup(data
);
1360 conf_set_connect_accept_password(void *data
)
1362 if(yy_server
->passwd
)
1364 memset(yy_server
->passwd
, 0, strlen(yy_server
->passwd
));
1365 rb_free(yy_server
->passwd
);
1367 yy_server
->passwd
= rb_strdup(data
);
1371 conf_set_connect_fingerprint(void *data
)
1373 if (yy_server
->certfp
)
1374 rb_free(yy_server
->certfp
);
1375 yy_server
->certfp
= rb_strdup((char *) data
);
1377 /* force SSL to be enabled if fingerprint is enabled. */
1378 yy_server
->flags
|= SERVER_SSL
;
1382 conf_set_connect_port(void *data
)
1384 int port
= *(unsigned int *) data
;
1389 yy_server
->port
= port
;
1393 conf_set_connect_aftype(void *data
)
1397 if(strcasecmp(aft
, "ipv4") == 0)
1398 yy_server
->aftype
= AF_INET
;
1400 else if(strcasecmp(aft
, "ipv6") == 0)
1401 yy_server
->aftype
= AF_INET6
;
1404 conf_report_error("connect::aftype '%s' is unknown.", aft
);
1408 conf_set_connect_flags(void *data
)
1410 conf_parm_t
*args
= data
;
1412 /* note, we allow them to set compressed, then remove it later if
1413 * they do and LIBZ isnt available
1415 set_modes_from_table(&yy_server
->flags
, "flag", connect_table
, args
);
1419 conf_set_connect_hub_mask(void *data
)
1421 struct remote_conf
*yy_hub
;
1423 if(EmptyString(yy_server
->name
))
1426 yy_hub
= make_remote_conf();
1427 yy_hub
->flags
= CONF_HUB
;
1429 yy_hub
->host
= rb_strdup(data
);
1430 yy_hub
->server
= rb_strdup(yy_server
->name
);
1431 rb_dlinkAdd(yy_hub
, &yy_hub
->node
, &hubleaf_conf_list
);
1435 conf_set_connect_leaf_mask(void *data
)
1437 struct remote_conf
*yy_leaf
;
1439 if(EmptyString(yy_server
->name
))
1442 yy_leaf
= make_remote_conf();
1443 yy_leaf
->flags
= CONF_LEAF
;
1445 yy_leaf
->host
= rb_strdup(data
);
1446 yy_leaf
->server
= rb_strdup(yy_server
->name
);
1447 rb_dlinkAdd(yy_leaf
, &yy_leaf
->node
, &hubleaf_conf_list
);
1451 conf_set_connect_class(void *data
)
1453 rb_free(yy_server
->class_name
);
1454 yy_server
->class_name
= rb_strdup(data
);
1458 conf_set_exempt_ip(void *data
)
1460 struct ConfItem
*yy_tmp
;
1462 if(parse_netmask(data
, NULL
, NULL
) == HM_HOST
)
1464 conf_report_error("Ignoring exempt -- invalid exempt::ip.");
1468 yy_tmp
= make_conf();
1469 yy_tmp
->passwd
= rb_strdup("*");
1470 yy_tmp
->host
= rb_strdup(data
);
1471 yy_tmp
->status
= CONF_EXEMPTDLINE
;
1472 add_conf_by_address(yy_tmp
->host
, CONF_EXEMPTDLINE
, NULL
, NULL
, yy_tmp
);
1476 conf_cleanup_cluster(struct TopConf
*tc
)
1478 rb_dlink_node
*ptr
, *next_ptr
;
1480 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, yy_cluster_list
.head
)
1482 free_remote_conf(ptr
->data
);
1483 rb_dlinkDestroy(ptr
, &yy_cluster_list
);
1486 if(yy_shared
!= NULL
)
1488 free_remote_conf(yy_shared
);
1496 conf_set_cluster_name(void *data
)
1498 if(yy_shared
!= NULL
)
1499 free_remote_conf(yy_shared
);
1501 yy_shared
= make_remote_conf();
1502 yy_shared
->server
= rb_strdup(data
);
1503 rb_dlinkAddAlloc(yy_shared
, &yy_cluster_list
);
1509 conf_set_cluster_flags(void *data
)
1511 conf_parm_t
*args
= data
;
1513 rb_dlink_node
*ptr
, *next_ptr
;
1515 if(yy_shared
!= NULL
)
1516 free_remote_conf(yy_shared
);
1518 set_modes_from_table(&flags
, "flag", cluster_table
, args
);
1520 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, yy_cluster_list
.head
)
1522 yy_shared
= ptr
->data
;
1523 yy_shared
->flags
= flags
;
1524 rb_dlinkAddTail(yy_shared
, &yy_shared
->node
, &cluster_conf_list
);
1525 rb_dlinkDestroy(ptr
, &yy_cluster_list
);
1532 conf_set_general_havent_read_conf(void *data
)
1534 if(*(unsigned int *) data
)
1536 conf_report_error("You haven't read your config file properly.");
1538 ("There is a line in the example conf that will kill your server if not removed.");
1540 ("Consider actually reading/editing the conf file, and removing this line.");
1547 conf_set_general_hide_error_messages(void *data
)
1551 if(strcasecmp(val
, "yes") == 0)
1552 ConfigFileEntry
.hide_error_messages
= 2;
1553 else if(strcasecmp(val
, "opers") == 0)
1554 ConfigFileEntry
.hide_error_messages
= 1;
1555 else if(strcasecmp(val
, "no") == 0)
1556 ConfigFileEntry
.hide_error_messages
= 0;
1558 conf_report_error("Invalid setting '%s' for general::hide_error_messages.", val
);
1562 conf_set_general_kline_delay(void *data
)
1564 ConfigFileEntry
.kline_delay
= *(unsigned int *) data
;
1566 /* THIS MUST BE HERE to stop us being unable to check klines */
1567 kline_queued
= false;
1571 conf_set_general_stats_k_oper_only(void *data
)
1575 if(strcasecmp(val
, "yes") == 0)
1576 ConfigFileEntry
.stats_k_oper_only
= 2;
1577 else if(strcasecmp(val
, "masked") == 0)
1578 ConfigFileEntry
.stats_k_oper_only
= 1;
1579 else if(strcasecmp(val
, "no") == 0)
1580 ConfigFileEntry
.stats_k_oper_only
= 0;
1582 conf_report_error("Invalid setting '%s' for general::stats_k_oper_only.", val
);
1586 conf_set_general_stats_i_oper_only(void *data
)
1590 if(strcasecmp(val
, "yes") == 0)
1591 ConfigFileEntry
.stats_i_oper_only
= 2;
1592 else if(strcasecmp(val
, "masked") == 0)
1593 ConfigFileEntry
.stats_i_oper_only
= 1;
1594 else if(strcasecmp(val
, "no") == 0)
1595 ConfigFileEntry
.stats_i_oper_only
= 0;
1597 conf_report_error("Invalid setting '%s' for general::stats_i_oper_only.", val
);
1601 conf_set_general_compression_level(void *data
)
1604 ConfigFileEntry
.compression_level
= *(unsigned int *) data
;
1606 if((ConfigFileEntry
.compression_level
< 1) || (ConfigFileEntry
.compression_level
> 9))
1609 ("Invalid general::compression_level %d -- using default.",
1610 ConfigFileEntry
.compression_level
);
1611 ConfigFileEntry
.compression_level
= 0;
1614 conf_report_error("Ignoring general::compression_level -- zlib not available.");
1619 conf_set_general_default_umodes(void *data
)
1622 int what
= MODE_ADD
, flag
;
1624 ConfigFileEntry
.default_umodes
= 0;
1625 for (pm
= (char *) data
; *pm
; pm
++)
1636 /* don't allow +o */
1644 if ((flag
= user_modes
[(unsigned char) *pm
]))
1646 /* Proper value has probably not yet been set
1647 * so don't check oper_only_umodes -- jilles */
1648 if (what
== MODE_ADD
)
1649 ConfigFileEntry
.default_umodes
|= flag
;
1651 ConfigFileEntry
.default_umodes
&= ~flag
;
1659 conf_set_general_oper_umodes(void *data
)
1661 set_modes_from_table(&ConfigFileEntry
.oper_umodes
, "umode", umode_table
, data
);
1665 conf_set_general_certfp_method(void *data
)
1667 char *method
= data
;
1669 if (!strcasecmp(method
, "sha1"))
1670 ConfigFileEntry
.certfp_method
= RB_SSL_CERTFP_METH_SHA1
;
1671 else if (!strcasecmp(method
, "sha256"))
1672 ConfigFileEntry
.certfp_method
= RB_SSL_CERTFP_METH_SHA256
;
1673 else if (!strcasecmp(method
, "sha512"))
1674 ConfigFileEntry
.certfp_method
= RB_SSL_CERTFP_METH_SHA512
;
1677 ConfigFileEntry
.certfp_method
= RB_SSL_CERTFP_METH_SHA1
;
1678 conf_report_error("Ignoring general::certfp_method -- bogus certfp method %s", method
);
1683 conf_set_general_oper_only_umodes(void *data
)
1685 set_modes_from_table(&ConfigFileEntry
.oper_only_umodes
, "umode", umode_table
, data
);
1689 conf_set_general_oper_snomask(void *data
)
1692 int what
= MODE_ADD
, flag
;
1694 ConfigFileEntry
.oper_snomask
= 0;
1695 for (pm
= (char *) data
; *pm
; pm
++)
1707 if ((flag
= snomask_modes
[(unsigned char) *pm
]))
1709 if (what
== MODE_ADD
)
1710 ConfigFileEntry
.oper_snomask
|= flag
;
1712 ConfigFileEntry
.oper_snomask
&= ~flag
;
1720 conf_set_serverhide_links_delay(void *data
)
1722 int val
= *(unsigned int *) data
;
1724 ConfigServerHide
.links_delay
= val
;
1728 conf_set_service_name(void *data
)
1734 for(s
= data
; *s
!= '\0'; s
++)
1738 conf_report_error("Ignoring service::name "
1739 "-- bogus servername.");
1748 conf_report_error("Ignoring service::name -- must contain '.'");
1752 tmp
= rb_strdup(data
);
1753 rb_dlinkAddAlloc(tmp
, &service_list
);
1757 conf_begin_alias(struct TopConf
*tc
)
1759 yy_alias
= rb_malloc(sizeof(struct alias_entry
));
1761 if (conf_cur_block_name
!= NULL
)
1762 yy_alias
->name
= rb_strdup(conf_cur_block_name
);
1764 yy_alias
->flags
= 0;
1771 conf_end_alias(struct TopConf
*tc
)
1773 if (yy_alias
== NULL
)
1776 if (yy_alias
->name
== NULL
)
1778 conf_report_error("Ignoring alias -- must have a name.");
1785 if (yy_alias
->target
== NULL
)
1787 conf_report_error("Ignoring alias -- must have a target.");
1794 rb_dictionary_add(alias_dict
, yy_alias
->name
, yy_alias
);
1800 conf_set_alias_name(void *data
)
1802 if (data
== NULL
|| yy_alias
== NULL
) /* this shouldn't ever happen */
1805 yy_alias
->name
= rb_strdup(data
);
1809 conf_set_alias_target(void *data
)
1811 if (data
== NULL
|| yy_alias
== NULL
) /* this shouldn't ever happen */
1814 yy_alias
->target
= rb_strdup(data
);
1818 conf_set_channel_autochanmodes(void *data
)
1821 int what
= MODE_ADD
;
1823 ConfigChannel
.autochanmodes
= 0;
1824 for (pm
= (char *) data
; *pm
; pm
++)
1836 if (chmode_table
[(unsigned char) *pm
].set_func
== chm_simple
)
1838 if (what
== MODE_ADD
)
1839 ConfigChannel
.autochanmodes
|= chmode_table
[(unsigned char) *pm
].mode_type
;
1841 ConfigChannel
.autochanmodes
&= ~chmode_table
[(unsigned char) *pm
].mode_type
;
1845 conf_report_error("channel::autochanmodes -- Invalid channel mode %c", *pm
);
1854 static void conf_set_blacklist_reason(void *data
);
1856 #define IPTYPE_IPV4 1
1857 #define IPTYPE_IPV6 2
1860 conf_set_blacklist_host(void *data
)
1862 if (yy_blacklist_host
)
1864 conf_report_error("blacklist::host %s overlaps existing host %s",
1865 (char *)data
, yy_blacklist_host
);
1868 conf_set_blacklist_reason(NULL
);
1872 yy_blacklist_iptype
|= IPTYPE_IPV4
;
1873 yy_blacklist_host
= rb_strdup(data
);
1877 conf_set_blacklist_type(void *data
)
1879 conf_parm_t
*args
= data
;
1881 /* Don't assume we have either if we got here */
1882 yy_blacklist_iptype
= 0;
1884 for (; args
; args
= args
->next
)
1886 if (!strcasecmp(args
->v
.string
, "ipv4"))
1887 yy_blacklist_iptype
|= IPTYPE_IPV4
;
1888 else if (!strcasecmp(args
->v
.string
, "ipv6"))
1889 yy_blacklist_iptype
|= IPTYPE_IPV6
;
1891 conf_report_error("blacklist::type has unknown address family %s",
1895 /* If we have neither, just default to IPv4 */
1896 if (!yy_blacklist_iptype
)
1898 conf_report_warning("blacklist::type has neither IPv4 nor IPv6 (defaulting to IPv4)");
1899 yy_blacklist_iptype
= IPTYPE_IPV4
;
1904 conf_set_blacklist_matches(void *data
)
1906 conf_parm_t
*args
= data
;
1907 enum filter_t
{ FILTER_NONE
, FILTER_ALL
, FILTER_LAST
};
1909 for (; args
; args
= args
->next
)
1911 char *str
= args
->v
.string
;
1913 enum filter_t type
= FILTER_LAST
;
1915 if (CF_TYPE(args
->type
) != CF_QSTRING
)
1917 conf_report_error("blacklist::matches -- must be quoted string");
1923 conf_report_error("blacklist::matches -- invalid entry");
1927 if (strlen(str
) > HOSTIPLEN
)
1929 conf_report_error("blacklist::matches has an entry too long: %s",
1934 for (p
= str
; *p
!= '\0'; p
++)
1936 /* Check for validity */
1939 else if (!isdigit((unsigned char)*p
))
1941 conf_report_error("blacklist::matches has invalid IP match entry %s",
1948 if (type
== FILTER_ALL
)
1950 /* Basic IP sanity check */
1951 struct rb_sockaddr_storage tmp
;
1952 if (rb_inet_pton(AF_INET
, str
, &tmp
) <= 0)
1954 conf_report_error("blacklist::matches has invalid IP match entry %s",
1959 else if (type
== FILTER_LAST
)
1961 /* Verify it's the correct length */
1962 if (strlen(str
) > 3)
1964 conf_report_error("blacklist::matches has invalid octet match entry %s",
1971 continue; /* Invalid entry */
1974 rb_dlinkAddAlloc(rb_strdup(str
), &yy_blacklist_filters
);
1979 conf_set_blacklist_reason(void *data
)
1981 rb_dlink_node
*ptr
, *nptr
;
1983 if (yy_blacklist_host
&& data
)
1985 yy_blacklist_reason
= rb_strdup(data
);
1986 if (yy_blacklist_iptype
& IPTYPE_IPV6
)
1988 /* Make sure things fit (magic number 64 = alnum count + dots)
1989 * 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
1991 if ((64 + strlen(yy_blacklist_host
)) > IRCD_RES_HOSTLEN
)
1993 conf_report_error("blacklist::host %s results in IPv6 queries that are too long",
1998 /* Avoid doing redundant check, IPv6 is bigger than IPv4 --Elizabeth */
1999 if ((yy_blacklist_iptype
& IPTYPE_IPV4
) && !(yy_blacklist_iptype
& IPTYPE_IPV6
))
2001 /* Make sure things fit for worst case (magic number 16 = number of nums + dots)
2002 * Example: 127.127.127.127.in-addr.arpa
2004 if ((16 + strlen(yy_blacklist_host
)) > IRCD_RES_HOSTLEN
)
2006 conf_report_error("blacklist::host %s results in IPv4 queries that are too long",
2012 add_blacklist(yy_blacklist_host
, yy_blacklist_reason
, yy_blacklist_iptype
, &yy_blacklist_filters
);
2016 RB_DLINK_FOREACH_SAFE(ptr
, nptr
, yy_blacklist_filters
.head
)
2019 rb_dlinkDestroy(ptr
, &yy_blacklist_filters
);
2022 yy_blacklist_filters
= (rb_dlink_list
){ NULL
, NULL
, 0 };
2024 rb_free(yy_blacklist_host
);
2025 rb_free(yy_blacklist_reason
);
2026 yy_blacklist_host
= NULL
;
2027 yy_blacklist_reason
= NULL
;
2028 yy_blacklist_iptype
= 0;
2041 conf_begin_opm(struct TopConf
*tc
)
2043 yy_opm_address_ipv4
= yy_opm_address_ipv6
= NULL
;
2044 yy_opm_port_ipv4
= yy_opm_port_ipv6
= 0;
2049 conf_end_opm(struct TopConf
*tc
)
2051 rb_dlink_node
*ptr
, *nptr
;
2054 if(!rb_dlink_list_length(&yy_opm_scanner_list
))
2056 conf_report_error("No opm scanners configured, disabling opm.");
2061 if(yy_opm_port_ipv4
> 0)
2063 if(yy_opm_address_ipv4
!= NULL
)
2064 create_opm_listener(yy_opm_address_ipv4
, yy_opm_port_ipv4
);
2068 if(!rb_inet_ntop_sock((struct sockaddr
*)&ServerInfo
.ip
, ip
, sizeof(ip
)))
2069 conf_report_error("No opm::listen_ipv4 nor serverinfo::vhost directive; cannot listen on IPv4");
2071 create_opm_listener(ip
, yy_opm_port_ipv4
);
2075 if(yy_opm_port_ipv6
> 0)
2077 if(yy_opm_address_ipv6
!= NULL
)
2078 create_opm_listener(yy_opm_address_ipv6
, yy_opm_port_ipv6
);
2082 if(!rb_inet_ntop_sock((struct sockaddr
*)&ServerInfo
.ip6
, ip
, sizeof(ip
)))
2083 conf_report_error("No opm::listen_ipv6 nor serverinfo::vhost directive; cannot listen on IPv6");
2085 create_opm_listener(ip
, yy_opm_port_ipv6
);
2089 /* If there's no listeners... */
2090 fail
= (yy_opm_port_ipv4
== 0 || yy_opm_port_ipv6
== 0);
2093 RB_DLINK_FOREACH_SAFE(ptr
, nptr
, yy_opm_scanner_list
.head
)
2095 struct opm_scanner
*scanner
= ptr
->data
;
2098 create_opm_proxy_scanner(scanner
->type
, scanner
->port
);
2100 rb_dlinkDelete(&scanner
->node
, &yy_opm_scanner_list
);
2104 rb_free(yy_opm_address_ipv4
);
2105 rb_free(yy_opm_address_ipv6
);
2111 conf_set_opm_listen_address_both(void *data
, bool ipv6
)
2113 struct rb_sockaddr_storage addr
;
2114 const char *confstr
= (ipv6
? "opm::listen_ipv6" : "opm::listen_ipv4");
2117 if(!rb_inet_pton_sock(ip
, (struct sockaddr
*)&addr
))
2119 conf_report_error("%s is an invalid address: %s", confstr
, ip
);
2126 if(GET_SS_FAMILY(&addr
) != AF_INET6
)
2128 conf_report_error("%s is of the wrong address type: %s", confstr
, ip
);
2132 if(yy_opm_address_ipv6
!= NULL
)
2134 conf_report_error("%s overwrites previous address %s", confstr
, ip
);
2138 yy_opm_address_ipv6
= rb_strdup(ip
);
2140 conf_report_error("%s requires IPv6 support in your ircd", confstr
, ip
);
2146 if(GET_SS_FAMILY(&addr
) != AF_INET
)
2148 conf_report_error("%s is of the wrong address type: %s", confstr
, ip
);
2152 if(yy_opm_address_ipv4
!= NULL
)
2154 conf_report_error("%s overwrites previous address %s", confstr
, ip
);
2158 yy_opm_address_ipv4
= rb_strdup(ip
);
2163 conf_set_opm_listen_address_ipv4(void *data
)
2165 conf_set_opm_listen_address_both(data
, false);
2169 conf_set_opm_listen_address_ipv6(void *data
)
2171 conf_set_opm_listen_address_both(data
, true);
2175 conf_set_opm_listen_port_both(void *data
, bool ipv6
)
2177 int port
= *((int *)data
);
2178 const char *confstr
= (ipv6
? "opm::port_ipv6" : "opm::port_ipv4");
2183 conf_report_error("%s requires IPv6 support in your ircd", confstr
);
2188 if(port
> 65535 || port
<= 0)
2190 conf_report_error("%s is out of range: %d", confstr
, port
);
2196 if(yy_opm_port_ipv4
)
2198 conf_report_error("%s overwrites existing port %hu",
2199 confstr
, yy_opm_port_ipv4
);
2203 yy_opm_port_ipv4
= port
;
2207 if(yy_opm_port_ipv6
)
2209 conf_report_error("%s overwrites existing port %hu",
2210 confstr
, yy_opm_port_ipv6
);
2214 yy_opm_port_ipv6
= port
;
2219 conf_set_opm_listen_port_ipv4(void *data
)
2221 conf_set_opm_listen_port_both(data
, false);
2225 conf_set_opm_listen_port_ipv6(void *data
)
2227 conf_set_opm_listen_port_both(data
, true);
2231 conf_set_opm_listen_port(void *data
)
2233 conf_set_opm_listen_port_both(data
, true);
2234 conf_set_opm_listen_port_both(data
, false);
2238 conf_set_opm_scan_ports_all(void *data
, const char *node
, const char *type
)
2240 conf_parm_t
*args
= data
;
2241 for (; args
; args
= args
->next
)
2246 if(CF_TYPE(args
->type
) != CF_INT
)
2248 conf_report_error("%s argument is not an integer -- ignoring.", node
);
2252 if(args
->v
.number
> 65535 || args
->v
.number
<= 0)
2254 conf_report_error("%s argument is not an integer between 1 and 65535 -- ignoring.", node
);
2258 /* Check for duplicates */
2259 RB_DLINK_FOREACH(ptr
, yy_opm_scanner_list
.head
)
2261 struct opm_scanner
*scanner
= ptr
->data
;
2263 if(scanner
->port
== args
->v
.number
&& strcmp(type
, scanner
->type
) == 0)
2265 conf_report_error("%s argument is duplicate", node
);
2273 struct opm_scanner
*scanner
= rb_malloc(sizeof(struct opm_scanner
));
2274 scanner
->port
= args
->v
.number
;
2275 scanner
->type
= type
;
2276 rb_dlinkAdd(scanner
, &scanner
->node
, &yy_opm_scanner_list
);
2282 conf_set_opm_scan_ports_socks4(void *data
)
2284 conf_set_opm_scan_ports_all(data
, "opm::socks4_ports", "socks4");
2288 conf_set_opm_scan_ports_socks5(void *data
)
2290 conf_set_opm_scan_ports_all(data
, "opm::socks5_ports", "socks5");
2293 /* public functions */
2297 conf_report_error(const char *fmt
, ...)
2300 char msg
[BUFSIZE
+ 1] = { 0 };
2303 vsnprintf(msg
, BUFSIZE
, fmt
, ap
);
2308 fprintf(stderr
, "\"%s\", line %d: %s\n", current_file
, lineno
+ 1, msg
);
2312 ierror("\"%s\", line %d: %s", current_file
, lineno
+ 1, msg
);
2313 sendto_realops_snomask(SNO_GENERAL
, L_ALL
, "error: \"%s\", line %d: %s", current_file
, lineno
+ 1, msg
);
2317 conf_report_warning(const char *fmt
, ...)
2320 char msg
[BUFSIZE
+ 1] = { 0 };
2323 vsnprintf(msg
, BUFSIZE
, fmt
, ap
);
2328 fprintf(stderr
, "\"%s\", line %d: %s\n", current_file
, lineno
+ 1, msg
);
2332 iwarn("\"%s\", line %d: %s", current_file
, lineno
+ 1, msg
);
2333 sendto_realops_snomask(SNO_GENERAL
, L_ALL
, "warning: \"%s\", line %d: %s", current_file
, lineno
+ 1, msg
);
2337 conf_start_block(char *block
, char *name
)
2339 if((conf_cur_block
= find_top_conf(block
)) == NULL
)
2341 conf_report_error("Configuration block '%s' is not defined.", block
);
2346 conf_cur_block_name
= rb_strdup(name
);
2348 conf_cur_block_name
= NULL
;
2350 if(conf_cur_block
->tc_sfunc
)
2351 if(conf_cur_block
->tc_sfunc(conf_cur_block
) < 0)
2358 conf_end_block(struct TopConf
*tc
)
2362 ret
= tc
->tc_efunc(tc
);
2364 rb_free(conf_cur_block_name
);
2365 conf_cur_block_name
= NULL
;
2370 conf_set_generic_int(void *data
, void *location
)
2372 *((int *) location
) = *((unsigned int *) data
);
2376 conf_set_generic_string(void *data
, int len
, void *location
)
2378 char **loc
= location
;
2381 if(len
&& strlen(input
) > (unsigned int)len
)
2385 *loc
= rb_strdup(input
);
2389 conf_call_set(struct TopConf
*tc
, char *item
, conf_parm_t
* value
)
2391 struct ConfEntry
*cf
;
2397 if((cf
= find_conf_item(tc
, item
)) == NULL
)
2400 ("Non-existant configuration setting %s::%s.", tc
->tc_name
, (char *) item
);
2404 /* if it takes one thing, make sure they only passed one thing,
2405 and handle as needed. */
2406 if((value
->v
.list
->type
& CF_FLIST
) && !(cf
->cf_type
& CF_FLIST
))
2409 ("Option %s::%s does not take a list of values.", tc
->tc_name
, item
);
2416 if(CF_TYPE(value
->v
.list
->type
) != CF_TYPE(cf
->cf_type
))
2418 /* if it expects a string value, but we got a yesno,
2421 if((CF_TYPE(value
->v
.list
->type
) == CF_YESNO
) &&
2422 (CF_TYPE(cf
->cf_type
) == CF_STRING
))
2424 value
->v
.list
->type
= CF_STRING
;
2426 if(cp
->v
.number
== 1)
2427 cp
->v
.string
= rb_strdup("yes");
2429 cp
->v
.string
= rb_strdup("no");
2432 /* maybe it's a CF_TIME and they passed CF_INT --
2433 should still be valid */
2434 else if(!((CF_TYPE(value
->v
.list
->type
) == CF_INT
) &&
2435 (CF_TYPE(cf
->cf_type
) == CF_TIME
)))
2438 ("Wrong type for %s::%s (expected %s, got %s)",
2439 tc
->tc_name
, (char *) item
,
2440 conf_strtype(cf
->cf_type
), conf_strtype(value
->v
.list
->type
));
2445 if(cf
->cf_type
& CF_FLIST
)
2449 conf_set_generic_list(value
->v
.list
, cf
->cf_arg
);
2452 /* just pass it the extended argument list */
2453 cf
->cf_func(value
->v
.list
);
2457 /* it's old-style, needs only one arg */
2458 switch (cf
->cf_type
)
2464 conf_set_generic_int(&cp
->v
.number
, cf
->cf_arg
);
2466 cf
->cf_func(&cp
->v
.number
);
2470 if(EmptyString(cp
->v
.string
))
2471 conf_report_error("Ignoring %s::%s -- empty field",
2474 conf_set_generic_string(cp
->v
.string
, cf
->cf_len
, cf
->cf_arg
);
2476 cf
->cf_func(cp
->v
.string
);
2486 add_conf_item(const char *topconf
, const char *name
, int type
, void (*func
) (void *))
2489 struct ConfEntry
*cf
;
2491 if((tc
= find_top_conf(topconf
)) == NULL
)
2494 if(find_conf_item(tc
, name
) != NULL
)
2497 cf
= rb_malloc(sizeof(struct ConfEntry
));
2504 rb_dlinkAddAlloc(cf
, &tc
->tc_items
);
2510 remove_conf_item(const char *topconf
, const char *name
)
2513 struct ConfEntry
*cf
;
2516 if((tc
= find_top_conf(topconf
)) == NULL
)
2519 if((cf
= find_conf_item(tc
, name
)) == NULL
)
2522 if((ptr
= rb_dlinkFind(cf
, &tc
->tc_items
)) == NULL
)
2525 rb_dlinkDestroy(ptr
, &tc
->tc_items
);
2532 static struct ConfEntry conf_serverinfo_table
[] =
2534 { "description", CF_QSTRING
, NULL
, 0, &ServerInfo
.description
},
2536 { "network_name", CF_QSTRING
, conf_set_serverinfo_network_name
, 0, NULL
},
2537 { "name", CF_QSTRING
, conf_set_serverinfo_name
, 0, NULL
},
2538 { "sid", CF_QSTRING
, conf_set_serverinfo_sid
, 0, NULL
},
2539 { "vhost", CF_QSTRING
, conf_set_serverinfo_vhost
, 0, NULL
},
2540 { "vhost6", CF_QSTRING
, conf_set_serverinfo_vhost6
, 0, NULL
},
2542 { "ssl_private_key", CF_QSTRING
, NULL
, 0, &ServerInfo
.ssl_private_key
},
2543 { "ssl_ca_cert", CF_QSTRING
, NULL
, 0, &ServerInfo
.ssl_ca_cert
},
2544 { "ssl_cert", CF_QSTRING
, NULL
, 0, &ServerInfo
.ssl_cert
},
2545 { "ssl_dh_params", CF_QSTRING
, NULL
, 0, &ServerInfo
.ssl_dh_params
},
2546 { "ssl_cipher_list", CF_QSTRING
, NULL
, 0, &ServerInfo
.ssl_cipher_list
},
2547 { "ssld_count", CF_INT
, NULL
, 0, &ServerInfo
.ssld_count
},
2549 { "default_max_clients",CF_INT
, NULL
, 0, &ServerInfo
.default_max_clients
},
2551 { "nicklen", CF_INT
, conf_set_serverinfo_nicklen
, 0, NULL
},
2553 { "\0", 0, NULL
, 0, NULL
}
2556 static struct ConfEntry conf_admin_table
[] =
2558 { "name", CF_QSTRING
, NULL
, 200, &AdminInfo
.name
},
2559 { "description",CF_QSTRING
, NULL
, 200, &AdminInfo
.description
},
2560 { "email", CF_QSTRING
, NULL
, 200, &AdminInfo
.email
},
2561 { "\0", 0, NULL
, 0, NULL
}
2564 static struct ConfEntry conf_log_table
[] =
2566 { "fname_userlog", CF_QSTRING
, NULL
, PATH_MAX
, &ConfigFileEntry
.fname_userlog
},
2567 { "fname_fuserlog", CF_QSTRING
, NULL
, PATH_MAX
, &ConfigFileEntry
.fname_fuserlog
},
2568 { "fname_operlog", CF_QSTRING
, NULL
, PATH_MAX
, &ConfigFileEntry
.fname_operlog
},
2569 { "fname_foperlog", CF_QSTRING
, NULL
, PATH_MAX
, &ConfigFileEntry
.fname_foperlog
},
2570 { "fname_serverlog", CF_QSTRING
, NULL
, PATH_MAX
, &ConfigFileEntry
.fname_serverlog
},
2571 { "fname_killlog", CF_QSTRING
, NULL
, PATH_MAX
, &ConfigFileEntry
.fname_killlog
},
2572 { "fname_klinelog", CF_QSTRING
, NULL
, PATH_MAX
, &ConfigFileEntry
.fname_klinelog
},
2573 { "fname_operspylog", CF_QSTRING
, NULL
, PATH_MAX
, &ConfigFileEntry
.fname_operspylog
},
2574 { "fname_ioerrorlog", CF_QSTRING
, NULL
, PATH_MAX
, &ConfigFileEntry
.fname_ioerrorlog
},
2575 { "\0", 0, NULL
, 0, NULL
}
2578 static struct ConfEntry conf_operator_table
[] =
2580 { "rsa_public_key_file", CF_QSTRING
, conf_set_oper_rsa_public_key_file
, 0, NULL
},
2581 { "flags", CF_STRING
| CF_FLIST
, conf_set_oper_flags
, 0, NULL
},
2582 { "umodes", CF_STRING
| CF_FLIST
, conf_set_oper_umodes
, 0, NULL
},
2583 { "privset", CF_QSTRING
, conf_set_oper_privset
, 0, NULL
},
2584 { "snomask", CF_QSTRING
, conf_set_oper_snomask
, 0, NULL
},
2585 { "user", CF_QSTRING
, conf_set_oper_user
, 0, NULL
},
2586 { "password", CF_QSTRING
, conf_set_oper_password
, 0, NULL
},
2587 { "fingerprint", CF_QSTRING
, conf_set_oper_fingerprint
, 0, NULL
},
2588 { "\0", 0, NULL
, 0, NULL
}
2591 static struct ConfEntry conf_privset_table
[] =
2593 { "extends", CF_QSTRING
, conf_set_privset_extends
, 0, NULL
},
2594 { "privs", CF_STRING
| CF_FLIST
, conf_set_privset_privs
, 0, NULL
},
2595 { "\0", 0, NULL
, 0, NULL
}
2598 static struct ConfEntry conf_class_table
[] =
2600 { "ping_time", CF_TIME
, conf_set_class_ping_time
, 0, NULL
},
2601 { "cidr_ipv4_bitlen", CF_INT
, conf_set_class_cidr_ipv4_bitlen
, 0, NULL
},
2603 { "cidr_ipv6_bitlen", CF_INT
, conf_set_class_cidr_ipv6_bitlen
, 0, NULL
},
2605 { "number_per_cidr", CF_INT
, conf_set_class_number_per_cidr
, 0, NULL
},
2606 { "number_per_ip", CF_INT
, conf_set_class_number_per_ip
, 0, NULL
},
2607 { "number_per_ip_global", CF_INT
,conf_set_class_number_per_ip_global
, 0, NULL
},
2608 { "number_per_ident", CF_INT
, conf_set_class_number_per_ident
, 0, NULL
},
2609 { "connectfreq", CF_TIME
, conf_set_class_connectfreq
, 0, NULL
},
2610 { "max_number", CF_INT
, conf_set_class_max_number
, 0, NULL
},
2611 { "sendq", CF_TIME
, conf_set_class_sendq
, 0, NULL
},
2612 { "\0", 0, NULL
, 0, NULL
}
2615 static struct ConfEntry conf_auth_table
[] =
2617 { "user", CF_QSTRING
, conf_set_auth_user
, 0, NULL
},
2618 { "auth_user", CF_QSTRING
, conf_set_auth_auth_user
, 0, NULL
},
2619 { "password", CF_QSTRING
, conf_set_auth_passwd
, 0, NULL
},
2620 { "class", CF_QSTRING
, conf_set_auth_class
, 0, NULL
},
2621 { "spoof", CF_QSTRING
, conf_set_auth_spoof
, 0, NULL
},
2622 { "redirserv", CF_QSTRING
, conf_set_auth_redir_serv
, 0, NULL
},
2623 { "redirport", CF_INT
, conf_set_auth_redir_port
, 0, NULL
},
2624 { "flags", CF_STRING
| CF_FLIST
, conf_set_auth_flags
, 0, NULL
},
2625 { "\0", 0, NULL
, 0, NULL
}
2628 static struct ConfEntry conf_connect_table
[] =
2630 { "send_password", CF_QSTRING
, conf_set_connect_send_password
, 0, NULL
},
2631 { "accept_password", CF_QSTRING
, conf_set_connect_accept_password
, 0, NULL
},
2632 { "fingerprint", CF_QSTRING
, conf_set_connect_fingerprint
, 0, NULL
},
2633 { "flags", CF_STRING
| CF_FLIST
, conf_set_connect_flags
, 0, NULL
},
2634 { "host", CF_QSTRING
, conf_set_connect_host
, 0, NULL
},
2635 { "vhost", CF_QSTRING
, conf_set_connect_vhost
, 0, NULL
},
2636 { "port", CF_INT
, conf_set_connect_port
, 0, NULL
},
2637 { "aftype", CF_STRING
, conf_set_connect_aftype
, 0, NULL
},
2638 { "hub_mask", CF_QSTRING
, conf_set_connect_hub_mask
, 0, NULL
},
2639 { "leaf_mask", CF_QSTRING
, conf_set_connect_leaf_mask
, 0, NULL
},
2640 { "class", CF_QSTRING
, conf_set_connect_class
, 0, NULL
},
2641 { "\0", 0, NULL
, 0, NULL
}
2644 static struct ConfEntry conf_general_table
[] =
2646 { "oper_only_umodes", CF_STRING
| CF_FLIST
, conf_set_general_oper_only_umodes
, 0, NULL
},
2647 { "oper_umodes", CF_STRING
| CF_FLIST
, conf_set_general_oper_umodes
, 0, NULL
},
2648 { "oper_snomask", CF_QSTRING
, conf_set_general_oper_snomask
, 0, NULL
},
2649 { "compression_level", CF_INT
, conf_set_general_compression_level
, 0, NULL
},
2650 { "havent_read_conf", CF_YESNO
, conf_set_general_havent_read_conf
, 0, NULL
},
2651 { "hide_error_messages",CF_STRING
, conf_set_general_hide_error_messages
,0, NULL
},
2652 { "kline_delay", CF_TIME
, conf_set_general_kline_delay
, 0, NULL
},
2653 { "stats_k_oper_only", CF_STRING
, conf_set_general_stats_k_oper_only
, 0, NULL
},
2654 { "stats_i_oper_only", CF_STRING
, conf_set_general_stats_i_oper_only
, 0, NULL
},
2655 { "default_umodes", CF_QSTRING
, conf_set_general_default_umodes
, 0, NULL
},
2657 { "default_operstring", CF_QSTRING
, NULL
, REALLEN
, &ConfigFileEntry
.default_operstring
},
2658 { "default_adminstring",CF_QSTRING
, NULL
, REALLEN
, &ConfigFileEntry
.default_adminstring
},
2659 { "servicestring", CF_QSTRING
, NULL
, REALLEN
, &ConfigFileEntry
.servicestring
},
2660 { "kline_reason", CF_QSTRING
, NULL
, REALLEN
, &ConfigFileEntry
.kline_reason
},
2661 { "identify_service", CF_QSTRING
, NULL
, REALLEN
, &ConfigFileEntry
.identifyservice
},
2662 { "identify_command", CF_QSTRING
, NULL
, REALLEN
, &ConfigFileEntry
.identifycommand
},
2663 { "sasl_service", CF_QSTRING
, NULL
, REALLEN
, &ConfigFileEntry
.sasl_service
},
2665 { "anti_spam_exit_message_time", CF_TIME
, NULL
, 0, &ConfigFileEntry
.anti_spam_exit_message_time
},
2666 { "disable_fake_channels", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.disable_fake_channels
},
2667 { "min_nonwildcard_simple", CF_INT
, NULL
, 0, &ConfigFileEntry
.min_nonwildcard_simple
},
2668 { "non_redundant_klines", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.non_redundant_klines
},
2669 { "tkline_expire_notices", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.tkline_expire_notices
},
2671 { "anti_nick_flood", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.anti_nick_flood
},
2672 { "burst_away", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.burst_away
},
2673 { "caller_id_wait", CF_TIME
, NULL
, 0, &ConfigFileEntry
.caller_id_wait
},
2674 { "client_exit", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.client_exit
},
2675 { "collision_fnc", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.collision_fnc
},
2676 { "resv_fnc", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.resv_fnc
},
2677 { "connect_timeout", CF_TIME
, NULL
, 0, &ConfigFileEntry
.connect_timeout
},
2678 { "default_floodcount", CF_INT
, NULL
, 0, &ConfigFileEntry
.default_floodcount
},
2679 { "default_ident_timeout", CF_INT
, NULL
, 0, &ConfigFileEntry
.default_ident_timeout
},
2680 { "disable_auth", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.disable_auth
},
2681 { "dots_in_ident", CF_INT
, NULL
, 0, &ConfigFileEntry
.dots_in_ident
},
2682 { "failed_oper_notice", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.failed_oper_notice
},
2683 { "global_snotices", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.global_snotices
},
2684 { "hide_spoof_ips", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.hide_spoof_ips
},
2685 { "dline_with_reason", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.dline_with_reason
},
2686 { "kline_with_reason", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.kline_with_reason
},
2687 { "map_oper_only", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.map_oper_only
},
2688 { "max_accept", CF_INT
, NULL
, 0, &ConfigFileEntry
.max_accept
},
2689 { "max_monitor", CF_INT
, NULL
, 0, &ConfigFileEntry
.max_monitor
},
2690 { "max_nick_time", CF_TIME
, NULL
, 0, &ConfigFileEntry
.max_nick_time
},
2691 { "max_nick_changes", CF_INT
, NULL
, 0, &ConfigFileEntry
.max_nick_changes
},
2692 { "max_targets", CF_INT
, NULL
, 0, &ConfigFileEntry
.max_targets
},
2693 { "min_nonwildcard", CF_INT
, NULL
, 0, &ConfigFileEntry
.min_nonwildcard
},
2694 { "nick_delay", CF_TIME
, NULL
, 0, &ConfigFileEntry
.nick_delay
},
2695 { "no_oper_flood", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.no_oper_flood
},
2696 { "operspy_admin_only", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.operspy_admin_only
},
2697 { "operspy_dont_care_user_info", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.operspy_dont_care_user_info
},
2698 { "pace_wait", CF_TIME
, NULL
, 0, &ConfigFileEntry
.pace_wait
},
2699 { "pace_wait_simple", CF_TIME
, NULL
, 0, &ConfigFileEntry
.pace_wait_simple
},
2700 { "ping_cookie", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.ping_cookie
},
2701 { "reject_after_count", CF_INT
, NULL
, 0, &ConfigFileEntry
.reject_after_count
},
2702 { "reject_ban_time", CF_TIME
, NULL
, 0, &ConfigFileEntry
.reject_ban_time
},
2703 { "reject_duration", CF_TIME
, NULL
, 0, &ConfigFileEntry
.reject_duration
},
2704 { "throttle_count", CF_INT
, NULL
, 0, &ConfigFileEntry
.throttle_count
},
2705 { "throttle_duration", CF_TIME
, NULL
, 0, &ConfigFileEntry
.throttle_duration
},
2706 { "short_motd", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.short_motd
},
2707 { "stats_c_oper_only", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.stats_c_oper_only
},
2708 { "stats_e_disabled", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.stats_e_disabled
},
2709 { "stats_h_oper_only", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.stats_h_oper_only
},
2710 { "stats_o_oper_only", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.stats_o_oper_only
},
2711 { "stats_P_oper_only", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.stats_P_oper_only
},
2712 { "stats_y_oper_only", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.stats_y_oper_only
},
2713 { "target_change", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.target_change
},
2714 { "ts_max_delta", CF_TIME
, NULL
, 0, &ConfigFileEntry
.ts_max_delta
},
2715 { "ts_warn_delta", CF_TIME
, NULL
, 0, &ConfigFileEntry
.ts_warn_delta
},
2716 { "use_whois_actually", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.use_whois_actually
},
2717 { "warn_no_nline", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.warn_no_nline
},
2718 { "use_propagated_bans",CF_YESNO
, NULL
, 0, &ConfigFileEntry
.use_propagated_bans
},
2719 { "client_flood_max_lines", CF_INT
, NULL
, 0, &ConfigFileEntry
.client_flood_max_lines
},
2720 { "client_flood_burst_rate", CF_INT
, NULL
, 0, &ConfigFileEntry
.client_flood_burst_rate
},
2721 { "client_flood_burst_max", CF_INT
, NULL
, 0, &ConfigFileEntry
.client_flood_burst_max
},
2722 { "client_flood_message_num", CF_INT
, NULL
, 0, &ConfigFileEntry
.client_flood_message_num
},
2723 { "client_flood_message_time", CF_INT
, NULL
, 0, &ConfigFileEntry
.client_flood_message_time
},
2724 { "max_ratelimit_tokens", CF_INT
, NULL
, 0, &ConfigFileEntry
.max_ratelimit_tokens
},
2725 { "away_interval", CF_INT
, NULL
, 0, &ConfigFileEntry
.away_interval
},
2726 { "hide_opers_in_whois", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.hide_opers_in_whois
},
2727 { "certfp_method", CF_STRING
, conf_set_general_certfp_method
, 0, NULL
},
2728 { "\0", 0, NULL
, 0, NULL
}
2731 static struct ConfEntry conf_channel_table
[] =
2733 { "default_split_user_count", CF_INT
, NULL
, 0, &ConfigChannel
.default_split_user_count
},
2734 { "default_split_server_count", CF_INT
, NULL
, 0, &ConfigChannel
.default_split_server_count
},
2735 { "burst_topicwho", CF_YESNO
, NULL
, 0, &ConfigChannel
.burst_topicwho
},
2736 { "kick_on_split_riding", CF_YESNO
, NULL
, 0, &ConfigChannel
.kick_on_split_riding
},
2737 { "knock_delay", CF_TIME
, NULL
, 0, &ConfigChannel
.knock_delay
},
2738 { "knock_delay_channel",CF_TIME
, NULL
, 0, &ConfigChannel
.knock_delay_channel
},
2739 { "max_bans", CF_INT
, NULL
, 0, &ConfigChannel
.max_bans
},
2740 { "max_bans_large", CF_INT
, NULL
, 0, &ConfigChannel
.max_bans_large
},
2741 { "max_chans_per_user", CF_INT
, NULL
, 0, &ConfigChannel
.max_chans_per_user
},
2742 { "max_chans_per_user_large", CF_INT
, NULL
, 0, &ConfigChannel
.max_chans_per_user_large
},
2743 { "no_create_on_split", CF_YESNO
, NULL
, 0, &ConfigChannel
.no_create_on_split
},
2744 { "no_join_on_split", CF_YESNO
, NULL
, 0, &ConfigChannel
.no_join_on_split
},
2745 { "only_ascii_channels", CF_YESNO
, NULL
, 0, &ConfigChannel
.only_ascii_channels
},
2746 { "use_except", CF_YESNO
, NULL
, 0, &ConfigChannel
.use_except
},
2747 { "use_invex", CF_YESNO
, NULL
, 0, &ConfigChannel
.use_invex
},
2748 { "use_forward", CF_YESNO
, NULL
, 0, &ConfigChannel
.use_forward
},
2749 { "use_knock", CF_YESNO
, NULL
, 0, &ConfigChannel
.use_knock
},
2750 { "resv_forcepart", CF_YESNO
, NULL
, 0, &ConfigChannel
.resv_forcepart
},
2751 { "channel_target_change", CF_YESNO
, NULL
, 0, &ConfigChannel
.channel_target_change
},
2752 { "disable_local_channels", CF_YESNO
, NULL
, 0, &ConfigChannel
.disable_local_channels
},
2753 { "autochanmodes", CF_QSTRING
, conf_set_channel_autochanmodes
, 0, NULL
},
2754 { "displayed_usercount", CF_INT
, NULL
, 0, &ConfigChannel
.displayed_usercount
},
2755 { "strip_topic_colors", CF_YESNO
, NULL
, 0, &ConfigChannel
.strip_topic_colors
},
2756 { "\0", 0, NULL
, 0, NULL
}
2759 static struct ConfEntry conf_serverhide_table
[] =
2761 { "disable_hidden", CF_YESNO
, NULL
, 0, &ConfigServerHide
.disable_hidden
},
2762 { "flatten_links", CF_YESNO
, NULL
, 0, &ConfigServerHide
.flatten_links
},
2763 { "hidden", CF_YESNO
, NULL
, 0, &ConfigServerHide
.hidden
},
2764 { "links_delay", CF_TIME
, conf_set_serverhide_links_delay
, 0, NULL
},
2765 { "\0", 0, NULL
, 0, NULL
}
2772 add_top_conf("modules", NULL
, NULL
, NULL
);
2773 add_conf_item("modules", "path", CF_QSTRING
, conf_set_modules_path
);
2774 add_conf_item("modules", "module", CF_QSTRING
, conf_set_modules_module
);
2776 add_top_conf("serverinfo", NULL
, NULL
, conf_serverinfo_table
);
2777 add_top_conf("admin", NULL
, NULL
, conf_admin_table
);
2778 add_top_conf("log", NULL
, NULL
, conf_log_table
);
2779 add_top_conf("operator", conf_begin_oper
, conf_end_oper
, conf_operator_table
);
2780 add_top_conf("class", conf_begin_class
, conf_end_class
, conf_class_table
);
2781 add_top_conf("privset", NULL
, NULL
, conf_privset_table
);
2783 add_top_conf("listen", conf_begin_listen
, conf_end_listen
, NULL
);
2784 add_conf_item("listen", "defer_accept", CF_YESNO
, conf_set_listen_defer_accept
);
2785 add_conf_item("listen", "wsock", CF_YESNO
, conf_set_listen_wsock
);
2786 add_conf_item("listen", "port", CF_INT
| CF_FLIST
, conf_set_listen_port
);
2787 add_conf_item("listen", "sslport", CF_INT
| CF_FLIST
, conf_set_listen_sslport
);
2788 add_conf_item("listen", "ip", CF_QSTRING
, conf_set_listen_address
);
2789 add_conf_item("listen", "host", CF_QSTRING
, conf_set_listen_address
);
2791 add_top_conf("auth", conf_begin_auth
, conf_end_auth
, conf_auth_table
);
2793 add_top_conf("shared", conf_cleanup_shared
, conf_cleanup_shared
, NULL
);
2794 add_conf_item("shared", "oper", CF_QSTRING
| CF_FLIST
, conf_set_shared_oper
);
2795 add_conf_item("shared", "flags", CF_STRING
| CF_FLIST
, conf_set_shared_flags
);
2797 add_top_conf("connect", conf_begin_connect
, conf_end_connect
, conf_connect_table
);
2799 add_top_conf("exempt", NULL
, NULL
, NULL
);
2800 add_conf_item("exempt", "ip", CF_QSTRING
, conf_set_exempt_ip
);
2802 add_top_conf("cluster", conf_cleanup_cluster
, conf_cleanup_cluster
, NULL
);
2803 add_conf_item("cluster", "name", CF_QSTRING
, conf_set_cluster_name
);
2804 add_conf_item("cluster", "flags", CF_STRING
| CF_FLIST
, conf_set_cluster_flags
);
2806 add_top_conf("general", NULL
, NULL
, conf_general_table
);
2807 add_top_conf("channel", NULL
, NULL
, conf_channel_table
);
2808 add_top_conf("serverhide", NULL
, NULL
, conf_serverhide_table
);
2810 add_top_conf("service", NULL
, NULL
, NULL
);
2811 add_conf_item("service", "name", CF_QSTRING
, conf_set_service_name
);
2813 add_top_conf("alias", conf_begin_alias
, conf_end_alias
, NULL
);
2814 add_conf_item("alias", "name", CF_QSTRING
, conf_set_alias_name
);
2815 add_conf_item("alias", "target", CF_QSTRING
, conf_set_alias_target
);
2817 add_top_conf("blacklist", NULL
, NULL
, NULL
);
2818 add_conf_item("blacklist", "host", CF_QSTRING
, conf_set_blacklist_host
);
2819 add_conf_item("blacklist", "type", CF_STRING
| CF_FLIST
, conf_set_blacklist_type
);
2820 add_conf_item("blacklist", "matches", CF_QSTRING
| CF_FLIST
, conf_set_blacklist_matches
);
2821 add_conf_item("blacklist", "reject_reason", CF_QSTRING
, conf_set_blacklist_reason
);
2823 add_top_conf("opm", conf_begin_opm
, conf_end_opm
, NULL
);
2824 add_conf_item("opm", "listen_ipv4", CF_QSTRING
, conf_set_opm_listen_address_ipv4
);
2825 add_conf_item("opm", "listen_ipv6", CF_QSTRING
, conf_set_opm_listen_address_ipv6
);
2826 add_conf_item("opm", "port_v4", CF_INT
, conf_set_opm_listen_port_ipv4
);
2827 add_conf_item("opm", "port_v6", CF_INT
, conf_set_opm_listen_port_ipv6
);
2828 add_conf_item("opm", "listen_port", CF_INT
, conf_set_opm_listen_port
);
2829 add_conf_item("opm", "socks4_ports", CF_INT
| CF_FLIST
, conf_set_opm_scan_ports_socks4
);
2830 add_conf_item("opm", "socks5_ports", CF_INT
| CF_FLIST
, conf_set_opm_scan_ports_socks5
);