00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef INCLUDED_s_conf_h
00026 #define INCLUDED_s_conf_h
00027 #include "setup.h"
00028 #ifdef HAVE_LIBCRYPTO
00029 #include <openssl/rsa.h>
00030 #endif
00031 #include "fileio.h"
00032 #include "ircd_defs.h"
00033 #include "motd.h"
00034 #include "client.h"
00035 #include "hook.h"
00036 #include "pcre.h"
00037
00038 struct Client;
00039 struct DNSReply;
00040 struct hostent;
00041
00042 extern FBFILE *conf_fbfile_in;
00043 extern struct Callback *client_check_cb;
00044
00045 typedef enum
00046 {
00047 CONF_TYPE,
00048 CLASS_TYPE,
00049 OPER_TYPE,
00050 CLIENT_TYPE,
00051 SERVER_TYPE,
00052 HUB_TYPE,
00053 LEAF_TYPE,
00054 KLINE_TYPE,
00055 DLINE_TYPE,
00056 EXEMPTDLINE_TYPE,
00057 CLUSTER_TYPE,
00058 RKLINE_TYPE,
00059 RXLINE_TYPE,
00060 XLINE_TYPE,
00061 ULINE_TYPE,
00062 GLINE_TYPE,
00063 CRESV_TYPE,
00064 NRESV_TYPE,
00065 GDENY_TYPE
00066 } ConfType;
00067
00068 struct split_nuh_item
00069 {
00070 dlink_node node;
00071
00072 char *nuhmask;
00073 char *nickptr;
00074 char *userptr;
00075 char *hostptr;
00076
00077 size_t nicksize;
00078 size_t usersize;
00079 size_t hostsize;
00080 };
00081
00082 struct ConfItem
00083 {
00084 char *name;
00085 pcre *regexpname;
00086 dlink_node node;
00087 unsigned int flags;
00088 ConfType type;
00089 };
00090
00091
00092
00093
00094 struct MatchItem
00095 {
00096 char *user;
00097 char *host;
00098 char *reason;
00099 char *oper_reason;
00100 int action;
00101 int count;
00102 int ref_count;
00103 int illegal;
00104 time_t hold;
00105 };
00106
00107 struct AccessItem
00108 {
00109 dlink_node node;
00110 unsigned int status;
00111 unsigned int flags;
00112 unsigned int modes;
00113 int clients;
00114 struct irc_ssaddr my_ipnum;
00115 struct irc_ssaddr ipnum;
00116 char * host;
00117 char * passwd;
00118 char * spasswd;
00119 char * reason;
00120 char * oper_reason;
00121 char * user;
00122 int port;
00123 char * fakename;
00124 time_t hold;
00125 struct ConfItem *class_ptr;
00126 struct DNSQuery* dns_query;
00127 int aftype;
00128 #ifdef HAVE_LIBCRYPTO
00129 char * rsa_public_key_file;
00130 RSA * rsa_public_key;
00131 struct EncCapability *cipher_preference;
00132 #endif
00133 pcre *regexuser;
00134 pcre *regexhost;
00135 };
00136
00137 struct ClassItem
00138 {
00139 long max_sendq;
00140 int con_freq;
00141 int ping_freq;
00142 int ping_warning;
00143 int max_total;
00144 int max_local;
00145 int max_global;
00146 int max_ident;
00147 int max_perip;
00148 int curr_user_count;
00149 int cidr_bitlen_ipv4;
00150 int cidr_bitlen_ipv6;
00151 int number_per_cidr;
00152 dlink_list list_ipv4;
00153 dlink_list list_ipv6;
00154 int active;
00155 };
00156
00157 struct CidrItem
00158 {
00159 struct irc_ssaddr mask;
00160 int number_on_this_cidr;
00161 dlink_node node;
00162 };
00163
00164 #define ConFreq(x) ((x)->con_freq)
00165 #define PingFreq(x) ((x)->ping_freq)
00166 #define PingWarning(x) ((x)->ping_warning)
00167 #define MaxTotal(x) ((x)->max_total)
00168 #define MaxGlobal(x) ((x)->max_global)
00169 #define MaxLocal(x) ((x)->max_local)
00170 #define MaxIdent(x) ((x)->max_ident)
00171 #define MaxPerIp(x) ((x)->max_perip)
00172 #define MaxSendq(x) ((x)->max_sendq)
00173 #define CurrUserCount(x) ((x)->curr_user_count)
00174 #define CidrBitlenIPV4(x) ((x)->cidr_bitlen_ipv4)
00175 #define CidrBitlenIPV6(x) ((x)->cidr_bitlen_ipv6)
00176 #define NumberPerCidr(x) ((x)->number_per_cidr)
00177
00178 #define ClassPtr(x) ((x)->class_ptr)
00179
00180
00181 #define CONF_ILLEGAL 0x80000000
00182 #define CONF_RESERVED 0x00000001
00183 #define CONF_CLIENT 0x00000002
00184 #define CONF_SERVER 0x00000004
00185 #define CONF_OPERATOR 0x00000008
00186 #define CONF_KILL 0x00000010
00187 #define CONF_KLINE CONF_KILL
00188 #define CONF_CLASS 0x00000020
00189 #define CONF_LEAF 0x00000040
00190 #define CONF_LISTEN_PORT 0x00000080
00191 #define CONF_HUB 0x00000100
00192 #define CONF_EXEMPTKLINE 0x00000200
00193 #define CONF_NOLIMIT 0x00000400
00194 #define CONF_DLINE 0x00000800
00195 #define CONF_XLINE 0x00001000
00196 #define CONF_ULINE 0x00002000
00197 #define CONF_EXEMPTDLINE 0x00004000
00198 #define CONF_GLINE 0x00008000
00199
00200 #define CONF_SERVER_MASK CONF_SERVER
00201 #define CONF_CLIENT_MASK (CONF_CLIENT | CONF_OPERATOR | CONF_SERVER_MASK)
00202
00203
00204 #define CONF_CRESV 0x80000001
00205 #define CONF_NRESV 0x80000002
00206
00207 #define IsConfIllegal(x) ((x)->status & CONF_ILLEGAL)
00208 #define SetConfIllegal(x) ((x)->status |= CONF_ILLEGAL)
00209 #define IsConfServer(x) ((x)->status == CONF_SERVER)
00210 #define SetConfServer(x) ((x)->status = CONF_SERVER)
00211 #define IsConfOperator(x) ((x)->status & CONF_OPERATOR)
00212 #define IsConfHub(x) ((x)->status == CONF_HUB)
00213 #define SetConfHub(x) ((x)->status = CONF_HUB)
00214 #define IsConfLeaf(x) ((x)->status == CONF_LEAF)
00215 #define SetConfLeaf(x) ((x)->status = CONF_LEAF)
00216 #define IsConfHubOrLeaf(x) ((x)->status & (CONF_HUB|CONF_LEAF))
00217 #define IsConfKill(x) ((x)->status == CONF_KILL)
00218 #define IsConfClient(x) ((x)->status & CONF_CLIENT)
00219 #define IsConfTypeOfClient(x) ((x)->status & CONF_CLIENT_MASK)
00220 #define IsConfUline(x) ((x)->status & CONF_ULINE)
00221 #define IsConfXline(x) ((x)->status & CONF_XLINE)
00222 #define IsConfGline(x) ((x)->status == CONF_GLINE)
00223
00224
00225
00226
00227
00228 #define CONF_FLAGS_DO_IDENTD 0x00000001
00229 #define CONF_FLAGS_LIMIT_IP 0x00000002
00230 #define CONF_FLAGS_NO_TILDE 0x00000004
00231 #define CONF_FLAGS_NEED_IDENTD 0x00000008
00232
00233 #define CONF_FLAGS_NOMATCH_IP 0x00000020
00234 #define CONF_FLAGS_EXEMPTKLINE 0x00000040
00235 #define CONF_FLAGS_NOLIMIT 0x00000080
00236 #define CONF_FLAGS_IDLE_LINED 0x00000100
00237 #define CONF_FLAGS_SPOOF_IP 0x00000200
00238 #define CONF_FLAGS_SPOOF_NOTICE 0x00000400
00239 #define CONF_FLAGS_REDIR 0x00000800
00240 #define CONF_FLAGS_EXEMPTGLINE 0x00001000
00241 #define CONF_FLAGS_RESTRICTED 0x00002000
00242 #define CONF_FLAGS_CAN_FLOOD 0x00100000
00243 #define CONF_FLAGS_NEED_PASSWORD 0x00200000
00244
00245 #define CONF_FLAGS_ALLOW_AUTO_CONN 0x00004000
00246 #define CONF_FLAGS_LAZY_LINK 0x00008000
00247 #define CONF_FLAGS_ENCRYPTED 0x00010000
00248 #define CONF_FLAGS_COMPRESSED 0x00020000
00249 #define CONF_FLAGS_TEMPORARY 0x00040000
00250 #define CONF_FLAGS_CRYPTLINK 0x00080000
00251 #define CONF_FLAGS_BURST_AWAY 0x00400000
00252 #define CONF_FLAGS_EXEMPTRESV 0x00800000
00253 #define CONF_FLAGS_TOPICBURST 0x01000000
00254
00255
00256 #define IsLimitIp(x) ((x)->flags & CONF_FLAGS_LIMIT_IP)
00257 #define IsNoTilde(x) ((x)->flags & CONF_FLAGS_NO_TILDE)
00258 #define IsConfCanFlood(x) ((x)->flags & CONF_FLAGS_CAN_FLOOD)
00259 #define IsNeedPassword(x) ((x)->flags & CONF_FLAGS_NEED_PASSWORD)
00260 #define IsNeedIdentd(x) ((x)->flags & CONF_FLAGS_NEED_IDENTD)
00261 #define IsNoMatchIp(x) ((x)->flags & CONF_FLAGS_NOMATCH_IP)
00262 #define IsConfExemptKline(x) ((x)->flags & CONF_FLAGS_EXEMPTKLINE)
00263 #define IsConfExemptLimits(x) ((x)->flags & CONF_FLAGS_NOLIMIT)
00264 #define IsConfExemptGline(x) ((x)->flags & CONF_FLAGS_EXEMPTGLINE)
00265 #define IsConfExemptResv(x) ((x)->flags & CONF_FLAGS_EXEMPTRESV)
00266 #define IsConfIdlelined(x) ((x)->flags & CONF_FLAGS_IDLE_LINED)
00267 #define IsConfDoIdentd(x) ((x)->flags & CONF_FLAGS_DO_IDENTD)
00268 #define IsConfDoSpoofIp(x) ((x)->flags & CONF_FLAGS_SPOOF_IP)
00269 #define IsConfSpoofNotice(x) ((x)->flags & CONF_FLAGS_SPOOF_NOTICE)
00270 #define IsConfRestricted(x) ((x)->flags & CONF_FLAGS_RESTRICTED)
00271 #define IsConfEncrypted(x) ((x)->flags & CONF_FLAGS_ENCRYPTED)
00272 #define SetConfEncrypted(x) ((x)->flags |= CONF_FLAGS_ENCRYPTED)
00273 #define ClearConfEncrypted(x) ((x)->flags &= ~CONF_FLAGS_ENCRYPTED)
00274 #define IsConfCompressed(x) ((x)->flags & CONF_FLAGS_COMPRESSED)
00275 #define SetConfCompressed(x) ((x)->flags |= CONF_FLAGS_COMPRESSED)
00276 #define ClearConfCompressed(x) ((x)->flags &= ~CONF_FLAGS_COMPRESSED)
00277 #define IsConfCryptLink(x) ((x)->flags & CONF_FLAGS_CRYPTLINK)
00278 #define SetConfCryptLink(x) ((x)->flags |= CONF_FLAGS_CRYPTLINK)
00279 #define ClearConfCryptLink(x) ((x)->flags &= ~CONF_FLAGS_CRYPTLINK)
00280 #define IsConfLazyLink(x) ((x)->flags & CONF_FLAGS_LAZY_LINK)
00281 #define SetConfLazyLink(x) ((x)->flags = CONF_FLAGS_LAZY_LINK)
00282 #define ClearConfLazyLink(x) ((x)->flags &= ~CONF_FLAGS_LAZY_LINK)
00283 #define IsConfAllowAutoConn(x) ((x)->flags & CONF_FLAGS_ALLOW_AUTO_CONN)
00284 #define SetConfAllowAutoConn(x) ((x)->flags |= CONF_FLAGS_ALLOW_AUTO_CONN)
00285 #define ClearConfAllowAutoConn(x) ((x)->flags &= ~CONF_FLAGS_ALLOW_AUTO_CONN)
00286 #define IsConfTemporary(x) ((x)->flags & CONF_FLAGS_TEMPORARY)
00287 #define SetConfTemporary(x) ((x)->flags |= CONF_FLAGS_TEMPORARY)
00288 #define IsConfRedir(x) ((x)->flags & CONF_FLAGS_REDIR)
00289 #define IsConfAwayBurst(x) ((x)->flags & CONF_FLAGS_BURST_AWAY)
00290 #define SetConfAwayBurst(x) ((x)->flags |= CONF_FLAGS_BURST_AWAY)
00291 #define ClearConfAwayBurst(x) ((x)->flags &= ~CONF_FLAGS_BURST_AWAY)
00292 #define IsConfTopicBurst(x) ((x)->flags & CONF_FLAGS_TOPICBURST)
00293 #define SetConfTopicBurst(x) ((x)->flags |= CONF_FLAGS_TOPICBURST)
00294 #define ClearConfTopicBurst(x) ((x)->flags &= ~CONF_FLAGS_TOPICBURST)
00295
00296
00297
00298
00299 #define SHARED_KLINE 0x0001
00300 #define SHARED_TKLINE 0x0002
00301 #define SHARED_UNKLINE 0x0004
00302 #define SHARED_XLINE 0x0008
00303 #define SHARED_TXLINE 0x0010
00304 #define SHARED_UNXLINE 0x0020
00305 #define SHARED_RESV 0x0040
00306 #define SHARED_TRESV 0x0080
00307 #define SHARED_UNRESV 0x0100
00308 #define SHARED_LOCOPS 0x0200
00309 #define SHARED_ALL (SHARED_KLINE | SHARED_TKLINE | SHARED_UNKLINE | \
00310 SHARED_XLINE | SHARED_TXLINE | SHARED_UNXLINE | \
00311 SHARED_RESV | SHARED_TRESV | SHARED_UNRESV |\
00312 SHARED_LOCOPS)
00313
00314
00315 #define GDENY_BLOCK 0x1
00316 #define GDENY_REJECT 0x2
00317
00318 struct config_file_entry
00319 {
00320 const char *dpath;
00321 const char *configfile;
00322 const char *klinefile;
00323 const char *xlinefile;
00324 const char *rxlinefile;
00325 const char *rklinefile;
00326 const char *dlinefile;
00327 const char *glinefile;
00328 const char *cresvfile;
00329 const char *nresvfile;
00330
00331 char *logpath;
00332 char *operlog;
00333
00334 char *servlink_path;
00335 char *egdpool_path;
00336
00337 MessageFile motd;
00338 MessageFile opermotd;
00339 MessageFile linksfile;
00340
00341 unsigned char compression_level;
00342 int gline_min_cidr;
00343 int gline_min_cidr6;
00344 int dot_in_ip6_addr;
00345 int dots_in_ident;
00346 int failed_oper_notice;
00347 int anti_spam_exit_message_time;
00348 int max_accept;
00349 int max_nick_time;
00350 int max_nick_changes;
00351 int ts_max_delta;
00352 int ts_warn_delta;
00353 int anti_nick_flood;
00354 int kline_with_reason;
00355 int warn_no_nline;
00356 int invisible_on_connect;
00357 int stats_e_disabled;
00358 int stats_o_oper_only;
00359 int stats_k_oper_only;
00360 int stats_i_oper_only;
00361 int stats_P_oper_only;
00362 int short_motd;
00363 int no_oper_flood;
00364 int true_no_oper_flood;
00365 int oper_pass_resv;
00366 int glines;
00367 int hide_spoof_ips;
00368 int burst_away;
00369 int use_whois_actually;
00370 int tkline_expire_notices;
00371 int opers_bypass_callerid;
00372 int ignore_bogus_ts;
00373 char *kline_reason;
00374 int pace_wait;
00375 int pace_wait_simple;
00376 int gline_time;
00377 int gline_logging;
00378 int idletime;
00379 int oper_only_umodes;
00380 int oper_umodes;
00381 int max_targets;
00382 int caller_id_wait;
00383 int min_nonwildcard;
00384 int min_nonwildcard_simple;
00385 int kill_chase_time_limit;
00386 int default_floodcount;
00387 int client_flood;
00388
00389 int throttle_time;
00390 int use_egd;
00391 int ping_cookie;
00392 int disable_auth;
00393 int disable_remote;
00394 #ifdef HAVE_LIBCRYPTO
00395 struct EncCapability *default_cipher_preference;
00396 #endif
00397 };
00398
00399 struct config_channel_entry
00400 {
00401 int disable_fake_channels;
00402 int restrict_channels;
00403 int disable_local_channels;
00404 int use_except;
00405 int use_invex;
00406 int use_knock;
00407 int knock_delay;
00408 int knock_delay_channel;
00409 unsigned int max_bans;
00410 unsigned int max_chans_per_user;
00411 int no_create_on_split;
00412 int no_join_on_split;
00413 int quiet_on_ban;
00414 int burst_topicwho;
00415 int default_split_server_count;
00416 int default_split_user_count;
00417 };
00418
00419 struct config_server_hide
00420 {
00421 int flatten_links;
00422 int hide_servers;
00423 char *hidden_name;
00424 int links_delay;
00425 int links_disabled;
00426 int hidden;
00427 int disable_hidden;
00428 int hide_server_ips;
00429 };
00430
00431 struct server_info
00432 {
00433 char *name;
00434 char *description;
00435 char *network_name;
00436 char *network_desc;
00437 #ifdef HAVE_LIBCRYPTO
00438 char *rsa_private_key_file;
00439 RSA *rsa_private_key;
00440 SSL_CTX *ctx;
00441 #endif
00442 char *sid;
00443 int hub;
00444 struct irc_ssaddr ip;
00445 struct irc_ssaddr ip6;
00446 int max_clients;
00447 int specific_ipv4_vhost;
00448 int specific_ipv6_vhost;
00449 struct sockaddr_in dns_host;
00450 int can_use_v6;
00451 };
00452
00453 struct admin_info
00454 {
00455 char *name;
00456 char *description;
00457 char *email;
00458 };
00459
00460 struct logging_entry
00461 {
00462 unsigned int use_logging;
00463 char operlog[PATH_MAX + 1];
00464 char userlog[PATH_MAX + 1];
00465 char glinelog[PATH_MAX + 1];
00466 char ioerrlog[PATH_MAX + 1];
00467 char klinelog[PATH_MAX + 1];
00468 char killlog[PATH_MAX + 1];
00469 char operspylog[PATH_MAX + 1];
00470 char failed_operlog[PATH_MAX + 1];
00471 };
00472
00473 extern int ypass;
00474 extern dlink_list class_items;
00475 extern dlink_list server_items;
00476 extern dlink_list cluster_items;
00477 extern dlink_list hub_items;
00478 extern dlink_list rxconf_items;
00479 extern dlink_list rkconf_items;
00480 extern dlink_list leaf_items;
00481 extern dlink_list temporary_klines;
00482 extern dlink_list temporary_dlines;
00483 extern dlink_list temporary_glines;
00484 extern dlink_list temporary_xlines;
00485 extern dlink_list temporary_rxlines;
00486 extern dlink_list temporary_rklines;
00487 extern struct logging_entry ConfigLoggingEntry;
00488 extern struct config_file_entry ConfigFileEntry;
00489 extern struct config_channel_entry ConfigChannel;
00490 extern struct config_server_hide ConfigServerHide;
00491 extern struct server_info ServerInfo;
00492 extern struct admin_info AdminInfo;
00493 extern int valid_wild_card(struct Client *, int, int, ...);
00494
00495
00496 extern unsigned long get_sendq(struct Client *);
00497 extern const char *get_client_class(struct Client *);
00498 extern int get_client_ping(struct Client *, int *);
00499 extern void check_class(void);
00500 extern void init_class(void);
00501 extern struct ConfItem *find_class(const char *);
00502 extern void init_ip_hash_table(void);
00503 extern void count_ip_hash(int *, unsigned long *);
00504 extern void remove_one_ip(struct irc_ssaddr *);
00505 extern struct ConfItem *make_conf_item(ConfType type);
00506 extern void free_access_item(struct AccessItem *);
00507 extern void read_conf_files(int);
00508 extern int attach_conf(struct Client *, struct ConfItem *);
00509 extern int attach_connect_block(struct Client *, const char *, const char *);
00510
00511 extern int detach_conf(struct Client *, ConfType);
00512
00513 extern struct ConfItem *find_conf_name(dlink_list *, const char *, ConfType);
00514 extern struct ConfItem *find_conf_exact(ConfType, const char *, const char *, const char *);
00515 extern struct AccessItem *find_kill(struct Client *);
00516 extern struct AccessItem *find_gline(struct Client *);
00517 extern int conf_connect_allowed(struct irc_ssaddr *, int);
00518 extern char *oper_privs_as_string(const unsigned int);
00519 extern void split_nuh(struct split_nuh_item *);
00520 extern struct ConfItem *find_matching_name_conf(ConfType, const char *,
00521 const char *, const char *, int);
00522 extern struct ConfItem *find_exact_name_conf(ConfType, const char *,
00523 const char *, const char *);
00524 extern void delete_conf_item(struct ConfItem *);
00525 extern void report_confitem_types(struct Client *, ConfType, int);
00526 extern void yyerror(const char *);
00527 extern int conf_yy_fatal_error(const char *);
00528 extern int conf_fbgets(char *, unsigned int, FBFILE *);
00529 extern void write_conf_line(struct Client *, struct ConfItem *,
00530 const char *, time_t);
00531 extern int remove_conf_line(ConfType, struct Client *, const char *,
00532 const char *);
00533 extern void add_temp_line(struct ConfItem *);
00534 extern void cleanup_tklines(void *);
00535 extern const char *get_conf_name(ConfType);
00536 extern int rehash(int);
00537 extern int conf_add_server(struct ConfItem *, const char *);
00538 extern void conf_add_class_to_conf(struct ConfItem *, const char *);
00539 extern void conf_add_d_conf(struct AccessItem *);
00540
00541
00542 extern void parse_csv_file(FBFILE *, ConfType);
00543
00544 extern char *get_oper_name(const struct Client *);
00545
00546 extern void *map_to_conf(struct ConfItem *);
00547 extern struct ConfItem *unmap_conf_item(void *);
00548
00549 #define AWILD 0x1
00550 #define NOUSERLOOKUP 0x2
00551 extern int parse_aline(const char *, struct Client *, int, char **,
00552 int, char **, char **, time_t *, char **, char **);
00553 extern int valid_comment(struct Client *, char *, int);
00554
00555
00556 extern int yylex(void);
00557
00558 #define TK_SECONDS 0
00559 #define TK_MINUTES 1
00560 extern time_t valid_tkline(char *, int);
00561 extern int match_conf_password(const char *, const struct AccessItem *);
00562
00563 #define NOT_AUTHORIZED (-1)
00564 #define I_LINE_FULL (-2)
00565 #define TOO_MANY (-3)
00566 #define BANNED_CLIENT (-4)
00567 #define TOO_FAST (-5)
00568
00569 #define CLEANUP_TKLINES_TIME 60
00570
00571 extern void cluster_a_line(struct Client *,
00572 const char *, int, int, const char *,...);
00573 extern void rebuild_cidr_class(struct ConfItem *, struct ClassItem *);
00574
00575 #endif