]>
Commit | Line | Data |
---|---|---|
212380e3 AC |
1 | /* |
2 | * charybdis: Advanced, scalable Internet Relay Chat. | |
3 | * s_conf.h: A header for the configuration functions. | |
4 | * | |
5 | * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center | |
6 | * Copyright (C) 1996-2002 Hybrid Development Team | |
7 | * Copyright (C) 2002-2004 ircd-ratbox development team | |
8 | * | |
9 | * This program is free software; you can redistribute it and/or modify | |
10 | * it under the terms of the GNU General Public License as published by | |
11 | * the Free Software Foundation; either version 2 of the License, or | |
12 | * (at your option) any later version. | |
13 | * | |
14 | * This program is distributed in the hope that it will be useful, | |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | * GNU General Public License for more details. | |
18 | * | |
19 | * You should have received a copy of the GNU General Public License | |
20 | * along with this program; if not, write to the Free Software | |
21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 | |
22 | * USA | |
23 | * | |
cda8e9b8 | 24 | * $Id: s_conf.h 3550 2007-08-09 06:47:26Z nenolod $ |
212380e3 AC |
25 | */ |
26 | ||
27 | #ifndef INCLUDED_s_conf_h | |
28 | #define INCLUDED_s_conf_h | |
29 | #include "setup.h" | |
30 | ||
31 | #ifdef HAVE_LIBCRYPTO | |
32 | #include <openssl/rsa.h> | |
33 | #endif | |
34 | ||
35 | #include "ircd_defs.h" | |
36 | #include "class.h" | |
37 | #include "client.h" | |
38 | #include "common.h" | |
39 | #include "patricia.h" | |
40 | ||
41 | struct Client; | |
42 | struct DNSReply; | |
43 | struct hostent; | |
44 | ||
45 | /* used by new parser */ | |
46 | /* yacc/lex love globals!!! */ | |
47 | ||
48 | struct ip_value | |
49 | { | |
50 | struct irc_sockaddr_storage ip; | |
51 | int ip_mask; | |
52 | int type; | |
53 | }; | |
54 | ||
55 | extern FILE *conf_fbfile_in; | |
56 | extern char conf_line_in[256]; | |
57 | ||
58 | struct ConfItem | |
59 | { | |
60 | struct ConfItem *next; /* list node pointer */ | |
61 | unsigned int status; /* If CONF_ILLEGAL, delete when no clients */ | |
62 | unsigned int flags; | |
63 | int clients; /* Number of *LOCAL* clients using this */ | |
64 | char *name; /* IRC name, nick, server name, or original u@h */ | |
65 | char *host; /* host part of user@host */ | |
66 | char *passwd; /* doubles as kline reason *ugh* */ | |
67 | char *spasswd; /* Password to send. */ | |
68 | char *user; /* user part of user@host */ | |
69 | int port; | |
70 | time_t hold; /* Hold action until this time (calendar time) */ | |
71 | char *className; /* Name of class */ | |
72 | struct Class *c_class; /* Class of connection */ | |
73 | patricia_node_t *pnode; /* Our patricia node */ | |
74 | }; | |
75 | ||
76 | #define CONF_ILLEGAL 0x80000000 | |
77 | #define CONF_QUARANTINED_NICK 0x0001 | |
78 | #define CONF_CLIENT 0x0002 | |
79 | #define CONF_KILL 0x0040 | |
80 | #define CONF_XLINE 0x0080 | |
81 | #define CONF_RESV_CHANNEL 0x0100 | |
82 | #define CONF_RESV_NICK 0x0200 | |
83 | #define CONF_RESV (CONF_RESV_CHANNEL | CONF_RESV_NICK) | |
84 | ||
85 | #define CONF_CLASS 0x0400 | |
86 | #define CONF_LISTEN_PORT 0x1000 | |
87 | #define CONF_EXEMPTKLINE 0x4000 | |
88 | #define CONF_NOLIMIT 0x8000 | |
89 | #define CONF_GLINE 0x10000 | |
90 | #define CONF_DLINE 0x20000 | |
91 | #define CONF_EXEMPTDLINE 0x100000 | |
92 | ||
93 | #define IsIllegal(x) ((x)->status & CONF_ILLEGAL) | |
94 | ||
95 | /* aConfItem->flags */ | |
96 | ||
97 | /* Generic flags... */ | |
98 | /* access flags... */ | |
99 | #define CONF_FLAGS_DO_IDENTD 0x00000001 | |
100 | #define CONF_FLAGS_LIMIT_IP 0x00000002 | |
101 | #define CONF_FLAGS_NO_TILDE 0x00000004 | |
102 | #define CONF_FLAGS_NEED_IDENTD 0x00000008 | |
103 | #define CONF_FLAGS_PASS_IDENTD 0x00000010 | |
104 | #define CONF_FLAGS_NOMATCH_IP 0x00000020 | |
105 | #define CONF_FLAGS_EXEMPTKLINE 0x00000040 | |
106 | #define CONF_FLAGS_NOLIMIT 0x00000080 | |
107 | #define CONF_FLAGS_IDLE_LINED 0x00000100 | |
108 | #define CONF_FLAGS_SPOOF_IP 0x00000200 | |
109 | #define CONF_FLAGS_SPOOF_NOTICE 0x00000400 | |
110 | #define CONF_FLAGS_REDIR 0x00000800 | |
111 | #define CONF_FLAGS_EXEMPTGLINE 0x00001000 | |
112 | #define CONF_FLAGS_EXEMPTRESV 0x00002000 /* exempt from resvs */ | |
113 | #define CONF_FLAGS_EXEMPTFLOOD 0x00004000 | |
114 | #define CONF_FLAGS_EXEMPTSPAMBOT 0x00008000 | |
115 | #define CONF_FLAGS_EXEMPTSHIDE 0x00010000 | |
116 | #define CONF_FLAGS_EXEMPTJUPE 0x00020000 /* exempt from resv generating warnings */ | |
117 | #define CONF_FLAGS_NEED_SASL 0x00040000 | |
118 | /* server flags */ | |
119 | #define CONF_FLAGS_ALLOW_AUTO_CONN 0x00080000 | |
120 | #define CONF_FLAGS_LAZY_LINK 0x00100000 | |
121 | #define CONF_FLAGS_ENCRYPTED 0x00200000 | |
122 | #define CONF_FLAGS_COMPRESSED 0x00400000 | |
123 | #define CONF_FLAGS_TEMPORARY 0x00800000 | |
124 | #define CONF_FLAGS_TB 0x01000000 | |
125 | #define CONF_FLAGS_VHOSTED 0x02000000 | |
126 | #define CONF_FLAGS_EXEMPTDNSBL 0x04000000 | |
127 | ||
128 | ||
129 | /* Macros for struct ConfItem */ | |
130 | #define IsLimitIp(x) ((x)->flags & CONF_FLAGS_LIMIT_IP) | |
131 | #define IsNoTilde(x) ((x)->flags & CONF_FLAGS_NO_TILDE) | |
132 | #define IsNeedIdentd(x) ((x)->flags & CONF_FLAGS_NEED_IDENTD) | |
133 | #define IsPassIdentd(x) ((x)->flags & CONF_FLAGS_PASS_IDENTD) | |
134 | #define IsNoMatchIp(x) ((x)->flags & CONF_FLAGS_NOMATCH_IP) | |
135 | #define IsConfExemptKline(x) ((x)->flags & CONF_FLAGS_EXEMPTKLINE) | |
136 | #define IsConfExemptLimits(x) ((x)->flags & CONF_FLAGS_NOLIMIT) | |
137 | #define IsConfExemptGline(x) ((x)->flags & CONF_FLAGS_EXEMPTGLINE) | |
138 | #define IsConfExemptFlood(x) ((x)->flags & CONF_FLAGS_EXEMPTFLOOD) | |
139 | #define IsConfExemptSpambot(x) ((x)->flags & CONF_FLAGS_EXEMPTSPAMBOT) | |
140 | #define IsConfExemptShide(x) ((x)->flags & CONF_FLAGS_EXEMPTSHIDE) | |
141 | #define IsConfExemptJupe(x) ((x)->flags & CONF_FLAGS_EXEMPTJUPE) | |
142 | #define IsConfExemptResv(x) ((x)->flags & CONF_FLAGS_EXEMPTRESV) | |
143 | #define IsConfIdlelined(x) ((x)->flags & CONF_FLAGS_IDLE_LINED) | |
144 | #define IsConfDoIdentd(x) ((x)->flags & CONF_FLAGS_DO_IDENTD) | |
145 | #define IsConfDoSpoofIp(x) ((x)->flags & CONF_FLAGS_SPOOF_IP) | |
146 | #define IsConfSpoofNotice(x) ((x)->flags & CONF_FLAGS_SPOOF_NOTICE) | |
147 | #define IsConfEncrypted(x) ((x)->flags & CONF_FLAGS_ENCRYPTED) | |
148 | #define IsConfCompressed(x) ((x)->flags & CONF_FLAGS_COMPRESSED) | |
149 | #define IsConfVhosted(x) ((x)->flags & CONF_FLAGS_VHOSTED) | |
150 | #define IsConfTburst(x) ((x)->flags & CONF_FLAGS_TB) | |
151 | #define IsNeedSasl(x) ((x)->flags & CONF_FLAGS_NEED_SASL) | |
152 | #define IsConfExemptDNSBL(x) ((x)->flags & CONF_FLAGS_EXEMPTDNSBL) | |
153 | ||
154 | /* flag definitions for opers now in client.h */ | |
155 | ||
156 | struct config_file_entry | |
157 | { | |
158 | const char *dpath; /* DPATH if set from command line */ | |
159 | const char *configfile; | |
160 | const char *klinefile; | |
161 | const char *dlinefile; | |
162 | const char *xlinefile; | |
163 | const char *resvfile; | |
164 | ||
165 | char *servlink_path; | |
166 | char *egdpool_path; | |
167 | ||
168 | char *default_operstring; | |
169 | char *default_adminstring; | |
170 | char *servicestring; | |
171 | char *kline_reason; | |
172 | ||
173 | char *identifyservice; | |
174 | char *identifycommand; | |
175 | ||
176 | char *fname_userlog; | |
177 | char *fname_fuserlog; | |
178 | char *fname_operlog; | |
179 | char *fname_foperlog; | |
180 | char *fname_serverlog; | |
181 | char *fname_killlog; | |
182 | char *fname_glinelog; | |
183 | char *fname_klinelog; | |
184 | char *fname_operspylog; | |
185 | char *fname_ioerrorlog; | |
186 | ||
187 | unsigned char compression_level; | |
188 | int disable_fake_channels; | |
189 | int dot_in_ip6_addr; | |
190 | int dots_in_ident; | |
191 | int failed_oper_notice; | |
192 | int anti_nick_flood; | |
193 | int anti_spam_exit_message_time; | |
194 | int max_accept; | |
195 | int max_monitor; | |
196 | int max_nick_time; | |
197 | int max_nick_changes; | |
198 | int ts_max_delta; | |
199 | int ts_warn_delta; | |
200 | int dline_with_reason; | |
201 | int kline_with_reason; | |
202 | int kline_delay; | |
203 | int warn_no_nline; | |
204 | int nick_delay; | |
205 | int non_redundant_klines; | |
206 | int stats_e_disabled; | |
207 | int stats_c_oper_only; | |
208 | int stats_y_oper_only; | |
209 | int stats_h_oper_only; | |
210 | int stats_o_oper_only; | |
211 | int stats_k_oper_only; | |
212 | int stats_i_oper_only; | |
213 | int stats_P_oper_only; | |
214 | int map_oper_only; | |
215 | int operspy_admin_only; | |
216 | int pace_wait; | |
217 | int pace_wait_simple; | |
218 | int short_motd; | |
219 | int no_oper_flood; | |
220 | int glines; | |
221 | int gline_time; | |
222 | int gline_min_cidr; | |
223 | int gline_min_cidr6; | |
224 | int idletime; | |
225 | int hide_server; | |
226 | int hide_spoof_ips; | |
227 | int hide_error_messages; | |
228 | int client_exit; | |
229 | int oper_only_umodes; | |
230 | int oper_umodes; | |
231 | int oper_snomask; | |
232 | int max_targets; | |
233 | int caller_id_wait; | |
234 | int min_nonwildcard; | |
235 | int min_nonwildcard_simple; | |
236 | int default_floodcount; | |
237 | int client_flood; | |
238 | int use_egd; | |
239 | int ping_cookie; | |
240 | int tkline_expire_notices; | |
241 | int use_whois_actually; | |
242 | int disable_auth; | |
243 | int connect_timeout; | |
244 | int burst_away; | |
245 | int reject_ban_time; | |
246 | int reject_after_count; | |
247 | int reject_duration; | |
248 | int target_change; | |
249 | int collision_fnc; | |
250 | int default_umodes; | |
251 | int global_snotices; | |
252 | int operspy_dont_care_user_info; | |
54015b5f | 253 | int max_unknown_ip; |
212380e3 AC |
254 | }; |
255 | ||
256 | struct config_channel_entry | |
257 | { | |
258 | int use_except; | |
259 | int use_invex; | |
260 | int use_knock; | |
261 | int use_forward; | |
262 | int knock_delay; | |
263 | int knock_delay_channel; | |
264 | int max_bans; | |
265 | int max_bans_large; | |
266 | int max_chans_per_user; | |
267 | int no_create_on_split; | |
268 | int no_join_on_split; | |
269 | int default_split_server_count; | |
270 | int default_split_user_count; | |
271 | int burst_topicwho; | |
212380e3 AC |
272 | int kick_on_split_riding; |
273 | }; | |
274 | ||
275 | struct config_server_hide | |
276 | { | |
277 | int flatten_links; | |
278 | int links_delay; | |
279 | int links_disabled; | |
280 | int hidden; | |
281 | int disable_hidden; | |
282 | }; | |
283 | ||
284 | struct server_info | |
285 | { | |
286 | char *name; | |
287 | char sid[3]; | |
288 | char *description; | |
289 | char *network_name; | |
290 | char *network_desc; | |
291 | int hub; | |
212380e3 AC |
292 | struct sockaddr_in ip; |
293 | #ifdef IPV6 | |
294 | struct sockaddr_in6 ip6; | |
295 | #endif | |
296 | int specific_ipv4_vhost; | |
297 | #ifdef IPV6 | |
298 | int specific_ipv6_vhost; | |
299 | #endif | |
c2d96fcb AC |
300 | |
301 | int max_clients; | |
212380e3 AC |
302 | }; |
303 | ||
304 | struct admin_info | |
305 | { | |
306 | char *name; | |
307 | char *description; | |
308 | char *email; | |
309 | }; | |
310 | ||
311 | struct alias_entry | |
312 | { | |
313 | char *name; | |
314 | char *target; | |
315 | int flags; /* reserved for later use */ | |
316 | int hits; | |
317 | }; | |
318 | ||
319 | /* All variables are GLOBAL */ | |
320 | extern int specific_ipv4_vhost; /* used in s_bsd.c */ | |
321 | extern int specific_ipv6_vhost; | |
322 | extern struct config_file_entry ConfigFileEntry; /* defined in ircd.c */ | |
323 | extern struct config_channel_entry ConfigChannel; /* defined in channel.c */ | |
324 | extern struct config_server_hide ConfigServerHide; /* defined in s_conf.c */ | |
325 | extern struct server_info ServerInfo; /* defined in ircd.c */ | |
326 | extern struct admin_info AdminInfo; /* defined in ircd.c */ | |
327 | /* End GLOBAL section */ | |
328 | ||
329 | dlink_list service_list; | |
330 | ||
331 | typedef enum temp_list | |
332 | { | |
333 | TEMP_MIN, | |
334 | TEMP_HOUR, | |
335 | TEMP_DAY, | |
336 | TEMP_WEEK, | |
337 | LAST_TEMP_TYPE | |
338 | } temp_list; | |
339 | ||
340 | dlink_list temp_klines[LAST_TEMP_TYPE]; | |
341 | dlink_list temp_dlines[LAST_TEMP_TYPE]; | |
342 | ||
343 | extern void init_s_conf(void); | |
344 | ||
345 | extern struct ConfItem *make_conf(void); | |
346 | extern void free_conf(struct ConfItem *); | |
347 | ||
348 | extern void read_conf_files(int cold); | |
349 | ||
350 | extern int attach_conf(struct Client *, struct ConfItem *); | |
351 | extern int check_client(struct Client *client_p, struct Client *source_p, const char *); | |
352 | ||
353 | extern int detach_conf(struct Client *); | |
354 | ||
212380e3 AC |
355 | extern struct ConfItem *find_tkline(const char *, const char *, struct sockaddr *); |
356 | extern char *show_iline_prefix(struct Client *, struct ConfItem *, char *); | |
357 | extern void get_printable_conf(struct ConfItem *, | |
358 | char **, char **, char **, char **, int *, char **); | |
359 | extern void get_printable_kline(struct Client *, struct ConfItem *, | |
360 | char **, char **, char **, char **); | |
361 | ||
362 | extern void yyerror(const char *); | |
363 | extern int conf_yy_fatal_error(const char *); | |
364 | extern int conf_fgets(char *, int, FILE *); | |
365 | ||
366 | typedef enum | |
367 | { | |
368 | CONF_TYPE, | |
369 | KLINE_TYPE, | |
370 | DLINE_TYPE, | |
371 | RESV_TYPE | |
372 | } | |
373 | KlineType; | |
374 | ||
375 | extern void write_confitem(KlineType, struct Client *, char *, char *, | |
376 | const char *, const char *, const char *, int); | |
377 | extern void add_temp_kline(struct ConfItem *); | |
378 | extern void add_temp_dline(struct ConfItem *); | |
379 | extern void report_temp_klines(struct Client *); | |
380 | extern void show_temp_klines(struct Client *, dlink_list *); | |
381 | ||
382 | extern const char *get_conf_name(KlineType); | |
383 | extern int rehash(int); | |
384 | extern void rehash_bans(int); | |
385 | ||
386 | extern int conf_add_server(struct ConfItem *, int); | |
387 | extern void conf_add_class_to_conf(struct ConfItem *); | |
388 | extern void conf_add_me(struct ConfItem *); | |
389 | extern void conf_add_class(struct ConfItem *, int); | |
390 | extern void conf_add_d_conf(struct ConfItem *); | |
391 | extern void flush_expired_ips(void *); | |
392 | ||
393 | ||
394 | /* XXX consider moving these into kdparse.h */ | |
395 | extern void parse_k_file(FILE * fb); | |
396 | extern void parse_d_file(FILE * fb); | |
397 | extern void parse_x_file(FILE * fb); | |
398 | extern void parse_resv_file(FILE *); | |
399 | extern char *getfield(char *newline); | |
400 | ||
401 | extern char *get_oper_name(struct Client *client_p); | |
402 | ||
403 | extern int yylex(void); | |
404 | ||
405 | extern unsigned long cidr_to_bitmask[]; | |
406 | ||
407 | extern char conffilebuf[IRCD_BUFSIZE + 1]; | |
408 | extern int lineno; | |
409 | ||
410 | #define NOT_AUTHORISED (-1) | |
411 | #define SOCKET_ERROR (-2) | |
412 | #define I_LINE_FULL (-3) | |
413 | #define BANNED_CLIENT (-4) | |
414 | #define TOO_MANY_LOCAL (-6) | |
415 | #define TOO_MANY_GLOBAL (-7) | |
416 | #define TOO_MANY_IDENT (-8) | |
417 | ||
418 | #endif /* INCLUDED_s_conf_h */ |