1 |
/* |
2 |
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
3 |
* |
4 |
* Copyright (c) 1997-2015 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_s_conf_h |
28 |
#define INCLUDED_s_conf_h |
29 |
#include "config.h" |
30 |
#include "ircd_defs.h" |
31 |
#include "client.h" |
32 |
#include "conf_class.h" |
33 |
|
34 |
|
35 |
#define CONF_NOREASON "<No reason supplied>" |
36 |
|
37 |
#define IsConfKill(x) ((x)->type == CONF_KLINE) |
38 |
#define IsConfClient(x) ((x)->type == CONF_CLIENT) |
39 |
|
40 |
/* MaskItem->flags */ |
41 |
#define CONF_FLAGS_NO_TILDE 0x00000001U |
42 |
#define CONF_FLAGS_NEED_IDENTD 0x00000002U |
43 |
#define CONF_FLAGS_EXEMPTKLINE 0x00000004U |
44 |
#define CONF_FLAGS_NOLIMIT 0x00000008U |
45 |
#define CONF_FLAGS_SPOOF_IP 0x00000010U |
46 |
#define CONF_FLAGS_SPOOF_NOTICE 0x00000020U |
47 |
#define CONF_FLAGS_REDIR 0x00000040U |
48 |
#define CONF_FLAGS_CAN_FLOOD 0x00000080U |
49 |
#define CONF_FLAGS_NEED_PASSWORD 0x00000100U |
50 |
#define CONF_FLAGS_ALLOW_AUTO_CONN 0x00000200U |
51 |
#define CONF_FLAGS_ENCRYPTED 0x00000400U |
52 |
#define CONF_FLAGS_IN_DATABASE 0x00000800U |
53 |
#define CONF_FLAGS_EXEMPTRESV 0x00001000U |
54 |
#define CONF_FLAGS_SSL 0x00002000U |
55 |
#define CONF_FLAGS_WEBIRC 0x00004000U |
56 |
|
57 |
/* Macros for struct MaskItem */ |
58 |
#define IsConfWebIRC(x) ((x)->flags & CONF_FLAGS_WEBIRC) |
59 |
#define IsNoTilde(x) ((x)->flags & CONF_FLAGS_NO_TILDE) |
60 |
#define IsConfCanFlood(x) ((x)->flags & CONF_FLAGS_CAN_FLOOD) |
61 |
#define IsNeedPassword(x) ((x)->flags & CONF_FLAGS_NEED_PASSWORD) |
62 |
#define IsNeedIdentd(x) ((x)->flags & CONF_FLAGS_NEED_IDENTD) |
63 |
#define IsConfExemptKline(x) ((x)->flags & CONF_FLAGS_EXEMPTKLINE) |
64 |
#define IsConfExemptLimits(x) ((x)->flags & CONF_FLAGS_NOLIMIT) |
65 |
#define IsConfExemptResv(x) ((x)->flags & CONF_FLAGS_EXEMPTRESV) |
66 |
#define IsConfDoSpoofIp(x) ((x)->flags & CONF_FLAGS_SPOOF_IP) |
67 |
#define IsConfSpoofNotice(x) ((x)->flags & CONF_FLAGS_SPOOF_NOTICE) |
68 |
#define IsConfAllowAutoConn(x) ((x)->flags & CONF_FLAGS_ALLOW_AUTO_CONN) |
69 |
#define SetConfAllowAutoConn(x) ((x)->flags |= CONF_FLAGS_ALLOW_AUTO_CONN) |
70 |
#define ClearConfAllowAutoConn(x) ((x)->flags &= ~CONF_FLAGS_ALLOW_AUTO_CONN) |
71 |
#define IsConfRedir(x) ((x)->flags & CONF_FLAGS_REDIR) |
72 |
#define IsConfSSL(x) ((x)->flags & CONF_FLAGS_SSL) |
73 |
#define IsConfDatabase(x) ((x)->flags & CONF_FLAGS_IN_DATABASE) |
74 |
#define SetConfDatabase(x) ((x)->flags |= CONF_FLAGS_IN_DATABASE) |
75 |
|
76 |
|
77 |
/* shared/cluster server entry types |
78 |
* These defines are used for both shared and cluster. |
79 |
*/ |
80 |
#define SHARED_KLINE 0x00000001U |
81 |
#define SHARED_UNKLINE 0x00000002U |
82 |
#define SHARED_XLINE 0x00000004U |
83 |
#define SHARED_UNXLINE 0x00000008U |
84 |
#define SHARED_RESV 0x00000010U |
85 |
#define SHARED_UNRESV 0x00000020U |
86 |
#define SHARED_LOCOPS 0x00000040U |
87 |
#define SHARED_DLINE 0x00000080U |
88 |
#define SHARED_UNDLINE 0x00000100U |
89 |
#define SHARED_ALL (SHARED_KLINE | SHARED_UNKLINE |\ |
90 |
SHARED_XLINE | SHARED_UNXLINE |\ |
91 |
SHARED_RESV | SHARED_UNRESV |\ |
92 |
SHARED_LOCOPS | SHARED_DLINE | SHARED_UNDLINE) |
93 |
|
94 |
|
95 |
enum maskitem_type |
96 |
{ |
97 |
CONF_CLIENT = 1 << 0, |
98 |
CONF_SERVER = 1 << 1, |
99 |
CONF_KLINE = 1 << 2, |
100 |
CONF_DLINE = 1 << 3, |
101 |
CONF_EXEMPT = 1 << 4, |
102 |
CONF_CLUSTER = 1 << 5, |
103 |
CONF_XLINE = 1 << 6, |
104 |
CONF_ULINE = 1 << 7, |
105 |
CONF_CRESV = 1 << 8, |
106 |
CONF_NRESV = 1 << 9, |
107 |
CONF_SERVICE = 1 << 10, |
108 |
CONF_OPER = 1 << 11 |
109 |
}; |
110 |
|
111 |
enum |
112 |
{ |
113 |
NOT_AUTHORIZED = -1, |
114 |
I_LINE_FULL = -2, |
115 |
TOO_MANY = -3, |
116 |
BANNED_CLIENT = -4, |
117 |
TOO_FAST = -5 |
118 |
}; |
119 |
|
120 |
struct split_nuh_item |
121 |
{ |
122 |
dlink_node node; |
123 |
|
124 |
char *nuhmask; |
125 |
char *nickptr; |
126 |
char *userptr; |
127 |
char *hostptr; |
128 |
|
129 |
size_t nicksize; |
130 |
size_t usersize; |
131 |
size_t hostsize; |
132 |
}; |
133 |
|
134 |
struct MaskItem |
135 |
{ |
136 |
dlink_node node; |
137 |
dlink_list leaf_list; |
138 |
dlink_list hub_list; |
139 |
dlink_list exempt_list; |
140 |
enum maskitem_type type; |
141 |
unsigned int dns_failed; |
142 |
unsigned int dns_pending; |
143 |
unsigned int flags; |
144 |
unsigned int modes; |
145 |
unsigned int port; |
146 |
unsigned int count; |
147 |
unsigned int aftype; |
148 |
unsigned int active; |
149 |
unsigned int htype; |
150 |
unsigned int ref_count; /* Number of *LOCAL* clients using this */ |
151 |
int bits; |
152 |
time_t until; /* Hold action until this time (calendar time) */ |
153 |
time_t setat; |
154 |
struct irc_ssaddr bind; /* ip to bind to for outgoing connect */ |
155 |
struct irc_ssaddr addr; /* ip to connect to */ |
156 |
struct ClassItem *class; /* Class of connection */ |
157 |
char *name; |
158 |
char *user; /* user part of user@host */ |
159 |
char *host; /* host part of user@host */ |
160 |
char *passwd; |
161 |
char *spasswd; /* Password to send. */ |
162 |
char *reason; |
163 |
char *certfp; |
164 |
char *whois; |
165 |
char *cipher_list; |
166 |
void *rsa_public_key; |
167 |
}; |
168 |
|
169 |
struct exempt |
170 |
{ |
171 |
dlink_node node; |
172 |
char *name; |
173 |
char *user; |
174 |
char *host; |
175 |
size_t len; |
176 |
time_t when; |
177 |
struct irc_ssaddr addr; |
178 |
int bits; |
179 |
int type; |
180 |
int country_id; |
181 |
}; |
182 |
|
183 |
struct CidrItem |
184 |
{ |
185 |
dlink_node node; |
186 |
struct irc_ssaddr mask; |
187 |
unsigned int number_on_this_cidr; |
188 |
}; |
189 |
|
190 |
struct conf_parser_context |
191 |
{ |
192 |
unsigned int boot; |
193 |
unsigned int pass; |
194 |
FILE *conf_file; |
195 |
}; |
196 |
|
197 |
struct config_general_entry |
198 |
{ |
199 |
const char *dpath; |
200 |
const char *mpath; |
201 |
const char *spath; |
202 |
const char *configfile; |
203 |
const char *klinefile; |
204 |
const char *xlinefile; |
205 |
const char *dlinefile; |
206 |
const char *resvfile; |
207 |
|
208 |
unsigned int dline_min_cidr; |
209 |
unsigned int dline_min_cidr6; |
210 |
unsigned int kline_min_cidr; |
211 |
unsigned int kline_min_cidr6; |
212 |
unsigned int dots_in_ident; |
213 |
unsigned int failed_oper_notice; |
214 |
unsigned int anti_spam_exit_message_time; |
215 |
unsigned int max_accept; |
216 |
unsigned int max_watch; |
217 |
unsigned int away_time; |
218 |
unsigned int away_count; |
219 |
unsigned int max_nick_time; |
220 |
unsigned int max_nick_changes; |
221 |
unsigned int ts_max_delta; |
222 |
unsigned int ts_warn_delta; |
223 |
unsigned int anti_nick_flood; |
224 |
unsigned int warn_no_connect_block; |
225 |
unsigned int invisible_on_connect; |
226 |
unsigned int stats_e_disabled; |
227 |
unsigned int stats_i_oper_only; |
228 |
unsigned int stats_k_oper_only; |
229 |
unsigned int stats_m_oper_only; |
230 |
unsigned int stats_o_oper_only; |
231 |
unsigned int stats_P_oper_only; |
232 |
unsigned int stats_u_oper_only; |
233 |
unsigned int short_motd; |
234 |
unsigned int no_oper_flood; |
235 |
unsigned int oper_pass_resv; |
236 |
unsigned int tkline_expire_notices; |
237 |
unsigned int opers_bypass_callerid; |
238 |
unsigned int ignore_bogus_ts; |
239 |
unsigned int pace_wait; |
240 |
unsigned int pace_wait_simple; |
241 |
unsigned int oper_only_umodes; |
242 |
unsigned int oper_umodes; |
243 |
unsigned int max_targets; |
244 |
unsigned int caller_id_wait; |
245 |
unsigned int min_nonwildcard; |
246 |
unsigned int min_nonwildcard_simple; |
247 |
unsigned int kill_chase_time_limit; |
248 |
unsigned int default_floodcount; |
249 |
unsigned int throttle_count; |
250 |
unsigned int throttle_time; |
251 |
unsigned int ping_cookie; |
252 |
unsigned int disable_auth; |
253 |
unsigned int cycle_on_host_change; |
254 |
}; |
255 |
|
256 |
struct config_channel_entry |
257 |
{ |
258 |
unsigned int disable_fake_channels; |
259 |
unsigned int invite_client_count; |
260 |
unsigned int invite_client_time; |
261 |
unsigned int knock_client_count; |
262 |
unsigned int knock_client_time; |
263 |
unsigned int knock_delay_channel; |
264 |
unsigned int max_bans; |
265 |
unsigned int max_channels; |
266 |
unsigned int default_join_flood_count; |
267 |
unsigned int default_join_flood_time; |
268 |
unsigned int no_create_on_split; |
269 |
unsigned int no_join_on_split; |
270 |
unsigned int default_split_server_count; |
271 |
unsigned int default_split_user_count; |
272 |
}; |
273 |
|
274 |
struct config_serverhide_entry |
275 |
{ |
276 |
char *hidden_name; |
277 |
unsigned int flatten_links; |
278 |
unsigned int disable_remote_commands; |
279 |
unsigned int hide_servers; |
280 |
unsigned int hide_services; |
281 |
unsigned int links_delay; |
282 |
unsigned int links_disabled; |
283 |
unsigned int hidden; |
284 |
unsigned int hide_server_ips; |
285 |
}; |
286 |
|
287 |
struct config_serverinfo_entry |
288 |
{ |
289 |
#ifdef HAVE_LIBCRYPTO |
290 |
const EVP_MD *message_digest_algorithm; |
291 |
#endif |
292 |
char *sid; |
293 |
char *name; |
294 |
char *description; |
295 |
char *network_name; |
296 |
char *network_desc; |
297 |
char *rsa_private_key_file; |
298 |
void *rsa_private_key; |
299 |
void *server_ctx; |
300 |
void *client_ctx; |
301 |
unsigned int hub; |
302 |
unsigned int default_max_clients; |
303 |
unsigned int max_nick_length; |
304 |
unsigned int max_topic_length; |
305 |
unsigned int specific_ipv4_vhost; |
306 |
unsigned int specific_ipv6_vhost; |
307 |
struct irc_ssaddr ip; |
308 |
struct irc_ssaddr ip6; |
309 |
}; |
310 |
|
311 |
struct config_admin_entry |
312 |
{ |
313 |
char *name; |
314 |
char *description; |
315 |
char *email; |
316 |
}; |
317 |
|
318 |
struct config_log_entry |
319 |
{ |
320 |
unsigned int use_logging; |
321 |
}; |
322 |
|
323 |
extern dlink_list flatten_links; |
324 |
extern dlink_list server_items; |
325 |
extern dlink_list cluster_items; |
326 |
extern dlink_list xconf_items; |
327 |
extern dlink_list uconf_items; |
328 |
extern dlink_list oconf_items; |
329 |
extern dlink_list service_items; |
330 |
extern dlink_list nresv_items; |
331 |
extern dlink_list cresv_items; |
332 |
extern struct conf_parser_context conf_parser_ctx; |
333 |
extern struct config_log_entry ConfigLog; |
334 |
extern struct config_general_entry ConfigGeneral; |
335 |
extern struct config_channel_entry ConfigChannel; |
336 |
extern struct config_serverhide_entry ConfigServerHide; |
337 |
extern struct config_serverinfo_entry ConfigServerInfo; |
338 |
extern struct config_admin_entry ConfigAdminInfo; |
339 |
|
340 |
extern int valid_wild_card_simple(const char *); |
341 |
extern int valid_wild_card(struct Client *, int, ...); |
342 |
/* End GLOBAL section */ |
343 |
|
344 |
extern struct MaskItem *conf_make(enum maskitem_type); |
345 |
extern void read_conf_files(int); |
346 |
extern int attach_conf(struct Client *, struct MaskItem *); |
347 |
extern int attach_connect_block(struct Client *, const char *, const char *); |
348 |
extern int check_client(struct Client *); |
349 |
|
350 |
|
351 |
extern void detach_conf(struct Client *, enum maskitem_type); |
352 |
extern struct MaskItem *find_conf_name(dlink_list *, const char *, enum maskitem_type); |
353 |
extern int conf_connect_allowed(struct irc_ssaddr *, int); |
354 |
extern const char *oper_privs_as_string(const unsigned int); |
355 |
extern void split_nuh(struct split_nuh_item *); |
356 |
extern struct MaskItem *find_matching_name_conf(enum maskitem_type, const char *, |
357 |
const char *, const char *, unsigned int); |
358 |
extern struct MaskItem *find_exact_name_conf(enum maskitem_type, const struct Client *, const char *, |
359 |
const char *, const char *); |
360 |
extern void conf_free(struct MaskItem *); |
361 |
extern void yyerror(const char *); |
362 |
extern void conf_error_report(const char *); |
363 |
extern void cleanup_tklines(void *); |
364 |
extern void conf_rehash(int); |
365 |
extern void lookup_confhost(struct MaskItem *); |
366 |
extern void conf_add_class_to_conf(struct MaskItem *, const char *); |
367 |
|
368 |
extern const char *get_oper_name(const struct Client *); |
369 |
|
370 |
/* XXX should the parse_aline stuff go into another file ?? */ |
371 |
#define AWILD 0x1 /* check wild cards */ |
372 |
extern int parse_aline(const char *, struct Client *, int, char **, |
373 |
int, char **, char **, time_t *, char **, char **); |
374 |
extern int valid_comment(struct Client *, char *, int); |
375 |
|
376 |
|
377 |
#define TK_SECONDS 0 |
378 |
#define TK_MINUTES 1 |
379 |
extern time_t valid_tkline(const char *, const int); |
380 |
extern int match_conf_password(const char *, const struct MaskItem *); |
381 |
|
382 |
#define CLEANUP_TKLINES_TIME 60 |
383 |
|
384 |
extern void cluster_a_line(struct Client *, const char *, unsigned int, unsigned int, const char *,...); |
385 |
#endif /* INCLUDED_s_conf_h */ |