]>
Commit | Line | Data |
---|---|---|
212380e3 AC |
1 | /* |
2 | * ircd-ratbox: an advanced Internet Relay Chat Daemon(ircd). | |
3 | * s_newconf.h: code for dealing with conf stuff | |
4 | * | |
5 | * Copyright (C) 2004 Lee Hardy <lee@leeh.co.uk> | |
6 | * Copyright (C) 2004 ircd-ratbox development team | |
7 | * | |
8 | * Redistribution and use in source and binary forms, with or without | |
9 | * modification, are permitted provided that the following conditions are | |
10 | * met: | |
11 | * | |
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. | |
19 | * | |
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. | |
31 | * | |
32 | * $Id: s_newconf.h 1747 2006-07-25 21:22:45Z jilles $ | |
33 | */ | |
34 | ||
35 | #ifndef INCLUDED_s_newconf_h | |
36 | #define INCLUDED_s_newconf_h | |
37 | ||
38 | #include "setup.h" | |
a2e1310c | 39 | #include "privilege.h" |
212380e3 AC |
40 | |
41 | #ifdef HAVE_LIBCRYPTO | |
42 | #include <openssl/rsa.h> | |
43 | #endif | |
44 | ||
45 | struct ConfItem; | |
46 | ||
5b96d9a6 AC |
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; | |
212380e3 | 56 | |
2e819b6b | 57 | extern struct _rb_patricia_tree_t *tgchange_tree; |
212380e3 AC |
58 | |
59 | extern void init_s_newconf(void); | |
60 | extern void clear_s_newconf(void); | |
61 | extern void clear_s_newconf_bans(void); | |
62 | ||
212380e3 AC |
63 | typedef struct |
64 | { | |
65 | char *ip; | |
66 | time_t expiry; | |
5b96d9a6 AC |
67 | rb_patricia_node_t *pnode; |
68 | rb_dlink_node node; | |
212380e3 AC |
69 | } tgchange; |
70 | ||
71 | void add_tgchange(const char *host); | |
72 | tgchange *find_tgchange(const char *host); | |
73 | ||
74 | /* shared/cluster/hub/leaf confs */ | |
75 | struct remote_conf | |
76 | { | |
77 | char *username; | |
78 | char *host; | |
79 | char *server; | |
80 | int flags; | |
5b96d9a6 | 81 | rb_dlink_node node; |
212380e3 AC |
82 | }; |
83 | ||
84 | /* flags used in shared/cluster */ | |
85 | #define SHARED_TKLINE 0x0001 | |
86 | #define SHARED_PKLINE 0x0002 | |
87 | #define SHARED_UNKLINE 0x0004 | |
88 | #define SHARED_LOCOPS 0x0008 | |
89 | #define SHARED_TXLINE 0x0010 | |
90 | #define SHARED_PXLINE 0x0020 | |
91 | #define SHARED_UNXLINE 0x0040 | |
de82e84f | 92 | #define SHARED_TRESV 0x0080 |
212380e3 AC |
93 | #define SHARED_PRESV 0x0100 |
94 | #define SHARED_UNRESV 0x0200 | |
95 | #define SHARED_REHASH 0x0400 | |
f5cb68d5 VY |
96 | #define SHARED_TDLINE 0x0800 |
97 | #define SHARED_PDLINE 0x1000 | |
98 | #define SHARED_UNDLINE 0x2000 | |
212380e3 AC |
99 | |
100 | #define SHARED_ALL (SHARED_TKLINE | SHARED_PKLINE | SHARED_UNKLINE |\ | |
101 | SHARED_PXLINE | SHARED_TXLINE | SHARED_UNXLINE |\ | |
c42fb00e | 102 | SHARED_TRESV | SHARED_PRESV | SHARED_UNRESV) |
212380e3 AC |
103 | #define CLUSTER_ALL (SHARED_ALL | SHARED_LOCOPS) |
104 | ||
105 | /* flags used in hub/leaf */ | |
106 | #define CONF_HUB 0x0001 | |
107 | #define CONF_LEAF 0x0002 | |
108 | ||
109 | struct oper_conf | |
110 | { | |
111 | char *name; | |
112 | char *username; | |
113 | char *host; | |
114 | char *passwd; | |
ff31db84 | 115 | char *certfp; |
212380e3 AC |
116 | |
117 | int flags; | |
118 | int umodes; | |
119 | ||
120 | unsigned int snomask; | |
121 | ||
a2e1310c AC |
122 | struct PrivilegeSet *privset; |
123 | ||
212380e3 AC |
124 | #ifdef HAVE_LIBCRYPTO |
125 | char *rsa_pubkey_file; | |
126 | RSA *rsa_pubkey; | |
127 | #endif | |
128 | }; | |
129 | ||
130 | extern struct remote_conf *make_remote_conf(void); | |
131 | extern void free_remote_conf(struct remote_conf *); | |
132 | ||
133 | extern int find_shared_conf(const char *username, const char *host, | |
134 | const char *server, int flags); | |
135 | extern void propagate_generic(struct Client *source_p, const char *command, | |
136 | const char *target, int cap, const char *format, ...); | |
137 | extern void cluster_generic(struct Client *, const char *, int cltype, | |
138 | int cap, const char *format, ...); | |
139 | ||
140 | #define OPER_ENCRYPTED 0x00001 | |
b1594414 | 141 | #define OPER_NEEDSSL 0x80000 |
3fec9477 | 142 | /* 0x400000 and above are in client.h */ |
212380e3 | 143 | |
10847f65 | 144 | #define OPER_FLAGS 0 /* no oper privs in Client.flags2/oper_conf.flags currently */ |
212380e3 AC |
145 | |
146 | #define IsOperConfEncrypted(x) ((x)->flags & OPER_ENCRYPTED) | |
b1594414 | 147 | #define IsOperConfNeedSSL(x) ((x)->flags & OPER_NEEDSSL) |
212380e3 | 148 | |
f37fc938 | 149 | #define HasPrivilege(x, y) ((x)->localClient != NULL && (x)->localClient->privset != NULL && privilegeset_in_set((x)->localClient->privset, (y))) |
6ac9e53e AC |
150 | |
151 | #define IsOperGlobalKill(x) (HasPrivilege((x), "oper:global_kill")) | |
152 | #define IsOperLocalKill(x) (HasPrivilege((x), "oper:local_kill")) | |
153 | #define IsOperRemote(x) (HasPrivilege((x), "oper:routing")) | |
154 | #define IsOperUnkline(x) (HasPrivilege((x), "oper:unkline")) | |
155 | #define IsOperN(x) (HasPrivilege((x), "snomask:nick_changes")) | |
156 | #define IsOperK(x) (HasPrivilege((x), "oper:kline")) | |
157 | #define IsOperXline(x) (HasPrivilege((x), "oper:xline")) | |
158 | #define IsOperResv(x) (HasPrivilege((x), "oper:resv")) | |
159 | #define IsOperDie(x) (HasPrivilege((x), "oper:die")) | |
160 | #define IsOperRehash(x) (HasPrivilege((x), "oper:rehash")) | |
161 | #define IsOperHiddenAdmin(x) (HasPrivilege((x), "oper:hidden_admin")) | |
162 | #define IsOperAdmin(x) (HasPrivilege((x), "oper:admin") || HasPrivilege((x), "oper:hidden_admin")) | |
163 | #define IsOperOperwall(x) (HasPrivilege((x), "oper:operwall")) | |
164 | #define IsOperSpy(x) (HasPrivilege((x), "oper:spy")) | |
165 | #define IsOperInvis(x) (HasPrivilege((x), "oper:hidden")) | |
166 | #define IsOperRemoteBan(x) (HasPrivilege((x), "oper:remoteban")) | |
167 | #define IsOperMassNotice(x) (HasPrivilege((x), "oper:mass_notice")) | |
212380e3 AC |
168 | |
169 | extern struct oper_conf *make_oper_conf(void); | |
170 | extern void free_oper_conf(struct oper_conf *); | |
171 | extern void clear_oper_conf(void); | |
172 | ||
173 | extern struct oper_conf *find_oper_conf(const char *username, const char *host, | |
174 | const char *locip, const char *oname); | |
175 | ||
176 | extern const char *get_oper_privs(int flags); | |
177 | ||
178 | struct server_conf | |
179 | { | |
180 | char *name; | |
181 | char *host; | |
182 | char *passwd; | |
183 | char *spasswd; | |
ff0cc1e6 | 184 | char *certfp; |
212380e3 AC |
185 | int port; |
186 | int flags; | |
187 | int servers; | |
188 | time_t hold; | |
189 | ||
190 | int aftype; | |
e7046ee5 | 191 | struct rb_sockaddr_storage my_ipnum; |
212380e3 AC |
192 | |
193 | char *class_name; | |
194 | struct Class *class; | |
5b96d9a6 | 195 | rb_dlink_node node; |
1d02144f AC |
196 | |
197 | uint16_t dns_query; | |
212380e3 AC |
198 | }; |
199 | ||
200 | #define SERVER_ILLEGAL 0x0001 | |
201 | #define SERVER_VHOSTED 0x0002 | |
202 | #define SERVER_ENCRYPTED 0x0004 | |
203 | #define SERVER_COMPRESSED 0x0008 | |
204 | #define SERVER_TB 0x0010 | |
205 | #define SERVER_AUTOCONN 0x0020 | |
c6d72037 | 206 | #define SERVER_SSL 0x0040 |
212380e3 AC |
207 | |
208 | #define ServerConfIllegal(x) ((x)->flags & SERVER_ILLEGAL) | |
209 | #define ServerConfVhosted(x) ((x)->flags & SERVER_VHOSTED) | |
210 | #define ServerConfEncrypted(x) ((x)->flags & SERVER_ENCRYPTED) | |
211 | #define ServerConfCompressed(x) ((x)->flags & SERVER_COMPRESSED) | |
212 | #define ServerConfTb(x) ((x)->flags & SERVER_TB) | |
213 | #define ServerConfAutoconn(x) ((x)->flags & SERVER_AUTOCONN) | |
c6d72037 | 214 | #define ServerConfSSL(x) ((x)->flags & SERVER_SSL) |
212380e3 AC |
215 | |
216 | extern struct server_conf *make_server_conf(void); | |
217 | extern void free_server_conf(struct server_conf *); | |
218 | extern void clear_server_conf(void); | |
219 | extern void add_server_conf(struct server_conf *); | |
220 | ||
221 | extern struct server_conf *find_server_conf(const char *name); | |
222 | ||
223 | extern void attach_server_conf(struct Client *, struct server_conf *); | |
224 | extern void detach_server_conf(struct Client *); | |
55abcbb2 | 225 | extern void set_server_conf_autoconn(struct Client *source_p, const char *name, |
212380e3 | 226 | int newval); |
53307da8 | 227 | extern void disable_server_conf_autoconn(const char *name); |
212380e3 AC |
228 | |
229 | ||
230 | extern struct ConfItem *find_xline(const char *, int); | |
0fdb2570 | 231 | extern struct ConfItem *find_xline_mask(const char *); |
212380e3 | 232 | extern struct ConfItem *find_nick_resv(const char *name); |
0fdb2570 | 233 | extern struct ConfItem *find_nick_resv_mask(const char *name); |
212380e3 AC |
234 | |
235 | extern int valid_wild_card_simple(const char *); | |
236 | extern int clean_resv_nick(const char *); | |
237 | time_t valid_temp_time(const char *p); | |
238 | ||
ae78a571 VY |
239 | struct nd_entry |
240 | { | |
241 | char name[NICKLEN+1]; | |
242 | time_t expire; | |
243 | rb_dlink_node lnode; /* node in ll */ | |
212380e3 AC |
244 | }; |
245 | ||
246 | extern void add_nd_entry(const char *name); | |
247 | extern void free_nd_entry(struct nd_entry *); | |
248 | extern unsigned long get_nd_count(void); | |
249 | ||
250 | #endif | |
251 |