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"
33 #define CF_TYPE(x) ((x) & CF_MTYPE)
35 static int yy_defer_accept
= 1;
36 static int yy_wsock
= 0;
38 struct TopConf
*conf_cur_block
;
39 static char *conf_cur_block_name
= NULL
;
41 static rb_dlink_list conf_items
;
43 static struct ConfItem
*yy_aconf
= NULL
;
45 static struct Class
*yy_class
= NULL
;
47 static struct remote_conf
*yy_shared
= NULL
;
48 static struct server_conf
*yy_server
= NULL
;
50 static rb_dlink_list yy_aconf_list
;
51 static rb_dlink_list yy_oper_list
;
52 static rb_dlink_list yy_shared_list
;
53 static rb_dlink_list yy_cluster_list
;
54 static struct oper_conf
*yy_oper
= NULL
;
56 static struct alias_entry
*yy_alias
= NULL
;
58 static char *yy_blacklist_host
= NULL
;
59 static char *yy_blacklist_reason
= NULL
;
60 static uint8_t yy_blacklist_iptype
= 0;
61 static rb_dlink_list yy_blacklist_filters
= { NULL
, NULL
, 0 };
63 static char *yy_opm_address_ipv4
= NULL
;
64 static char *yy_opm_address_ipv6
= NULL
;
65 static uint16_t yy_opm_port_ipv4
= 0;
66 static uint16_t yy_opm_port_ipv6
= 0;
67 static int yy_opm_timeout
= 0;
68 static rb_dlink_list yy_opm_scanner_list
;
70 static char *yy_privset_extends
= NULL
;
73 conf_strtype(int type
)
75 switch (CF_TYPE(type
))
78 return "integer value";
80 return "unquoted string";
82 return "yes/no value";
84 return "quoted string";
86 return "time/size value";
88 return "unknown type";
93 add_top_conf(const char *name
, int (*sfunc
) (struct TopConf
*),
94 int (*efunc
) (struct TopConf
*), struct ConfEntry
*items
)
98 tc
= rb_malloc(sizeof(struct TopConf
));
101 tc
->tc_sfunc
= sfunc
;
102 tc
->tc_efunc
= efunc
;
103 tc
->tc_entries
= items
;
105 rb_dlinkAddAlloc(tc
, &conf_items
);
110 find_top_conf(const char *name
)
115 RB_DLINK_FOREACH(d
, conf_items
.head
)
118 if(rb_strcasecmp(tc
->tc_name
, name
) == 0)
127 find_conf_item(const struct TopConf
*top
, const char *name
)
129 struct ConfEntry
*cf
;
136 for(i
= 0; top
->tc_entries
[i
].cf_type
; i
++)
138 cf
= &top
->tc_entries
[i
];
140 if(!rb_strcasecmp(cf
->cf_name
, name
))
145 RB_DLINK_FOREACH(d
, top
->tc_items
.head
)
148 if(rb_strcasecmp(cf
->cf_name
, name
) == 0)
156 remove_top_conf(char *name
)
161 if((tc
= find_top_conf(name
)) == NULL
)
164 if((ptr
= rb_dlinkFind(tc
, &conf_items
)) == NULL
)
167 rb_dlinkDestroy(ptr
, &conf_items
);
174 conf_set_serverinfo_name(void *data
)
176 if(ServerInfo
.name
== NULL
)
181 for(s
= data
; *s
!= '\0'; s
++)
185 conf_report_error("Ignoring serverinfo::name "
186 "-- bogus servername.");
195 conf_report_error("Ignoring serverinfo::name -- must contain '.'");
203 conf_report_error("Ignoring serverinfo::name -- cannot begin with digit.");
207 /* the ircd will exit() in main() if we dont set one */
208 if(strlen(s
) <= HOSTLEN
)
209 ServerInfo
.name
= rb_strdup((char *) data
);
214 conf_set_serverinfo_sid(void *data
)
218 if(ServerInfo
.sid
[0] == '\0')
220 if(!IsDigit(sid
[0]) || !IsIdChar(sid
[1]) ||
221 !IsIdChar(sid
[2]) || sid
[3] != '\0')
223 conf_report_error("Ignoring serverinfo::sid "
228 rb_strlcpy(ServerInfo
.sid
, sid
, sizeof(ServerInfo
.sid
));
233 conf_set_serverinfo_network_name(void *data
)
237 if((p
= strchr((char *) data
, ' ')))
240 rb_free(ServerInfo
.network_name
);
241 ServerInfo
.network_name
= rb_strdup((char *) data
);
245 conf_set_serverinfo_vhost(void *data
)
247 struct rb_sockaddr_storage addr
;
249 if(rb_inet_pton_sock(data
, &addr
) <= 0 || GET_SS_FAMILY(&addr
) != AF_INET
)
251 conf_report_error("Invalid IPv4 address for server vhost (%s)", (char *) data
);
255 ServerInfo
.bind4
= addr
;
259 conf_set_serverinfo_vhost6(void *data
)
262 struct rb_sockaddr_storage addr
;
264 if(rb_inet_pton_sock(data
, &addr
) <= 0 || GET_SS_FAMILY(&addr
) != AF_INET6
)
266 conf_report_error("Invalid IPv6 address for server vhost (%s)", (char *) data
);
270 ServerInfo
.bind6
= addr
;
274 conf_set_serverinfo_nicklen(void *data
)
276 ConfigFileEntry
.nicklen
= (*(unsigned int *) data
) + 1;
278 if (ConfigFileEntry
.nicklen
> NICKLEN
)
280 conf_report_error("Warning -- ignoring serverinfo::nicklen -- provided nicklen (%u) is greater than allowed nicklen (%u)",
281 ConfigFileEntry
.nicklen
- 1, NICKLEN
- 1);
282 ConfigFileEntry
.nicklen
= NICKLEN
;
284 else if (ConfigFileEntry
.nicklen
< 9 + 1)
286 conf_report_error("Warning -- serverinfo::nicklen is too low (%u) -- forcing 9",
287 ConfigFileEntry
.nicklen
- 1);
288 ConfigFileEntry
.nicklen
= 9 + 1;
293 conf_set_modules_module(void *data
)
297 m_bn
= rb_basename((char *) data
);
299 if(findmodule_byname(m_bn
) == NULL
)
300 load_one_module((char *) data
, MAPI_ORIGIN_EXTENSION
, false);
306 conf_set_modules_path(void *data
)
308 mod_add_path((char *) data
);
318 static struct mode_table umode_table
[] = {
319 {"callerid", UMODE_CALLERID
},
320 {"deaf", UMODE_DEAF
},
321 {"invisible", UMODE_INVISIBLE
},
322 {"locops", UMODE_LOCOPS
},
323 {"noforward", UMODE_NOFORWARD
},
324 {"regonlymsg", UMODE_REGONLYMSG
},
325 {"servnotice", UMODE_SERVNOTICE
},
326 {"wallop", UMODE_WALLOP
},
327 {"operwall", UMODE_OPERWALL
},
331 static struct mode_table oper_table
[] = {
332 {"encrypted", OPER_ENCRYPTED
},
333 {"need_ssl", OPER_NEEDSSL
},
337 static struct mode_table auth_table
[] = {
338 {"encrypted", CONF_FLAGS_ENCRYPTED
},
339 {"spoof_notice", CONF_FLAGS_SPOOF_NOTICE
},
340 {"exceed_limit", CONF_FLAGS_NOLIMIT
},
341 {"dnsbl_exempt", CONF_FLAGS_EXEMPTDNSBL
},
342 {"proxy_exempt", CONF_FLAGS_EXEMPTPROXY
},
343 {"kline_exempt", CONF_FLAGS_EXEMPTKLINE
},
344 {"flood_exempt", CONF_FLAGS_EXEMPTFLOOD
},
345 {"spambot_exempt", CONF_FLAGS_EXEMPTSPAMBOT
},
346 {"shide_exempt", CONF_FLAGS_EXEMPTSHIDE
},
347 {"jupe_exempt", CONF_FLAGS_EXEMPTJUPE
},
348 {"resv_exempt", CONF_FLAGS_EXEMPTRESV
},
349 {"no_tilde", CONF_FLAGS_NO_TILDE
},
350 {"need_ident", CONF_FLAGS_NEED_IDENTD
},
351 {"have_ident", CONF_FLAGS_NEED_IDENTD
},
352 {"need_ssl", CONF_FLAGS_NEED_SSL
},
353 {"need_sasl", CONF_FLAGS_NEED_SASL
},
354 {"extend_chans", CONF_FLAGS_EXTEND_CHANS
},
355 {"allow_sctp", CONF_FLAGS_ALLOW_SCTP
},
359 static struct mode_table connect_table
[] = {
360 { "autoconn", SERVER_AUTOCONN
},
361 { "compressed", SERVER_COMPRESSED
},
362 { "encrypted", SERVER_ENCRYPTED
},
363 { "topicburst", SERVER_TB
},
364 { "sctp", SERVER_SCTP
},
365 { "ssl", SERVER_SSL
},
366 { "no-export", SERVER_NO_EXPORT
},
370 static struct mode_table cluster_table
[] = {
371 { "kline", SHARED_PKLINE
},
372 { "tkline", SHARED_TKLINE
},
373 { "unkline", SHARED_UNKLINE
},
374 { "locops", SHARED_LOCOPS
},
375 { "xline", SHARED_PXLINE
},
376 { "txline", SHARED_TXLINE
},
377 { "unxline", SHARED_UNXLINE
},
378 { "resv", SHARED_PRESV
},
379 { "tresv", SHARED_TRESV
},
380 { "unresv", SHARED_UNRESV
},
381 { "all", CLUSTER_ALL
},
385 static struct mode_table shared_table
[] =
387 { "kline", SHARED_PKLINE
|SHARED_TKLINE
},
388 { "xline", SHARED_PXLINE
|SHARED_TXLINE
},
389 { "resv", SHARED_PRESV
|SHARED_TRESV
},
390 { "dline", SHARED_PDLINE
|SHARED_TDLINE
},
391 { "tdline", SHARED_TDLINE
},
392 { "pdline", SHARED_PDLINE
},
393 { "undline", SHARED_UNDLINE
},
394 { "tkline", SHARED_TKLINE
},
395 { "unkline", SHARED_UNKLINE
},
396 { "txline", SHARED_TXLINE
},
397 { "unxline", SHARED_UNXLINE
},
398 { "tresv", SHARED_TRESV
},
399 { "unresv", SHARED_UNRESV
},
400 { "locops", SHARED_LOCOPS
},
401 { "rehash", SHARED_REHASH
},
402 { "grant", SHARED_GRANT
},
403 { "die", SHARED_DIE
},
404 { "module", SHARED_MODULE
},
405 { "all", SHARED_ALL
},
412 find_umode(struct mode_table
*tab
, const char *name
)
416 for (i
= 0; tab
[i
].name
; i
++)
418 if(strcmp(tab
[i
].name
, name
) == 0)
426 set_modes_from_table(int *modes
, const char *whatis
, struct mode_table
*tab
, conf_parm_t
* args
)
428 for (; args
; args
= args
->next
)
434 if(CF_TYPE(args
->type
) != CF_STRING
)
436 conf_report_error("Warning -- %s is not a string; ignoring.", whatis
);
440 umode
= args
->v
.string
;
448 mode
= find_umode(tab
, umode
);
452 conf_report_error("Warning -- unknown %s %s.", whatis
, args
->v
.string
);
469 conf_set_privset_extends(void *data
)
471 yy_privset_extends
= rb_strdup((char *) data
);
475 conf_set_privset_privs(void *data
)
478 conf_parm_t
*args
= data
;
480 for (; args
; args
= args
->next
)
483 privs
= rb_strdup(args
->v
.string
);
486 char *privs_old
= privs
;
488 privs
= rb_malloc(strlen(privs_old
) + 1 + strlen(args
->v
.string
) + 1);
489 strcpy(privs
, privs_old
);
491 strcat(privs
, args
->v
.string
);
499 if (yy_privset_extends
)
501 struct PrivilegeSet
*set
= privilegeset_get(yy_privset_extends
);
505 conf_report_error("Warning -- unknown parent privilege set %s for %s; assuming defaults", yy_privset_extends
, conf_cur_block_name
);
507 set
= privilegeset_get("default");
510 privilegeset_extend(set
, conf_cur_block_name
!= NULL
? conf_cur_block_name
: "<unknown>", privs
, 0);
512 rb_free(yy_privset_extends
);
513 yy_privset_extends
= NULL
;
516 privilegeset_set_new(conf_cur_block_name
!= NULL
? conf_cur_block_name
: "<unknown>", privs
, 0);
523 conf_begin_oper(struct TopConf
*tc
)
526 rb_dlink_node
*next_ptr
;
530 free_oper_conf(yy_oper
);
534 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, yy_oper_list
.head
)
536 free_oper_conf(ptr
->data
);
537 rb_dlinkDestroy(ptr
, &yy_oper_list
);
540 yy_oper
= make_oper_conf();
541 yy_oper
->flags
|= OPER_ENCRYPTED
;
547 conf_end_oper(struct TopConf
*tc
)
549 struct oper_conf
*yy_tmpoper
;
551 rb_dlink_node
*next_ptr
;
553 if(conf_cur_block_name
!= NULL
)
555 if(strlen(conf_cur_block_name
) > OPERNICKLEN
)
556 conf_cur_block_name
[OPERNICKLEN
] = '\0';
558 yy_oper
->name
= rb_strdup(conf_cur_block_name
);
561 if(EmptyString(yy_oper
->name
))
563 conf_report_error("Ignoring operator block -- missing name.");
567 #ifdef HAVE_LIBCRYPTO
568 if(EmptyString(yy_oper
->passwd
) && EmptyString(yy_oper
->rsa_pubkey_file
))
570 if(EmptyString(yy_oper
->passwd
))
573 conf_report_error("Ignoring operator block for %s -- missing password",
579 if (!yy_oper
->privset
)
580 yy_oper
->privset
= privilegeset_get("default");
582 /* now, yy_oper_list contains a stack of oper_conf's with just user
583 * and host in, yy_oper contains the rest of the information which
584 * we need to copy into each element in yy_oper_list
586 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, yy_oper_list
.head
)
588 yy_tmpoper
= ptr
->data
;
590 yy_tmpoper
->name
= rb_strdup(yy_oper
->name
);
592 /* could be an rsa key instead.. */
593 if(!EmptyString(yy_oper
->passwd
))
594 yy_tmpoper
->passwd
= rb_strdup(yy_oper
->passwd
);
596 yy_tmpoper
->flags
= yy_oper
->flags
;
597 yy_tmpoper
->umodes
= yy_oper
->umodes
;
598 yy_tmpoper
->snomask
= yy_oper
->snomask
;
599 yy_tmpoper
->privset
= yy_oper
->privset
;
601 #ifdef HAVE_LIBCRYPTO
602 if(yy_oper
->rsa_pubkey_file
)
606 if((file
= BIO_new_file(yy_oper
->rsa_pubkey_file
, "r")) == NULL
)
608 conf_report_error("Ignoring operator block for %s -- "
609 "rsa_public_key_file cant be opened",
614 yy_tmpoper
->rsa_pubkey
=
615 (RSA
*) PEM_read_bio_RSA_PUBKEY(file
, NULL
, 0, NULL
);
617 (void)BIO_set_close(file
, BIO_CLOSE
);
620 if(yy_tmpoper
->rsa_pubkey
== NULL
)
622 conf_report_error("Ignoring operator block for %s -- "
623 "rsa_public_key_file key invalid; check syntax",
629 if(!EmptyString(yy_oper
->certfp
))
630 yy_tmpoper
->certfp
= rb_strdup(yy_oper
->certfp
);
633 /* all is ok, put it on oper_conf_list */
634 rb_dlinkMoveNode(ptr
, &yy_oper_list
, &oper_conf_list
);
637 free_oper_conf(yy_oper
);
644 conf_set_oper_flags(void *data
)
646 conf_parm_t
*args
= data
;
648 set_modes_from_table(&yy_oper
->flags
, "flag", oper_table
, args
);
652 conf_set_oper_fingerprint(void *data
)
655 rb_free(yy_oper
->certfp
);
656 yy_oper
->certfp
= rb_strdup((char *) data
);
660 conf_set_oper_privset(void *data
)
662 yy_oper
->privset
= privilegeset_get((char *) data
);
666 conf_set_oper_user(void *data
)
668 struct oper_conf
*yy_tmpoper
;
670 char *host
= (char *) data
;
672 yy_tmpoper
= make_oper_conf();
674 if((p
= strchr(host
, '@')))
678 yy_tmpoper
->username
= rb_strdup(host
);
679 yy_tmpoper
->host
= rb_strdup(p
);
684 yy_tmpoper
->username
= rb_strdup("*");
685 yy_tmpoper
->host
= rb_strdup(host
);
688 if(EmptyString(yy_tmpoper
->username
) || EmptyString(yy_tmpoper
->host
))
690 conf_report_error("Ignoring user -- missing username/host");
691 free_oper_conf(yy_tmpoper
);
695 rb_dlinkAddAlloc(yy_tmpoper
, &yy_oper_list
);
699 conf_set_oper_password(void *data
)
703 memset(yy_oper
->passwd
, 0, strlen(yy_oper
->passwd
));
704 rb_free(yy_oper
->passwd
);
707 yy_oper
->passwd
= rb_strdup((char *) data
);
711 conf_set_oper_rsa_public_key_file(void *data
)
713 #ifdef HAVE_LIBCRYPTO
714 rb_free(yy_oper
->rsa_pubkey_file
);
715 yy_oper
->rsa_pubkey_file
= rb_strdup((char *) data
);
717 conf_report_error("Warning -- ignoring rsa_public_key_file (OpenSSL support not available");
722 conf_set_oper_umodes(void *data
)
724 set_modes_from_table(&yy_oper
->umodes
, "umode", umode_table
, data
);
728 conf_set_oper_snomask(void *data
)
730 yy_oper
->snomask
= parse_snobuf_to_mask(0, (const char *) data
);
734 conf_begin_class(struct TopConf
*tc
)
737 free_class(yy_class
);
739 yy_class
= make_class();
744 conf_end_class(struct TopConf
*tc
)
746 if(conf_cur_block_name
!= NULL
)
747 yy_class
->class_name
= rb_strdup(conf_cur_block_name
);
749 if(EmptyString(yy_class
->class_name
))
751 conf_report_error("Ignoring connect block -- missing name.");
761 conf_set_class_ping_time(void *data
)
763 yy_class
->ping_freq
= *(unsigned int *) data
;
767 conf_set_class_cidr_ipv4_bitlen(void *data
)
769 unsigned int maxsize
= 32;
770 if(*(unsigned int *) data
> maxsize
)
772 ("class::cidr_ipv4_bitlen argument exceeds maxsize (%d > %d) - ignoring.",
773 *(unsigned int *) data
, maxsize
);
775 yy_class
->cidr_ipv4_bitlen
= *(unsigned int *) data
;
780 conf_set_class_cidr_ipv6_bitlen(void *data
)
782 unsigned int maxsize
= 128;
783 if(*(unsigned int *) data
> maxsize
)
785 ("class::cidr_ipv6_bitlen argument exceeds maxsize (%d > %d) - ignoring.",
786 *(unsigned int *) data
, maxsize
);
788 yy_class
->cidr_ipv6_bitlen
= *(unsigned int *) data
;
793 conf_set_class_number_per_cidr(void *data
)
795 yy_class
->cidr_amount
= *(unsigned int *) data
;
799 conf_set_class_number_per_ip(void *data
)
801 yy_class
->max_local
= *(unsigned int *) data
;
806 conf_set_class_number_per_ip_global(void *data
)
808 yy_class
->max_global
= *(unsigned int *) data
;
812 conf_set_class_number_per_ident(void *data
)
814 yy_class
->max_ident
= *(unsigned int *) data
;
818 conf_set_class_connectfreq(void *data
)
820 yy_class
->con_freq
= *(unsigned int *) data
;
824 conf_set_class_max_number(void *data
)
826 yy_class
->max_total
= *(unsigned int *) data
;
830 conf_set_class_sendq(void *data
)
832 yy_class
->max_sendq
= *(unsigned int *) data
;
835 static char *listener_address
[2];
838 conf_begin_listen(struct TopConf
*tc
)
840 for (int i
= 0; i
< ARRAY_SIZE(listener_address
); i
++) {
841 rb_free(listener_address
[i
]);
842 listener_address
[i
] = NULL
;
850 conf_end_listen(struct TopConf
*tc
)
852 for (int i
= 0; i
< ARRAY_SIZE(listener_address
); i
++) {
853 rb_free(listener_address
[i
]);
854 listener_address
[i
] = NULL
;
862 conf_set_listen_defer_accept(void *data
)
864 yy_defer_accept
= *(unsigned int *) data
;
868 conf_set_listen_wsock(void *data
)
870 yy_wsock
= *(unsigned int *) data
;
874 conf_set_listen_port_both(void *data
, int ssl
, int sctp
)
876 conf_parm_t
*args
= data
;
877 for (; args
; args
= args
->next
)
879 if(CF_TYPE(args
->type
) != CF_INT
)
881 conf_report_error("listener::port argument is not an integer -- ignoring.");
884 if(listener_address
[0] == NULL
)
887 conf_report_error("listener::sctp_port has no addresses -- ignoring.");
889 add_tcp_listener(args
->v
.number
, NULL
, AF_INET
, ssl
, ssl
|| yy_defer_accept
, yy_wsock
);
890 add_tcp_listener(args
->v
.number
, NULL
, AF_INET6
, ssl
, ssl
|| yy_defer_accept
, yy_wsock
);
896 if(strchr(listener_address
[0], ':') != NULL
)
903 add_sctp_listener(args
->v
.number
, listener_address
[0], listener_address
[1], ssl
, yy_wsock
);
905 conf_report_error("Warning -- ignoring listener::sctp_port -- SCTP support not available.");
908 add_tcp_listener(args
->v
.number
, listener_address
[0], family
, ssl
, ssl
|| yy_defer_accept
, yy_wsock
);
915 conf_set_listen_port(void *data
)
917 conf_set_listen_port_both(data
, 0, 0);
921 conf_set_listen_sslport(void *data
)
923 conf_set_listen_port_both(data
, 1, 0 );
927 conf_set_listen_sctp_port(void *data
)
929 conf_set_listen_port_both(data
, 0, 1);
933 conf_set_listen_sctp_sslport(void *data
)
935 conf_set_listen_port_both(data
, 1, 1);
939 conf_set_listen_address(void *data
)
941 rb_free(listener_address
[1]);
942 listener_address
[1] = listener_address
[0];
943 listener_address
[0] = rb_strdup(data
);
947 conf_begin_auth(struct TopConf
*tc
)
950 rb_dlink_node
*next_ptr
;
955 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, yy_aconf_list
.head
)
957 free_conf(ptr
->data
);
958 rb_dlinkDestroy(ptr
, &yy_aconf_list
);
961 yy_aconf
= make_conf();
962 yy_aconf
->status
= CONF_CLIENT
;
968 conf_end_auth(struct TopConf
*tc
)
970 struct ConfItem
*yy_tmp
, *found_conf
;
972 rb_dlink_node
*next_ptr
;
974 if(EmptyString(yy_aconf
->info
.name
))
975 yy_aconf
->info
.name
= rb_strdup("NOMATCH");
977 /* didnt even get one ->host? */
978 if(EmptyString(yy_aconf
->host
))
980 conf_report_error("Ignoring auth block -- missing user@host");
984 /* so the stacking works in order.. */
985 collapse(yy_aconf
->user
);
986 collapse(yy_aconf
->host
);
987 conf_add_class_to_conf(yy_aconf
);
988 if ((found_conf
= find_exact_conf_by_address("*", CONF_CLIENT
, "*")) && found_conf
->spasswd
== NULL
)
989 conf_report_error("Ignoring redundant auth block (after *@*)");
990 else if ((found_conf
= find_exact_conf_by_address(yy_aconf
->host
, CONF_CLIENT
, yy_aconf
->user
)) &&
991 (!found_conf
->spasswd
|| (yy_aconf
->spasswd
&&
992 0 == irccmp(found_conf
->spasswd
, yy_aconf
->spasswd
))))
993 conf_report_error("Ignoring duplicate auth block for %s@%s",
994 yy_aconf
->user
, yy_aconf
->host
);
996 add_conf_by_address(yy_aconf
->host
, CONF_CLIENT
, yy_aconf
->user
, yy_aconf
->spasswd
, yy_aconf
);
998 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, yy_aconf_list
.head
)
1002 if(yy_aconf
->passwd
)
1003 yy_tmp
->passwd
= rb_strdup(yy_aconf
->passwd
);
1005 if(yy_aconf
->spasswd
)
1006 yy_tmp
->spasswd
= rb_strdup(yy_aconf
->spasswd
);
1008 /* this will always exist.. */
1009 yy_tmp
->info
.name
= rb_strdup(yy_aconf
->info
.name
);
1011 if(yy_aconf
->className
)
1012 yy_tmp
->className
= rb_strdup(yy_aconf
->className
);
1014 yy_tmp
->flags
= yy_aconf
->flags
;
1015 yy_tmp
->port
= yy_aconf
->port
;
1017 collapse(yy_tmp
->user
);
1018 collapse(yy_tmp
->host
);
1020 conf_add_class_to_conf(yy_tmp
);
1022 if ((found_conf
= find_exact_conf_by_address("*", CONF_CLIENT
, "*")) && found_conf
->spasswd
== NULL
)
1023 conf_report_error("Ignoring redundant auth block (after *@*)");
1024 else if ((found_conf
= find_exact_conf_by_address(yy_tmp
->host
, CONF_CLIENT
, yy_tmp
->user
)) &&
1025 (!found_conf
->spasswd
|| (yy_tmp
->spasswd
&&
1026 0 == irccmp(found_conf
->spasswd
, yy_tmp
->spasswd
))))
1027 conf_report_error("Ignoring duplicate auth block for %s@%s",
1028 yy_tmp
->user
, yy_tmp
->host
);
1030 add_conf_by_address(yy_tmp
->host
, CONF_CLIENT
, yy_tmp
->user
, yy_tmp
->spasswd
, yy_tmp
);
1031 rb_dlinkDestroy(ptr
, &yy_aconf_list
);
1039 conf_set_auth_user(void *data
)
1041 struct ConfItem
*yy_tmp
;
1044 /* The first user= line doesn't allocate a new conf */
1045 if(!EmptyString(yy_aconf
->host
))
1047 yy_tmp
= make_conf();
1048 yy_tmp
->status
= CONF_CLIENT
;
1053 if((p
= strchr(data
, '@')))
1057 yy_tmp
->user
= rb_strdup(data
);
1058 yy_tmp
->host
= rb_strdup(p
);
1062 yy_tmp
->user
= rb_strdup("*");
1063 yy_tmp
->host
= rb_strdup(data
);
1066 if(yy_aconf
!= yy_tmp
)
1067 rb_dlinkAddAlloc(yy_tmp
, &yy_aconf_list
);
1071 conf_set_auth_auth_user(void *data
)
1073 if(yy_aconf
->spasswd
)
1074 memset(yy_aconf
->spasswd
, 0, strlen(yy_aconf
->spasswd
));
1075 rb_free(yy_aconf
->spasswd
);
1076 yy_aconf
->spasswd
= rb_strdup(data
);
1080 conf_set_auth_passwd(void *data
)
1082 if(yy_aconf
->passwd
)
1083 memset(yy_aconf
->passwd
, 0, strlen(yy_aconf
->passwd
));
1084 rb_free(yy_aconf
->passwd
);
1085 yy_aconf
->passwd
= rb_strdup(data
);
1089 conf_set_auth_spoof(void *data
)
1097 /* user@host spoof */
1098 if((p
= strchr(host
, '@')) != NULL
)
1104 if(EmptyString(user
))
1106 conf_report_error("Warning -- spoof ident empty.");
1110 if(strlen(user
) > USERLEN
)
1112 conf_report_error("Warning -- spoof ident length invalid.");
1116 if(!valid_username(user
))
1118 conf_report_error("Warning -- invalid spoof (ident).");
1122 /* this must be restored! */
1126 if(EmptyString(host
))
1128 conf_report_error("Warning -- spoof host empty.");
1132 if(strlen(host
) > HOSTLEN
)
1134 conf_report_error("Warning -- spoof host length invalid.");
1138 if(!valid_hostname(host
))
1140 conf_report_error("Warning -- invalid spoof (host).");
1144 rb_free(yy_aconf
->info
.name
);
1145 yy_aconf
->info
.name
= rb_strdup(data
);
1146 yy_aconf
->flags
|= CONF_FLAGS_SPOOF_IP
;
1150 conf_set_auth_flags(void *data
)
1152 conf_parm_t
*args
= data
;
1154 set_modes_from_table((int *) &yy_aconf
->flags
, "flag", auth_table
, args
);
1158 conf_set_auth_redir_serv(void *data
)
1160 yy_aconf
->flags
|= CONF_FLAGS_REDIR
;
1161 rb_free(yy_aconf
->info
.name
);
1162 yy_aconf
->info
.name
= rb_strdup(data
);
1166 conf_set_auth_redir_port(void *data
)
1168 int port
= *(unsigned int *) data
;
1170 yy_aconf
->flags
|= CONF_FLAGS_REDIR
;
1171 yy_aconf
->port
= port
;
1175 conf_set_auth_class(void *data
)
1177 rb_free(yy_aconf
->className
);
1178 yy_aconf
->className
= rb_strdup(data
);
1181 /* ok, shared_oper handles the stacking, shared_flags handles adding
1182 * things.. so all we need to do when we start and end a shared block, is
1183 * clean up anything thats been left over.
1186 conf_cleanup_shared(struct TopConf
*tc
)
1188 rb_dlink_node
*ptr
, *next_ptr
;
1190 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, yy_shared_list
.head
)
1192 free_remote_conf(ptr
->data
);
1193 rb_dlinkDestroy(ptr
, &yy_shared_list
);
1196 if(yy_shared
!= NULL
)
1198 free_remote_conf(yy_shared
);
1206 conf_set_shared_oper(void *data
)
1208 conf_parm_t
*args
= data
;
1209 const char *username
;
1212 if(yy_shared
!= NULL
)
1213 free_remote_conf(yy_shared
);
1215 yy_shared
= make_remote_conf();
1217 if(args
->next
!= NULL
)
1219 if(CF_TYPE(args
->type
) != CF_QSTRING
)
1221 conf_report_error("Ignoring shared::oper -- server is not a qstring");
1225 yy_shared
->server
= rb_strdup(args
->v
.string
);
1229 yy_shared
->server
= rb_strdup("*");
1231 if(CF_TYPE(args
->type
) != CF_QSTRING
)
1233 conf_report_error("Ignoring shared::oper -- oper is not a qstring");
1237 if((p
= strchr(args
->v
.string
, '@')) == NULL
)
1239 conf_report_error("Ignoring shard::oper -- oper is not a user@host");
1243 username
= args
->v
.string
;
1247 yy_shared
->host
= rb_strdup("*");
1249 yy_shared
->host
= rb_strdup(p
);
1251 if(EmptyString(username
))
1252 yy_shared
->username
= rb_strdup("*");
1254 yy_shared
->username
= rb_strdup(username
);
1256 rb_dlinkAddAlloc(yy_shared
, &yy_shared_list
);
1261 conf_set_shared_flags(void *data
)
1263 conf_parm_t
*args
= data
;
1265 rb_dlink_node
*ptr
, *next_ptr
;
1267 if(yy_shared
!= NULL
)
1268 free_remote_conf(yy_shared
);
1270 set_modes_from_table(&flags
, "flag", shared_table
, args
);
1272 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, yy_shared_list
.head
)
1274 yy_shared
= ptr
->data
;
1276 yy_shared
->flags
= flags
;
1277 rb_dlinkDestroy(ptr
, &yy_shared_list
);
1278 rb_dlinkAddTail(yy_shared
, &yy_shared
->node
, &shared_conf_list
);
1285 conf_begin_connect(struct TopConf
*tc
)
1288 free_server_conf(yy_server
);
1290 yy_server
= make_server_conf();
1291 yy_server
->port
= PORTNUM
;
1292 yy_server
->flags
|= SERVER_TB
;
1294 if(conf_cur_block_name
!= NULL
)
1295 yy_server
->name
= rb_strdup(conf_cur_block_name
);
1301 conf_end_connect(struct TopConf
*tc
)
1303 if(EmptyString(yy_server
->name
))
1305 conf_report_error("Ignoring connect block -- missing name.");
1309 if(ServerInfo
.name
!= NULL
&& !irccmp(ServerInfo
.name
, yy_server
->name
))
1311 conf_report_error("Ignoring connect block for %s -- name is equal to my own name.",
1316 if((EmptyString(yy_server
->passwd
) || EmptyString(yy_server
->spasswd
)) && EmptyString(yy_server
->certfp
))
1318 conf_report_error("Ignoring connect block for %s -- no fingerprint or password credentials provided.",
1323 if((yy_server
->flags
& SERVER_SSL
) && EmptyString(yy_server
->certfp
))
1325 conf_report_error("Ignoring connect block for %s -- no fingerprint provided for SSL connection.",
1330 if(EmptyString(yy_server
->connect_host
)
1331 && GET_SS_FAMILY(&yy_server
->connect4
) != AF_INET
1332 && GET_SS_FAMILY(&yy_server
->connect6
) != AF_INET6
1335 conf_report_error("Ignoring connect block for %s -- missing host.",
1341 if(ServerConfCompressed(yy_server
))
1343 conf_report_error("Ignoring connect::flags::compressed -- zlib not available.");
1344 yy_server
->flags
&= ~SERVER_COMPRESSED
;
1348 add_server_conf(yy_server
);
1349 rb_dlinkAdd(yy_server
, &yy_server
->node
, &server_conf_list
);
1356 conf_set_connect_host(void *data
)
1358 struct rb_sockaddr_storage addr
;
1360 if(rb_inet_pton_sock(data
, &addr
) <= 0)
1362 rb_free(yy_server
->connect_host
);
1363 yy_server
->connect_host
= rb_strdup(data
);
1365 else if(GET_SS_FAMILY(&addr
) == AF_INET
)
1367 yy_server
->connect4
= addr
;
1369 else if(GET_SS_FAMILY(&addr
) == AF_INET6
)
1371 yy_server
->connect6
= addr
;
1375 conf_report_error("Unsupported IP address for server connect host (%s)",
1382 conf_set_connect_vhost(void *data
)
1384 struct rb_sockaddr_storage addr
;
1386 if(rb_inet_pton_sock(data
, &addr
) <= 0)
1388 rb_free(yy_server
->bind_host
);
1389 yy_server
->bind_host
= rb_strdup(data
);
1391 else if(GET_SS_FAMILY(&addr
) == AF_INET
)
1393 yy_server
->bind4
= addr
;
1395 else if(GET_SS_FAMILY(&addr
) == AF_INET6
)
1397 yy_server
->bind6
= addr
;
1401 conf_report_error("Unsupported IP address for server connect vhost (%s)",
1408 conf_set_connect_send_password(void *data
)
1410 if(yy_server
->spasswd
)
1412 memset(yy_server
->spasswd
, 0, strlen(yy_server
->spasswd
));
1413 rb_free(yy_server
->spasswd
);
1416 yy_server
->spasswd
= rb_strdup(data
);
1420 conf_set_connect_accept_password(void *data
)
1422 if(yy_server
->passwd
)
1424 memset(yy_server
->passwd
, 0, strlen(yy_server
->passwd
));
1425 rb_free(yy_server
->passwd
);
1427 yy_server
->passwd
= rb_strdup(data
);
1431 conf_set_connect_fingerprint(void *data
)
1433 if (yy_server
->certfp
)
1434 rb_free(yy_server
->certfp
);
1435 yy_server
->certfp
= rb_strdup((char *) data
);
1437 /* force SSL to be enabled if fingerprint is enabled. */
1438 yy_server
->flags
|= SERVER_SSL
;
1442 conf_set_connect_port(void *data
)
1444 int port
= *(unsigned int *) data
;
1449 yy_server
->port
= port
;
1453 conf_set_connect_aftype(void *data
)
1457 if(rb_strcasecmp(aft
, "ipv4") == 0)
1458 yy_server
->aftype
= AF_INET
;
1459 else if(rb_strcasecmp(aft
, "ipv6") == 0)
1460 yy_server
->aftype
= AF_INET6
;
1462 conf_report_error("connect::aftype '%s' is unknown.", aft
);
1466 conf_set_connect_flags(void *data
)
1468 conf_parm_t
*args
= data
;
1470 /* note, we allow them to set compressed, then remove it later if
1471 * they do and LIBZ isnt available
1473 set_modes_from_table(&yy_server
->flags
, "flag", connect_table
, args
);
1477 conf_set_connect_hub_mask(void *data
)
1479 struct remote_conf
*yy_hub
;
1481 if(EmptyString(yy_server
->name
))
1484 yy_hub
= make_remote_conf();
1485 yy_hub
->flags
= CONF_HUB
;
1487 yy_hub
->host
= rb_strdup(data
);
1488 yy_hub
->server
= rb_strdup(yy_server
->name
);
1489 rb_dlinkAdd(yy_hub
, &yy_hub
->node
, &hubleaf_conf_list
);
1493 conf_set_connect_leaf_mask(void *data
)
1495 struct remote_conf
*yy_leaf
;
1497 if(EmptyString(yy_server
->name
))
1500 yy_leaf
= make_remote_conf();
1501 yy_leaf
->flags
= CONF_LEAF
;
1503 yy_leaf
->host
= rb_strdup(data
);
1504 yy_leaf
->server
= rb_strdup(yy_server
->name
);
1505 rb_dlinkAdd(yy_leaf
, &yy_leaf
->node
, &hubleaf_conf_list
);
1509 conf_set_connect_class(void *data
)
1511 rb_free(yy_server
->class_name
);
1512 yy_server
->class_name
= rb_strdup(data
);
1516 conf_set_exempt_ip(void *data
)
1518 struct ConfItem
*yy_tmp
;
1520 if(parse_netmask(data
, NULL
, NULL
) == HM_HOST
)
1522 conf_report_error("Ignoring exempt -- invalid exempt::ip.");
1526 yy_tmp
= make_conf();
1527 yy_tmp
->passwd
= rb_strdup("*");
1528 yy_tmp
->host
= rb_strdup(data
);
1529 yy_tmp
->status
= CONF_EXEMPTDLINE
;
1530 add_conf_by_address(yy_tmp
->host
, CONF_EXEMPTDLINE
, NULL
, NULL
, yy_tmp
);
1534 conf_cleanup_cluster(struct TopConf
*tc
)
1536 rb_dlink_node
*ptr
, *next_ptr
;
1538 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, yy_cluster_list
.head
)
1540 free_remote_conf(ptr
->data
);
1541 rb_dlinkDestroy(ptr
, &yy_cluster_list
);
1544 if(yy_shared
!= NULL
)
1546 free_remote_conf(yy_shared
);
1554 conf_set_cluster_name(void *data
)
1556 if(yy_shared
!= NULL
)
1557 free_remote_conf(yy_shared
);
1559 yy_shared
= make_remote_conf();
1560 yy_shared
->server
= rb_strdup(data
);
1561 rb_dlinkAddAlloc(yy_shared
, &yy_cluster_list
);
1567 conf_set_cluster_flags(void *data
)
1569 conf_parm_t
*args
= data
;
1571 rb_dlink_node
*ptr
, *next_ptr
;
1573 if(yy_shared
!= NULL
)
1574 free_remote_conf(yy_shared
);
1576 set_modes_from_table(&flags
, "flag", cluster_table
, args
);
1578 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, yy_cluster_list
.head
)
1580 yy_shared
= ptr
->data
;
1581 yy_shared
->flags
= flags
;
1582 rb_dlinkAddTail(yy_shared
, &yy_shared
->node
, &cluster_conf_list
);
1583 rb_dlinkDestroy(ptr
, &yy_cluster_list
);
1590 conf_set_general_havent_read_conf(void *data
)
1592 if(*(unsigned int *) data
)
1594 conf_report_error("You haven't read your config file properly.");
1596 ("There is a line in the example conf that will kill your server if not removed.");
1598 ("Consider actually reading/editing the conf file, and removing this line.");
1605 conf_set_general_hide_error_messages(void *data
)
1609 if(rb_strcasecmp(val
, "yes") == 0)
1610 ConfigFileEntry
.hide_error_messages
= 2;
1611 else if(rb_strcasecmp(val
, "opers") == 0)
1612 ConfigFileEntry
.hide_error_messages
= 1;
1613 else if(rb_strcasecmp(val
, "no") == 0)
1614 ConfigFileEntry
.hide_error_messages
= 0;
1616 conf_report_error("Invalid setting '%s' for general::hide_error_messages.", val
);
1620 conf_set_general_stats_k_oper_only(void *data
)
1624 if(rb_strcasecmp(val
, "yes") == 0)
1625 ConfigFileEntry
.stats_k_oper_only
= 2;
1626 else if(rb_strcasecmp(val
, "masked") == 0)
1627 ConfigFileEntry
.stats_k_oper_only
= 1;
1628 else if(rb_strcasecmp(val
, "no") == 0)
1629 ConfigFileEntry
.stats_k_oper_only
= 0;
1631 conf_report_error("Invalid setting '%s' for general::stats_k_oper_only.", val
);
1635 conf_set_general_stats_i_oper_only(void *data
)
1639 if(rb_strcasecmp(val
, "yes") == 0)
1640 ConfigFileEntry
.stats_i_oper_only
= 2;
1641 else if(rb_strcasecmp(val
, "masked") == 0)
1642 ConfigFileEntry
.stats_i_oper_only
= 1;
1643 else if(rb_strcasecmp(val
, "no") == 0)
1644 ConfigFileEntry
.stats_i_oper_only
= 0;
1646 conf_report_error("Invalid setting '%s' for general::stats_i_oper_only.", val
);
1650 conf_set_general_compression_level(void *data
)
1653 ConfigFileEntry
.compression_level
= *(unsigned int *) data
;
1655 if((ConfigFileEntry
.compression_level
< 1) || (ConfigFileEntry
.compression_level
> 9))
1658 ("Invalid general::compression_level %d -- using default.",
1659 ConfigFileEntry
.compression_level
);
1660 ConfigFileEntry
.compression_level
= 0;
1663 conf_report_error("Ignoring general::compression_level -- zlib not available.");
1668 conf_set_general_default_umodes(void *data
)
1671 int what
= MODE_ADD
, flag
;
1673 ConfigFileEntry
.default_umodes
= 0;
1674 for (pm
= (char *) data
; *pm
; pm
++)
1685 /* don't allow +o */
1693 if ((flag
= user_modes
[(unsigned char) *pm
]))
1695 /* Proper value has probably not yet been set
1696 * so don't check oper_only_umodes -- jilles */
1697 if (what
== MODE_ADD
)
1698 ConfigFileEntry
.default_umodes
|= flag
;
1700 ConfigFileEntry
.default_umodes
&= ~flag
;
1708 conf_set_general_oper_umodes(void *data
)
1710 set_modes_from_table(&ConfigFileEntry
.oper_umodes
, "umode", umode_table
, data
);
1714 conf_set_general_certfp_method(void *data
)
1716 char *method
= data
;
1718 if (!rb_strcasecmp(method
, CERTFP_NAME_CERT_SHA1
))
1719 ConfigFileEntry
.certfp_method
= RB_SSL_CERTFP_METH_CERT_SHA1
;
1720 else if (!rb_strcasecmp(method
, CERTFP_NAME_CERT_SHA256
))
1721 ConfigFileEntry
.certfp_method
= RB_SSL_CERTFP_METH_CERT_SHA256
;
1722 else if (!rb_strcasecmp(method
, CERTFP_NAME_CERT_SHA512
))
1723 ConfigFileEntry
.certfp_method
= RB_SSL_CERTFP_METH_CERT_SHA512
;
1724 else if (!rb_strcasecmp(method
, CERTFP_NAME_SPKI_SHA256
))
1725 ConfigFileEntry
.certfp_method
= RB_SSL_CERTFP_METH_SPKI_SHA256
;
1726 else if (!rb_strcasecmp(method
, CERTFP_NAME_SPKI_SHA512
))
1727 ConfigFileEntry
.certfp_method
= RB_SSL_CERTFP_METH_SPKI_SHA512
;
1730 ConfigFileEntry
.certfp_method
= RB_SSL_CERTFP_METH_CERT_SHA1
;
1731 conf_report_error("Ignoring general::certfp_method -- bogus certfp method %s", method
);
1736 conf_set_general_oper_only_umodes(void *data
)
1738 set_modes_from_table(&ConfigFileEntry
.oper_only_umodes
, "umode", umode_table
, data
);
1742 conf_set_general_oper_snomask(void *data
)
1745 int what
= MODE_ADD
, flag
;
1747 ConfigFileEntry
.oper_snomask
= 0;
1748 for (pm
= (char *) data
; *pm
; pm
++)
1760 if ((flag
= snomask_modes
[(unsigned char) *pm
]))
1762 if (what
== MODE_ADD
)
1763 ConfigFileEntry
.oper_snomask
|= flag
;
1765 ConfigFileEntry
.oper_snomask
&= ~flag
;
1773 conf_set_serverhide_links_delay(void *data
)
1775 int val
= *(unsigned int *) data
;
1777 ConfigServerHide
.links_delay
= val
;
1781 conf_set_service_name(void *data
)
1787 for(s
= data
; *s
!= '\0'; s
++)
1791 conf_report_error("Ignoring service::name "
1792 "-- bogus servername.");
1801 conf_report_error("Ignoring service::name -- must contain '.'");
1805 tmp
= rb_strdup(data
);
1806 rb_dlinkAddAlloc(tmp
, &service_list
);
1810 conf_begin_alias(struct TopConf
*tc
)
1812 yy_alias
= rb_malloc(sizeof(struct alias_entry
));
1814 if (conf_cur_block_name
!= NULL
)
1815 yy_alias
->name
= rb_strdup(conf_cur_block_name
);
1817 yy_alias
->flags
= 0;
1823 conf_end_alias(struct TopConf
*tc
)
1825 if (yy_alias
== NULL
)
1828 if (yy_alias
->name
== NULL
)
1830 conf_report_error("Ignoring alias -- must have a name.");
1837 if (yy_alias
->target
== NULL
)
1839 conf_report_error("Ignoring alias -- must have a target.");
1846 rb_dictionary_add(alias_dict
, yy_alias
->name
, yy_alias
);
1852 conf_set_alias_name(void *data
)
1854 if (data
== NULL
|| yy_alias
== NULL
) /* this shouldn't ever happen */
1857 yy_alias
->name
= rb_strdup(data
);
1861 conf_set_alias_target(void *data
)
1863 if (data
== NULL
|| yy_alias
== NULL
) /* this shouldn't ever happen */
1866 yy_alias
->target
= rb_strdup(data
);
1870 conf_set_channel_autochanmodes(void *data
)
1873 int what
= MODE_ADD
;
1875 ConfigChannel
.autochanmodes
= 0;
1876 for (pm
= (char *) data
; *pm
; pm
++)
1888 if (chmode_table
[(unsigned char) *pm
].set_func
== chm_simple
)
1890 if (what
== MODE_ADD
)
1891 ConfigChannel
.autochanmodes
|= chmode_table
[(unsigned char) *pm
].mode_type
;
1893 ConfigChannel
.autochanmodes
&= ~chmode_table
[(unsigned char) *pm
].mode_type
;
1897 conf_report_error("channel::autochanmodes -- Invalid channel mode %c", *pm
);
1906 static void conf_set_blacklist_reason(void *data
);
1908 #define IPTYPE_IPV4 1
1909 #define IPTYPE_IPV6 2
1912 conf_set_blacklist_host(void *data
)
1914 if (yy_blacklist_host
)
1916 conf_report_error("blacklist::host %s overlaps existing host %s",
1917 (char *)data
, yy_blacklist_host
);
1920 conf_set_blacklist_reason(NULL
);
1924 yy_blacklist_iptype
|= IPTYPE_IPV4
;
1925 yy_blacklist_host
= rb_strdup(data
);
1929 conf_set_blacklist_type(void *data
)
1931 conf_parm_t
*args
= data
;
1933 /* Don't assume we have either if we got here */
1934 yy_blacklist_iptype
= 0;
1936 for (; args
; args
= args
->next
)
1938 if (!rb_strcasecmp(args
->v
.string
, "ipv4"))
1939 yy_blacklist_iptype
|= IPTYPE_IPV4
;
1940 else if (!rb_strcasecmp(args
->v
.string
, "ipv6"))
1941 yy_blacklist_iptype
|= IPTYPE_IPV6
;
1943 conf_report_error("blacklist::type has unknown address family %s",
1947 /* If we have neither, just default to IPv4 */
1948 if (!yy_blacklist_iptype
)
1950 conf_report_warning("blacklist::type has neither IPv4 nor IPv6 (defaulting to IPv4)");
1951 yy_blacklist_iptype
= IPTYPE_IPV4
;
1956 conf_set_blacklist_matches(void *data
)
1958 conf_parm_t
*args
= data
;
1959 enum filter_t
{ FILTER_NONE
, FILTER_ALL
, FILTER_LAST
};
1961 for (; args
; args
= args
->next
)
1963 char *str
= args
->v
.string
;
1965 enum filter_t type
= FILTER_LAST
;
1967 if (CF_TYPE(args
->type
) != CF_QSTRING
)
1969 conf_report_error("blacklist::matches -- must be quoted string");
1975 conf_report_error("blacklist::matches -- invalid entry");
1979 if (strlen(str
) > HOSTIPLEN
)
1981 conf_report_error("blacklist::matches has an entry too long: %s",
1986 for (p
= str
; *p
!= '\0'; p
++)
1988 /* Check for validity */
1991 else if (!isdigit((unsigned char)*p
))
1993 conf_report_error("blacklist::matches has invalid IP match entry %s",
2000 if (type
== FILTER_ALL
)
2002 /* Basic IP sanity check */
2003 struct rb_sockaddr_storage tmp
;
2004 if (rb_inet_pton(AF_INET
, str
, &tmp
) <= 0)
2006 conf_report_error("blacklist::matches has invalid IP match entry %s",
2011 else if (type
== FILTER_LAST
)
2013 /* Verify it's the correct length */
2014 if (strlen(str
) > 3)
2016 conf_report_error("blacklist::matches has invalid octet match entry %s",
2023 continue; /* Invalid entry */
2026 rb_dlinkAddAlloc(rb_strdup(str
), &yy_blacklist_filters
);
2031 conf_set_blacklist_reason(void *data
)
2033 rb_dlink_node
*ptr
, *nptr
;
2035 if (yy_blacklist_host
&& data
)
2037 yy_blacklist_reason
= rb_strdup(data
);
2038 if (yy_blacklist_iptype
& IPTYPE_IPV6
)
2040 /* Make sure things fit (magic number 64 = alnum count + dots)
2041 * 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
2043 if ((64 + strlen(yy_blacklist_host
)) > IRCD_RES_HOSTLEN
)
2045 conf_report_error("blacklist::host %s results in IPv6 queries that are too long",
2050 /* Avoid doing redundant check, IPv6 is bigger than IPv4 --Elizabeth */
2051 if ((yy_blacklist_iptype
& IPTYPE_IPV4
) && !(yy_blacklist_iptype
& IPTYPE_IPV6
))
2053 /* Make sure things fit for worst case (magic number 16 = number of nums + dots)
2054 * Example: 127.127.127.127.in-addr.arpa
2056 if ((16 + strlen(yy_blacklist_host
)) > IRCD_RES_HOSTLEN
)
2058 conf_report_error("blacklist::host %s results in IPv4 queries that are too long",
2064 add_blacklist(yy_blacklist_host
, yy_blacklist_reason
, yy_blacklist_iptype
, &yy_blacklist_filters
);
2068 RB_DLINK_FOREACH_SAFE(ptr
, nptr
, yy_blacklist_filters
.head
)
2071 rb_dlinkDestroy(ptr
, &yy_blacklist_filters
);
2074 yy_blacklist_filters
= (rb_dlink_list
){ NULL
, NULL
, 0 };
2076 rb_free(yy_blacklist_host
);
2077 rb_free(yy_blacklist_reason
);
2078 yy_blacklist_host
= NULL
;
2079 yy_blacklist_reason
= NULL
;
2080 yy_blacklist_iptype
= 0;
2093 conf_begin_opm(struct TopConf
*tc
)
2095 yy_opm_address_ipv4
= yy_opm_address_ipv6
= NULL
;
2096 yy_opm_port_ipv4
= yy_opm_port_ipv6
= yy_opm_timeout
= 0;
2097 delete_opm_proxy_scanner_all();
2098 delete_opm_listener_all();
2103 conf_end_opm(struct TopConf
*tc
)
2105 rb_dlink_node
*ptr
, *nptr
;
2108 if(rb_dlink_list_length(&yy_opm_scanner_list
) == 0)
2110 conf_report_error("No opm scanners configured -- disabling opm.");
2115 if(yy_opm_port_ipv4
> 0)
2117 if(yy_opm_address_ipv4
!= NULL
)
2118 conf_create_opm_listener(yy_opm_address_ipv4
, yy_opm_port_ipv4
);
2122 if(!rb_inet_ntop_sock((struct sockaddr
*)&ServerInfo
.bind4
, ip
, sizeof(ip
)))
2123 conf_report_error("No opm::listen_ipv4 nor serverinfo::vhost directive; cannot listen on IPv4");
2125 conf_create_opm_listener(ip
, yy_opm_port_ipv4
);
2129 if(yy_opm_port_ipv6
> 0)
2131 if(yy_opm_address_ipv6
!= NULL
)
2132 conf_create_opm_listener(yy_opm_address_ipv6
, yy_opm_port_ipv6
);
2136 if(!rb_inet_ntop_sock((struct sockaddr
*)&ServerInfo
.bind6
, ip
, sizeof(ip
)))
2137 conf_report_error("No opm::listen_ipv6 nor serverinfo::vhost directive; cannot listen on IPv6");
2139 conf_create_opm_listener(ip
, yy_opm_port_ipv6
);
2143 /* If there's no listeners... */
2144 fail
= (yy_opm_port_ipv4
== 0 || yy_opm_port_ipv6
== 0);
2145 if(!fail
&& yy_opm_timeout
> 0 && yy_opm_timeout
< 60)
2147 set_authd_timeout("opm_timeout", yy_opm_timeout
);
2149 conf_report_error("No opm listeners -- disabling");
2150 else if(yy_opm_timeout
<= 0 || yy_opm_timeout
>= 60)
2151 conf_report_error("opm::timeout value is invalid -- ignoring");
2154 RB_DLINK_FOREACH_SAFE(ptr
, nptr
, yy_opm_scanner_list
.head
)
2156 struct opm_scanner
*scanner
= ptr
->data
;
2159 create_opm_proxy_scanner(scanner
->type
, scanner
->port
);
2161 rb_dlinkDelete(&scanner
->node
, &yy_opm_scanner_list
);
2166 opm_check_enable(true);
2168 rb_free(yy_opm_address_ipv4
);
2169 rb_free(yy_opm_address_ipv6
);
2174 conf_set_opm_timeout(void *data
)
2176 int timeout
= *((int *)data
);
2178 if(timeout
<= 0 || timeout
> 60)
2180 conf_report_error("opm::timeout value %d is bogus, ignoring", timeout
);
2184 yy_opm_timeout
= timeout
;
2188 conf_set_opm_listen_address_both(void *data
, bool ipv6
)
2190 struct rb_sockaddr_storage addr
;
2191 const char *confstr
= (ipv6
? "opm::listen_ipv6" : "opm::listen_ipv4");
2194 if(!rb_inet_pton_sock(ip
, &addr
))
2196 conf_report_error("%s is an invalid address: %s", confstr
, ip
);
2202 if(GET_SS_FAMILY(&addr
) != AF_INET6
)
2204 conf_report_error("%s is of the wrong address type: %s", confstr
, ip
);
2208 if(yy_opm_address_ipv6
!= NULL
)
2210 conf_report_error("%s overwrites previous address %s", confstr
, ip
);
2214 yy_opm_address_ipv6
= rb_strdup(ip
);
2218 if(GET_SS_FAMILY(&addr
) != AF_INET
)
2220 conf_report_error("%s is of the wrong address type: %s", confstr
, ip
);
2224 if(yy_opm_address_ipv4
!= NULL
)
2226 conf_report_error("%s overwrites previous address %s", confstr
, ip
);
2230 yy_opm_address_ipv4
= rb_strdup(ip
);
2235 conf_set_opm_listen_address_ipv4(void *data
)
2237 conf_set_opm_listen_address_both(data
, false);
2241 conf_set_opm_listen_address_ipv6(void *data
)
2243 conf_set_opm_listen_address_both(data
, true);
2247 conf_set_opm_listen_port_both(void *data
, bool ipv6
)
2249 int port
= *((int *)data
);
2250 const char *confstr
= (ipv6
? "opm::port_ipv6" : "opm::port_ipv4");
2252 if(port
> 65535 || port
<= 0)
2254 conf_report_error("%s is out of range: %d", confstr
, port
);
2260 if(yy_opm_port_ipv4
)
2262 conf_report_error("%s overwrites existing port %hu",
2263 confstr
, yy_opm_port_ipv4
);
2267 yy_opm_port_ipv4
= port
;
2271 if(yy_opm_port_ipv6
)
2273 conf_report_error("%s overwrites existing port %hu",
2274 confstr
, yy_opm_port_ipv6
);
2278 yy_opm_port_ipv6
= port
;
2283 conf_set_opm_listen_port_ipv4(void *data
)
2285 conf_set_opm_listen_port_both(data
, false);
2289 conf_set_opm_listen_port_ipv6(void *data
)
2291 conf_set_opm_listen_port_both(data
, true);
2295 conf_set_opm_listen_port(void *data
)
2297 conf_set_opm_listen_port_both(data
, true);
2298 conf_set_opm_listen_port_both(data
, false);
2302 conf_set_opm_scan_ports_all(void *data
, const char *node
, const char *type
)
2304 conf_parm_t
*args
= data
;
2305 for (; args
; args
= args
->next
)
2310 if(CF_TYPE(args
->type
) != CF_INT
)
2312 conf_report_error("%s argument is not an integer -- ignoring.", node
);
2316 if(args
->v
.number
> 65535 || args
->v
.number
<= 0)
2318 conf_report_error("%s argument is not an integer between 1 and 65535 -- ignoring.", node
);
2322 /* Check for duplicates */
2323 RB_DLINK_FOREACH(ptr
, yy_opm_scanner_list
.head
)
2325 struct opm_scanner
*scanner
= ptr
->data
;
2327 if(scanner
->port
== args
->v
.number
&& strcmp(type
, scanner
->type
) == 0)
2329 conf_report_error("%s argument is duplicate", node
);
2337 struct opm_scanner
*scanner
= rb_malloc(sizeof(struct opm_scanner
));
2338 scanner
->port
= args
->v
.number
;
2339 scanner
->type
= type
;
2340 rb_dlinkAdd(scanner
, &scanner
->node
, &yy_opm_scanner_list
);
2346 conf_set_opm_scan_ports_socks4(void *data
)
2348 conf_set_opm_scan_ports_all(data
, "opm::socks4_ports", "socks4");
2352 conf_set_opm_scan_ports_socks5(void *data
)
2354 conf_set_opm_scan_ports_all(data
, "opm::socks5_ports", "socks5");
2358 conf_set_opm_scan_ports_httpconnect(void *data
)
2360 conf_set_opm_scan_ports_all(data
, "opm::httpconnect_ports", "httpconnect");
2364 conf_set_opm_scan_ports_httpsconnect(void *data
)
2366 conf_set_opm_scan_ports_all(data
, "opm::httpsconnect_ports", "httpsconnect");
2369 /* public functions */
2373 conf_report_error(const char *fmt
, ...)
2376 char msg
[BUFSIZE
+ 1] = { 0 };
2379 vsnprintf(msg
, BUFSIZE
, fmt
, ap
);
2384 fprintf(stderr
, "\"%s\", line %d: %s\n", current_file
, lineno
+ 1, msg
);
2388 ierror("\"%s\", line %d: %s", current_file
, lineno
+ 1, msg
);
2389 sendto_realops_snomask(SNO_GENERAL
, L_ALL
, "error: \"%s\", line %d: %s", current_file
, lineno
+ 1, msg
);
2393 conf_report_warning(const char *fmt
, ...)
2396 char msg
[BUFSIZE
+ 1] = { 0 };
2399 vsnprintf(msg
, BUFSIZE
, fmt
, ap
);
2404 fprintf(stderr
, "\"%s\", line %d: %s\n", current_file
, lineno
+ 1, msg
);
2408 iwarn("\"%s\", line %d: %s", current_file
, lineno
+ 1, msg
);
2409 sendto_realops_snomask(SNO_GENERAL
, L_ALL
, "warning: \"%s\", line %d: %s", current_file
, lineno
+ 1, msg
);
2413 conf_start_block(char *block
, char *name
)
2415 if((conf_cur_block
= find_top_conf(block
)) == NULL
)
2417 conf_report_error("Configuration block '%s' is not defined.", block
);
2422 conf_cur_block_name
= rb_strdup(name
);
2424 conf_cur_block_name
= NULL
;
2426 if(conf_cur_block
->tc_sfunc
)
2427 if(conf_cur_block
->tc_sfunc(conf_cur_block
) < 0)
2434 conf_end_block(struct TopConf
*tc
)
2438 ret
= tc
->tc_efunc(tc
);
2440 rb_free(conf_cur_block_name
);
2441 conf_cur_block_name
= NULL
;
2446 conf_set_generic_int(void *data
, void *location
)
2448 *((int *) location
) = *((unsigned int *) data
);
2452 conf_set_generic_string(void *data
, int len
, void *location
)
2454 char **loc
= location
;
2457 if(len
&& strlen(input
) > (unsigned int)len
)
2461 *loc
= rb_strdup(input
);
2465 conf_call_set(struct TopConf
*tc
, char *item
, conf_parm_t
* value
)
2467 struct ConfEntry
*cf
;
2473 if((cf
= find_conf_item(tc
, item
)) == NULL
)
2476 ("Non-existent configuration setting %s::%s.", tc
->tc_name
, (char *) item
);
2480 /* if it takes one thing, make sure they only passed one thing,
2481 and handle as needed. */
2482 if((value
->v
.list
->type
& CF_FLIST
) && !(cf
->cf_type
& CF_FLIST
))
2485 ("Option %s::%s does not take a list of values.", tc
->tc_name
, item
);
2492 if(CF_TYPE(value
->v
.list
->type
) != CF_TYPE(cf
->cf_type
))
2494 /* if it expects a string value, but we got a yesno,
2497 if((CF_TYPE(value
->v
.list
->type
) == CF_YESNO
) &&
2498 (CF_TYPE(cf
->cf_type
) == CF_STRING
))
2500 value
->v
.list
->type
= CF_STRING
;
2502 if(cp
->v
.number
== 1)
2503 cp
->v
.string
= rb_strdup("yes");
2505 cp
->v
.string
= rb_strdup("no");
2508 /* maybe it's a CF_TIME and they passed CF_INT --
2509 should still be valid */
2510 else if(!((CF_TYPE(value
->v
.list
->type
) == CF_INT
) &&
2511 (CF_TYPE(cf
->cf_type
) == CF_TIME
)))
2514 ("Wrong type for %s::%s (expected %s, got %s)",
2515 tc
->tc_name
, (char *) item
,
2516 conf_strtype(cf
->cf_type
), conf_strtype(value
->v
.list
->type
));
2521 if(cf
->cf_type
& CF_FLIST
)
2525 conf_set_generic_list(value
->v
.list
, cf
->cf_arg
);
2528 /* just pass it the extended argument list */
2529 cf
->cf_func(value
->v
.list
);
2533 /* it's old-style, needs only one arg */
2534 switch (cf
->cf_type
)
2540 conf_set_generic_int(&cp
->v
.number
, cf
->cf_arg
);
2542 cf
->cf_func(&cp
->v
.number
);
2546 if(EmptyString(cp
->v
.string
))
2547 conf_report_error("Ignoring %s::%s -- empty field",
2550 conf_set_generic_string(cp
->v
.string
, cf
->cf_len
, cf
->cf_arg
);
2552 cf
->cf_func(cp
->v
.string
);
2562 add_conf_item(const char *topconf
, const char *name
, int type
, void (*func
) (void *))
2565 struct ConfEntry
*cf
;
2567 if((tc
= find_top_conf(topconf
)) == NULL
)
2570 if(find_conf_item(tc
, name
) != NULL
)
2573 cf
= rb_malloc(sizeof(struct ConfEntry
));
2580 rb_dlinkAddAlloc(cf
, &tc
->tc_items
);
2586 remove_conf_item(const char *topconf
, const char *name
)
2589 struct ConfEntry
*cf
;
2592 if((tc
= find_top_conf(topconf
)) == NULL
)
2595 if((cf
= find_conf_item(tc
, name
)) == NULL
)
2598 if((ptr
= rb_dlinkFind(cf
, &tc
->tc_items
)) == NULL
)
2601 rb_dlinkDestroy(ptr
, &tc
->tc_items
);
2608 static struct ConfEntry conf_serverinfo_table
[] =
2610 { "description", CF_QSTRING
, NULL
, 0, &ServerInfo
.description
},
2612 { "network_name", CF_QSTRING
, conf_set_serverinfo_network_name
, 0, NULL
},
2613 { "name", CF_QSTRING
, conf_set_serverinfo_name
, 0, NULL
},
2614 { "sid", CF_QSTRING
, conf_set_serverinfo_sid
, 0, NULL
},
2615 { "vhost", CF_QSTRING
, conf_set_serverinfo_vhost
, 0, NULL
},
2616 { "vhost6", CF_QSTRING
, conf_set_serverinfo_vhost6
, 0, NULL
},
2618 { "ssl_private_key", CF_QSTRING
, NULL
, 0, &ServerInfo
.ssl_private_key
},
2619 { "ssl_ca_cert", CF_QSTRING
, NULL
, 0, &ServerInfo
.ssl_ca_cert
},
2620 { "ssl_cert", CF_QSTRING
, NULL
, 0, &ServerInfo
.ssl_cert
},
2621 { "ssl_dh_params", CF_QSTRING
, NULL
, 0, &ServerInfo
.ssl_dh_params
},
2622 { "ssl_cipher_list", CF_QSTRING
, NULL
, 0, &ServerInfo
.ssl_cipher_list
},
2623 { "ssld_count", CF_INT
, NULL
, 0, &ServerInfo
.ssld_count
},
2625 { "default_max_clients",CF_INT
, NULL
, 0, &ServerInfo
.default_max_clients
},
2627 { "nicklen", CF_INT
, conf_set_serverinfo_nicklen
, 0, NULL
},
2629 { "\0", 0, NULL
, 0, NULL
}
2632 static struct ConfEntry conf_admin_table
[] =
2634 { "name", CF_QSTRING
, NULL
, 200, &AdminInfo
.name
},
2635 { "description",CF_QSTRING
, NULL
, 200, &AdminInfo
.description
},
2636 { "email", CF_QSTRING
, NULL
, 200, &AdminInfo
.email
},
2637 { "\0", 0, NULL
, 0, NULL
}
2640 static struct ConfEntry conf_log_table
[] =
2642 { "fname_userlog", CF_QSTRING
, NULL
, PATH_MAX
, &ConfigFileEntry
.fname_userlog
},
2643 { "fname_fuserlog", CF_QSTRING
, NULL
, PATH_MAX
, &ConfigFileEntry
.fname_fuserlog
},
2644 { "fname_operlog", CF_QSTRING
, NULL
, PATH_MAX
, &ConfigFileEntry
.fname_operlog
},
2645 { "fname_foperlog", CF_QSTRING
, NULL
, PATH_MAX
, &ConfigFileEntry
.fname_foperlog
},
2646 { "fname_serverlog", CF_QSTRING
, NULL
, PATH_MAX
, &ConfigFileEntry
.fname_serverlog
},
2647 { "fname_killlog", CF_QSTRING
, NULL
, PATH_MAX
, &ConfigFileEntry
.fname_killlog
},
2648 { "fname_klinelog", CF_QSTRING
, NULL
, PATH_MAX
, &ConfigFileEntry
.fname_klinelog
},
2649 { "fname_operspylog", CF_QSTRING
, NULL
, PATH_MAX
, &ConfigFileEntry
.fname_operspylog
},
2650 { "fname_ioerrorlog", CF_QSTRING
, NULL
, PATH_MAX
, &ConfigFileEntry
.fname_ioerrorlog
},
2651 { "\0", 0, NULL
, 0, NULL
}
2654 static struct ConfEntry conf_operator_table
[] =
2656 { "rsa_public_key_file", CF_QSTRING
, conf_set_oper_rsa_public_key_file
, 0, NULL
},
2657 { "flags", CF_STRING
| CF_FLIST
, conf_set_oper_flags
, 0, NULL
},
2658 { "umodes", CF_STRING
| CF_FLIST
, conf_set_oper_umodes
, 0, NULL
},
2659 { "privset", CF_QSTRING
, conf_set_oper_privset
, 0, NULL
},
2660 { "snomask", CF_QSTRING
, conf_set_oper_snomask
, 0, NULL
},
2661 { "user", CF_QSTRING
, conf_set_oper_user
, 0, NULL
},
2662 { "password", CF_QSTRING
, conf_set_oper_password
, 0, NULL
},
2663 { "fingerprint", CF_QSTRING
, conf_set_oper_fingerprint
, 0, NULL
},
2664 { "\0", 0, NULL
, 0, NULL
}
2667 static struct ConfEntry conf_privset_table
[] =
2669 { "extends", CF_QSTRING
, conf_set_privset_extends
, 0, NULL
},
2670 { "privs", CF_STRING
| CF_FLIST
, conf_set_privset_privs
, 0, NULL
},
2671 { "\0", 0, NULL
, 0, NULL
}
2674 static struct ConfEntry conf_class_table
[] =
2676 { "ping_time", CF_TIME
, conf_set_class_ping_time
, 0, NULL
},
2677 { "cidr_ipv4_bitlen", CF_INT
, conf_set_class_cidr_ipv4_bitlen
, 0, NULL
},
2678 { "cidr_ipv6_bitlen", CF_INT
, conf_set_class_cidr_ipv6_bitlen
, 0, NULL
},
2679 { "number_per_cidr", CF_INT
, conf_set_class_number_per_cidr
, 0, NULL
},
2680 { "number_per_ip", CF_INT
, conf_set_class_number_per_ip
, 0, NULL
},
2681 { "number_per_ip_global", CF_INT
,conf_set_class_number_per_ip_global
, 0, NULL
},
2682 { "number_per_ident", CF_INT
, conf_set_class_number_per_ident
, 0, NULL
},
2683 { "connectfreq", CF_TIME
, conf_set_class_connectfreq
, 0, NULL
},
2684 { "max_number", CF_INT
, conf_set_class_max_number
, 0, NULL
},
2685 { "sendq", CF_TIME
, conf_set_class_sendq
, 0, NULL
},
2686 { "\0", 0, NULL
, 0, NULL
}
2689 static struct ConfEntry conf_auth_table
[] =
2691 { "user", CF_QSTRING
, conf_set_auth_user
, 0, NULL
},
2692 { "auth_user", CF_QSTRING
, conf_set_auth_auth_user
, 0, NULL
},
2693 { "password", CF_QSTRING
, conf_set_auth_passwd
, 0, NULL
},
2694 { "class", CF_QSTRING
, conf_set_auth_class
, 0, NULL
},
2695 { "spoof", CF_QSTRING
, conf_set_auth_spoof
, 0, NULL
},
2696 { "redirserv", CF_QSTRING
, conf_set_auth_redir_serv
, 0, NULL
},
2697 { "redirport", CF_INT
, conf_set_auth_redir_port
, 0, NULL
},
2698 { "flags", CF_STRING
| CF_FLIST
, conf_set_auth_flags
, 0, NULL
},
2699 { "\0", 0, NULL
, 0, NULL
}
2702 static struct ConfEntry conf_connect_table
[] =
2704 { "send_password", CF_QSTRING
, conf_set_connect_send_password
, 0, NULL
},
2705 { "accept_password", CF_QSTRING
, conf_set_connect_accept_password
, 0, NULL
},
2706 { "fingerprint", CF_QSTRING
, conf_set_connect_fingerprint
, 0, NULL
},
2707 { "flags", CF_STRING
| CF_FLIST
, conf_set_connect_flags
, 0, NULL
},
2708 { "host", CF_QSTRING
, conf_set_connect_host
, 0, NULL
},
2709 { "vhost", CF_QSTRING
, conf_set_connect_vhost
, 0, NULL
},
2710 { "port", CF_INT
, conf_set_connect_port
, 0, NULL
},
2711 { "aftype", CF_STRING
, conf_set_connect_aftype
, 0, NULL
},
2712 { "hub_mask", CF_QSTRING
, conf_set_connect_hub_mask
, 0, NULL
},
2713 { "leaf_mask", CF_QSTRING
, conf_set_connect_leaf_mask
, 0, NULL
},
2714 { "class", CF_QSTRING
, conf_set_connect_class
, 0, NULL
},
2715 { "\0", 0, NULL
, 0, NULL
}
2718 static struct ConfEntry conf_general_table
[] =
2720 { "oper_only_umodes", CF_STRING
| CF_FLIST
, conf_set_general_oper_only_umodes
, 0, NULL
},
2721 { "oper_umodes", CF_STRING
| CF_FLIST
, conf_set_general_oper_umodes
, 0, NULL
},
2722 { "oper_snomask", CF_QSTRING
, conf_set_general_oper_snomask
, 0, NULL
},
2723 { "compression_level", CF_INT
, conf_set_general_compression_level
, 0, NULL
},
2724 { "havent_read_conf", CF_YESNO
, conf_set_general_havent_read_conf
, 0, NULL
},
2725 { "hide_error_messages",CF_STRING
, conf_set_general_hide_error_messages
,0, NULL
},
2726 { "stats_k_oper_only", CF_STRING
, conf_set_general_stats_k_oper_only
, 0, NULL
},
2727 { "stats_i_oper_only", CF_STRING
, conf_set_general_stats_i_oper_only
, 0, NULL
},
2728 { "default_umodes", CF_QSTRING
, conf_set_general_default_umodes
, 0, NULL
},
2730 { "default_operstring", CF_QSTRING
, NULL
, REALLEN
, &ConfigFileEntry
.default_operstring
},
2731 { "default_adminstring",CF_QSTRING
, NULL
, REALLEN
, &ConfigFileEntry
.default_adminstring
},
2732 { "servicestring", CF_QSTRING
, NULL
, REALLEN
, &ConfigFileEntry
.servicestring
},
2733 { "kline_reason", CF_QSTRING
, NULL
, REALLEN
, &ConfigFileEntry
.kline_reason
},
2734 { "identify_service", CF_QSTRING
, NULL
, REALLEN
, &ConfigFileEntry
.identifyservice
},
2735 { "identify_command", CF_QSTRING
, NULL
, REALLEN
, &ConfigFileEntry
.identifycommand
},
2736 { "sasl_service", CF_QSTRING
, NULL
, REALLEN
, &ConfigFileEntry
.sasl_service
},
2738 { "anti_spam_exit_message_time", CF_TIME
, NULL
, 0, &ConfigFileEntry
.anti_spam_exit_message_time
},
2739 { "disable_fake_channels", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.disable_fake_channels
},
2740 { "min_nonwildcard_simple", CF_INT
, NULL
, 0, &ConfigFileEntry
.min_nonwildcard_simple
},
2741 { "non_redundant_klines", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.non_redundant_klines
},
2742 { "tkline_expire_notices", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.tkline_expire_notices
},
2744 { "anti_nick_flood", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.anti_nick_flood
},
2745 { "burst_away", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.burst_away
},
2746 { "caller_id_wait", CF_TIME
, NULL
, 0, &ConfigFileEntry
.caller_id_wait
},
2747 { "client_exit", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.client_exit
},
2748 { "collision_fnc", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.collision_fnc
},
2749 { "resv_fnc", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.resv_fnc
},
2750 { "connect_timeout", CF_TIME
, NULL
, 0, &ConfigFileEntry
.connect_timeout
},
2751 { "default_floodcount", CF_INT
, NULL
, 0, &ConfigFileEntry
.default_floodcount
},
2752 { "default_ident_timeout", CF_INT
, NULL
, 0, &ConfigFileEntry
.default_ident_timeout
},
2753 { "disable_auth", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.disable_auth
},
2754 { "dots_in_ident", CF_INT
, NULL
, 0, &ConfigFileEntry
.dots_in_ident
},
2755 { "failed_oper_notice", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.failed_oper_notice
},
2756 { "global_snotices", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.global_snotices
},
2757 { "hide_spoof_ips", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.hide_spoof_ips
},
2758 { "dline_with_reason", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.dline_with_reason
},
2759 { "kline_with_reason", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.kline_with_reason
},
2760 { "map_oper_only", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.map_oper_only
},
2761 { "max_accept", CF_INT
, NULL
, 0, &ConfigFileEntry
.max_accept
},
2762 { "max_monitor", CF_INT
, NULL
, 0, &ConfigFileEntry
.max_monitor
},
2763 { "max_nick_time", CF_TIME
, NULL
, 0, &ConfigFileEntry
.max_nick_time
},
2764 { "max_nick_changes", CF_INT
, NULL
, 0, &ConfigFileEntry
.max_nick_changes
},
2765 { "max_targets", CF_INT
, NULL
, 0, &ConfigFileEntry
.max_targets
},
2766 { "min_nonwildcard", CF_INT
, NULL
, 0, &ConfigFileEntry
.min_nonwildcard
},
2767 { "nick_delay", CF_TIME
, NULL
, 0, &ConfigFileEntry
.nick_delay
},
2768 { "no_oper_flood", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.no_oper_flood
},
2769 { "operspy_admin_only", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.operspy_admin_only
},
2770 { "operspy_dont_care_user_info", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.operspy_dont_care_user_info
},
2771 { "pace_wait", CF_TIME
, NULL
, 0, &ConfigFileEntry
.pace_wait
},
2772 { "pace_wait_simple", CF_TIME
, NULL
, 0, &ConfigFileEntry
.pace_wait_simple
},
2773 { "ping_cookie", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.ping_cookie
},
2774 { "reject_after_count", CF_INT
, NULL
, 0, &ConfigFileEntry
.reject_after_count
},
2775 { "reject_ban_time", CF_TIME
, NULL
, 0, &ConfigFileEntry
.reject_ban_time
},
2776 { "reject_duration", CF_TIME
, NULL
, 0, &ConfigFileEntry
.reject_duration
},
2777 { "throttle_count", CF_INT
, NULL
, 0, &ConfigFileEntry
.throttle_count
},
2778 { "throttle_duration", CF_TIME
, NULL
, 0, &ConfigFileEntry
.throttle_duration
},
2779 { "short_motd", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.short_motd
},
2780 { "stats_c_oper_only", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.stats_c_oper_only
},
2781 { "stats_e_disabled", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.stats_e_disabled
},
2782 { "stats_h_oper_only", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.stats_h_oper_only
},
2783 { "stats_o_oper_only", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.stats_o_oper_only
},
2784 { "stats_P_oper_only", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.stats_P_oper_only
},
2785 { "stats_y_oper_only", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.stats_y_oper_only
},
2786 { "target_change", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.target_change
},
2787 { "ts_max_delta", CF_TIME
, NULL
, 0, &ConfigFileEntry
.ts_max_delta
},
2788 { "ts_warn_delta", CF_TIME
, NULL
, 0, &ConfigFileEntry
.ts_warn_delta
},
2789 { "use_whois_actually", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.use_whois_actually
},
2790 { "warn_no_nline", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.warn_no_nline
},
2791 { "use_propagated_bans",CF_YESNO
, NULL
, 0, &ConfigFileEntry
.use_propagated_bans
},
2792 { "client_flood_max_lines", CF_INT
, NULL
, 0, &ConfigFileEntry
.client_flood_max_lines
},
2793 { "client_flood_burst_rate", CF_INT
, NULL
, 0, &ConfigFileEntry
.client_flood_burst_rate
},
2794 { "client_flood_burst_max", CF_INT
, NULL
, 0, &ConfigFileEntry
.client_flood_burst_max
},
2795 { "client_flood_message_num", CF_INT
, NULL
, 0, &ConfigFileEntry
.client_flood_message_num
},
2796 { "client_flood_message_time", CF_INT
, NULL
, 0, &ConfigFileEntry
.client_flood_message_time
},
2797 { "max_ratelimit_tokens", CF_INT
, NULL
, 0, &ConfigFileEntry
.max_ratelimit_tokens
},
2798 { "away_interval", CF_INT
, NULL
, 0, &ConfigFileEntry
.away_interval
},
2799 { "hide_opers_in_whois", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.hide_opers_in_whois
},
2800 { "hide_opers", CF_YESNO
, NULL
, 0, &ConfigFileEntry
.hide_opers
},
2801 { "certfp_method", CF_STRING
, conf_set_general_certfp_method
, 0, NULL
},
2802 { "drain_reason", CF_QSTRING
, NULL
, BUFSIZE
, &ConfigFileEntry
.drain_reason
},
2803 { "\0", 0, NULL
, 0, NULL
}
2806 static struct ConfEntry conf_channel_table
[] =
2808 { "default_split_user_count", CF_INT
, NULL
, 0, &ConfigChannel
.default_split_user_count
},
2809 { "default_split_server_count", CF_INT
, NULL
, 0, &ConfigChannel
.default_split_server_count
},
2810 { "burst_topicwho", CF_YESNO
, NULL
, 0, &ConfigChannel
.burst_topicwho
},
2811 { "kick_on_split_riding", CF_YESNO
, NULL
, 0, &ConfigChannel
.kick_on_split_riding
},
2812 { "knock_delay", CF_TIME
, NULL
, 0, &ConfigChannel
.knock_delay
},
2813 { "knock_delay_channel",CF_TIME
, NULL
, 0, &ConfigChannel
.knock_delay_channel
},
2814 { "max_bans", CF_INT
, NULL
, 0, &ConfigChannel
.max_bans
},
2815 { "max_bans_large", CF_INT
, NULL
, 0, &ConfigChannel
.max_bans_large
},
2816 { "max_chans_per_user", CF_INT
, NULL
, 0, &ConfigChannel
.max_chans_per_user
},
2817 { "max_chans_per_user_large", CF_INT
, NULL
, 0, &ConfigChannel
.max_chans_per_user_large
},
2818 { "no_create_on_split", CF_YESNO
, NULL
, 0, &ConfigChannel
.no_create_on_split
},
2819 { "no_join_on_split", CF_YESNO
, NULL
, 0, &ConfigChannel
.no_join_on_split
},
2820 { "only_ascii_channels", CF_YESNO
, NULL
, 0, &ConfigChannel
.only_ascii_channels
},
2821 { "use_except", CF_YESNO
, NULL
, 0, &ConfigChannel
.use_except
},
2822 { "use_invex", CF_YESNO
, NULL
, 0, &ConfigChannel
.use_invex
},
2823 { "use_forward", CF_YESNO
, NULL
, 0, &ConfigChannel
.use_forward
},
2824 { "use_knock", CF_YESNO
, NULL
, 0, &ConfigChannel
.use_knock
},
2825 { "resv_forcepart", CF_YESNO
, NULL
, 0, &ConfigChannel
.resv_forcepart
},
2826 { "channel_target_change", CF_YESNO
, NULL
, 0, &ConfigChannel
.channel_target_change
},
2827 { "disable_local_channels", CF_YESNO
, NULL
, 0, &ConfigChannel
.disable_local_channels
},
2828 { "autochanmodes", CF_QSTRING
, conf_set_channel_autochanmodes
, 0, NULL
},
2829 { "displayed_usercount", CF_INT
, NULL
, 0, &ConfigChannel
.displayed_usercount
},
2830 { "strip_topic_colors", CF_YESNO
, NULL
, 0, &ConfigChannel
.strip_topic_colors
},
2831 { "\0", 0, NULL
, 0, NULL
}
2834 static struct ConfEntry conf_serverhide_table
[] =
2836 { "disable_hidden", CF_YESNO
, NULL
, 0, &ConfigServerHide
.disable_hidden
},
2837 { "flatten_links", CF_YESNO
, NULL
, 0, &ConfigServerHide
.flatten_links
},
2838 { "hidden", CF_YESNO
, NULL
, 0, &ConfigServerHide
.hidden
},
2839 { "links_delay", CF_TIME
, conf_set_serverhide_links_delay
, 0, NULL
},
2840 { "\0", 0, NULL
, 0, NULL
}
2847 add_top_conf("modules", NULL
, NULL
, NULL
);
2848 add_conf_item("modules", "path", CF_QSTRING
, conf_set_modules_path
);
2849 add_conf_item("modules", "module", CF_QSTRING
, conf_set_modules_module
);
2851 add_top_conf("serverinfo", NULL
, NULL
, conf_serverinfo_table
);
2852 add_top_conf("admin", NULL
, NULL
, conf_admin_table
);
2853 add_top_conf("log", NULL
, NULL
, conf_log_table
);
2854 add_top_conf("operator", conf_begin_oper
, conf_end_oper
, conf_operator_table
);
2855 add_top_conf("class", conf_begin_class
, conf_end_class
, conf_class_table
);
2856 add_top_conf("privset", NULL
, NULL
, conf_privset_table
);
2858 add_top_conf("listen", conf_begin_listen
, conf_end_listen
, NULL
);
2859 add_conf_item("listen", "defer_accept", CF_YESNO
, conf_set_listen_defer_accept
);
2860 add_conf_item("listen", "wsock", CF_YESNO
, conf_set_listen_wsock
);
2861 add_conf_item("listen", "port", CF_INT
| CF_FLIST
, conf_set_listen_port
);
2862 add_conf_item("listen", "sslport", CF_INT
| CF_FLIST
, conf_set_listen_sslport
);
2863 add_conf_item("listen", "sctp_port", CF_INT
| CF_FLIST
, conf_set_listen_sctp_port
);
2864 add_conf_item("listen", "sctp_sslport", CF_INT
| CF_FLIST
, conf_set_listen_sctp_sslport
);
2865 add_conf_item("listen", "ip", CF_QSTRING
, conf_set_listen_address
);
2866 add_conf_item("listen", "host", CF_QSTRING
, conf_set_listen_address
);
2868 add_top_conf("auth", conf_begin_auth
, conf_end_auth
, conf_auth_table
);
2870 add_top_conf("shared", conf_cleanup_shared
, conf_cleanup_shared
, NULL
);
2871 add_conf_item("shared", "oper", CF_QSTRING
| CF_FLIST
, conf_set_shared_oper
);
2872 add_conf_item("shared", "flags", CF_STRING
| CF_FLIST
, conf_set_shared_flags
);
2874 add_top_conf("connect", conf_begin_connect
, conf_end_connect
, conf_connect_table
);
2876 add_top_conf("exempt", NULL
, NULL
, NULL
);
2877 add_conf_item("exempt", "ip", CF_QSTRING
, conf_set_exempt_ip
);
2879 add_top_conf("cluster", conf_cleanup_cluster
, conf_cleanup_cluster
, NULL
);
2880 add_conf_item("cluster", "name", CF_QSTRING
, conf_set_cluster_name
);
2881 add_conf_item("cluster", "flags", CF_STRING
| CF_FLIST
, conf_set_cluster_flags
);
2883 add_top_conf("general", NULL
, NULL
, conf_general_table
);
2884 add_top_conf("channel", NULL
, NULL
, conf_channel_table
);
2885 add_top_conf("serverhide", NULL
, NULL
, conf_serverhide_table
);
2887 add_top_conf("service", NULL
, NULL
, NULL
);
2888 add_conf_item("service", "name", CF_QSTRING
, conf_set_service_name
);
2890 add_top_conf("alias", conf_begin_alias
, conf_end_alias
, NULL
);
2891 add_conf_item("alias", "name", CF_QSTRING
, conf_set_alias_name
);
2892 add_conf_item("alias", "target", CF_QSTRING
, conf_set_alias_target
);
2894 add_top_conf("blacklist", NULL
, NULL
, NULL
);
2895 add_conf_item("blacklist", "host", CF_QSTRING
, conf_set_blacklist_host
);
2896 add_conf_item("blacklist", "type", CF_STRING
| CF_FLIST
, conf_set_blacklist_type
);
2897 add_conf_item("blacklist", "matches", CF_QSTRING
| CF_FLIST
, conf_set_blacklist_matches
);
2898 add_conf_item("blacklist", "reject_reason", CF_QSTRING
, conf_set_blacklist_reason
);
2900 add_top_conf("opm", conf_begin_opm
, conf_end_opm
, NULL
);
2901 add_conf_item("opm", "timeout", CF_INT
, conf_set_opm_timeout
);
2902 add_conf_item("opm", "listen_ipv4", CF_QSTRING
, conf_set_opm_listen_address_ipv4
);
2903 add_conf_item("opm", "listen_ipv6", CF_QSTRING
, conf_set_opm_listen_address_ipv6
);
2904 add_conf_item("opm", "port_v4", CF_INT
, conf_set_opm_listen_port_ipv4
);
2905 add_conf_item("opm", "port_v6", CF_INT
, conf_set_opm_listen_port_ipv6
);
2906 add_conf_item("opm", "listen_port", CF_INT
, conf_set_opm_listen_port
);
2907 add_conf_item("opm", "socks4_ports", CF_INT
| CF_FLIST
, conf_set_opm_scan_ports_socks4
);
2908 add_conf_item("opm", "socks5_ports", CF_INT
| CF_FLIST
, conf_set_opm_scan_ports_socks5
);
2909 add_conf_item("opm", "httpconnect_ports", CF_INT
| CF_FLIST
, conf_set_opm_scan_ports_httpconnect
);
2910 add_conf_item("opm", "httpsconnect_ports", CF_INT
| CF_FLIST
, conf_set_opm_scan_ports_httpsconnect
);