ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/include/conf.h
Revision: 1636
Committed: Sun Nov 4 17:09:47 2012 UTC (11 years, 4 months ago) by michael
Content type: text/x-chdr
File size: 12678 byte(s)
Log Message:
- Cleanup configuration subsystem
- Fixed broken CIDR support for /challenge

File Contents

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

Properties

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