| 1 |
/* |
| 2 |
* ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). |
| 3 |
* conf.h: A header for the configuration functions. |
| 4 |
* |
| 5 |
* Copyright (C) 2005 by the past and present ircd coders, and others. |
| 6 |
* |
| 7 |
* This program is free software; you can redistribute it and/or modify |
| 8 |
* it under the terms of the GNU General Public License as published by |
| 9 |
* the Free Software Foundation; either version 2 of the License, or |
| 10 |
* (at your option) any later version. |
| 11 |
* |
| 12 |
* This program is distributed in the hope that it will be useful, |
| 13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
* GNU General Public License for more details. |
| 16 |
* |
| 17 |
* You should have received a copy of the GNU General Public License |
| 18 |
* along with this program; if not, write to the Free Software |
| 19 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
| 20 |
* USA |
| 21 |
* |
| 22 |
* $Id$ |
| 23 |
*/ |
| 24 |
|
| 25 |
#ifndef INCLUDED_s_conf_h |
| 26 |
#define INCLUDED_s_conf_h |
| 27 |
#include "config.h" |
| 28 |
#include "ircd_defs.h" |
| 29 |
#include "client.h" |
| 30 |
#include "hook.h" |
| 31 |
#include "conf_class.h" |
| 32 |
|
| 33 |
|
| 34 |
#define CONF_NOREASON "<No reason supplied>" |
| 35 |
|
| 36 |
#define IsConfOperator(x) ((x)->type == CONF_OPER) |
| 37 |
#define IsConfKill(x) ((x)->type == CONF_KLINE) |
| 38 |
#define IsConfClient(x) ((x)->type == CONF_CLIENT) |
| 39 |
#define IsConfGline(x) ((x)->type == CONF_GLINE) |
| 40 |
|
| 41 |
/* MaskItem->flags */ |
| 42 |
#define CONF_FLAGS_DO_IDENTD 0x00000001 |
| 43 |
#define CONF_FLAGS_LIMIT_IP 0x00000002 |
| 44 |
#define CONF_FLAGS_NO_TILDE 0x00000004 |
| 45 |
#define CONF_FLAGS_NEED_IDENTD 0x00000008 |
| 46 |
#define CONF_FLAGS_NOMATCH_IP 0x00000010 |
| 47 |
#define CONF_FLAGS_EXEMPTKLINE 0x00000020 |
| 48 |
#define CONF_FLAGS_NOLIMIT 0x00000040 |
| 49 |
#define CONF_FLAGS_SPOOF_IP 0x00000080 |
| 50 |
#define CONF_FLAGS_SPOOF_NOTICE 0x00000100 |
| 51 |
#define CONF_FLAGS_REDIR 0x00000200 |
| 52 |
#define CONF_FLAGS_EXEMPTGLINE 0x00000400 |
| 53 |
#define CONF_FLAGS_CAN_FLOOD 0x00000800 |
| 54 |
#define CONF_FLAGS_NEED_PASSWORD 0x00001000 |
| 55 |
#define CONF_FLAGS_ALLOW_AUTO_CONN 0x00002000 |
| 56 |
#define CONF_FLAGS_ENCRYPTED 0x00004000 |
| 57 |
#define CONF_FLAGS_IN_DATABASE 0x00008000 |
| 58 |
#define CONF_FLAGS_EXEMPTRESV 0x00010000 |
| 59 |
#define CONF_FLAGS_SSL 0x00020000 |
| 60 |
#define CONF_FLAGS_WEBIRC 0x00040000 |
| 61 |
|
| 62 |
/* Macros for struct MaskItem */ |
| 63 |
#define IsConfWebIRC(x) ((x)->flags & CONF_FLAGS_WEBIRC) |
| 64 |
#define IsLimitIp(x) ((x)->flags & CONF_FLAGS_LIMIT_IP) |
| 65 |
#define IsNoTilde(x) ((x)->flags & CONF_FLAGS_NO_TILDE) |
| 66 |
#define IsConfCanFlood(x) ((x)->flags & CONF_FLAGS_CAN_FLOOD) |
| 67 |
#define IsNeedPassword(x) ((x)->flags & CONF_FLAGS_NEED_PASSWORD) |
| 68 |
#define IsNeedIdentd(x) ((x)->flags & CONF_FLAGS_NEED_IDENTD) |
| 69 |
#define IsNoMatchIp(x) ((x)->flags & CONF_FLAGS_NOMATCH_IP) |
| 70 |
#define IsConfExemptKline(x) ((x)->flags & CONF_FLAGS_EXEMPTKLINE) |
| 71 |
#define IsConfExemptLimits(x) ((x)->flags & CONF_FLAGS_NOLIMIT) |
| 72 |
#define IsConfExemptGline(x) ((x)->flags & CONF_FLAGS_EXEMPTGLINE) |
| 73 |
#define IsConfExemptResv(x) ((x)->flags & CONF_FLAGS_EXEMPTRESV) |
| 74 |
#define IsConfDoIdentd(x) ((x)->flags & CONF_FLAGS_DO_IDENTD) |
| 75 |
#define IsConfDoSpoofIp(x) ((x)->flags & CONF_FLAGS_SPOOF_IP) |
| 76 |
#define IsConfSpoofNotice(x) ((x)->flags & CONF_FLAGS_SPOOF_NOTICE) |
| 77 |
#define IsConfEncrypted(x) ((x)->flags & CONF_FLAGS_ENCRYPTED) |
| 78 |
#define SetConfEncrypted(x) ((x)->flags |= CONF_FLAGS_ENCRYPTED) |
| 79 |
#define ClearConfEncrypted(x) ((x)->flags &= ~CONF_FLAGS_ENCRYPTED) |
| 80 |
#define IsConfAllowAutoConn(x) ((x)->flags & CONF_FLAGS_ALLOW_AUTO_CONN) |
| 81 |
#define SetConfAllowAutoConn(x) ((x)->flags |= CONF_FLAGS_ALLOW_AUTO_CONN) |
| 82 |
#define ClearConfAllowAutoConn(x) ((x)->flags &= ~CONF_FLAGS_ALLOW_AUTO_CONN) |
| 83 |
#define IsConfRedir(x) ((x)->flags & CONF_FLAGS_REDIR) |
| 84 |
#define IsConfSSL(x) ((x)->flags & CONF_FLAGS_SSL) |
| 85 |
#define SetConfSSL(x) ((x)->flags |= CONF_FLAGS_SSL) |
| 86 |
#define ClearConfSSL(x) ((x)->flags &= ~CONF_FLAGS_SSL) |
| 87 |
#define IsConfDatabase(x) ((x)->flags & CONF_FLAGS_IN_DATABASE) |
| 88 |
#define SetConfDatabase(x) ((x)->flags |= CONF_FLAGS_IN_DATABASE) |
| 89 |
|
| 90 |
|
| 91 |
/* shared/cluster server entry types |
| 92 |
* These defines are used for both shared and cluster. |
| 93 |
*/ |
| 94 |
#define SHARED_KLINE 0x0001 |
| 95 |
#define SHARED_UNKLINE 0x0002 |
| 96 |
#define SHARED_XLINE 0x0004 |
| 97 |
#define SHARED_UNXLINE 0x0008 |
| 98 |
#define SHARED_RESV 0x0010 |
| 99 |
#define SHARED_UNRESV 0x0020 |
| 100 |
#define SHARED_LOCOPS 0x0040 |
| 101 |
#define SHARED_DLINE 0x0080 |
| 102 |
#define SHARED_UNDLINE 0x0100 |
| 103 |
#define SHARED_ALL (SHARED_KLINE | SHARED_UNKLINE |\ |
| 104 |
SHARED_XLINE | SHARED_UNXLINE |\ |
| 105 |
SHARED_RESV | SHARED_UNRESV |\ |
| 106 |
SHARED_LOCOPS | SHARED_DLINE | SHARED_UNDLINE) |
| 107 |
|
| 108 |
|
| 109 |
enum maskitem_type |
| 110 |
{ |
| 111 |
CONF_RESERVED = 1 << 0, /* XXX */ |
| 112 |
CONF_CLIENT = 1 << 1, |
| 113 |
CONF_SERVER = 1 << 2, |
| 114 |
CONF_KLINE = 1 << 3, |
| 115 |
CONF_DLINE = 1 << 4, |
| 116 |
CONF_EXEMPT = 1 << 5, |
| 117 |
CONF_CLUSTER = 1 << 6, |
| 118 |
CONF_XLINE = 1 << 7, |
| 119 |
CONF_ULINE = 1 << 8, |
| 120 |
CONF_GLINE = 1 << 9, |
| 121 |
CONF_CRESV = 1 << 10, |
| 122 |
CONF_NRESV = 1 << 11, |
| 123 |
CONF_SERVICE = 1 << 12, |
| 124 |
CONF_OPER = 1 << 13, |
| 125 |
}; |
| 126 |
|
| 127 |
struct conf_parser_context |
| 128 |
{ |
| 129 |
unsigned int boot; |
| 130 |
unsigned int pass; |
| 131 |
FILE *conf_file; |
| 132 |
}; |
| 133 |
|
| 134 |
struct split_nuh_item |
| 135 |
{ |
| 136 |
dlink_node node; |
| 137 |
|
| 138 |
char *nuhmask; |
| 139 |
char *nickptr; |
| 140 |
char *userptr; |
| 141 |
char *hostptr; |
| 142 |
|
| 143 |
size_t nicksize; |
| 144 |
size_t usersize; |
| 145 |
size_t hostsize; |
| 146 |
}; |
| 147 |
|
| 148 |
struct MaskItem |
| 149 |
{ |
| 150 |
dlink_node node; |
| 151 |
dlink_list leaf_list; |
| 152 |
dlink_list hub_list; |
| 153 |
dlink_list exempt_list; |
| 154 |
enum maskitem_type type; |
| 155 |
unsigned int dns_failed; |
| 156 |
unsigned int dns_pending; |
| 157 |
unsigned int flags; |
| 158 |
unsigned int modes; |
| 159 |
unsigned int port; |
| 160 |
unsigned int count; |
| 161 |
unsigned int aftype; |
| 162 |
unsigned int active; |
| 163 |
unsigned int htype; |
| 164 |
unsigned int ref_count; /* Number of *LOCAL* clients using this */ |
| 165 |
int bits; |
| 166 |
time_t until; /* Hold action until this time (calendar time) */ |
| 167 |
time_t setat; |
| 168 |
struct irc_ssaddr bind; /* ip to bind to for outgoing connect */ |
| 169 |
struct irc_ssaddr addr; /* ip to connect to */ |
| 170 |
struct ClassItem *class; /* Class of connection */ |
| 171 |
char *name; |
| 172 |
char *user; /* user part of user@host */ |
| 173 |
char *host; /* host part of user@host */ |
| 174 |
char *passwd; |
| 175 |
char *spasswd; /* Password to send. */ |
| 176 |
char *reason; |
| 177 |
char *certfp; |
| 178 |
char *cipher_list; |
| 179 |
void *rsa_public_key; |
| 180 |
}; |
| 181 |
|
| 182 |
struct exempt |
| 183 |
{ |
| 184 |
dlink_node node; |
| 185 |
char *name; |
| 186 |
char *user; |
| 187 |
char *host; |
| 188 |
size_t len; |
| 189 |
time_t when; |
| 190 |
struct irc_ssaddr addr; |
| 191 |
int bits; |
| 192 |
int type; |
| 193 |
int coid; |
| 194 |
}; |
| 195 |
|
| 196 |
struct CidrItem |
| 197 |
{ |
| 198 |
dlink_node node; |
| 199 |
struct irc_ssaddr mask; |
| 200 |
unsigned int number_on_this_cidr; |
| 201 |
}; |
| 202 |
|
| 203 |
struct config_file_entry |
| 204 |
{ |
| 205 |
const char *dpath; /* DPATH if set from command line */ |
| 206 |
const char *configfile; |
| 207 |
const char *klinefile; |
| 208 |
const char *glinefile; |
| 209 |
const char *xlinefile; |
| 210 |
const char *dlinefile; |
| 211 |
const char *resvfile; |
| 212 |
char *mpath; |
| 213 |
char *rpath; |
| 214 |
|
| 215 |
char *egdpool_path; |
| 216 |
char *service_name; |
| 217 |
|
| 218 |
int gline_min_cidr; |
| 219 |
int gline_min_cidr6; |
| 220 |
int dots_in_ident; |
| 221 |
int failed_oper_notice; |
| 222 |
int anti_spam_exit_message_time; |
| 223 |
unsigned int max_accept; |
| 224 |
unsigned int max_watch; |
| 225 |
int max_nick_time; |
| 226 |
unsigned int max_nick_changes; |
| 227 |
int ts_max_delta; |
| 228 |
int ts_warn_delta; |
| 229 |
int anti_nick_flood; |
| 230 |
int warn_no_nline; |
| 231 |
int invisible_on_connect; |
| 232 |
int stats_e_disabled; |
| 233 |
int stats_o_oper_only; |
| 234 |
int stats_k_oper_only; |
| 235 |
int stats_i_oper_only; |
| 236 |
int stats_P_oper_only; |
| 237 |
int short_motd; |
| 238 |
int no_oper_flood; |
| 239 |
int true_no_oper_flood; |
| 240 |
int oper_pass_resv; |
| 241 |
int glines; |
| 242 |
int hide_spoof_ips; |
| 243 |
int tkline_expire_notices; |
| 244 |
int opers_bypass_callerid; |
| 245 |
int ignore_bogus_ts; |
| 246 |
int pace_wait; |
| 247 |
int pace_wait_simple; |
| 248 |
int gline_time; |
| 249 |
int gline_request_time; |
| 250 |
int oper_only_umodes; |
| 251 |
int oper_umodes; |
| 252 |
int max_targets; |
| 253 |
int caller_id_wait; |
| 254 |
int min_nonwildcard; |
| 255 |
int min_nonwildcard_simple; |
| 256 |
int kill_chase_time_limit; |
| 257 |
int default_floodcount; |
| 258 |
/* 0 == don't use throttle... */ |
| 259 |
int throttle_time; |
| 260 |
int use_egd; |
| 261 |
int ping_cookie; |
| 262 |
int disable_auth; |
| 263 |
}; |
| 264 |
|
| 265 |
struct config_channel_entry |
| 266 |
{ |
| 267 |
int disable_fake_channels; |
| 268 |
int knock_delay; |
| 269 |
int knock_delay_channel; |
| 270 |
unsigned int max_bans; |
| 271 |
unsigned int max_chans_per_user; |
| 272 |
unsigned int max_chans_per_oper; |
| 273 |
int no_create_on_split; |
| 274 |
int no_join_on_split; |
| 275 |
int default_split_server_count; |
| 276 |
int default_split_user_count; |
| 277 |
}; |
| 278 |
|
| 279 |
struct config_server_hide |
| 280 |
{ |
| 281 |
char *hidden_name; |
| 282 |
int flatten_links; |
| 283 |
int disable_remote_commands; |
| 284 |
int hide_servers; |
| 285 |
int hide_services; |
| 286 |
int links_delay; |
| 287 |
int links_disabled; |
| 288 |
int hidden; |
| 289 |
int hide_server_ips; |
| 290 |
}; |
| 291 |
|
| 292 |
struct server_info |
| 293 |
{ |
| 294 |
char *sid; |
| 295 |
char *name; |
| 296 |
char *description; |
| 297 |
char *network_name; |
| 298 |
char *network_desc; |
| 299 |
char *rsa_private_key_file; |
| 300 |
void *rsa_private_key; |
| 301 |
void *server_ctx; |
| 302 |
void *client_ctx; |
| 303 |
int hub; |
| 304 |
struct irc_ssaddr ip; |
| 305 |
struct irc_ssaddr ip6; |
| 306 |
unsigned int max_clients; |
| 307 |
unsigned int max_nick_length; |
| 308 |
unsigned int max_topic_length; |
| 309 |
int specific_ipv4_vhost; |
| 310 |
int specific_ipv6_vhost; |
| 311 |
struct sockaddr_in dns_host; |
| 312 |
int can_use_v6; |
| 313 |
}; |
| 314 |
|
| 315 |
struct admin_info |
| 316 |
{ |
| 317 |
char *name; |
| 318 |
char *description; |
| 319 |
char *email; |
| 320 |
}; |
| 321 |
|
| 322 |
struct logging_entry |
| 323 |
{ |
| 324 |
unsigned int use_logging; |
| 325 |
}; |
| 326 |
|
| 327 |
extern dlink_list flatten_links; |
| 328 |
extern dlink_list server_items; |
| 329 |
extern dlink_list cluster_items; |
| 330 |
extern dlink_list xconf_items; |
| 331 |
extern dlink_list uconf_items; |
| 332 |
extern dlink_list oconf_items; |
| 333 |
extern dlink_list service_items; |
| 334 |
extern dlink_list nresv_items; |
| 335 |
extern dlink_list cresv_items; |
| 336 |
extern struct conf_parser_context conf_parser_ctx; |
| 337 |
extern struct logging_entry ConfigLoggingEntry; |
| 338 |
extern struct config_file_entry ConfigFileEntry;/* defined in ircd.c*/ |
| 339 |
extern struct config_channel_entry ConfigChannel;/* defined in channel.c*/ |
| 340 |
extern struct config_server_hide ConfigServerHide; /* defined in s_conf.c */ |
| 341 |
extern struct server_info ServerInfo; /* defined in ircd.c */ |
| 342 |
extern struct admin_info AdminInfo; /* defined in ircd.c */ |
| 343 |
extern int valid_wild_card_simple(const char *); |
| 344 |
extern int valid_wild_card(struct Client *, int, int, ...); |
| 345 |
/* End GLOBAL section */ |
| 346 |
|
| 347 |
extern void init_ip_hash_table(void); |
| 348 |
extern void count_ip_hash(unsigned int *, uint64_t *); |
| 349 |
extern void remove_one_ip(struct irc_ssaddr *); |
| 350 |
extern struct MaskItem *conf_make(enum maskitem_type); |
| 351 |
extern void read_conf_files(int); |
| 352 |
extern int attach_conf(struct Client *, struct MaskItem *); |
| 353 |
extern int attach_connect_block(struct Client *, const char *, const char *); |
| 354 |
extern int check_client(struct Client *); |
| 355 |
|
| 356 |
|
| 357 |
extern void detach_conf(struct Client *, enum maskitem_type); |
| 358 |
extern struct MaskItem *find_conf_name(dlink_list *, const char *, enum maskitem_type); |
| 359 |
extern struct MaskItem *find_kill(struct Client *); |
| 360 |
extern struct MaskItem *find_gline(struct Client *); |
| 361 |
extern int conf_connect_allowed(struct irc_ssaddr *, int); |
| 362 |
extern char *oper_privs_as_string(const unsigned int); |
| 363 |
extern void split_nuh(struct split_nuh_item *); |
| 364 |
extern struct MaskItem *find_matching_name_conf(enum maskitem_type, const char *, |
| 365 |
const char *, const char *, unsigned int); |
| 366 |
extern struct MaskItem *find_exact_name_conf(enum maskitem_type, const struct Client *, const char *, |
| 367 |
const char *, const char *); |
| 368 |
extern void conf_free(struct MaskItem *); |
| 369 |
extern void yyerror(const char *); |
| 370 |
extern void conf_error_report(const char *); |
| 371 |
extern void cleanup_tklines(void *); |
| 372 |
extern int rehash(int); |
| 373 |
extern void lookup_confhost(struct MaskItem *); |
| 374 |
extern void conf_add_class_to_conf(struct MaskItem *, const char *); |
| 375 |
|
| 376 |
extern const char *get_oper_name(const struct Client *); |
| 377 |
|
| 378 |
/* XXX should the parse_aline stuff go into another file ?? */ |
| 379 |
#define AWILD 0x1 /* check wild cards */ |
| 380 |
extern int parse_aline(const char *, struct Client *, int, char **, |
| 381 |
int, char **, char **, time_t *, char **, char **); |
| 382 |
extern int valid_comment(struct Client *, char *, int); |
| 383 |
|
| 384 |
|
| 385 |
#define TK_SECONDS 0 |
| 386 |
#define TK_MINUTES 1 |
| 387 |
extern time_t valid_tkline(const char *, int); |
| 388 |
extern int match_conf_password(const char *, const struct MaskItem *); |
| 389 |
|
| 390 |
#define NOT_AUTHORIZED (-1) |
| 391 |
#define I_LINE_FULL (-2) |
| 392 |
#define TOO_MANY (-3) |
| 393 |
#define BANNED_CLIENT (-4) |
| 394 |
#define TOO_FAST (-5) |
| 395 |
|
| 396 |
#define CLEANUP_TKLINES_TIME 60 |
| 397 |
|
| 398 |
extern void cluster_a_line(struct Client *, |
| 399 |
const char *, int, int, const char *,...); |
| 400 |
#endif /* INCLUDED_s_conf_h */ |