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