]> jfr.im git - solanum.git/blob - include/s_conf.h
Resolve shfit/reduce conflict in timespec production (#54)
[solanum.git] / include / s_conf.h
1 /*
2 * solanum: 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 */
24
25 #ifndef INCLUDED_s_conf_h
26 #define INCLUDED_s_conf_h
27 #include "setup.h"
28
29 #ifdef HAVE_LIBCRYPTO
30 #include <openssl/rsa.h>
31 #endif
32
33 #include "ircd_defs.h"
34 #include "class.h"
35 #include "client.h"
36
37 struct Client;
38 struct DNSReply;
39 struct hostent;
40
41 /* used by new parser */
42 /* yacc/lex love globals!!! */
43
44 struct ip_value
45 {
46 struct rb_sockaddr_storage ip;
47 int ip_mask;
48 int type;
49 };
50
51 extern FILE *conf_fbfile_in;
52 extern char conf_line_in[256];
53
54 struct ConfItem
55 {
56 unsigned int status; /* If CONF_ILLEGAL, delete when no clients */
57 unsigned int flags;
58 int clients; /* Number of *LOCAL* clients using this */
59 union
60 {
61 char *name; /* IRC name, nick, server name, or original u@h */
62 const char *oper;
63 } info;
64 char *host; /* host part of user@host */
65 char *passwd; /* doubles as kline reason *ugh* */
66 char *spasswd; /* Password to send. */
67 char *user; /* user part of user@host */
68 int port;
69 time_t hold; /* Hold action until this time (calendar time) */
70 time_t created; /* Creation time (for klines etc) */
71 time_t lifetime; /* Propagated lines: remember until this time */
72 char *className; /* Name of class */
73 struct Class *c_class; /* Class of connection */
74 rb_patricia_node_t *pnode; /* Our patricia node */
75 };
76
77 #define CONF_ILLEGAL 0x80000000
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_DLINE 0x020000
86 #define CONF_EXEMPTDLINE 0x100000
87 #define CONF_SECURE 0x200000
88
89 #define IsIllegal(x) ((x)->status & CONF_ILLEGAL)
90
91 /* aConfItem->flags */
92
93 /* Generic flags... */
94 #define CONF_FLAGS_TEMPORARY 0x00800000
95 #define CONF_FLAGS_NEED_SSL 0x00000002
96 #define CONF_FLAGS_MYOPER 0x00080000 /* need to rewrite info.oper on burst */
97 /* auth{} flags... */
98 #define CONF_FLAGS_NO_TILDE 0x00000004
99 #define CONF_FLAGS_NEED_IDENTD 0x00000008
100 #define CONF_FLAGS_EXEMPTKLINE 0x00000040
101 #define CONF_FLAGS_NOLIMIT 0x00000080
102 #define CONF_FLAGS_SPOOF_IP 0x00000200
103 #define CONF_FLAGS_SPOOF_NOTICE 0x00000400
104 #define CONF_FLAGS_REDIR 0x00000800
105 #define CONF_FLAGS_EXEMPTRESV 0x00002000 /* exempt from resvs */
106 #define CONF_FLAGS_EXEMPTFLOOD 0x00004000
107 #define CONF_FLAGS_EXEMPTSPAMBOT 0x00008000
108 #define CONF_FLAGS_EXEMPTSHIDE 0x00010000
109 #define CONF_FLAGS_EXEMPTJUPE 0x00020000 /* exempt from resv generating warnings */
110 #define CONF_FLAGS_NEED_SASL 0x00040000
111 #define CONF_FLAGS_EXTEND_CHANS 0x00080000
112 #define CONF_FLAGS_ENCRYPTED 0x00200000
113 #define CONF_FLAGS_EXEMPTDNSBL 0x04000000
114 #define CONF_FLAGS_EXEMPTPROXY 0x08000000
115 #define CONF_FLAGS_ALLOW_SCTP 0x10000000
116 #define CONF_FLAGS_KLINE_SPOOF 0x20000000
117
118
119 /* Macros for struct ConfItem */
120 #define IsConfBan(x) ((x)->status & (CONF_KILL|CONF_XLINE|CONF_DLINE|\
121 CONF_RESV_CHANNEL|CONF_RESV_NICK))
122
123 #define IsNoTilde(x) ((x)->flags & CONF_FLAGS_NO_TILDE)
124 #define IsNeedIdentd(x) ((x)->flags & CONF_FLAGS_NEED_IDENTD)
125 #define IsConfExemptKline(x) ((x)->flags & CONF_FLAGS_EXEMPTKLINE)
126 #define IsConfExemptLimits(x) ((x)->flags & CONF_FLAGS_NOLIMIT)
127 #define IsConfExemptFlood(x) ((x)->flags & CONF_FLAGS_EXEMPTFLOOD)
128 #define IsConfExemptSpambot(x) ((x)->flags & CONF_FLAGS_EXEMPTSPAMBOT)
129 #define IsConfExemptShide(x) ((x)->flags & CONF_FLAGS_EXEMPTSHIDE)
130 #define IsConfExemptJupe(x) ((x)->flags & CONF_FLAGS_EXEMPTJUPE)
131 #define IsConfExemptResv(x) ((x)->flags & CONF_FLAGS_EXEMPTRESV)
132 #define IsConfDoSpoofIp(x) ((x)->flags & CONF_FLAGS_SPOOF_IP)
133 #define IsConfSpoofNotice(x) ((x)->flags & CONF_FLAGS_SPOOF_NOTICE)
134 #define IsConfEncrypted(x) ((x)->flags & CONF_FLAGS_ENCRYPTED)
135 #define IsNeedSasl(x) ((x)->flags & CONF_FLAGS_NEED_SASL)
136 #define IsConfExemptDNSBL(x) ((x)->flags & CONF_FLAGS_EXEMPTDNSBL)
137 #define IsConfExemptProxy(x) ((x)->flags & CONF_FLAGS_EXEMPTPROXY)
138 #define IsConfExtendChans(x) ((x)->flags & CONF_FLAGS_EXTEND_CHANS)
139 #define IsConfSSLNeeded(x) ((x)->flags & CONF_FLAGS_NEED_SSL)
140 #define IsConfAllowSCTP(x) ((x)->flags & CONF_FLAGS_ALLOW_SCTP)
141 #define IsConfKlineSpoof(x) ((x)->flags & CONF_FLAGS_KLINE_SPOOF)
142
143 /* flag definitions for opers now in client.h */
144
145 struct config_file_entry
146 {
147 const char *dpath; /* DPATH if set from command line */
148 const char *configfile;
149
150 char *default_operstring;
151 char *default_adminstring;
152 char *servicestring;
153 char *kline_reason;
154
155 char *identifyservice;
156 char *identifycommand;
157
158 char *sasl_service;
159
160 char *fname_userlog;
161 char *fname_fuserlog;
162 char *fname_operlog;
163 char *fname_foperlog;
164 char *fname_serverlog;
165 char *fname_killlog;
166 char *fname_klinelog;
167 char *fname_operspylog;
168 char *fname_ioerrorlog;
169
170 unsigned char compression_level;
171 int disable_fake_channels;
172 int dots_in_ident;
173 int failed_oper_notice;
174 int anti_nick_flood;
175 int anti_spam_exit_message_time;
176 int max_accept;
177 int max_monitor;
178 int max_nick_time;
179 int max_nick_changes;
180 int ts_max_delta;
181 int ts_warn_delta;
182 int dline_with_reason;
183 int kline_with_reason;
184 int hide_tkdline_duration;
185 int warn_no_nline;
186 int nick_delay;
187 int non_redundant_klines;
188 int stats_e_disabled;
189 int stats_c_oper_only;
190 int stats_y_oper_only;
191 int stats_h_oper_only;
192 int stats_o_oper_only;
193 int stats_k_oper_only;
194 int stats_i_oper_only;
195 int stats_P_oper_only;
196 int map_oper_only;
197 int operspy_admin_only;
198 int pace_wait;
199 int pace_wait_simple;
200 int short_motd;
201 int no_oper_flood;
202 int hide_server;
203 int hide_spoof_ips;
204 int hide_error_messages;
205 int client_exit;
206 int oper_only_umodes;
207 int oper_umodes;
208 int oper_snomask;
209 int max_targets;
210 int caller_id_wait;
211 int min_nonwildcard;
212 int min_nonwildcard_simple;
213 int default_floodcount;
214 int default_ident_timeout;
215 int ping_cookie;
216 int tkline_expire_notices;
217 int use_whois_actually;
218 int disable_auth;
219 int post_registration_delay;
220 int connect_timeout;
221 int burst_away;
222 int reject_ban_time;
223 int reject_after_count;
224 int reject_duration;
225 int throttle_count;
226 int throttle_duration;
227 int target_change;
228 int collision_fnc;
229 int resv_fnc;
230 int default_umodes;
231 int global_snotices;
232 int operspy_dont_care_user_info;
233 int use_propagated_bans;
234 int max_ratelimit_tokens;
235 int away_interval;
236 int tls_ciphers_oper_only;
237
238 int client_flood_max_lines;
239 int client_flood_burst_rate;
240 int client_flood_burst_max;
241 int client_flood_message_time;
242 int client_flood_message_num;
243
244 unsigned int nicklen;
245 int certfp_method;
246
247 int hide_opers_in_whois;
248 int hide_opers;
249
250 char *drain_reason;
251 };
252
253 struct config_channel_entry
254 {
255 int use_except;
256 int use_invex;
257 int use_forward;
258 int use_knock;
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 max_chans_per_user_large;
265 int no_create_on_split;
266 int no_join_on_split;
267 int default_split_server_count;
268 int default_split_user_count;
269 int burst_topicwho;
270 int kick_on_split_riding;
271 int only_ascii_channels;
272 int resv_forcepart;
273 int channel_target_change;
274 int disable_local_channels;
275 unsigned int autochanmodes;
276 int displayed_usercount;
277 int strip_topic_colors;
278 int opmod_send_statusmsg;
279 };
280
281 struct config_server_hide
282 {
283 int flatten_links;
284 int links_delay;
285 int hidden;
286 int disable_hidden;
287 };
288
289 struct server_info
290 {
291 char *name;
292 char sid[4];
293 char *description;
294 char *network_name;
295 int hub;
296 struct rb_sockaddr_storage bind4;
297 struct rb_sockaddr_storage bind6;
298 int default_max_clients;
299 char *ssl_private_key;
300 char *ssl_ca_cert;
301 char *ssl_cert;
302 char *ssl_dh_params;
303 char *ssl_cipher_list;
304 int ssld_count;
305 int wsockd_count;
306 };
307
308 struct admin_info
309 {
310 char *name;
311 char *description;
312 char *email;
313 };
314
315 struct alias_entry
316 {
317 char *name;
318 char *target;
319 int flags; /* reserved for later use */
320 };
321
322 /* All variables are GLOBAL */
323 extern struct config_file_entry ConfigFileEntry; /* defined in ircd.c */
324 extern struct config_channel_entry ConfigChannel; /* defined in channel.c */
325 extern struct config_server_hide ConfigServerHide; /* defined in s_conf.c */
326 extern struct server_info ServerInfo; /* defined in ircd.c */
327 extern struct admin_info AdminInfo; /* defined in ircd.c */
328 /* End GLOBAL section */
329
330 extern rb_dlink_list service_list;
331
332 extern rb_dlink_list prop_bans;
333
334 typedef enum temp_list
335 {
336 TEMP_MIN,
337 TEMP_HOUR,
338 TEMP_DAY,
339 TEMP_WEEK,
340 LAST_TEMP_TYPE
341 } temp_list;
342
343 extern rb_dlink_list temp_klines[LAST_TEMP_TYPE];
344 extern rb_dlink_list temp_dlines[LAST_TEMP_TYPE];
345
346 extern void init_s_conf(void);
347
348 extern struct ConfItem *make_conf(void);
349 extern void free_conf(struct ConfItem *);
350
351 extern rb_dlink_node *find_prop_ban(unsigned int status, const char *user, const char *host);
352 extern void deactivate_conf(struct ConfItem *, rb_dlink_node *, time_t);
353 extern void replace_old_ban(struct ConfItem *);
354
355 extern void read_conf_files(bool cold);
356
357 extern int attach_conf(struct Client *, struct ConfItem *);
358 extern int check_client(struct Client *client_p, struct Client *source_p, const char *);
359
360 extern void deref_conf(struct ConfItem *);
361 extern int detach_conf(struct Client *);
362
363 extern struct ConfItem *find_tkline(const char *, const char *, struct sockaddr *);
364 extern char *show_iline_prefix(struct Client *, struct ConfItem *, char *);
365 extern void get_printable_conf(struct ConfItem *,
366 char **, char **, const char **, char **, int *, char **);
367 extern char *get_user_ban_reason(struct ConfItem *aconf);
368 extern void get_printable_kline(struct Client *, struct ConfItem *,
369 char **, char **, char **, char **);
370
371 extern void yyerror(const char *);
372 extern int conf_yy_fatal_error(const char *);
373 extern int conf_fgets(char *, int, FILE *);
374
375 extern int valid_wild_card(const char *, const char *);
376 extern void add_temp_kline(struct ConfItem *);
377 extern void add_temp_dline(struct ConfItem *);
378 extern void report_temp_klines(struct Client *);
379 extern void show_temp_klines(struct Client *, rb_dlink_list *);
380
381 extern bool rehash(bool);
382 extern void rehash_bans(void);
383
384 extern int conf_add_server(struct ConfItem *, int);
385 extern void conf_add_class_to_conf(struct ConfItem *);
386 extern void conf_add_me(struct ConfItem *);
387 extern void conf_add_class(struct ConfItem *, int);
388 extern void conf_add_d_conf(struct ConfItem *);
389 extern void flush_expired_ips(void *);
390
391 extern char *get_oper_name(struct Client *client_p);
392
393 extern int yylex(void);
394
395 extern unsigned long cidr_to_bitmask[];
396
397 extern char conffilebuf[BUFSIZE + 1];
398 extern int lineno;
399
400 #define NOT_AUTHORISED (-1)
401 #define I_SOCKET_ERROR (-2)
402 #define I_LINE_FULL (-3)
403 #define BANNED_CLIENT (-4)
404 #define TOO_MANY_LOCAL (-6)
405 #define TOO_MANY_GLOBAL (-7)
406 #define TOO_MANY_IDENT (-8)
407
408 #endif /* INCLUDED_s_conf_h */