| 1 |
/* |
| 2 |
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
| 3 |
* |
| 4 |
* Copyright (c) 1997-2016 ircd-hybrid development team |
| 5 |
* |
| 6 |
* This program is free software; you can redistribute it and/or modify |
| 7 |
* it under the terms of the GNU General Public License as published by |
| 8 |
* the Free Software Foundation; either version 2 of the License, or |
| 9 |
* (at your option) any later version. |
| 10 |
* |
| 11 |
* This program is distributed in the hope that it will be useful, |
| 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
* GNU General Public License for more details. |
| 15 |
* |
| 16 |
* You should have received a copy of the GNU General Public License |
| 17 |
* along with this program; if not, write to the Free Software |
| 18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 |
| 19 |
* USA |
| 20 |
*/ |
| 21 |
|
| 22 |
/*! \file conf.h |
| 23 |
* \brief A header for the configuration functions. |
| 24 |
* \version $Id$ |
| 25 |
*/ |
| 26 |
|
| 27 |
#ifndef INCLUDED_conf_h |
| 28 |
#define INCLUDED_conf_h |
| 29 |
#include "config.h" |
| 30 |
#include "client.h" |
| 31 |
#include "conf_class.h" |
| 32 |
#include "tls.h" |
| 33 |
|
| 34 |
|
| 35 |
#define CONF_NOREASON "<No reason supplied>" |
| 36 |
|
| 37 |
/* MaskItem->flags */ |
| 38 |
enum |
| 39 |
{ |
| 40 |
CONF_FLAGS_NO_TILDE = 0x00000001U, |
| 41 |
CONF_FLAGS_NEED_IDENTD = 0x00000002U, |
| 42 |
CONF_FLAGS_EXEMPTKLINE = 0x00000004U, |
| 43 |
CONF_FLAGS_NOLIMIT = 0x00000008U, |
| 44 |
CONF_FLAGS_SPOOF_IP = 0x00000010U, |
| 45 |
CONF_FLAGS_SPOOF_NOTICE = 0x00000020U, |
| 46 |
CONF_FLAGS_REDIR = 0x00000040U, |
| 47 |
CONF_FLAGS_CAN_FLOOD = 0x00000080U, |
| 48 |
CONF_FLAGS_NEED_PASSWORD = 0x00000100U, |
| 49 |
CONF_FLAGS_ALLOW_AUTO_CONN = 0x00000200U, |
| 50 |
CONF_FLAGS_ENCRYPTED = 0x00000400U, |
| 51 |
CONF_FLAGS_IN_DATABASE = 0x00000800U, |
| 52 |
CONF_FLAGS_EXEMPTRESV = 0x00001000U, |
| 53 |
CONF_FLAGS_SSL = 0x00002000U, |
| 54 |
CONF_FLAGS_WEBIRC = 0x00004000U, |
| 55 |
CONF_FLAGS_EXEMPTXLINE = 0x00008000U |
| 56 |
}; |
| 57 |
|
| 58 |
/* Macros for struct MaskItem */ |
| 59 |
#define IsConfWebIRC(x) ((x)->flags & CONF_FLAGS_WEBIRC) |
| 60 |
#define IsNoTilde(x) ((x)->flags & CONF_FLAGS_NO_TILDE) |
| 61 |
#define IsConfCanFlood(x) ((x)->flags & CONF_FLAGS_CAN_FLOOD) |
| 62 |
#define IsNeedPassword(x) ((x)->flags & CONF_FLAGS_NEED_PASSWORD) |
| 63 |
#define IsNeedIdentd(x) ((x)->flags & CONF_FLAGS_NEED_IDENTD) |
| 64 |
#define IsConfExemptKline(x) ((x)->flags & CONF_FLAGS_EXEMPTKLINE) |
| 65 |
#define IsConfExemptXline(x) ((x)->flags & CONF_FLAGS_EXEMPTXLINE) |
| 66 |
#define IsConfExemptLimits(x) ((x)->flags & CONF_FLAGS_NOLIMIT) |
| 67 |
#define IsConfExemptResv(x) ((x)->flags & CONF_FLAGS_EXEMPTRESV) |
| 68 |
#define IsConfDoSpoofIp(x) ((x)->flags & CONF_FLAGS_SPOOF_IP) |
| 69 |
#define IsConfSpoofNotice(x) ((x)->flags & CONF_FLAGS_SPOOF_NOTICE) |
| 70 |
#define IsConfAllowAutoConn(x) ((x)->flags & CONF_FLAGS_ALLOW_AUTO_CONN) |
| 71 |
#define SetConfAllowAutoConn(x) ((x)->flags |= CONF_FLAGS_ALLOW_AUTO_CONN) |
| 72 |
#define ClearConfAllowAutoConn(x) ((x)->flags &= ~CONF_FLAGS_ALLOW_AUTO_CONN) |
| 73 |
#define IsConfRedir(x) ((x)->flags & CONF_FLAGS_REDIR) |
| 74 |
#define IsConfSSL(x) ((x)->flags & CONF_FLAGS_SSL) |
| 75 |
#define IsConfDatabase(x) ((x)->flags & CONF_FLAGS_IN_DATABASE) |
| 76 |
#define SetConfDatabase(x) ((x)->flags |= CONF_FLAGS_IN_DATABASE) |
| 77 |
|
| 78 |
|
| 79 |
enum maskitem_type |
| 80 |
{ |
| 81 |
CONF_CLIENT = 1 << 0, |
| 82 |
CONF_SERVER = 1 << 1, |
| 83 |
CONF_KLINE = 1 << 2, |
| 84 |
CONF_DLINE = 1 << 3, |
| 85 |
CONF_EXEMPT = 1 << 4, |
| 86 |
CONF_OPER = 1 << 5 |
| 87 |
}; |
| 88 |
|
| 89 |
#define IsConfKill(x) ((x)->type == CONF_KLINE) |
| 90 |
#define IsConfClient(x) ((x)->type == CONF_CLIENT) |
| 91 |
|
| 92 |
enum |
| 93 |
{ |
| 94 |
NOT_AUTHORIZED = -1, |
| 95 |
I_LINE_FULL = -2, |
| 96 |
TOO_MANY = -3, |
| 97 |
BANNED_CLIENT = -4, |
| 98 |
TOO_FAST = -5 |
| 99 |
}; |
| 100 |
|
| 101 |
struct split_nuh_item |
| 102 |
{ |
| 103 |
dlink_node node; |
| 104 |
|
| 105 |
char *nuhmask; |
| 106 |
char *nickptr; |
| 107 |
char *userptr; |
| 108 |
char *hostptr; |
| 109 |
|
| 110 |
size_t nicksize; |
| 111 |
size_t usersize; |
| 112 |
size_t hostsize; |
| 113 |
}; |
| 114 |
|
| 115 |
struct MaskItem |
| 116 |
{ |
| 117 |
dlink_node node; |
| 118 |
dlink_list leaf_list; |
| 119 |
dlink_list hub_list; |
| 120 |
enum maskitem_type type; |
| 121 |
unsigned int dns_failed; |
| 122 |
unsigned int dns_pending; |
| 123 |
unsigned int flags; |
| 124 |
unsigned int modes; |
| 125 |
unsigned int port; |
| 126 |
unsigned int count; |
| 127 |
unsigned int aftype; |
| 128 |
unsigned int active; |
| 129 |
unsigned int htype; |
| 130 |
unsigned int ref_count; /* Number of *LOCAL* clients using this */ |
| 131 |
int bits; |
| 132 |
time_t until; /* Hold action until this time (calendar time) */ |
| 133 |
time_t setat; |
| 134 |
struct irc_ssaddr bind; /* ip to bind to for outgoing connect */ |
| 135 |
struct irc_ssaddr addr; /* ip to connect to */ |
| 136 |
struct ClassItem *class; /* Class of connection */ |
| 137 |
char *name; |
| 138 |
char *user; /* user part of user@host */ |
| 139 |
char *host; /* host part of user@host */ |
| 140 |
char *passwd; |
| 141 |
char *spasswd; /* Password to send. */ |
| 142 |
char *reason; |
| 143 |
char *certfp; |
| 144 |
char *whois; |
| 145 |
char *cipher_list; |
| 146 |
}; |
| 147 |
|
| 148 |
struct CidrItem |
| 149 |
{ |
| 150 |
dlink_node node; |
| 151 |
struct irc_ssaddr mask; |
| 152 |
unsigned int number_on_this_cidr; |
| 153 |
}; |
| 154 |
|
| 155 |
struct conf_parser_context |
| 156 |
{ |
| 157 |
unsigned int boot; |
| 158 |
unsigned int pass; |
| 159 |
FILE *conf_file; |
| 160 |
}; |
| 161 |
|
| 162 |
struct config_general_entry |
| 163 |
{ |
| 164 |
const char *dpath; |
| 165 |
const char *mpath; |
| 166 |
const char *spath; |
| 167 |
const char *configfile; |
| 168 |
const char *klinefile; |
| 169 |
const char *xlinefile; |
| 170 |
const char *dlinefile; |
| 171 |
const char *resvfile; |
| 172 |
|
| 173 |
unsigned int dline_min_cidr; |
| 174 |
unsigned int dline_min_cidr6; |
| 175 |
unsigned int kline_min_cidr; |
| 176 |
unsigned int kline_min_cidr6; |
| 177 |
unsigned int dots_in_ident; |
| 178 |
unsigned int failed_oper_notice; |
| 179 |
unsigned int anti_spam_exit_message_time; |
| 180 |
unsigned int max_accept; |
| 181 |
unsigned int max_watch; |
| 182 |
unsigned int away_time; |
| 183 |
unsigned int away_count; |
| 184 |
unsigned int max_nick_time; |
| 185 |
unsigned int max_nick_changes; |
| 186 |
unsigned int ts_max_delta; |
| 187 |
unsigned int ts_warn_delta; |
| 188 |
unsigned int anti_nick_flood; |
| 189 |
unsigned int warn_no_connect_block; |
| 190 |
unsigned int invisible_on_connect; |
| 191 |
unsigned int stats_e_disabled; |
| 192 |
unsigned int stats_i_oper_only; |
| 193 |
unsigned int stats_k_oper_only; |
| 194 |
unsigned int stats_m_oper_only; |
| 195 |
unsigned int stats_o_oper_only; |
| 196 |
unsigned int stats_P_oper_only; |
| 197 |
unsigned int stats_u_oper_only; |
| 198 |
unsigned int short_motd; |
| 199 |
unsigned int no_oper_flood; |
| 200 |
unsigned int tkline_expire_notices; |
| 201 |
unsigned int opers_bypass_callerid; |
| 202 |
unsigned int ignore_bogus_ts; |
| 203 |
unsigned int pace_wait; |
| 204 |
unsigned int pace_wait_simple; |
| 205 |
unsigned int oper_only_umodes; |
| 206 |
unsigned int oper_umodes; |
| 207 |
unsigned int max_targets; |
| 208 |
unsigned int caller_id_wait; |
| 209 |
unsigned int min_nonwildcard; |
| 210 |
unsigned int min_nonwildcard_simple; |
| 211 |
unsigned int kill_chase_time_limit; |
| 212 |
unsigned int default_floodcount; |
| 213 |
unsigned int throttle_count; |
| 214 |
unsigned int throttle_time; |
| 215 |
unsigned int ping_cookie; |
| 216 |
unsigned int disable_auth; |
| 217 |
unsigned int cycle_on_host_change; |
| 218 |
}; |
| 219 |
|
| 220 |
struct config_channel_entry |
| 221 |
{ |
| 222 |
unsigned int disable_fake_channels; |
| 223 |
unsigned int invite_client_count; |
| 224 |
unsigned int invite_client_time; |
| 225 |
unsigned int invite_delay_channel; |
| 226 |
unsigned int knock_client_count; |
| 227 |
unsigned int knock_client_time; |
| 228 |
unsigned int knock_delay_channel; |
| 229 |
unsigned int max_bans; |
| 230 |
unsigned int max_channels; |
| 231 |
unsigned int default_join_flood_count; |
| 232 |
unsigned int default_join_flood_time; |
| 233 |
}; |
| 234 |
|
| 235 |
struct config_serverhide_entry |
| 236 |
{ |
| 237 |
char *hidden_name; |
| 238 |
char *flatten_links_file; |
| 239 |
unsigned int flatten_links; |
| 240 |
unsigned int flatten_links_delay; |
| 241 |
unsigned int disable_remote_commands; |
| 242 |
unsigned int hide_servers; |
| 243 |
unsigned int hide_services; |
| 244 |
unsigned int hidden; |
| 245 |
unsigned int hide_server_ips; |
| 246 |
}; |
| 247 |
|
| 248 |
struct config_serverinfo_entry |
| 249 |
{ |
| 250 |
char *sid; |
| 251 |
char *name; |
| 252 |
char *description; |
| 253 |
char *network_name; |
| 254 |
char *network_desc; |
| 255 |
char *libgeoip_ipv4_database_file; |
| 256 |
char *libgeoip_ipv6_database_file; |
| 257 |
char *rsa_private_key_file; |
| 258 |
char *ssl_certificate_file; |
| 259 |
char *ssl_dh_param_file; |
| 260 |
char *ssl_dh_elliptic_curve; |
| 261 |
char *ssl_cipher_list; |
| 262 |
char *ssl_message_digest_algorithm; |
| 263 |
tls_context_t tls_ctx; |
| 264 |
tls_md_t message_digest_algorithm; |
| 265 |
unsigned int hub; |
| 266 |
unsigned int default_max_clients; |
| 267 |
unsigned int max_nick_length; |
| 268 |
unsigned int max_topic_length; |
| 269 |
unsigned int libgeoip_database_options; |
| 270 |
unsigned int specific_ipv4_vhost; |
| 271 |
unsigned int specific_ipv6_vhost; |
| 272 |
struct irc_ssaddr ip; |
| 273 |
struct irc_ssaddr ip6; |
| 274 |
}; |
| 275 |
|
| 276 |
struct config_admin_entry |
| 277 |
{ |
| 278 |
char *name; |
| 279 |
char *description; |
| 280 |
char *email; |
| 281 |
}; |
| 282 |
|
| 283 |
struct config_log_entry |
| 284 |
{ |
| 285 |
unsigned int use_logging; |
| 286 |
}; |
| 287 |
|
| 288 |
extern dlink_list flatten_links; |
| 289 |
extern dlink_list server_items; |
| 290 |
extern dlink_list operator_items; |
| 291 |
extern struct conf_parser_context conf_parser_ctx; |
| 292 |
extern struct config_log_entry ConfigLog; |
| 293 |
extern struct config_general_entry ConfigGeneral; |
| 294 |
extern struct config_channel_entry ConfigChannel; |
| 295 |
extern struct config_serverhide_entry ConfigServerHide; |
| 296 |
extern struct config_serverinfo_entry ConfigServerInfo; |
| 297 |
extern struct config_admin_entry ConfigAdminInfo; |
| 298 |
|
| 299 |
extern int valid_wild_card_simple(const char *); |
| 300 |
extern int valid_wild_card(struct Client *, int, ...); |
| 301 |
/* End GLOBAL section */ |
| 302 |
|
| 303 |
extern struct MaskItem *conf_make(enum maskitem_type); |
| 304 |
extern void read_conf_files(int); |
| 305 |
extern int attach_conf(struct Client *, struct MaskItem *); |
| 306 |
extern int attach_connect_block(struct Client *, const char *, const char *); |
| 307 |
extern int check_client(struct Client *); |
| 308 |
|
| 309 |
|
| 310 |
extern void detach_conf(struct Client *, enum maskitem_type); |
| 311 |
extern struct MaskItem *find_conf_name(dlink_list *, const char *, enum maskitem_type); |
| 312 |
extern int conf_connect_allowed(struct irc_ssaddr *, int); |
| 313 |
extern const char *oper_privs_as_string(const unsigned int); |
| 314 |
extern void split_nuh(struct split_nuh_item *); |
| 315 |
extern struct MaskItem *find_matching_name_conf(enum maskitem_type, const char *, |
| 316 |
const char *, const char *, unsigned int); |
| 317 |
extern struct MaskItem *find_exact_name_conf(enum maskitem_type, const struct Client *, const char *, |
| 318 |
const char *, const char *); |
| 319 |
extern void conf_free(struct MaskItem *); |
| 320 |
extern void yyerror(const char *); |
| 321 |
extern void conf_error_report(const char *); |
| 322 |
extern void cleanup_tklines(void *); |
| 323 |
extern void conf_rehash(int); |
| 324 |
extern void lookup_confhost(struct MaskItem *); |
| 325 |
extern void conf_add_class_to_conf(struct MaskItem *, const char *); |
| 326 |
|
| 327 |
extern const char *get_oper_name(const struct Client *); |
| 328 |
|
| 329 |
/* XXX should the parse_aline stuff go into another file ?? */ |
| 330 |
#define AWILD 0x1 /* check wild cards */ |
| 331 |
extern int parse_aline(const char *, struct Client *, int, char **, |
| 332 |
int, char **, char **, time_t *, char **, char **); |
| 333 |
|
| 334 |
#define TK_SECONDS 0 |
| 335 |
#define TK_MINUTES 1 |
| 336 |
extern time_t valid_tkline(const char *, const int); |
| 337 |
extern int match_conf_password(const char *, const struct MaskItem *); |
| 338 |
|
| 339 |
enum { CLEANUP_TKLINES_TIME = 60 }; |
| 340 |
|
| 341 |
extern void cluster_a_line(struct Client *, const char *, unsigned int, unsigned int, const char *,...); |
| 342 |
#endif /* INCLUDED_s_conf_h */ |