]> jfr.im git - solanum.git/blob - include/s_newconf.h
Remove Windows support
[solanum.git] / include / s_newconf.h
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
33 #ifndef INCLUDED_s_newconf_h
34 #define INCLUDED_s_newconf_h
35
36 #include "setup.h"
37 #include "privilege.h"
38
39 #ifdef HAVE_LIBCRYPTO
40 #include <openssl/rsa.h>
41 #endif
42
43 struct ConfItem;
44
45 extern rb_dlink_list cluster_conf_list;
46 extern rb_dlink_list oper_conf_list;
47 extern rb_dlink_list server_conf_list;
48 extern rb_dlink_list xline_conf_list;
49 extern rb_dlink_list resv_conf_list;
50 extern rb_dlink_list nd_list;
51 extern rb_dlink_list tgchange_list;
52
53 extern struct _rb_patricia_tree_t *tgchange_tree;
54
55 extern void init_s_newconf(void);
56 extern void clear_s_newconf(void);
57 extern void clear_s_newconf_bans(void);
58
59 typedef struct
60 {
61 char *ip;
62 time_t expiry;
63 rb_patricia_node_t *pnode;
64 rb_dlink_node node;
65 } tgchange;
66
67 void add_tgchange(const char *host);
68 tgchange *find_tgchange(const char *host);
69
70 /* cluster confs */
71 struct remote_conf
72 {
73 char *username;
74 char *host;
75 char *server;
76 int flags;
77 rb_dlink_node node;
78 };
79
80 /* flags used in shared/cluster */
81 #define SHARED_TKLINE 0x00001
82 #define SHARED_PKLINE 0x00002
83 #define SHARED_UNKLINE 0x00004
84 #define SHARED_LOCOPS 0x00008
85 #define SHARED_TXLINE 0x00010
86 #define SHARED_PXLINE 0x00020
87 #define SHARED_UNXLINE 0x00040
88 #define SHARED_TRESV 0x00080
89 #define SHARED_PRESV 0x00100
90 #define SHARED_UNRESV 0x00200
91 #define SHARED_REHASH 0x00400
92 #define SHARED_TDLINE 0x00800
93 #define SHARED_PDLINE 0x01000
94 #define SHARED_UNDLINE 0x02000
95 #define SHARED_GRANT 0x04000
96 #define SHARED_DIE 0x08000
97 #define SHARED_MODULE 0x10000
98
99 #define SHARED_ALL (SHARED_TKLINE | SHARED_PKLINE | SHARED_UNKLINE |\
100 SHARED_PXLINE | SHARED_TXLINE | SHARED_UNXLINE |\
101 SHARED_TRESV | SHARED_PRESV | SHARED_UNRESV | SHARED_GRANT)
102 #define CLUSTER_ALL (SHARED_ALL | SHARED_LOCOPS)
103
104 struct oper_conf
105 {
106 char *name;
107 char *username;
108 char *host;
109 char *passwd;
110 char *certfp;
111
112 int flags;
113 int umodes;
114
115 unsigned int snomask;
116
117 struct PrivilegeSet *privset;
118
119 #ifdef HAVE_LIBCRYPTO
120 char *rsa_pubkey_file;
121 RSA *rsa_pubkey;
122 #endif
123 };
124
125 extern struct remote_conf *make_remote_conf(void);
126 extern void free_remote_conf(struct remote_conf *);
127
128 extern void propagate_generic(struct Client *source_p, const char *command,
129 const char *target, int cap, const char *format, ...);
130 extern void cluster_generic(struct Client *, const char *, int cltype,
131 int cap, const char *format, ...);
132
133 #define OPER_ENCRYPTED 0x00001
134 #define OPER_NEEDSSL 0x80000
135
136 #define OPER_FLAGS 0 /* no oper privs in Client.flags/oper_conf.flags currently */
137
138 #define IsOperConfEncrypted(x) ((x)->flags & OPER_ENCRYPTED)
139 #define IsOperConfNeedSSL(x) ((x)->flags & OPER_NEEDSSL)
140
141 #define HasPrivilege(x, y) ((x)->user != NULL && (x)->user->privset != NULL && privilegeset_in_set((x)->user->privset, (y)))
142 #define MayHavePrivilege(x, y) (HasPrivilege((x), (y)) || (IsOper((x)) && (x)->user != NULL && (x)->user->privset == NULL))
143
144 #define IsOperKill(x) (HasPrivilege((x), "oper:kill"))
145 #define IsOperRemote(x) (HasPrivilege((x), "oper:routing"))
146 #define IsOperUnkline(x) (HasPrivilege((x), "oper:unkline"))
147 #define IsOperN(x) (HasPrivilege((x), "snomask:nick_changes"))
148 #define IsOperK(x) (HasPrivilege((x), "oper:kline"))
149 #define IsOperXline(x) (HasPrivilege((x), "oper:xline"))
150 #define IsOperResv(x) (HasPrivilege((x), "oper:resv"))
151 #define IsOperDie(x) (HasPrivilege((x), "oper:die"))
152 #define IsOperRehash(x) (HasPrivilege((x), "oper:rehash"))
153 #define IsOperHiddenAdmin(x) (HasPrivilege((x), "oper:hidden_admin"))
154 #define IsOperAdmin(x) (HasPrivilege((x), "oper:admin") || HasPrivilege((x), "oper:hidden_admin"))
155 #define IsOperOperwall(x) (HasPrivilege((x), "oper:operwall"))
156 #define IsOperSpy(x) (HasPrivilege((x), "oper:spy"))
157 #define IsOperInvis(x) (HasPrivilege((x), "oper:hidden"))
158 #define IsOperRemoteBan(x) (HasPrivilege((x), "oper:remoteban"))
159 #define IsOperMassNotice(x) (HasPrivilege((x), "oper:mass_notice"))
160 #define IsOperGeneral(x) (MayHavePrivilege((x), "oper:general"))
161
162 #define SeesOper(target, source) (IsOper((target)) && ((!ConfigFileEntry.hide_opers && !HasPrivilege((target), "oper:hidden")) || HasPrivilege((source), "auspex:oper")))
163
164 extern struct oper_conf *make_oper_conf(void);
165 extern void free_oper_conf(struct oper_conf *);
166 extern void clear_oper_conf(void);
167
168 extern struct oper_conf *find_oper_conf(const char *username, const char *host,
169 const char *locip, const char *oname);
170
171 extern const char *get_oper_privs(int flags);
172
173 struct server_conf
174 {
175 char *name;
176 char *connect_host;
177 struct rb_sockaddr_storage connect4;
178 uint16_t dns_query_connect4;
179 struct rb_sockaddr_storage connect6;
180 uint16_t dns_query_connect6;
181 char *passwd;
182 char *spasswd;
183 char *certfp;
184 int port;
185 int flags;
186 int servers;
187 time_t hold;
188
189 int aftype;
190 char *bind_host;
191 struct rb_sockaddr_storage bind4;
192 uint16_t dns_query_bind4;
193 struct rb_sockaddr_storage bind6;
194 uint16_t dns_query_bind6;
195
196 char *class_name;
197 struct Class *class;
198 rb_dlink_node node;
199 };
200
201 #define SERVER_ILLEGAL 0x0001
202 #define SERVER_ENCRYPTED 0x0004
203 #define SERVER_COMPRESSED 0x0008
204 #define SERVER_TB 0x0010
205 #define SERVER_AUTOCONN 0x0020
206 #define SERVER_SSL 0x0040
207 #define SERVER_NO_EXPORT 0x0080
208 #define SERVER_SCTP 0x0100
209
210 #define ServerConfIllegal(x) ((x)->flags & SERVER_ILLEGAL)
211 #define ServerConfEncrypted(x) ((x)->flags & SERVER_ENCRYPTED)
212 #define ServerConfCompressed(x) ((x)->flags & SERVER_COMPRESSED)
213 #define ServerConfTb(x) ((x)->flags & SERVER_TB)
214 #define ServerConfAutoconn(x) ((x)->flags & SERVER_AUTOCONN)
215 #define ServerConfSCTP(x) ((x)->flags & SERVER_SCTP)
216 #define ServerConfSSL(x) ((x)->flags & SERVER_SSL)
217 #define ServerConfNoExport(x) ((x)->flags & SERVER_NO_EXPORT)
218
219 extern struct server_conf *make_server_conf(void);
220 extern void free_server_conf(struct server_conf *);
221 extern void clear_server_conf(void);
222 extern void add_server_conf(struct server_conf *);
223
224 extern struct server_conf *find_server_conf(const char *name);
225
226 extern void attach_server_conf(struct Client *, struct server_conf *);
227 extern void detach_server_conf(struct Client *);
228 extern void set_server_conf_autoconn(struct Client *source_p, const char *name,
229 int newval);
230 extern void disable_server_conf_autoconn(const char *name);
231
232
233 extern struct ConfItem *find_xline(const char *, int);
234 extern struct ConfItem *find_xline_mask(const char *);
235 extern struct ConfItem *find_nick_resv(const char *name);
236 extern struct ConfItem *find_nick_resv_mask(const char *name);
237
238 extern int valid_wild_card_simple(const char *);
239 extern int clean_resv_nick(const char *);
240 time_t valid_temp_time(const char *p);
241
242 struct nd_entry
243 {
244 char name[NICKLEN+1];
245 time_t expire;
246 rb_dlink_node lnode; /* node in ll */
247 };
248
249 extern void add_nd_entry(const char *name);
250 extern void free_nd_entry(struct nd_entry *);
251 extern unsigned long get_nd_count(void);
252
253 #endif
254