]> jfr.im git - solanum.git/blame - include/s_newconf.h
Add tests for valid_temp_time
[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
7a246575 43struct Client;
212380e3
AC
44struct ConfItem;
45
5b96d9a6 46extern rb_dlink_list cluster_conf_list;
5b96d9a6 47extern rb_dlink_list oper_conf_list;
5b96d9a6
AC
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
64850052 71/* cluster confs */
212380e3
AC
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
212380e3
AC
105struct oper_conf
106{
107 char *name;
108 char *username;
109 char *host;
110 char *passwd;
ff31db84 111 char *certfp;
212380e3
AC
112
113 int flags;
114 int umodes;
115
116 unsigned int snomask;
117
a2e1310c
AC
118 struct PrivilegeSet *privset;
119
212380e3
AC
120#ifdef HAVE_LIBCRYPTO
121 char *rsa_pubkey_file;
122 RSA *rsa_pubkey;
123#endif
124};
125
126extern struct remote_conf *make_remote_conf(void);
127extern void free_remote_conf(struct remote_conf *);
128
212380e3
AC
129extern void propagate_generic(struct Client *source_p, const char *command,
130 const char *target, int cap, const char *format, ...);
131extern void cluster_generic(struct Client *, const char *, int cltype,
132 int cap, const char *format, ...);
133
5a22e925
EM
134#define OPER_ENCRYPTED 0x00001
135#define OPER_NEEDSSL 0x80000
212380e3 136
66f7fe67 137#define OPER_FLAGS 0 /* no oper privs in Client.flags/oper_conf.flags currently */
212380e3
AC
138
139#define IsOperConfEncrypted(x) ((x)->flags & OPER_ENCRYPTED)
b1594414 140#define IsOperConfNeedSSL(x) ((x)->flags & OPER_NEEDSSL)
212380e3 141
ed3ca2ff 142#define HasPrivilege(x, y) ((x)->user != NULL && (x)->user->privset != NULL && privilegeset_in_set((x)->user->privset, (y)))
64c9f509 143#define MayHavePrivilege(x, y) (HasPrivilege((x), (y)) || (IsOper((x)) && (x)->user != NULL && (x)->user->privset == NULL))
6ac9e53e 144
7d84719d 145#define IsOperKill(x) (HasPrivilege((x), "oper:kill"))
6ac9e53e
AC
146#define IsOperRemote(x) (HasPrivilege((x), "oper:routing"))
147#define IsOperUnkline(x) (HasPrivilege((x), "oper:unkline"))
148#define IsOperN(x) (HasPrivilege((x), "snomask:nick_changes"))
149#define IsOperK(x) (HasPrivilege((x), "oper:kline"))
150#define IsOperXline(x) (HasPrivilege((x), "oper:xline"))
151#define IsOperResv(x) (HasPrivilege((x), "oper:resv"))
152#define IsOperDie(x) (HasPrivilege((x), "oper:die"))
153#define IsOperRehash(x) (HasPrivilege((x), "oper:rehash"))
154#define IsOperHiddenAdmin(x) (HasPrivilege((x), "oper:hidden_admin"))
155#define IsOperAdmin(x) (HasPrivilege((x), "oper:admin") || HasPrivilege((x), "oper:hidden_admin"))
156#define IsOperOperwall(x) (HasPrivilege((x), "oper:operwall"))
157#define IsOperSpy(x) (HasPrivilege((x), "oper:spy"))
158#define IsOperInvis(x) (HasPrivilege((x), "oper:hidden"))
7d84719d
EK
159#define IsOperRemoteBan(x) (HasPrivilege((x), "oper:remoteban"))
160#define IsOperMassNotice(x) (HasPrivilege((x), "oper:mass_notice"))
161#define IsOperGeneral(x) (MayHavePrivilege((x), "oper:general"))
212380e3 162
1cd6639a 163#define SeesOper(target, source) (IsOper((target)) && ((!ConfigFileEntry.hide_opers && !HasPrivilege((target), "oper:hidden")) || HasPrivilege((source), "auspex:oper")))
1123eefc 164
212380e3
AC
165extern struct oper_conf *make_oper_conf(void);
166extern void free_oper_conf(struct oper_conf *);
167extern void clear_oper_conf(void);
168
169extern struct oper_conf *find_oper_conf(const char *username, const char *host,
170 const char *locip, const char *oname);
171
172extern const char *get_oper_privs(int flags);
173
174struct server_conf
175{
176 char *name;
d4214e94
SA
177 char *connect_host;
178 struct rb_sockaddr_storage connect4;
179 uint16_t dns_query_connect4;
d4214e94
SA
180 struct rb_sockaddr_storage connect6;
181 uint16_t dns_query_connect6;
212380e3
AC
182 char *passwd;
183 char *spasswd;
ff0cc1e6 184 char *certfp;
212380e3
AC
185 int port;
186 int flags;
187 int servers;
188 time_t hold;
189
190 int aftype;
d4214e94
SA
191 char *bind_host;
192 struct rb_sockaddr_storage bind4;
193 uint16_t dns_query_bind4;
d4214e94
SA
194 struct rb_sockaddr_storage bind6;
195 uint16_t dns_query_bind6;
212380e3
AC
196
197 char *class_name;
198 struct Class *class;
5b96d9a6 199 rb_dlink_node node;
212380e3
AC
200};
201
202#define SERVER_ILLEGAL 0x0001
212380e3
AC
203#define SERVER_ENCRYPTED 0x0004
204#define SERVER_COMPRESSED 0x0008
205#define SERVER_TB 0x0010
206#define SERVER_AUTOCONN 0x0020
c6d72037 207#define SERVER_SSL 0x0040
087555a0 208#define SERVER_NO_EXPORT 0x0080
6003ce76 209#define SERVER_SCTP 0x0100
212380e3
AC
210
211#define ServerConfIllegal(x) ((x)->flags & SERVER_ILLEGAL)
212380e3
AC
212#define ServerConfEncrypted(x) ((x)->flags & SERVER_ENCRYPTED)
213#define ServerConfCompressed(x) ((x)->flags & SERVER_COMPRESSED)
214#define ServerConfTb(x) ((x)->flags & SERVER_TB)
215#define ServerConfAutoconn(x) ((x)->flags & SERVER_AUTOCONN)
6003ce76 216#define ServerConfSCTP(x) ((x)->flags & SERVER_SCTP)
c6d72037 217#define ServerConfSSL(x) ((x)->flags & SERVER_SSL)
087555a0 218#define ServerConfNoExport(x) ((x)->flags & SERVER_NO_EXPORT)
212380e3
AC
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 *);
55abcbb2 229extern void set_server_conf_autoconn(struct Client *source_p, const char *name,
212380e3 230 int newval);
53307da8 231extern void disable_server_conf_autoconn(const char *name);
212380e3
AC
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
AC
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
ae78a571
VY
243struct nd_entry
244{
245 char name[NICKLEN+1];
246 time_t expire;
247 rb_dlink_node lnode; /* node in ll */
212380e3
AC
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