2 * ircd-ratbox: an advanced Internet Relay Chat Daemon(ircd).
3 * s_newconf.h: code for dealing with conf stuff
5 * Copyright (C) 2004 Lee Hardy <lee@leeh.co.uk>
6 * Copyright (C) 2004 ircd-ratbox development team
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are
12 * 1.Redistributions of source code must retain the above copyright notice,
13 * this list of conditions and the following disclaimer.
14 * 2.Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3.The name of the author may not be used to endorse or promote products
18 * derived from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
32 * $Id: s_newconf.h 1747 2006-07-25 21:22:45Z jilles $
35 #ifndef INCLUDED_s_newconf_h
36 #define INCLUDED_s_newconf_h
39 #include "privilege.h"
42 #include <openssl/rsa.h>
47 extern rb_dlink_list cluster_conf_list
;
48 extern rb_dlink_list shared_conf_list
;
49 extern rb_dlink_list oper_conf_list
;
50 extern rb_dlink_list hubleaf_conf_list
;
51 extern rb_dlink_list server_conf_list
;
52 extern rb_dlink_list xline_conf_list
;
53 extern rb_dlink_list resv_conf_list
;
54 extern rb_dlink_list nd_list
;
55 extern rb_dlink_list tgchange_list
;
57 extern struct _rb_patricia_tree_t
*tgchange_tree
;
59 extern void init_s_newconf(void);
60 extern void clear_s_newconf(void);
61 extern void clear_s_newconf_bans(void);
63 #define FREE_TARGET(x) ((x)->localClient->targinfo[0])
64 #define USED_TARGETS(x) ((x)->localClient->targinfo[1])
70 rb_patricia_node_t
*pnode
;
74 void add_tgchange(const char *host
);
75 tgchange
*find_tgchange(const char *host
);
77 /* shared/cluster/hub/leaf confs */
87 /* flags used in shared/cluster */
88 #define SHARED_TKLINE 0x0001
89 #define SHARED_PKLINE 0x0002
90 #define SHARED_UNKLINE 0x0004
91 #define SHARED_LOCOPS 0x0008
92 #define SHARED_TXLINE 0x0010
93 #define SHARED_PXLINE 0x0020
94 #define SHARED_UNXLINE 0x0040
95 #define SHARED_TRESV 0x0080
96 #define SHARED_PRESV 0x0100
97 #define SHARED_UNRESV 0x0200
98 #define SHARED_REHASH 0x0400
99 #define SHARED_TDLINE 0x0800
100 #define SHARED_PDLINE 0x1000
101 #define SHARED_UNDLINE 0x2000
103 #define SHARED_ALL (SHARED_TKLINE | SHARED_PKLINE | SHARED_UNKLINE |\
104 SHARED_PXLINE | SHARED_TXLINE | SHARED_UNXLINE |\
105 SHARED_TRESV | SHARED_PRESV | SHARED_UNRESV)
106 #define CLUSTER_ALL (SHARED_ALL | SHARED_LOCOPS)
108 /* flags used in hub/leaf */
109 #define CONF_HUB 0x0001
110 #define CONF_LEAF 0x0002
122 unsigned int snomask
;
124 struct PrivilegeSet
*privset
;
126 #ifdef HAVE_LIBCRYPTO
127 char *rsa_pubkey_file
;
132 extern struct remote_conf
*make_remote_conf(void);
133 extern void free_remote_conf(struct remote_conf
*);
135 extern int find_shared_conf(const char *username
, const char *host
,
136 const char *server
, int flags
);
137 extern void propagate_generic(struct Client
*source_p
, const char *command
,
138 const char *target
, int cap
, const char *format
, ...);
139 extern void cluster_generic(struct Client
*, const char *, int cltype
,
140 int cap
, const char *format
, ...);
142 #define OPER_ENCRYPTED 0x00001
143 #define OPER_NEEDSSL 0x80000
144 /* 0x400000 and above are in client.h */
146 #define OPER_FLAGS 0 /* no oper privs in Client.flags2/oper_conf.flags currently */
148 #define IsOperConfEncrypted(x) ((x)->flags & OPER_ENCRYPTED)
149 #define IsOperConfNeedSSL(x) ((x)->flags & OPER_NEEDSSL)
151 #define HasPrivilege(x, y) ((x)->localClient != NULL && (x)->localClient->privset != NULL && privilegeset_in_set((x)->localClient->privset, (y)))
153 #define IsOperGlobalKill(x) (HasPrivilege((x), "oper:global_kill"))
154 #define IsOperLocalKill(x) (HasPrivilege((x), "oper:local_kill"))
155 #define IsOperRemote(x) (HasPrivilege((x), "oper:routing"))
156 #define IsOperUnkline(x) (HasPrivilege((x), "oper:unkline"))
157 #define IsOperN(x) (HasPrivilege((x), "snomask:nick_changes"))
158 #define IsOperK(x) (HasPrivilege((x), "oper:kline"))
159 #define IsOperXline(x) (HasPrivilege((x), "oper:xline"))
160 #define IsOperResv(x) (HasPrivilege((x), "oper:resv"))
161 #define IsOperDie(x) (HasPrivilege((x), "oper:die"))
162 #define IsOperRehash(x) (HasPrivilege((x), "oper:rehash"))
163 #define IsOperHiddenAdmin(x) (HasPrivilege((x), "oper:hidden_admin"))
164 #define IsOperAdmin(x) (HasPrivilege((x), "oper:admin") || HasPrivilege((x), "oper:hidden_admin"))
165 #define IsOperOperwall(x) (HasPrivilege((x), "oper:operwall"))
166 #define IsOperSpy(x) (HasPrivilege((x), "oper:spy"))
167 #define IsOperInvis(x) (HasPrivilege((x), "oper:hidden"))
168 #define IsOperRemoteBan(x) (HasPrivilege((x), "oper:remoteban"))
169 #define IsOperMassNotice(x) (HasPrivilege((x), "oper:mass_notice"))
171 extern struct oper_conf
*make_oper_conf(void);
172 extern void free_oper_conf(struct oper_conf
*);
173 extern void clear_oper_conf(void);
175 extern struct oper_conf
*find_oper_conf(const char *username
, const char *host
,
176 const char *locip
, const char *oname
);
178 extern const char *get_oper_privs(int flags
);
192 struct rb_sockaddr_storage my_ipnum
;
199 #define SERVER_ILLEGAL 0x0001
200 #define SERVER_VHOSTED 0x0002
201 #define SERVER_ENCRYPTED 0x0004
202 #define SERVER_COMPRESSED 0x0008
203 #define SERVER_TB 0x0010
204 #define SERVER_AUTOCONN 0x0020
205 #define SERVER_SSL 0x0040
207 #define ServerConfIllegal(x) ((x)->flags & SERVER_ILLEGAL)
208 #define ServerConfVhosted(x) ((x)->flags & SERVER_VHOSTED)
209 #define ServerConfEncrypted(x) ((x)->flags & SERVER_ENCRYPTED)
210 #define ServerConfCompressed(x) ((x)->flags & SERVER_COMPRESSED)
211 #define ServerConfTb(x) ((x)->flags & SERVER_TB)
212 #define ServerConfAutoconn(x) ((x)->flags & SERVER_AUTOCONN)
213 #define ServerConfSSL(x) ((x)->flags & SERVER_SSL)
215 extern struct server_conf
*make_server_conf(void);
216 extern void free_server_conf(struct server_conf
*);
217 extern void clear_server_conf(void);
218 extern void add_server_conf(struct server_conf
*);
220 extern struct server_conf
*find_server_conf(const char *name
);
222 extern void attach_server_conf(struct Client
*, struct server_conf
*);
223 extern void detach_server_conf(struct Client
*);
224 extern void set_server_conf_autoconn(struct Client
*source_p
, const char *name
,
228 extern struct ConfItem
*find_xline(const char *, int);
229 extern struct ConfItem
*find_xline_mask(const char *);
230 extern struct ConfItem
*find_nick_resv(const char *name
);
231 extern struct ConfItem
*find_nick_resv_mask(const char *name
);
233 extern int valid_wild_card_simple(const char *);
234 extern int clean_resv_nick(const char *);
235 time_t valid_temp_time(const char *p
);
239 char name
[NICKLEN
+1];
241 rb_dlink_node lnode
; /* node in ll */
244 extern void add_nd_entry(const char *name
);
245 extern void free_nd_entry(struct nd_entry
*);
246 extern unsigned long get_nd_count(void);