]> jfr.im git - solanum.git/blame - include/s_conf.h
Never allow a duplicate kline; always allow a wider kline.
[solanum.git] / include / s_conf.h
CommitLineData
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
41struct Client;
42struct DNSReply;
43struct hostent;
44
45/* used by new parser */
46/* yacc/lex love globals!!! */
47
48struct ip_value
49{
50 struct irc_sockaddr_storage ip;
51 int ip_mask;
52 int type;
53};
54
55extern FILE *conf_fbfile_in;
56extern char conf_line_in[256];
57
58struct 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... */
212380e3
AC
99#define CONF_FLAGS_LIMIT_IP 0x00000002
100#define CONF_FLAGS_NO_TILDE 0x00000004
101#define CONF_FLAGS_NEED_IDENTD 0x00000008
102#define CONF_FLAGS_PASS_IDENTD 0x00000010
103#define CONF_FLAGS_NOMATCH_IP 0x00000020
104#define CONF_FLAGS_EXEMPTKLINE 0x00000040
105#define CONF_FLAGS_NOLIMIT 0x00000080
106#define CONF_FLAGS_IDLE_LINED 0x00000100
107#define CONF_FLAGS_SPOOF_IP 0x00000200
108#define CONF_FLAGS_SPOOF_NOTICE 0x00000400
109#define CONF_FLAGS_REDIR 0x00000800
110#define CONF_FLAGS_EXEMPTGLINE 0x00001000
111#define CONF_FLAGS_EXEMPTRESV 0x00002000 /* exempt from resvs */
112#define CONF_FLAGS_EXEMPTFLOOD 0x00004000
113#define CONF_FLAGS_EXEMPTSPAMBOT 0x00008000
114#define CONF_FLAGS_EXEMPTSHIDE 0x00010000
115#define CONF_FLAGS_EXEMPTJUPE 0x00020000 /* exempt from resv generating warnings */
116#define CONF_FLAGS_NEED_SASL 0x00040000
117/* server flags */
118#define CONF_FLAGS_ALLOW_AUTO_CONN 0x00080000
119#define CONF_FLAGS_LAZY_LINK 0x00100000
120#define CONF_FLAGS_ENCRYPTED 0x00200000
121#define CONF_FLAGS_COMPRESSED 0x00400000
122#define CONF_FLAGS_TEMPORARY 0x00800000
123#define CONF_FLAGS_TB 0x01000000
124#define CONF_FLAGS_VHOSTED 0x02000000
125#define CONF_FLAGS_EXEMPTDNSBL 0x04000000
126
127
128/* Macros for struct ConfItem */
129#define IsLimitIp(x) ((x)->flags & CONF_FLAGS_LIMIT_IP)
130#define IsNoTilde(x) ((x)->flags & CONF_FLAGS_NO_TILDE)
131#define IsNeedIdentd(x) ((x)->flags & CONF_FLAGS_NEED_IDENTD)
132#define IsPassIdentd(x) ((x)->flags & CONF_FLAGS_PASS_IDENTD)
133#define IsNoMatchIp(x) ((x)->flags & CONF_FLAGS_NOMATCH_IP)
134#define IsConfExemptKline(x) ((x)->flags & CONF_FLAGS_EXEMPTKLINE)
135#define IsConfExemptLimits(x) ((x)->flags & CONF_FLAGS_NOLIMIT)
136#define IsConfExemptGline(x) ((x)->flags & CONF_FLAGS_EXEMPTGLINE)
137#define IsConfExemptFlood(x) ((x)->flags & CONF_FLAGS_EXEMPTFLOOD)
138#define IsConfExemptSpambot(x) ((x)->flags & CONF_FLAGS_EXEMPTSPAMBOT)
139#define IsConfExemptShide(x) ((x)->flags & CONF_FLAGS_EXEMPTSHIDE)
140#define IsConfExemptJupe(x) ((x)->flags & CONF_FLAGS_EXEMPTJUPE)
141#define IsConfExemptResv(x) ((x)->flags & CONF_FLAGS_EXEMPTRESV)
142#define IsConfIdlelined(x) ((x)->flags & CONF_FLAGS_IDLE_LINED)
212380e3
AC
143#define IsConfDoSpoofIp(x) ((x)->flags & CONF_FLAGS_SPOOF_IP)
144#define IsConfSpoofNotice(x) ((x)->flags & CONF_FLAGS_SPOOF_NOTICE)
145#define IsConfEncrypted(x) ((x)->flags & CONF_FLAGS_ENCRYPTED)
146#define IsConfCompressed(x) ((x)->flags & CONF_FLAGS_COMPRESSED)
147#define IsConfVhosted(x) ((x)->flags & CONF_FLAGS_VHOSTED)
148#define IsConfTburst(x) ((x)->flags & CONF_FLAGS_TB)
149#define IsNeedSasl(x) ((x)->flags & CONF_FLAGS_NEED_SASL)
150#define IsConfExemptDNSBL(x) ((x)->flags & CONF_FLAGS_EXEMPTDNSBL)
151
152/* flag definitions for opers now in client.h */
153
154struct config_file_entry
155{
156 const char *dpath; /* DPATH if set from command line */
157 const char *configfile;
158 const char *klinefile;
159 const char *dlinefile;
160 const char *xlinefile;
161 const char *resvfile;
162
163 char *servlink_path;
164 char *egdpool_path;
165
166 char *default_operstring;
167 char *default_adminstring;
168 char *servicestring;
169 char *kline_reason;
170
171 char *identifyservice;
172 char *identifycommand;
173
174 char *fname_userlog;
175 char *fname_fuserlog;
176 char *fname_operlog;
177 char *fname_foperlog;
178 char *fname_serverlog;
179 char *fname_killlog;
180 char *fname_glinelog;
181 char *fname_klinelog;
182 char *fname_operspylog;
183 char *fname_ioerrorlog;
184
185 unsigned char compression_level;
186 int disable_fake_channels;
212380e3
AC
187 int dots_in_ident;
188 int failed_oper_notice;
189 int anti_nick_flood;
190 int anti_spam_exit_message_time;
191 int max_accept;
192 int max_monitor;
193 int max_nick_time;
194 int max_nick_changes;
195 int ts_max_delta;
196 int ts_warn_delta;
197 int dline_with_reason;
198 int kline_with_reason;
199 int kline_delay;
200 int warn_no_nline;
201 int nick_delay;
202 int non_redundant_klines;
203 int stats_e_disabled;
204 int stats_c_oper_only;
205 int stats_y_oper_only;
206 int stats_h_oper_only;
207 int stats_o_oper_only;
208 int stats_k_oper_only;
209 int stats_i_oper_only;
210 int stats_P_oper_only;
211 int map_oper_only;
212 int operspy_admin_only;
213 int pace_wait;
214 int pace_wait_simple;
215 int short_motd;
216 int no_oper_flood;
217 int glines;
218 int gline_time;
219 int gline_min_cidr;
220 int gline_min_cidr6;
221 int idletime;
222 int hide_server;
223 int hide_spoof_ips;
224 int hide_error_messages;
225 int client_exit;
226 int oper_only_umodes;
227 int oper_umodes;
228 int oper_snomask;
229 int max_targets;
230 int caller_id_wait;
231 int min_nonwildcard;
232 int min_nonwildcard_simple;
233 int default_floodcount;
234 int client_flood;
235 int use_egd;
236 int ping_cookie;
237 int tkline_expire_notices;
238 int use_whois_actually;
239 int disable_auth;
240 int connect_timeout;
241 int burst_away;
242 int reject_ban_time;
243 int reject_after_count;
244 int reject_duration;
245 int target_change;
246 int collision_fnc;
247 int default_umodes;
248 int global_snotices;
249 int operspy_dont_care_user_info;
54015b5f 250 int max_unknown_ip;
212380e3
AC
251};
252
253struct config_channel_entry
254{
255 int use_except;
256 int use_invex;
257 int use_knock;
258 int use_forward;
259 int knock_delay;
260 int knock_delay_channel;
261 int max_bans;
262 int max_bans_large;
263 int max_chans_per_user;
264 int no_create_on_split;
265 int no_join_on_split;
266 int default_split_server_count;
267 int default_split_user_count;
268 int burst_topicwho;
212380e3
AC
269 int kick_on_split_riding;
270};
271
272struct config_server_hide
273{
274 int flatten_links;
275 int links_delay;
212380e3
AC
276 int hidden;
277 int disable_hidden;
278};
279
280struct server_info
281{
282 char *name;
283 char sid[3];
284 char *description;
285 char *network_name;
286 char *network_desc;
287 int hub;
212380e3
AC
288 struct sockaddr_in ip;
289#ifdef IPV6
290 struct sockaddr_in6 ip6;
291#endif
292 int specific_ipv4_vhost;
293#ifdef IPV6
294 int specific_ipv6_vhost;
295#endif
c2d96fcb
AC
296
297 int max_clients;
212380e3
AC
298};
299
300struct admin_info
301{
302 char *name;
303 char *description;
304 char *email;
305};
306
307struct alias_entry
308{
309 char *name;
310 char *target;
311 int flags; /* reserved for later use */
312 int hits;
313};
314
315/* All variables are GLOBAL */
316extern int specific_ipv4_vhost; /* used in s_bsd.c */
317extern int specific_ipv6_vhost;
318extern struct config_file_entry ConfigFileEntry; /* defined in ircd.c */
319extern struct config_channel_entry ConfigChannel; /* defined in channel.c */
320extern struct config_server_hide ConfigServerHide; /* defined in s_conf.c */
321extern struct server_info ServerInfo; /* defined in ircd.c */
322extern struct admin_info AdminInfo; /* defined in ircd.c */
323/* End GLOBAL section */
324
325dlink_list service_list;
326
327typedef enum temp_list
328{
329 TEMP_MIN,
330 TEMP_HOUR,
331 TEMP_DAY,
332 TEMP_WEEK,
333 LAST_TEMP_TYPE
334} temp_list;
335
336dlink_list temp_klines[LAST_TEMP_TYPE];
337dlink_list temp_dlines[LAST_TEMP_TYPE];
338
339extern void init_s_conf(void);
340
341extern struct ConfItem *make_conf(void);
342extern void free_conf(struct ConfItem *);
343
344extern void read_conf_files(int cold);
345
346extern int attach_conf(struct Client *, struct ConfItem *);
347extern int check_client(struct Client *client_p, struct Client *source_p, const char *);
348
349extern int detach_conf(struct Client *);
350
212380e3
AC
351extern struct ConfItem *find_tkline(const char *, const char *, struct sockaddr *);
352extern char *show_iline_prefix(struct Client *, struct ConfItem *, char *);
353extern void get_printable_conf(struct ConfItem *,
354 char **, char **, char **, char **, int *, char **);
355extern void get_printable_kline(struct Client *, struct ConfItem *,
356 char **, char **, char **, char **);
357
358extern void yyerror(const char *);
359extern int conf_yy_fatal_error(const char *);
360extern int conf_fgets(char *, int, FILE *);
361
362typedef enum
363{
364 CONF_TYPE,
365 KLINE_TYPE,
366 DLINE_TYPE,
367 RESV_TYPE
368}
369KlineType;
370
371extern void write_confitem(KlineType, struct Client *, char *, char *,
372 const char *, const char *, const char *, int);
373extern void add_temp_kline(struct ConfItem *);
374extern void add_temp_dline(struct ConfItem *);
375extern void report_temp_klines(struct Client *);
376extern void show_temp_klines(struct Client *, dlink_list *);
377
378extern const char *get_conf_name(KlineType);
379extern int rehash(int);
380extern void rehash_bans(int);
381
382extern int conf_add_server(struct ConfItem *, int);
383extern void conf_add_class_to_conf(struct ConfItem *);
384extern void conf_add_me(struct ConfItem *);
385extern void conf_add_class(struct ConfItem *, int);
386extern void conf_add_d_conf(struct ConfItem *);
387extern void flush_expired_ips(void *);
388
389
390/* XXX consider moving these into kdparse.h */
391extern void parse_k_file(FILE * fb);
392extern void parse_d_file(FILE * fb);
393extern void parse_x_file(FILE * fb);
394extern void parse_resv_file(FILE *);
395extern char *getfield(char *newline);
396
397extern char *get_oper_name(struct Client *client_p);
398
399extern int yylex(void);
400
401extern unsigned long cidr_to_bitmask[];
402
403extern char conffilebuf[IRCD_BUFSIZE + 1];
404extern int lineno;
405
406#define NOT_AUTHORISED (-1)
407#define SOCKET_ERROR (-2)
408#define I_LINE_FULL (-3)
409#define BANNED_CLIENT (-4)
410#define TOO_MANY_LOCAL (-6)
411#define TOO_MANY_GLOBAL (-7)
412#define TOO_MANY_IDENT (-8)
413
414#endif /* INCLUDED_s_conf_h */