]> jfr.im git - irc/rqf/shadowircd.git/blob - include/s_conf.h
Remove dot_in_ip6_addr config option.
[irc/rqf/shadowircd.git] / include / s_conf.h
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 *
24 * $Id: s_conf.h 3550 2007-08-09 06:47:26Z nenolod $
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 dots_in_ident;
190 int failed_oper_notice;
191 int anti_nick_flood;
192 int anti_spam_exit_message_time;
193 int max_accept;
194 int max_monitor;
195 int max_nick_time;
196 int max_nick_changes;
197 int ts_max_delta;
198 int ts_warn_delta;
199 int dline_with_reason;
200 int kline_with_reason;
201 int kline_delay;
202 int warn_no_nline;
203 int nick_delay;
204 int non_redundant_klines;
205 int stats_e_disabled;
206 int stats_c_oper_only;
207 int stats_y_oper_only;
208 int stats_h_oper_only;
209 int stats_o_oper_only;
210 int stats_k_oper_only;
211 int stats_i_oper_only;
212 int stats_P_oper_only;
213 int map_oper_only;
214 int operspy_admin_only;
215 int pace_wait;
216 int pace_wait_simple;
217 int short_motd;
218 int no_oper_flood;
219 int glines;
220 int gline_time;
221 int gline_min_cidr;
222 int gline_min_cidr6;
223 int idletime;
224 int hide_server;
225 int hide_spoof_ips;
226 int hide_error_messages;
227 int client_exit;
228 int oper_only_umodes;
229 int oper_umodes;
230 int oper_snomask;
231 int max_targets;
232 int caller_id_wait;
233 int min_nonwildcard;
234 int min_nonwildcard_simple;
235 int default_floodcount;
236 int client_flood;
237 int use_egd;
238 int ping_cookie;
239 int tkline_expire_notices;
240 int use_whois_actually;
241 int disable_auth;
242 int connect_timeout;
243 int burst_away;
244 int reject_ban_time;
245 int reject_after_count;
246 int reject_duration;
247 int target_change;
248 int collision_fnc;
249 int default_umodes;
250 int global_snotices;
251 int operspy_dont_care_user_info;
252 int max_unknown_ip;
253 };
254
255 struct config_channel_entry
256 {
257 int use_except;
258 int use_invex;
259 int use_knock;
260 int use_forward;
261 int knock_delay;
262 int knock_delay_channel;
263 int max_bans;
264 int max_bans_large;
265 int max_chans_per_user;
266 int no_create_on_split;
267 int no_join_on_split;
268 int default_split_server_count;
269 int default_split_user_count;
270 int burst_topicwho;
271 int kick_on_split_riding;
272 };
273
274 struct config_server_hide
275 {
276 int flatten_links;
277 int links_delay;
278 int hidden;
279 int disable_hidden;
280 };
281
282 struct server_info
283 {
284 char *name;
285 char sid[3];
286 char *description;
287 char *network_name;
288 char *network_desc;
289 int hub;
290 struct sockaddr_in ip;
291 #ifdef IPV6
292 struct sockaddr_in6 ip6;
293 #endif
294 int specific_ipv4_vhost;
295 #ifdef IPV6
296 int specific_ipv6_vhost;
297 #endif
298
299 int max_clients;
300 };
301
302 struct admin_info
303 {
304 char *name;
305 char *description;
306 char *email;
307 };
308
309 struct alias_entry
310 {
311 char *name;
312 char *target;
313 int flags; /* reserved for later use */
314 int hits;
315 };
316
317 /* All variables are GLOBAL */
318 extern int specific_ipv4_vhost; /* used in s_bsd.c */
319 extern int specific_ipv6_vhost;
320 extern struct config_file_entry ConfigFileEntry; /* defined in ircd.c */
321 extern struct config_channel_entry ConfigChannel; /* defined in channel.c */
322 extern struct config_server_hide ConfigServerHide; /* defined in s_conf.c */
323 extern struct server_info ServerInfo; /* defined in ircd.c */
324 extern struct admin_info AdminInfo; /* defined in ircd.c */
325 /* End GLOBAL section */
326
327 dlink_list service_list;
328
329 typedef enum temp_list
330 {
331 TEMP_MIN,
332 TEMP_HOUR,
333 TEMP_DAY,
334 TEMP_WEEK,
335 LAST_TEMP_TYPE
336 } temp_list;
337
338 dlink_list temp_klines[LAST_TEMP_TYPE];
339 dlink_list temp_dlines[LAST_TEMP_TYPE];
340
341 extern void init_s_conf(void);
342
343 extern struct ConfItem *make_conf(void);
344 extern void free_conf(struct ConfItem *);
345
346 extern void read_conf_files(int cold);
347
348 extern int attach_conf(struct Client *, struct ConfItem *);
349 extern int check_client(struct Client *client_p, struct Client *source_p, const char *);
350
351 extern int detach_conf(struct Client *);
352
353 extern struct ConfItem *find_tkline(const char *, const char *, struct sockaddr *);
354 extern char *show_iline_prefix(struct Client *, struct ConfItem *, char *);
355 extern void get_printable_conf(struct ConfItem *,
356 char **, char **, char **, char **, int *, char **);
357 extern void get_printable_kline(struct Client *, struct ConfItem *,
358 char **, char **, char **, char **);
359
360 extern void yyerror(const char *);
361 extern int conf_yy_fatal_error(const char *);
362 extern int conf_fgets(char *, int, FILE *);
363
364 typedef enum
365 {
366 CONF_TYPE,
367 KLINE_TYPE,
368 DLINE_TYPE,
369 RESV_TYPE
370 }
371 KlineType;
372
373 extern void write_confitem(KlineType, struct Client *, char *, char *,
374 const char *, const char *, const char *, int);
375 extern void add_temp_kline(struct ConfItem *);
376 extern void add_temp_dline(struct ConfItem *);
377 extern void report_temp_klines(struct Client *);
378 extern void show_temp_klines(struct Client *, dlink_list *);
379
380 extern const char *get_conf_name(KlineType);
381 extern int rehash(int);
382 extern void rehash_bans(int);
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
392 /* XXX consider moving these into kdparse.h */
393 extern void parse_k_file(FILE * fb);
394 extern void parse_d_file(FILE * fb);
395 extern void parse_x_file(FILE * fb);
396 extern void parse_resv_file(FILE *);
397 extern char *getfield(char *newline);
398
399 extern char *get_oper_name(struct Client *client_p);
400
401 extern int yylex(void);
402
403 extern unsigned long cidr_to_bitmask[];
404
405 extern char conffilebuf[IRCD_BUFSIZE + 1];
406 extern int lineno;
407
408 #define NOT_AUTHORISED (-1)
409 #define SOCKET_ERROR (-2)
410 #define I_LINE_FULL (-3)
411 #define BANNED_CLIENT (-4)
412 #define TOO_MANY_LOCAL (-6)
413 #define TOO_MANY_GLOBAL (-7)
414 #define TOO_MANY_IDENT (-8)
415
416 #endif /* INCLUDED_s_conf_h */