| 1 |
/* |
| 2 |
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
| 3 |
* |
| 4 |
* Copyright (c) 1997-2020 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 |
enum |
| 36 |
{ |
| 37 |
TK_SECONDS, |
| 38 |
TK_MINUTES |
| 39 |
}; |
| 40 |
|
| 41 |
enum { CLEANUP_TKLINES_TIME = 60 }; |
| 42 |
|
| 43 |
#define CONF_NOREASON "<No reason supplied>" |
| 44 |
|
| 45 |
/* MaskItem->flags */ |
| 46 |
enum |
| 47 |
{ |
| 48 |
CONF_FLAGS_NO_TILDE = 1 << 0, |
| 49 |
CONF_FLAGS_NEED_IDENTD = 1 << 1, |
| 50 |
CONF_FLAGS_EXEMPTKLINE = 1 << 2, |
| 51 |
CONF_FLAGS_NOLIMIT = 1 << 3, |
| 52 |
CONF_FLAGS_SPOOF_IP = 1 << 4, |
| 53 |
CONF_FLAGS_SPOOF_NOTICE = 1 << 5, |
| 54 |
CONF_FLAGS_REDIR = 1 << 6, |
| 55 |
CONF_FLAGS_CAN_FLOOD = 1 << 7, |
| 56 |
CONF_FLAGS_NEED_PASSWORD = 1 << 8, |
| 57 |
CONF_FLAGS_ALLOW_AUTO_CONN = 1 << 9, |
| 58 |
CONF_FLAGS_ENCRYPTED = 1 << 10, |
| 59 |
CONF_FLAGS_IN_DATABASE = 1 << 11, |
| 60 |
CONF_FLAGS_EXEMPTRESV = 1 << 12, |
| 61 |
CONF_FLAGS_SSL = 1 << 13, |
| 62 |
CONF_FLAGS_WEBIRC = 1 << 14, |
| 63 |
CONF_FLAGS_EXEMPTXLINE = 1 << 15 |
| 64 |
}; |
| 65 |
|
| 66 |
/* Macros for struct MaskItem */ |
| 67 |
#define IsConfWebIRC(x) ((x)->flags & CONF_FLAGS_WEBIRC) |
| 68 |
#define IsNoTilde(x) ((x)->flags & CONF_FLAGS_NO_TILDE) |
| 69 |
#define IsConfCanFlood(x) ((x)->flags & CONF_FLAGS_CAN_FLOOD) |
| 70 |
#define IsNeedPassword(x) ((x)->flags & CONF_FLAGS_NEED_PASSWORD) |
| 71 |
#define IsNeedIdentd(x) ((x)->flags & CONF_FLAGS_NEED_IDENTD) |
| 72 |
#define IsConfExemptKline(x) ((x)->flags & CONF_FLAGS_EXEMPTKLINE) |
| 73 |
#define IsConfExemptXline(x) ((x)->flags & CONF_FLAGS_EXEMPTXLINE) |
| 74 |
#define IsConfExemptLimits(x) ((x)->flags & CONF_FLAGS_NOLIMIT) |
| 75 |
#define IsConfExemptResv(x) ((x)->flags & CONF_FLAGS_EXEMPTRESV) |
| 76 |
#define IsConfDoSpoofIp(x) ((x)->flags & CONF_FLAGS_SPOOF_IP) |
| 77 |
#define IsConfSpoofNotice(x) ((x)->flags & CONF_FLAGS_SPOOF_NOTICE) |
| 78 |
#define IsConfAllowAutoConn(x) ((x)->flags & CONF_FLAGS_ALLOW_AUTO_CONN) |
| 79 |
#define SetConfAllowAutoConn(x) ((x)->flags |= CONF_FLAGS_ALLOW_AUTO_CONN) |
| 80 |
#define ClearConfAllowAutoConn(x) ((x)->flags &= ~CONF_FLAGS_ALLOW_AUTO_CONN) |
| 81 |
#define IsConfRedir(x) ((x)->flags & CONF_FLAGS_REDIR) |
| 82 |
#define IsConfSSL(x) ((x)->flags & CONF_FLAGS_SSL) |
| 83 |
#define IsConfDatabase(x) ((x)->flags & CONF_FLAGS_IN_DATABASE) |
| 84 |
#define SetConfDatabase(x) ((x)->flags |= CONF_FLAGS_IN_DATABASE) |
| 85 |
|
| 86 |
|
| 87 |
enum maskitem_type |
| 88 |
{ |
| 89 |
CONF_CLIENT = 1, |
| 90 |
CONF_SERVER, |
| 91 |
CONF_KLINE, |
| 92 |
CONF_DLINE, |
| 93 |
CONF_EXEMPT, |
| 94 |
CONF_OPER |
| 95 |
}; |
| 96 |
|
| 97 |
#define IsConfKill(x) ((x)->type == CONF_KLINE) |
| 98 |
#define IsConfClient(x) ((x)->type == CONF_CLIENT) |
| 99 |
|
| 100 |
enum |
| 101 |
{ |
| 102 |
NOT_AUTHORIZED = -1, |
| 103 |
I_LINE_FULL = -2, |
| 104 |
TOO_MANY = -3, |
| 105 |
BANNED_CLIENT = -4, |
| 106 |
TOO_FAST = -5 |
| 107 |
}; |
| 108 |
|
| 109 |
struct split_nuh_item |
| 110 |
{ |
| 111 |
dlink_node node; |
| 112 |
|
| 113 |
char *nuhmask; |
| 114 |
char *nickptr; |
| 115 |
char *userptr; |
| 116 |
char *hostptr; |
| 117 |
|
| 118 |
size_t nicksize; |
| 119 |
size_t usersize; |
| 120 |
size_t hostsize; |
| 121 |
}; |
| 122 |
|
| 123 |
struct MaskItem |
| 124 |
{ |
| 125 |
dlink_node node; |
| 126 |
dlink_list leaf_list; |
| 127 |
dlink_list hub_list; |
| 128 |
enum maskitem_type type; |
| 129 |
bool active; |
| 130 |
bool dns_failed; |
| 131 |
bool dns_pending; |
| 132 |
unsigned int flags; |
| 133 |
unsigned int modes; |
| 134 |
unsigned int port; |
| 135 |
unsigned int aftype; |
| 136 |
unsigned int htype; |
| 137 |
unsigned int ref_count; /* Number of *LOCAL* clients using this */ |
| 138 |
int bits; |
| 139 |
uintmax_t until; /* Hold action until this time (calendar time) */ |
| 140 |
uintmax_t setat; |
| 141 |
uintmax_t timeout; |
| 142 |
struct irc_ssaddr *bind; /* ip to bind to for outgoing connect */ |
| 143 |
struct irc_ssaddr *addr; /* ip to connect to */ |
| 144 |
struct ClassItem *class; /* Class of connection */ |
| 145 |
char *name; |
| 146 |
char *user; /* user part of user@host */ |
| 147 |
char *host; /* host part of user@host */ |
| 148 |
char *passwd; |
| 149 |
char *spasswd; /* Password to send. */ |
| 150 |
char *reason; |
| 151 |
char *certfp; |
| 152 |
char *whois; |
| 153 |
char *cipher_list; |
| 154 |
}; |
| 155 |
|
| 156 |
struct conf_parser_context |
| 157 |
{ |
| 158 |
unsigned int boot; |
| 159 |
unsigned int pass; |
| 160 |
FILE *conf_file; |
| 161 |
}; |
| 162 |
|
| 163 |
struct config_general_entry |
| 164 |
{ |
| 165 |
const char *dpath; |
| 166 |
const char *mpath; |
| 167 |
const char *spath; |
| 168 |
const char *configfile; |
| 169 |
const char *klinefile; |
| 170 |
const char *xlinefile; |
| 171 |
const char *dlinefile; |
| 172 |
const char *resvfile; |
| 173 |
|
| 174 |
unsigned int dline_min_cidr; |
| 175 |
unsigned int dline_min_cidr6; |
| 176 |
unsigned int kline_min_cidr; |
| 177 |
unsigned int kline_min_cidr6; |
| 178 |
unsigned int dots_in_ident; |
| 179 |
unsigned int failed_oper_notice; |
| 180 |
unsigned int anti_spam_exit_message_time; |
| 181 |
unsigned int max_accept; |
| 182 |
unsigned int max_watch; |
| 183 |
unsigned int whowas_history_length; |
| 184 |
unsigned int away_time; |
| 185 |
unsigned int away_count; |
| 186 |
unsigned int max_nick_time; |
| 187 |
unsigned int max_nick_changes; |
| 188 |
unsigned int ts_max_delta; |
| 189 |
unsigned int ts_warn_delta; |
| 190 |
unsigned int anti_nick_flood; |
| 191 |
unsigned int warn_no_connect_block; |
| 192 |
unsigned int invisible_on_connect; |
| 193 |
unsigned int stats_e_disabled; |
| 194 |
unsigned int stats_i_oper_only; |
| 195 |
unsigned int stats_k_oper_only; |
| 196 |
unsigned int stats_m_oper_only; |
| 197 |
unsigned int stats_o_oper_only; |
| 198 |
unsigned int stats_P_oper_only; |
| 199 |
unsigned int stats_u_oper_only; |
| 200 |
unsigned int short_motd; |
| 201 |
unsigned int no_oper_flood; |
| 202 |
unsigned int opers_bypass_callerid; |
| 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 default_floodtime; |
| 214 |
unsigned int throttle_count; |
| 215 |
unsigned int throttle_time; |
| 216 |
unsigned int ping_cookie; |
| 217 |
unsigned int disable_auth; |
| 218 |
unsigned int cycle_on_host_change; |
| 219 |
}; |
| 220 |
|
| 221 |
struct config_channel_entry |
| 222 |
{ |
| 223 |
unsigned int disable_fake_channels; |
| 224 |
unsigned int invite_client_count; |
| 225 |
unsigned int invite_client_time; |
| 226 |
unsigned int invite_delay_channel; |
| 227 |
unsigned int invite_expire_time; |
| 228 |
unsigned int knock_client_count; |
| 229 |
unsigned int knock_client_time; |
| 230 |
unsigned int knock_delay_channel; |
| 231 |
unsigned int max_invites; |
| 232 |
unsigned int max_bans; |
| 233 |
unsigned int max_bans_large; |
| 234 |
unsigned int max_channels; |
| 235 |
unsigned int default_join_flood_count; |
| 236 |
unsigned int default_join_flood_time; |
| 237 |
}; |
| 238 |
|
| 239 |
struct config_serverhide_entry |
| 240 |
{ |
| 241 |
char *hidden_name; |
| 242 |
char *flatten_links_file; |
| 243 |
unsigned int flatten_links; |
| 244 |
unsigned int flatten_links_delay; |
| 245 |
unsigned int disable_remote_commands; |
| 246 |
unsigned int hide_servers; |
| 247 |
unsigned int hide_services; |
| 248 |
unsigned int hidden; |
| 249 |
unsigned int hide_server_ips; |
| 250 |
}; |
| 251 |
|
| 252 |
struct config_serverinfo_entry |
| 253 |
{ |
| 254 |
char *sid; |
| 255 |
char *name; |
| 256 |
char *description; |
| 257 |
char *network_name; |
| 258 |
char *network_desc; |
| 259 |
char *rsa_private_key_file; |
| 260 |
char *ssl_certificate_file; |
| 261 |
char *ssl_dh_param_file; |
| 262 |
char *ssl_dh_elliptic_curve; |
| 263 |
char *ssl_cipher_list; |
| 264 |
char *ssl_message_digest_algorithm; |
| 265 |
tls_context_t tls_ctx; |
| 266 |
tls_md_t message_digest_algorithm; |
| 267 |
unsigned int hub; |
| 268 |
unsigned int default_max_clients; |
| 269 |
unsigned int max_nick_length; |
| 270 |
unsigned int max_topic_length; |
| 271 |
}; |
| 272 |
|
| 273 |
struct config_admin_entry |
| 274 |
{ |
| 275 |
char *name; |
| 276 |
char *description; |
| 277 |
char *email; |
| 278 |
}; |
| 279 |
|
| 280 |
struct config_log_entry |
| 281 |
{ |
| 282 |
unsigned int use_logging; |
| 283 |
}; |
| 284 |
|
| 285 |
struct aline_ctx |
| 286 |
{ |
| 287 |
bool add; |
| 288 |
bool simple_mask; |
| 289 |
char *mask; |
| 290 |
char *user; |
| 291 |
char *host; |
| 292 |
char *reason; |
| 293 |
char *server; |
| 294 |
uintmax_t duration; |
| 295 |
}; |
| 296 |
|
| 297 |
extern dlink_list flatten_links; |
| 298 |
extern dlink_list connect_items; |
| 299 |
extern dlink_list operator_items; |
| 300 |
extern struct conf_parser_context conf_parser_ctx; |
| 301 |
extern struct config_log_entry ConfigLog; |
| 302 |
extern struct config_general_entry ConfigGeneral; |
| 303 |
extern struct config_channel_entry ConfigChannel; |
| 304 |
extern struct config_serverhide_entry ConfigServerHide; |
| 305 |
extern struct config_serverinfo_entry ConfigServerInfo; |
| 306 |
extern struct config_admin_entry ConfigAdminInfo; |
| 307 |
|
| 308 |
extern bool valid_wild_card_simple(const char *); |
| 309 |
extern bool valid_wild_card(int, ...); |
| 310 |
|
| 311 |
extern struct MaskItem *conf_make(enum maskitem_type); |
| 312 |
extern void read_conf_files(bool); |
| 313 |
extern int conf_attach(struct Client *, struct MaskItem *); |
| 314 |
extern int check_client(struct Client *); |
| 315 |
|
| 316 |
|
| 317 |
extern void conf_detach(struct Client *, enum maskitem_type); |
| 318 |
extern struct MaskItem *find_conf_name(dlink_list *, const char *, enum maskitem_type); |
| 319 |
extern int conf_connect_allowed(struct irc_ssaddr *); |
| 320 |
extern void split_nuh(struct split_nuh_item *); |
| 321 |
extern struct MaskItem *operator_find(const struct Client *, const char *); |
| 322 |
extern struct MaskItem *connect_find(const char *, int (*)(const char *, const char *)); |
| 323 |
extern void conf_free(struct MaskItem *); |
| 324 |
extern void yyerror(const char *); |
| 325 |
extern void conf_error_report(const char *); |
| 326 |
extern void cleanup_tklines(void *); |
| 327 |
extern void conf_rehash(bool); |
| 328 |
extern void lookup_confhost(struct MaskItem *); |
| 329 |
extern void conf_add_class_to_conf(struct MaskItem *, const char *); |
| 330 |
|
| 331 |
extern const char *get_oper_name(const struct Client *); |
| 332 |
|
| 333 |
/* XXX should the parse_aline stuff go into another file ?? */ |
| 334 |
extern bool parse_aline(const char *, struct Client *, int, char **, struct aline_ctx *); |
| 335 |
|
| 336 |
extern uintmax_t valid_tkline(const char *, const int); |
| 337 |
extern bool match_conf_password(const char *, const struct MaskItem *); |
| 338 |
#endif /* INCLUDED_conf_h */ |