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