]> jfr.im git - irc/rqf/shadowircd.git/blame - include/s_newconf.h
Add mr_flea (and Taros) to the list of Charybdis contributors.
[irc/rqf/shadowircd.git] / include / s_newconf.h
CommitLineData
212380e3 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 *
212380e3 32 */
33
34#ifndef INCLUDED_s_newconf_h
35#define INCLUDED_s_newconf_h
36
37#include "setup.h"
120b37f9 38#include "privilege.h"
212380e3 39
40#ifdef HAVE_LIBCRYPTO
41#include <openssl/rsa.h>
42#endif
43
44struct ConfItem;
45
08d11e34
WP
46extern rb_dlink_list cluster_conf_list;
47extern rb_dlink_list shared_conf_list;
48extern rb_dlink_list oper_conf_list;
49extern rb_dlink_list hubleaf_conf_list;
50extern rb_dlink_list server_conf_list;
51extern rb_dlink_list xline_conf_list;
52extern rb_dlink_list resv_conf_list;
53extern rb_dlink_list nd_list;
54extern rb_dlink_list tgchange_list;
212380e3 55
aa65834c 56extern struct _rb_patricia_tree_t *tgchange_tree;
212380e3 57
58extern void init_s_newconf(void);
59extern void clear_s_newconf(void);
60extern void clear_s_newconf_bans(void);
61
212380e3 62typedef struct
63{
64 char *ip;
65 time_t expiry;
08d11e34
WP
66 rb_patricia_node_t *pnode;
67 rb_dlink_node node;
212380e3 68} tgchange;
69
70void add_tgchange(const char *host);
71tgchange *find_tgchange(const char *host);
72
73/* shared/cluster/hub/leaf confs */
74struct remote_conf
75{
76 char *username;
77 char *host;
78 char *server;
79 int flags;
08d11e34 80 rb_dlink_node node;
212380e3 81};
82
83/* flags used in shared/cluster */
84#define SHARED_TKLINE 0x0001
85#define SHARED_PKLINE 0x0002
86#define SHARED_UNKLINE 0x0004
87#define SHARED_LOCOPS 0x0008
88#define SHARED_TXLINE 0x0010
89#define SHARED_PXLINE 0x0020
90#define SHARED_UNXLINE 0x0040
f726dd09 91#define SHARED_TRESV 0x0080
212380e3 92#define SHARED_PRESV 0x0100
93#define SHARED_UNRESV 0x0200
94#define SHARED_REHASH 0x0400
45be325c
VY
95#define SHARED_TDLINE 0x0800
96#define SHARED_PDLINE 0x1000
97#define SHARED_UNDLINE 0x2000
74e3e4f1 98#define SHARED_DIE 0x4000
069f104a 99#define SHARED_MODULE 0x8000
212380e3 100
101#define SHARED_ALL (SHARED_TKLINE | SHARED_PKLINE | SHARED_UNKLINE |\
102 SHARED_PXLINE | SHARED_TXLINE | SHARED_UNXLINE |\
ceb3eb1d 103 SHARED_TRESV | SHARED_PRESV | SHARED_UNRESV | SHARED_REHASH)
212380e3 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
110struct oper_conf
111{
112 char *name;
113 char *username;
114 char *host;
115 char *passwd;
d8a023ed 116 char *certfp;
212380e3 117
118 int flags;
119 int umodes;
120
121 unsigned int snomask;
122
08e35f66 123 char *vhost;
e787d3a2
G
124 char *swhois;
125 char *operstring;
08e35f66 126
120b37f9
WP
127 struct PrivilegeSet *privset;
128
212380e3 129#ifdef HAVE_LIBCRYPTO
130 char *rsa_pubkey_file;
131 RSA *rsa_pubkey;
132#endif
133};
134
135extern struct remote_conf *make_remote_conf(void);
136extern void free_remote_conf(struct remote_conf *);
137
138extern int find_shared_conf(const char *username, const char *host,
139 const char *server, int flags);
140extern void propagate_generic(struct Client *source_p, const char *command,
141 const char *target, int cap, const char *format, ...);
142extern void cluster_generic(struct Client *, const char *, int cltype,
143 int cap, const char *format, ...);
144
145#define OPER_ENCRYPTED 0x00001
663bbb28 146#define OPER_NEEDSSL 0x80000
333d73ff 147/* 0x400000 and above are in client.h */
212380e3 148
850b23f3 149#define OPER_FLAGS 0 /* no oper privs in Client.flags2/oper_conf.flags currently */
212380e3 150
151#define IsOperConfEncrypted(x) ((x)->flags & OPER_ENCRYPTED)
663bbb28 152#define IsOperConfNeedSSL(x) ((x)->flags & OPER_NEEDSSL)
212380e3 153
4db97a82 154#define HasPrivilege(x, y) ((x)->localClient != NULL && (x)->localClient->privset != NULL && privilegeset_in_set((x)->localClient->privset, (y)))
73a34351
WP
155
156#define IsOperGlobalKill(x) (HasPrivilege((x), "oper:global_kill"))
157#define IsOperLocalKill(x) (HasPrivilege((x), "oper:local_kill"))
158#define IsOperRemote(x) (HasPrivilege((x), "oper:routing"))
159#define IsOperUnkline(x) (HasPrivilege((x), "oper:unkline"))
160#define IsOperN(x) (HasPrivilege((x), "snomask:nick_changes"))
161#define IsOperK(x) (HasPrivilege((x), "oper:kline"))
162#define IsOperXline(x) (HasPrivilege((x), "oper:xline"))
163#define IsOperResv(x) (HasPrivilege((x), "oper:resv"))
164#define IsOperDie(x) (HasPrivilege((x), "oper:die"))
165#define IsOperRehash(x) (HasPrivilege((x), "oper:rehash"))
166#define IsOperHiddenAdmin(x) (HasPrivilege((x), "oper:hidden_admin"))
167#define IsOperAdmin(x) (HasPrivilege((x), "oper:admin") || HasPrivilege((x), "oper:hidden_admin"))
168#define IsOperOperwall(x) (HasPrivilege((x), "oper:operwall"))
169#define IsOperSpy(x) (HasPrivilege((x), "oper:spy"))
0a9c5766 170#define IsOperOverride(x) (HasPrivilege((x), "oper:override"))
73a34351
WP
171#define IsOperInvis(x) (HasPrivilege((x), "oper:hidden"))
172#define IsOperRemoteBan(x) (HasPrivilege((x), "oper:remoteban"))
173#define IsOperMassNotice(x) (HasPrivilege((x), "oper:mass_notice"))
212380e3 174
175extern struct oper_conf *make_oper_conf(void);
176extern void free_oper_conf(struct oper_conf *);
177extern void clear_oper_conf(void);
178
179extern struct oper_conf *find_oper_conf(const char *username, const char *host,
180 const char *locip, const char *oname);
181
182extern const char *get_oper_privs(int flags);
183
184struct server_conf
185{
186 char *name;
187 char *host;
188 char *passwd;
189 char *spasswd;
5ac47047 190 char *certfp;
212380e3 191 int port;
192 int flags;
193 int servers;
194 time_t hold;
195
196 int aftype;
3ea5fee7 197 struct rb_sockaddr_storage my_ipnum;
212380e3 198
199 char *class_name;
200 struct Class *class;
08d11e34 201 rb_dlink_node node;
212380e3 202};
203
204#define SERVER_ILLEGAL 0x0001
205#define SERVER_VHOSTED 0x0002
206#define SERVER_ENCRYPTED 0x0004
207#define SERVER_COMPRESSED 0x0008
208#define SERVER_TB 0x0010
209#define SERVER_AUTOCONN 0x0020
8db00894 210#define SERVER_SSL 0x0040
212380e3 211
212#define ServerConfIllegal(x) ((x)->flags & SERVER_ILLEGAL)
213#define ServerConfVhosted(x) ((x)->flags & SERVER_VHOSTED)
214#define ServerConfEncrypted(x) ((x)->flags & SERVER_ENCRYPTED)
215#define ServerConfCompressed(x) ((x)->flags & SERVER_COMPRESSED)
216#define ServerConfTb(x) ((x)->flags & SERVER_TB)
217#define ServerConfAutoconn(x) ((x)->flags & SERVER_AUTOCONN)
8db00894 218#define ServerConfSSL(x) ((x)->flags & SERVER_SSL)
212380e3 219
220extern struct server_conf *make_server_conf(void);
221extern void free_server_conf(struct server_conf *);
222extern void clear_server_conf(void);
223extern void add_server_conf(struct server_conf *);
224
225extern struct server_conf *find_server_conf(const char *name);
226
227extern void attach_server_conf(struct Client *, struct server_conf *);
228extern void detach_server_conf(struct Client *);
6d18bf1a 229extern void set_server_conf_autoconn(struct Client *source_p, const char *name,
212380e3 230 int newval);
6b2cf989 231extern void disable_server_conf_autoconn(const char *name);
212380e3 232
233
234extern struct ConfItem *find_xline(const char *, int);
0fdb2570 235extern struct ConfItem *find_xline_mask(const char *);
212380e3 236extern struct ConfItem *find_nick_resv(const char *name);
0fdb2570 237extern struct ConfItem *find_nick_resv_mask(const char *name);
212380e3 238
239extern int valid_wild_card_simple(const char *);
240extern int clean_resv_nick(const char *);
241time_t valid_temp_time(const char *p);
242
58e8319c
VY
243struct nd_entry
244{
245 char name[NICKLEN+1];
246 time_t expire;
247 rb_dlink_node lnode; /* node in ll */
212380e3 248};
249
250extern void add_nd_entry(const char *name);
251extern void free_nd_entry(struct nd_entry *);
252extern unsigned long get_nd_count(void);
253
254#endif
255