ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/include/s_conf.h
Revision: 399
Committed: Tue Feb 7 12:23:17 2006 UTC (20 years, 5 months ago) by michael
Content type: text/x-chdr
File size: 17763 byte(s)
Log Message:
- Removed LL leftovers

File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 * s_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 "setup.h"
28 #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 "resv.h"
35
36 struct Client;
37 struct DNSReply;
38 struct hostent;
39
40 extern FBFILE *conf_fbfile_in;
41 extern struct Callback *client_check_cb;
42
43 struct CidrItem
44 {
45 struct irc_ssaddr mask;
46 int number_on_this_cidr;
47 dlink_node node;
48 };
49
50 struct split_nuh_item
51 {
52 dlink_node node;
53
54 char *nuhmask;
55 char *nickptr;
56 char *userptr;
57 char *hostptr;
58
59 size_t nicksize;
60 size_t usersize;
61 size_t hostsize;
62 };
63
64 #define ConFreq(x) ((x)->con_freq)
65 #define PingFreq(x) ((x)->ping_freq)
66 #define PingWarning(x) ((x)->ping_warning)
67 #define MaxTotal(x) ((x)->max_total)
68 #define MaxGlobal(x) ((x)->max_global)
69 #define MaxLocal(x) ((x)->max_local)
70 #define MaxIdent(x) ((x)->max_ident)
71 #define MaxPerIp(x) ((x)->max_perip)
72 #define MaxSendq(x) ((x)->max_sendq)
73 #define CurrUserCount(x) ((x)->curr_user_count)
74 #define CidrBitlenIPV4(x) ((x)->cidr_bitlen_ipv4)
75 #define CidrBitlenIPV6(x) ((x)->cidr_bitlen_ipv6)
76 #define NumberPerCidr(x) ((x)->number_per_cidr)
77
78 #define ClassPtr(x) ((x)->class_ptr)
79
80
81 #define CONF_ILLEGAL 0x80000000
82 #define CONF_RESERVED 0x00000001
83 #define CONF_CLIENT 0x00000002
84 #define CONF_SERVER 0x00000004
85 #define CONF_OPERATOR 0x00000008
86 #define CONF_KILL 0x00000010
87 #define CONF_KLINE CONF_KILL
88 #define CONF_CLASS 0x00000020
89 #define CONF_LEAF 0x00000040
90 #define CONF_LISTEN_PORT 0x00000080
91 #define CONF_HUB 0x00000100
92 #define CONF_EXEMPTKLINE 0x00000200
93 #define CONF_NOLIMIT 0x00000400
94 #define CONF_DLINE 0x00000800
95 #define CONF_XLINE 0x00001000
96 #define CONF_ULINE 0x00002000
97 #define CONF_EXEMPTDLINE 0x00004000
98 #define CONF_GLINE 0x00008000
99
100 #define CONF_SERVER_MASK CONF_SERVER
101 #define CONF_CLIENT_MASK (CONF_CLIENT | CONF_OPERATOR | CONF_SERVER_MASK)
102
103 /* XXX temporary hack */
104 #define CONF_CRESV 0x80000001
105 #define CONF_NRESV 0x80000002
106
107 #define IsConfIllegal(x) ((x)->status & CONF_ILLEGAL)
108 #define SetConfIllegal(x) ((x)->status |= CONF_ILLEGAL)
109 #define IsConfServer(x) ((x)->status == CONF_SERVER)
110 #define SetConfServer(x) ((x)->status = CONF_SERVER)
111 #define IsConfOperator(x) ((x)->status & CONF_OPERATOR)
112 #define IsConfHub(x) ((x)->status == CONF_HUB)
113 #define SetConfHub(x) ((x)->status = CONF_HUB)
114 #define IsConfLeaf(x) ((x)->status == CONF_LEAF)
115 #define SetConfLeaf(x) ((x)->status = CONF_LEAF)
116 #define IsConfHubOrLeaf(x) ((x)->status & (CONF_HUB|CONF_LEAF))
117 #define IsConfKill(x) ((x)->status == CONF_KILL)
118 #define IsConfClient(x) ((x)->status & CONF_CLIENT)
119 #define IsConfTypeOfClient(x) ((x)->status & CONF_CLIENT_MASK)
120 #define IsConfUline(x) ((x)->status & CONF_ULINE)
121 #define IsConfXline(x) ((x)->status & CONF_XLINE)
122 #define IsConfGline(x) ((x)->status == CONF_GLINE)
123
124 /* AccessItem->flags */
125
126 /* Generic flags... */
127 /* access flags... */
128 #define CONF_FLAGS_DO_IDENTD 0x00000001
129 #define CONF_FLAGS_LIMIT_IP 0x00000002
130 #define CONF_FLAGS_NO_TILDE 0x00000004
131 #define CONF_FLAGS_NEED_IDENTD 0x00000008
132 /* 0x00000010 */
133 #define CONF_FLAGS_NOMATCH_IP 0x00000020
134 #define CONF_FLAGS_EXEMPTKLINE 0x00000040
135 #define CONF_FLAGS_NOLIMIT 0x00000080
136 #define CONF_FLAGS_IDLE_LINED 0x00000100
137 #define CONF_FLAGS_SPOOF_IP 0x00000200
138 #define CONF_FLAGS_SPOOF_NOTICE 0x00000400
139 #define CONF_FLAGS_REDIR 0x00000800
140 #define CONF_FLAGS_EXEMPTGLINE 0x00001000
141 #define CONF_FLAGS_RESTRICTED 0x00002000
142 #define CONF_FLAGS_CAN_FLOOD 0x00100000
143 #define CONF_FLAGS_NEED_PASSWORD 0x00200000
144 /* server flags */
145 #define CONF_FLAGS_ALLOW_AUTO_CONN 0x00004000
146 #define CONF_FLAGS_ENCRYPTED 0x00010000
147 #define CONF_FLAGS_COMPRESSED 0x00020000
148 #define CONF_FLAGS_TEMPORARY 0x00040000
149 #define CONF_FLAGS_CRYPTLINK 0x00080000
150 #define CONF_FLAGS_BURST_AWAY 0x00400000
151 #define CONF_FLAGS_EXEMPTRESV 0x00800000
152 #define CONF_FLAGS_TOPICBURST 0x01000000
153
154 /* Macros for struct AccessItem */
155 #define IsLimitIp(x) ((x)->flags & CONF_FLAGS_LIMIT_IP)
156 #define IsNoTilde(x) ((x)->flags & CONF_FLAGS_NO_TILDE)
157 #define IsConfCanFlood(x) ((x)->flags & CONF_FLAGS_CAN_FLOOD)
158 #define IsNeedPassword(x) ((x)->flags & CONF_FLAGS_NEED_PASSWORD)
159 #define IsNeedIdentd(x) ((x)->flags & CONF_FLAGS_NEED_IDENTD)
160 #define IsNoMatchIp(x) ((x)->flags & CONF_FLAGS_NOMATCH_IP)
161 #define IsConfExemptKline(x) ((x)->flags & CONF_FLAGS_EXEMPTKLINE)
162 #define IsConfExemptLimits(x) ((x)->flags & CONF_FLAGS_NOLIMIT)
163 #define IsConfExemptGline(x) ((x)->flags & CONF_FLAGS_EXEMPTGLINE)
164 #define IsConfExemptResv(x) ((x)->flags & CONF_FLAGS_EXEMPTRESV)
165 #define IsConfIdlelined(x) ((x)->flags & CONF_FLAGS_IDLE_LINED)
166 #define IsConfDoIdentd(x) ((x)->flags & CONF_FLAGS_DO_IDENTD)
167 #define IsConfDoSpoofIp(x) ((x)->flags & CONF_FLAGS_SPOOF_IP)
168 #define IsConfSpoofNotice(x) ((x)->flags & CONF_FLAGS_SPOOF_NOTICE)
169 #define IsConfRestricted(x) ((x)->flags & CONF_FLAGS_RESTRICTED)
170 #define IsConfEncrypted(x) ((x)->flags & CONF_FLAGS_ENCRYPTED)
171 #define SetConfEncrypted(x) ((x)->flags |= CONF_FLAGS_ENCRYPTED)
172 #define ClearConfEncrypted(x) ((x)->flags &= ~CONF_FLAGS_ENCRYPTED)
173 #define IsConfCompressed(x) ((x)->flags & CONF_FLAGS_COMPRESSED)
174 #define SetConfCompressed(x) ((x)->flags |= CONF_FLAGS_COMPRESSED)
175 #define ClearConfCompressed(x) ((x)->flags &= ~CONF_FLAGS_COMPRESSED)
176 #define IsConfCryptLink(x) ((x)->flags & CONF_FLAGS_CRYPTLINK)
177 #define SetConfCryptLink(x) ((x)->flags |= CONF_FLAGS_CRYPTLINK)
178 #define ClearConfCryptLink(x) ((x)->flags &= ~CONF_FLAGS_CRYPTLINK)
179 #define IsConfAllowAutoConn(x) ((x)->flags & CONF_FLAGS_ALLOW_AUTO_CONN)
180 #define SetConfAllowAutoConn(x) ((x)->flags |= CONF_FLAGS_ALLOW_AUTO_CONN)
181 #define ClearConfAllowAutoConn(x) ((x)->flags &= ~CONF_FLAGS_ALLOW_AUTO_CONN)
182 #define IsConfTemporary(x) ((x)->flags & CONF_FLAGS_TEMPORARY)
183 #define SetConfTemporary(x) ((x)->flags |= CONF_FLAGS_TEMPORARY)
184 #define IsConfRedir(x) ((x)->flags & CONF_FLAGS_REDIR)
185 #define IsConfAwayBurst(x) ((x)->flags & CONF_FLAGS_BURST_AWAY)
186 #define SetConfAwayBurst(x) ((x)->flags |= CONF_FLAGS_BURST_AWAY)
187 #define ClearConfAwayBurst(x) ((x)->flags &= ~CONF_FLAGS_BURST_AWAY)
188 #define IsConfTopicBurst(x) ((x)->flags & CONF_FLAGS_TOPICBURST)
189 #define SetConfTopicBurst(x) ((x)->flags |= CONF_FLAGS_TOPICBURST)
190 #define ClearConfTopicBurst(x) ((x)->flags &= ~CONF_FLAGS_TOPICBURST)
191
192 /* shared/cluster server entry types
193 * These defines are used for both shared and cluster.
194 */
195 #define SHARED_KLINE 0x0001
196 #define SHARED_TKLINE 0x0002
197 #define SHARED_UNKLINE 0x0004
198 #define SHARED_XLINE 0x0008
199 #define SHARED_TXLINE 0x0010
200 #define SHARED_UNXLINE 0x0020
201 #define SHARED_RESV 0x0040
202 #define SHARED_TRESV 0x0080
203 #define SHARED_UNRESV 0x0100
204 #define SHARED_LOCOPS 0x0200
205 #define SHARED_ALL (SHARED_KLINE | SHARED_TKLINE | SHARED_UNKLINE | \
206 SHARED_XLINE | SHARED_TXLINE | SHARED_UNXLINE | \
207 SHARED_RESV | SHARED_TRESV | SHARED_UNRESV |\
208 SHARED_LOCOPS)
209
210 /* gline acl entry actions */
211 #define GDENY_BLOCK 0x1
212 #define GDENY_REJECT 0x2
213
214 typedef enum
215 {
216 CONF_TYPE,
217 CLASS_TYPE,
218 OPER_TYPE,
219 CLIENT_TYPE,
220 SERVER_TYPE,
221 HUB_TYPE,
222 LEAF_TYPE,
223 KLINE_TYPE,
224 DLINE_TYPE,
225 EXEMPTDLINE_TYPE,
226 CLUSTER_TYPE,
227 RKLINE_TYPE,
228 RXLINE_TYPE,
229 XLINE_TYPE,
230 ULINE_TYPE,
231 GLINE_TYPE,
232 CRESV_TYPE,
233 NRESV_TYPE,
234 GDENY_TYPE
235 } ConfType;
236
237
238 /*
239 * MatchItem - used for XLINE and ULINE types
240 */
241 struct MatchItem
242 {
243 void *conf_ptr; /* pointer back to conf */
244 char *user; /* Used for ULINE only */
245 char *host; /* Used for ULINE only */
246 char *reason;
247 char *oper_reason;
248 int action; /* used for uline */
249 int count; /* How many times this matchitem has been matched */
250 int ref_count; /* How many times is this matchitem in use */
251 int illegal; /* Should it be deleted when possible? */
252 time_t hold; /* Hold action until this time (calendar time) */
253 };
254
255 struct AccessItem
256 {
257 void *conf_ptr; /* pointer back to conf */
258 dlink_node node;
259 unsigned int status; /* If CONF_ILLEGAL, delete when no clients */
260 unsigned int flags;
261 unsigned int modes;
262 struct irc_ssaddr my_ipnum; /* ip to bind to for outgoing connect */
263 struct irc_ssaddr ipnum; /* ip to connect to */
264 char * host; /* host part of user@host */
265 char * passwd;
266 char * spasswd; /* Password to send. */
267 char * reason;
268 char * oper_reason;
269 char * user; /* user part of user@host */
270 int port;
271 char * fakename; /* Mask name */
272 time_t hold; /* Hold action until this time (calendar time) */
273 struct ConfItem *class_ptr; /* Class of connection */
274 struct DNSQuery* dns_query;
275 int aftype;
276 #ifdef HAVE_LIBCRYPTO
277 char * rsa_public_key_file;
278 RSA * rsa_public_key;
279 struct EncCapability *cipher_preference;
280 #endif
281 pcre *regexuser;
282 pcre *regexhost;
283 };
284
285 struct ClassItem
286 {
287 void *conf_ptr; /* pointer back to conf */
288 long max_sendq;
289 int con_freq;
290 int ping_freq;
291 int ping_warning;
292 int max_total;
293 int max_local;
294 int max_global;
295 int max_ident;
296 int max_perip;
297 int curr_user_count;
298 int cidr_bitlen_ipv4;
299 int cidr_bitlen_ipv6;
300 int number_per_cidr;
301 dlink_list list_ipv4; /* base of per cidr ipv4 client link list */
302 dlink_list list_ipv6; /* base of per cidr ipv6 client link list */
303 };
304
305 struct ConfItem
306 {
307 char *name; /* Primary key */
308 pcre *regexpname;
309 dlink_node node; /* link into known ConfItems of this type */
310 unsigned int flags;
311 ConfType type;
312 dlink_list mask_list;
313
314 union
315 {
316 struct MatchItem MatchItem;
317 struct AccessItem AccessItem;
318 struct ClassItem ClassItem;
319 struct ResvChannel ResvChannel;
320 } conf;
321 };
322
323 struct conf_item_table_type
324 {
325 size_t size;
326 int status;
327 dlink_list *list;
328 void (*freer)(struct ConfItem *, dlink_list *);
329 };
330
331 struct config_file_entry
332 {
333 const char *dpath; /* DPATH if set from command line */
334 const char *configfile;
335 const char *klinefile;
336 const char *xlinefile;
337 const char *rxlinefile;
338 const char *rklinefile;
339 const char *dlinefile;
340 const char *glinefile;
341 const char *cresvfile;
342 const char *nresvfile;
343
344 char *logpath;
345 char *operlog;
346
347 char *servlink_path;
348 char *egdpool_path;
349
350 MessageFile motd;
351 MessageFile opermotd;
352 MessageFile linksfile;
353
354 unsigned char compression_level;
355 int max_watch;
356 int gline_min_cidr;
357 int gline_min_cidr6;
358 int dot_in_ip6_addr;
359 int dots_in_ident;
360 int failed_oper_notice;
361 int anti_spam_exit_message_time;
362 int max_accept;
363 int max_nick_time;
364 int max_nick_changes;
365 int ts_max_delta;
366 int ts_warn_delta;
367 int anti_nick_flood;
368 int kline_with_reason;
369 int warn_no_nline;
370 int invisible_on_connect;
371 int stats_o_oper_only;
372 int stats_k_oper_only;
373 int stats_i_oper_only;
374 int stats_P_oper_only;
375 int short_motd;
376 int no_oper_flood;
377 int true_no_oper_flood;
378 int oper_pass_resv;
379 int glines;
380 int hide_spoof_ips;
381 int burst_away;
382 int use_whois_actually;
383 int tkline_expire_notices;
384 int opers_bypass_callerid;
385 int ignore_bogus_ts;
386 char *kline_reason;
387 int pace_wait;
388 int pace_wait_simple;
389 int gline_time;
390 int gline_logging;
391 int idletime;
392 int oper_only_umodes;
393 int oper_umodes;
394 int max_targets;
395 int caller_id_wait;
396 int min_nonwildcard;
397 int min_nonwildcard_simple;
398 int kill_chase_time_limit;
399 int default_floodcount;
400 int client_flood;
401 /* 0 == don't use throttle... */
402 int throttle_time;
403 int use_egd;
404 int ping_cookie;
405 int disable_auth;
406 int disable_remote;
407 #ifdef HAVE_LIBCRYPTO
408 struct EncCapability *default_cipher_preference;
409 #endif
410 };
411
412 struct config_channel_entry
413 {
414 int restrict_channels;
415 int disable_local_channels;
416 int use_except;
417 int use_invex;
418 int use_knock;
419 int knock_delay;
420 int knock_delay_channel;
421 unsigned int max_bans;
422 unsigned int max_chans_per_user;
423 int no_create_on_split;
424 int no_join_on_split;
425 int quiet_on_ban;
426 int burst_topicwho;
427 int default_split_server_count;
428 int default_split_user_count;
429 };
430
431 struct config_server_hide
432 {
433 int flatten_links;
434 int hide_servers;
435 char *hidden_name;
436 int links_delay;
437 int links_disabled;
438 int hidden;
439 int disable_hidden;
440 int hide_server_ips;
441 };
442
443 struct server_info
444 {
445 char *name;
446 char *description;
447 char *network_name;
448 char *network_desc;
449 #ifdef HAVE_LIBCRYPTO
450 char *rsa_private_key_file;
451 RSA *rsa_private_key;
452 SSL_CTX *ctx;
453 #endif
454 char *sid;
455 int hub;
456 struct irc_ssaddr ip;
457 struct irc_ssaddr ip6;
458 int max_clients;
459 int specific_ipv4_vhost;
460 int specific_ipv6_vhost;
461 struct sockaddr_in dns_host;
462 int can_use_v6;
463 };
464
465 struct admin_info
466 {
467 char *name;
468 char *description;
469 char *email;
470 };
471
472 struct logging_entry
473 {
474 unsigned int use_logging;
475 char operlog[PATH_MAX + 1];
476 char userlog[PATH_MAX + 1];
477 char glinelog[PATH_MAX + 1];
478 char ioerrlog[PATH_MAX + 1];
479 char klinelog[PATH_MAX + 1];
480 char killlog[PATH_MAX + 1];
481 char operspylog[PATH_MAX + 1];
482 char failed_operlog[PATH_MAX + 1];
483 };
484
485 void init_class(void);
486 void check_class(void);
487 void init_ip_hash_table(void);
488 void yyerror(const char *);
489 int conf_yy_fatal_error(const char *);
490 void read_conf_files(int);
491 int yylex(void);
492 void rebuild_cidr_class(struct ClassItem *, struct ClassItem *);
493
494 EXTERN unsigned int scount;
495 EXTERN int ypass;
496 EXTERN dlink_list class_items;
497 EXTERN dlink_list server_items;
498 EXTERN dlink_list cluster_items;
499 EXTERN dlink_list hub_items;
500 EXTERN dlink_list leaf_items;
501 EXTERN struct logging_entry ConfigLoggingEntry;
502 EXTERN struct config_file_entry ConfigFileEntry;/* defined in ircd.c*/
503 EXTERN struct config_channel_entry ConfigChannel;/* defined in channel.c*/
504 EXTERN struct config_server_hide ConfigServerHide; /* defined in s_conf.c */
505 EXTERN struct server_info ServerInfo; /* defined in ircd.c */
506 EXTERN struct admin_info AdminInfo; /* defined in ircd.c */
507
508 /* End GLOBAL section */
509
510 EXTERN unsigned long get_sendq(struct Client *);
511 EXTERN const char *get_client_className(struct Client *);
512 EXTERN int get_client_ping(struct Client *, int *);
513 EXTERN struct ConfItem *find_class(const char *);
514 EXTERN void count_ip_hash(int *, unsigned long *);
515 EXTERN void remove_one_ip(struct irc_ssaddr *);
516 EXTERN struct ConfItem *make_conf_item(ConfType);
517 EXTERN int attach_class(struct Client *, struct ConfItem *);
518 EXTERN int attach_connect_block(struct Client *, const char *, const char *);
519 EXTERN int attach_server_conf(struct Client *, struct ConfItem *);
520 EXTERN int attach_leaf_hub(struct Client *, struct ConfItem *);
521 EXTERN int detach_confs(struct Client *);
522
523 EXTERN int conf_connect_allowed(struct irc_ssaddr *, int);
524 EXTERN char *oper_privs_as_string(const unsigned int);
525 EXTERN void split_nuh(struct split_nuh_item *);
526 EXTERN struct ConfItem *find_matching_name_conf(ConfType, const char *,
527 const char *, const char *, int);
528 EXTERN struct ConfItem *find_exact_name_conf(ConfType, const char *,
529 const char *, const char *);
530 EXTERN void delete_conf_item(struct ConfItem *);
531 EXTERN void report_confitem_types(struct Client *, ConfType, int);
532 EXTERN int conf_fbgets(char *, unsigned int, FBFILE *);
533 EXTERN void write_conf_line(struct Client *, struct ConfItem *,
534 const char *, time_t);
535 EXTERN int remove_conf_line(ConfType, struct Client *, const char *,
536 const char *);
537
538 EXTERN const char *get_conf_name(ConfType);
539 EXTERN int rehash(int);
540 EXTERN int conf_add_server(struct ConfItem *, unsigned int, const char *);
541 EXTERN void conf_add_class_to_conf(struct ConfItem *, const char *);
542 EXTERN void conf_add_d_conf(struct AccessItem *);
543
544 /* XXX consider moving these into csvlib.h */
545 EXTERN void parse_csv_file(FBFILE *, ConfType);
546
547 EXTERN char *get_oper_name(const struct Client *);
548
549 EXTERN int match_conf_password(const char *, const struct AccessItem *);
550
551 #define NOT_AUTHORIZED (-1)
552 #define IRCD_SOCKET_ERROR (-2)
553 #define I_LINE_FULL (-3)
554 #define TOO_MANY (-4)
555 #define BANNED_CLIENT (-5)
556 #define TOO_FAST (-6)
557
558 #endif /* INCLUDED_s_conf_h */

Properties

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