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