ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/branches/8.2.x/include/conf.h
Revision: 1647
Committed: Fri Nov 9 20:11:58 2012 UTC (11 years, 5 months ago) by michael
Content type: text/x-chdr
Original Path: ircd-hybrid/trunk/include/conf.h
File size: 12569 byte(s)
Log Message:
- Finish stabilizing/cleanup of conf parser

File Contents

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

Properties

Name Value
svn:eol-style native
svn:keywords Id Revision