]> jfr.im git - solanum.git/blame - include/s_newconf.h
Keep propagated bans in a dictionary, not a list
[solanum.git] / include / s_newconf.h
CommitLineData
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
43struct ConfItem;
44
5b96d9a6 45extern rb_dlink_list cluster_conf_list;
5b96d9a6 46extern rb_dlink_list oper_conf_list;
5b96d9a6
AC
47extern rb_dlink_list server_conf_list;
48extern rb_dlink_list xline_conf_list;
49extern rb_dlink_list resv_conf_list;
50extern rb_dlink_list nd_list;
51extern rb_dlink_list tgchange_list;
212380e3 52
2e819b6b 53extern struct _rb_patricia_tree_t *tgchange_tree;
212380e3
AC
54
55extern void init_s_newconf(void);
56extern void clear_s_newconf(void);
57extern void clear_s_newconf_bans(void);
58
212380e3
AC
59typedef struct
60{
61 char *ip;
62 time_t expiry;
5b96d9a6
AC
63 rb_patricia_node_t *pnode;
64 rb_dlink_node node;
212380e3
AC
65} tgchange;
66
67void add_tgchange(const char *host);
68tgchange *find_tgchange(const char *host);
69
64850052 70/* cluster confs */
212380e3
AC
71struct remote_conf
72{
73 char *username;
74 char *host;
75 char *server;
76 int flags;
5b96d9a6 77 rb_dlink_node node;
212380e3
AC
78};
79
80/* flags used in shared/cluster */
15feac53
AC
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
212380e3
AC
98
99#define SHARED_ALL (SHARED_TKLINE | SHARED_PKLINE | SHARED_UNKLINE |\
100 SHARED_PXLINE | SHARED_TXLINE | SHARED_UNXLINE |\
fe749d37 101 SHARED_TRESV | SHARED_PRESV | SHARED_UNRESV | SHARED_GRANT)
212380e3
AC
102#define CLUSTER_ALL (SHARED_ALL | SHARED_LOCOPS)
103
212380e3
AC
104struct oper_conf
105{
106 char *name;
107 char *username;
108 char *host;
109 char *passwd;
ff31db84 110 char *certfp;
212380e3
AC
111
112 int flags;
113 int umodes;
114
115 unsigned int snomask;
116
a2e1310c
AC
117 struct PrivilegeSet *privset;
118
212380e3
AC
119#ifdef HAVE_LIBCRYPTO
120 char *rsa_pubkey_file;
121 RSA *rsa_pubkey;
122#endif
123};
124
125extern struct remote_conf *make_remote_conf(void);
126extern void free_remote_conf(struct remote_conf *);
127
212380e3
AC
128extern void propagate_generic(struct Client *source_p, const char *command,
129 const char *target, int cap, const char *format, ...);
130extern void cluster_generic(struct Client *, const char *, int cltype,
131 int cap, const char *format, ...);
132
5a22e925
EM
133#define OPER_ENCRYPTED 0x00001
134#define OPER_NEEDSSL 0x80000
212380e3 135
66f7fe67 136#define OPER_FLAGS 0 /* no oper privs in Client.flags/oper_conf.flags currently */
212380e3
AC
137
138#define IsOperConfEncrypted(x) ((x)->flags & OPER_ENCRYPTED)
b1594414 139#define IsOperConfNeedSSL(x) ((x)->flags & OPER_NEEDSSL)
212380e3 140
ed3ca2ff 141#define HasPrivilege(x, y) ((x)->user != NULL && (x)->user->privset != NULL && privilegeset_in_set((x)->user->privset, (y)))
64c9f509 142#define MayHavePrivilege(x, y) (HasPrivilege((x), (y)) || (IsOper((x)) && (x)->user != NULL && (x)->user->privset == NULL))
6ac9e53e 143
7d84719d 144#define IsOperKill(x) (HasPrivilege((x), "oper:kill"))
6ac9e53e
AC
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"))
7d84719d
EK
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"))
212380e3 161
1cd6639a 162#define SeesOper(target, source) (IsOper((target)) && ((!ConfigFileEntry.hide_opers && !HasPrivilege((target), "oper:hidden")) || HasPrivilege((source), "auspex:oper")))
1123eefc 163
212380e3
AC
164extern struct oper_conf *make_oper_conf(void);
165extern void free_oper_conf(struct oper_conf *);
166extern void clear_oper_conf(void);
167
168extern struct oper_conf *find_oper_conf(const char *username, const char *host,
169 const char *locip, const char *oname);
170
171extern const char *get_oper_privs(int flags);
172
173struct server_conf
174{
175 char *name;
d4214e94
SA
176 char *connect_host;
177 struct rb_sockaddr_storage connect4;
178 uint16_t dns_query_connect4;
d4214e94
SA
179 struct rb_sockaddr_storage connect6;
180 uint16_t dns_query_connect6;
212380e3
AC
181 char *passwd;
182 char *spasswd;
ff0cc1e6 183 char *certfp;
212380e3
AC
184 int port;
185 int flags;
186 int servers;
187 time_t hold;
188
189 int aftype;
d4214e94
SA
190 char *bind_host;
191 struct rb_sockaddr_storage bind4;
192 uint16_t dns_query_bind4;
d4214e94
SA
193 struct rb_sockaddr_storage bind6;
194 uint16_t dns_query_bind6;
212380e3
AC
195
196 char *class_name;
197 struct Class *class;
5b96d9a6 198 rb_dlink_node node;
212380e3
AC
199};
200
201#define SERVER_ILLEGAL 0x0001
212380e3
AC
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
087555a0 207#define SERVER_NO_EXPORT 0x0080
6003ce76 208#define SERVER_SCTP 0x0100
212380e3
AC
209
210#define ServerConfIllegal(x) ((x)->flags & SERVER_ILLEGAL)
212380e3
AC
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)
6003ce76 215#define ServerConfSCTP(x) ((x)->flags & SERVER_SCTP)
c6d72037 216#define ServerConfSSL(x) ((x)->flags & SERVER_SSL)
087555a0 217#define ServerConfNoExport(x) ((x)->flags & SERVER_NO_EXPORT)
212380e3
AC
218
219extern struct server_conf *make_server_conf(void);
220extern void free_server_conf(struct server_conf *);
221extern void clear_server_conf(void);
222extern void add_server_conf(struct server_conf *);
223
224extern struct server_conf *find_server_conf(const char *name);
225
226extern void attach_server_conf(struct Client *, struct server_conf *);
227extern void detach_server_conf(struct Client *);
55abcbb2 228extern void set_server_conf_autoconn(struct Client *source_p, const char *name,
212380e3 229 int newval);
53307da8 230extern void disable_server_conf_autoconn(const char *name);
212380e3
AC
231
232
233extern struct ConfItem *find_xline(const char *, int);
0fdb2570 234extern struct ConfItem *find_xline_mask(const char *);
212380e3 235extern struct ConfItem *find_nick_resv(const char *name);
0fdb2570 236extern struct ConfItem *find_nick_resv_mask(const char *name);
212380e3
AC
237
238extern int valid_wild_card_simple(const char *);
239extern int clean_resv_nick(const char *);
240time_t valid_temp_time(const char *p);
241
ae78a571
VY
242struct nd_entry
243{
244 char name[NICKLEN+1];
245 time_t expire;
246 rb_dlink_node lnode; /* node in ll */
212380e3
AC
247};
248
249extern void add_nd_entry(const char *name);
250extern void free_nd_entry(struct nd_entry *);
251extern unsigned long get_nd_count(void);
252
253#endif
254