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