]>
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. | |
212380e3 AC |
31 | */ |
32 | ||
33 | #ifndef INCLUDED_s_newconf_h | |
34 | #define INCLUDED_s_newconf_h | |
35 | ||
36 | #include "setup.h" | |
a2e1310c | 37 | #include "privilege.h" |
212380e3 AC |
38 | |
39 | #ifdef HAVE_LIBCRYPTO | |
40 | #include <openssl/rsa.h> | |
41 | #endif | |
42 | ||
43 | struct ConfItem; | |
44 | ||
5b96d9a6 AC |
45 | extern rb_dlink_list cluster_conf_list; |
46 | extern rb_dlink_list shared_conf_list; | |
47 | extern rb_dlink_list oper_conf_list; | |
48 | extern rb_dlink_list hubleaf_conf_list; | |
49 | extern rb_dlink_list server_conf_list; | |
50 | extern rb_dlink_list xline_conf_list; | |
51 | extern rb_dlink_list resv_conf_list; | |
52 | extern rb_dlink_list nd_list; | |
53 | extern rb_dlink_list tgchange_list; | |
212380e3 | 54 | |
2e819b6b | 55 | extern struct _rb_patricia_tree_t *tgchange_tree; |
212380e3 AC |
56 | |
57 | extern void init_s_newconf(void); | |
58 | extern void clear_s_newconf(void); | |
59 | extern void clear_s_newconf_bans(void); | |
60 | ||
212380e3 AC |
61 | typedef struct |
62 | { | |
63 | char *ip; | |
64 | time_t expiry; | |
5b96d9a6 AC |
65 | rb_patricia_node_t *pnode; |
66 | rb_dlink_node node; | |
212380e3 AC |
67 | } tgchange; |
68 | ||
69 | void add_tgchange(const char *host); | |
70 | tgchange *find_tgchange(const char *host); | |
71 | ||
72 | /* shared/cluster/hub/leaf confs */ | |
73 | struct remote_conf | |
74 | { | |
75 | char *username; | |
76 | char *host; | |
77 | char *server; | |
78 | int flags; | |
5b96d9a6 | 79 | rb_dlink_node node; |
212380e3 AC |
80 | }; |
81 | ||
82 | /* flags used in shared/cluster */ | |
15feac53 AC |
83 | #define SHARED_TKLINE 0x00001 |
84 | #define SHARED_PKLINE 0x00002 | |
85 | #define SHARED_UNKLINE 0x00004 | |
86 | #define SHARED_LOCOPS 0x00008 | |
87 | #define SHARED_TXLINE 0x00010 | |
88 | #define SHARED_PXLINE 0x00020 | |
89 | #define SHARED_UNXLINE 0x00040 | |
90 | #define SHARED_TRESV 0x00080 | |
91 | #define SHARED_PRESV 0x00100 | |
92 | #define SHARED_UNRESV 0x00200 | |
93 | #define SHARED_REHASH 0x00400 | |
94 | #define SHARED_TDLINE 0x00800 | |
95 | #define SHARED_PDLINE 0x01000 | |
96 | #define SHARED_UNDLINE 0x02000 | |
97 | #define SHARED_GRANT 0x04000 | |
98 | #define SHARED_DIE 0x08000 | |
99 | #define SHARED_MODULE 0x10000 | |
212380e3 AC |
100 | |
101 | #define SHARED_ALL (SHARED_TKLINE | SHARED_PKLINE | SHARED_UNKLINE |\ | |
102 | SHARED_PXLINE | SHARED_TXLINE | SHARED_UNXLINE |\ | |
fe749d37 | 103 | SHARED_TRESV | SHARED_PRESV | SHARED_UNRESV | SHARED_GRANT) |
212380e3 AC |
104 | #define CLUSTER_ALL (SHARED_ALL | SHARED_LOCOPS) |
105 | ||
106 | /* flags used in hub/leaf */ | |
107 | #define CONF_HUB 0x0001 | |
108 | #define CONF_LEAF 0x0002 | |
109 | ||
110 | struct oper_conf | |
111 | { | |
112 | char *name; | |
113 | char *username; | |
114 | char *host; | |
115 | char *passwd; | |
ff31db84 | 116 | char *certfp; |
212380e3 AC |
117 | |
118 | int flags; | |
119 | int umodes; | |
120 | ||
121 | unsigned int snomask; | |
122 | ||
a2e1310c AC |
123 | struct PrivilegeSet *privset; |
124 | ||
212380e3 AC |
125 | #ifdef HAVE_LIBCRYPTO |
126 | char *rsa_pubkey_file; | |
127 | RSA *rsa_pubkey; | |
128 | #endif | |
129 | }; | |
130 | ||
131 | extern struct remote_conf *make_remote_conf(void); | |
132 | extern void free_remote_conf(struct remote_conf *); | |
133 | ||
bd43a444 | 134 | extern bool find_shared_conf(const char *username, const char *host, |
212380e3 AC |
135 | const char *server, int flags); |
136 | extern void propagate_generic(struct Client *source_p, const char *command, | |
137 | const char *target, int cap, const char *format, ...); | |
138 | extern void cluster_generic(struct Client *, const char *, int cltype, | |
139 | int cap, const char *format, ...); | |
140 | ||
5a22e925 EM |
141 | #define OPER_ENCRYPTED 0x00001 |
142 | #define OPER_NEEDSSL 0x80000 | |
212380e3 | 143 | |
66f7fe67 | 144 | #define OPER_FLAGS 0 /* no oper privs in Client.flags/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; | |
d4214e94 SA |
181 | char *connect_host; |
182 | struct rb_sockaddr_storage connect4; | |
183 | uint16_t dns_query_connect4; | |
184 | #ifdef RB_IPV6 | |
185 | struct rb_sockaddr_storage connect6; | |
186 | uint16_t dns_query_connect6; | |
187 | #endif | |
212380e3 AC |
188 | char *passwd; |
189 | char *spasswd; | |
ff0cc1e6 | 190 | char *certfp; |
212380e3 AC |
191 | int port; |
192 | int flags; | |
193 | int servers; | |
194 | time_t hold; | |
195 | ||
196 | int aftype; | |
d4214e94 SA |
197 | char *bind_host; |
198 | struct rb_sockaddr_storage bind4; | |
199 | uint16_t dns_query_bind4; | |
200 | #ifdef RB_IPV6 | |
201 | struct rb_sockaddr_storage bind6; | |
202 | uint16_t dns_query_bind6; | |
203 | #endif | |
212380e3 AC |
204 | |
205 | char *class_name; | |
206 | struct Class *class; | |
5b96d9a6 | 207 | rb_dlink_node node; |
212380e3 AC |
208 | }; |
209 | ||
210 | #define SERVER_ILLEGAL 0x0001 | |
212380e3 AC |
211 | #define SERVER_ENCRYPTED 0x0004 |
212 | #define SERVER_COMPRESSED 0x0008 | |
213 | #define SERVER_TB 0x0010 | |
214 | #define SERVER_AUTOCONN 0x0020 | |
c6d72037 | 215 | #define SERVER_SSL 0x0040 |
087555a0 | 216 | #define SERVER_NO_EXPORT 0x0080 |
212380e3 AC |
217 | |
218 | #define ServerConfIllegal(x) ((x)->flags & SERVER_ILLEGAL) | |
212380e3 AC |
219 | #define ServerConfEncrypted(x) ((x)->flags & SERVER_ENCRYPTED) |
220 | #define ServerConfCompressed(x) ((x)->flags & SERVER_COMPRESSED) | |
221 | #define ServerConfTb(x) ((x)->flags & SERVER_TB) | |
222 | #define ServerConfAutoconn(x) ((x)->flags & SERVER_AUTOCONN) | |
c6d72037 | 223 | #define ServerConfSSL(x) ((x)->flags & SERVER_SSL) |
087555a0 | 224 | #define ServerConfNoExport(x) ((x)->flags & SERVER_NO_EXPORT) |
212380e3 AC |
225 | |
226 | extern struct server_conf *make_server_conf(void); | |
227 | extern void free_server_conf(struct server_conf *); | |
228 | extern void clear_server_conf(void); | |
229 | extern void add_server_conf(struct server_conf *); | |
230 | ||
231 | extern struct server_conf *find_server_conf(const char *name); | |
232 | ||
233 | extern void attach_server_conf(struct Client *, struct server_conf *); | |
234 | extern void detach_server_conf(struct Client *); | |
55abcbb2 | 235 | extern void set_server_conf_autoconn(struct Client *source_p, const char *name, |
212380e3 | 236 | int newval); |
53307da8 | 237 | extern void disable_server_conf_autoconn(const char *name); |
212380e3 AC |
238 | |
239 | ||
240 | extern struct ConfItem *find_xline(const char *, int); | |
0fdb2570 | 241 | extern struct ConfItem *find_xline_mask(const char *); |
212380e3 | 242 | extern struct ConfItem *find_nick_resv(const char *name); |
0fdb2570 | 243 | extern struct ConfItem *find_nick_resv_mask(const char *name); |
212380e3 AC |
244 | |
245 | extern int valid_wild_card_simple(const char *); | |
246 | extern int clean_resv_nick(const char *); | |
247 | time_t valid_temp_time(const char *p); | |
248 | ||
ae78a571 VY |
249 | struct nd_entry |
250 | { | |
251 | char name[NICKLEN+1]; | |
252 | time_t expire; | |
253 | rb_dlink_node lnode; /* node in ll */ | |
212380e3 AC |
254 | }; |
255 | ||
256 | extern void add_nd_entry(const char *name); | |
257 | extern void free_nd_entry(struct nd_entry *); | |
258 | extern unsigned long get_nd_count(void); | |
259 | ||
260 | #endif | |
261 |