ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/include/conf.h
Revision: 8872
Committed: Sat Feb 16 21:49:34 2019 UTC (5 years, 1 month ago) by michael
Content type: text/x-chdr
File size: 10141 byte(s)
Log Message:
- Cleanup server connecting related code even further
- Make comm_connect_tcp() take less arguments and remove unused dns resolving functionality

File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 *
4 * Copyright (c) 1997-2019 ircd-hybrid development team
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 * USA
20 */
21
22 /*! \file conf.h
23 * \brief A header for the configuration functions.
24 * \version $Id$
25 */
26
27 #ifndef INCLUDED_conf_h
28 #define INCLUDED_conf_h
29 #include "config.h"
30 #include "client.h"
31 #include "conf_class.h"
32 #include "tls.h"
33
34
35 enum
36 {
37 TK_SECONDS,
38 TK_MINUTES
39 };
40
41 enum { CLEANUP_TKLINES_TIME = 60 };
42
43 #define CONF_NOREASON "<No reason supplied>"
44
45 /* MaskItem->flags */
46 enum
47 {
48 CONF_FLAGS_NO_TILDE = 1 << 0,
49 CONF_FLAGS_NEED_IDENTD = 1 << 1,
50 CONF_FLAGS_EXEMPTKLINE = 1 << 2,
51 CONF_FLAGS_NOLIMIT = 1 << 3,
52 CONF_FLAGS_SPOOF_IP = 1 << 4,
53 CONF_FLAGS_SPOOF_NOTICE = 1 << 5,
54 CONF_FLAGS_REDIR = 1 << 6,
55 CONF_FLAGS_CAN_FLOOD = 1 << 7,
56 CONF_FLAGS_NEED_PASSWORD = 1 << 8,
57 CONF_FLAGS_ALLOW_AUTO_CONN = 1 << 9,
58 CONF_FLAGS_ENCRYPTED = 1 << 10,
59 CONF_FLAGS_IN_DATABASE = 1 << 11,
60 CONF_FLAGS_EXEMPTRESV = 1 << 12,
61 CONF_FLAGS_SSL = 1 << 13,
62 CONF_FLAGS_WEBIRC = 1 << 14,
63 CONF_FLAGS_EXEMPTXLINE = 1 << 15
64 };
65
66 /* Macros for struct MaskItem */
67 #define IsConfWebIRC(x) ((x)->flags & CONF_FLAGS_WEBIRC)
68 #define IsNoTilde(x) ((x)->flags & CONF_FLAGS_NO_TILDE)
69 #define IsConfCanFlood(x) ((x)->flags & CONF_FLAGS_CAN_FLOOD)
70 #define IsNeedPassword(x) ((x)->flags & CONF_FLAGS_NEED_PASSWORD)
71 #define IsNeedIdentd(x) ((x)->flags & CONF_FLAGS_NEED_IDENTD)
72 #define IsConfExemptKline(x) ((x)->flags & CONF_FLAGS_EXEMPTKLINE)
73 #define IsConfExemptXline(x) ((x)->flags & CONF_FLAGS_EXEMPTXLINE)
74 #define IsConfExemptLimits(x) ((x)->flags & CONF_FLAGS_NOLIMIT)
75 #define IsConfExemptResv(x) ((x)->flags & CONF_FLAGS_EXEMPTRESV)
76 #define IsConfDoSpoofIp(x) ((x)->flags & CONF_FLAGS_SPOOF_IP)
77 #define IsConfSpoofNotice(x) ((x)->flags & CONF_FLAGS_SPOOF_NOTICE)
78 #define IsConfAllowAutoConn(x) ((x)->flags & CONF_FLAGS_ALLOW_AUTO_CONN)
79 #define SetConfAllowAutoConn(x) ((x)->flags |= CONF_FLAGS_ALLOW_AUTO_CONN)
80 #define ClearConfAllowAutoConn(x) ((x)->flags &= ~CONF_FLAGS_ALLOW_AUTO_CONN)
81 #define IsConfRedir(x) ((x)->flags & CONF_FLAGS_REDIR)
82 #define IsConfSSL(x) ((x)->flags & CONF_FLAGS_SSL)
83 #define IsConfDatabase(x) ((x)->flags & CONF_FLAGS_IN_DATABASE)
84 #define SetConfDatabase(x) ((x)->flags |= CONF_FLAGS_IN_DATABASE)
85
86
87 enum maskitem_type
88 {
89 CONF_CLIENT = 1,
90 CONF_SERVER,
91 CONF_KLINE,
92 CONF_DLINE,
93 CONF_EXEMPT,
94 CONF_OPER
95 };
96
97 #define IsConfKill(x) ((x)->type == CONF_KLINE)
98 #define IsConfClient(x) ((x)->type == CONF_CLIENT)
99
100 enum
101 {
102 NOT_AUTHORIZED = -1,
103 I_LINE_FULL = -2,
104 TOO_MANY = -3,
105 BANNED_CLIENT = -4,
106 TOO_FAST = -5
107 };
108
109 struct split_nuh_item
110 {
111 dlink_node node;
112
113 char *nuhmask;
114 char *nickptr;
115 char *userptr;
116 char *hostptr;
117
118 size_t nicksize;
119 size_t usersize;
120 size_t hostsize;
121 };
122
123 struct MaskItem
124 {
125 dlink_node node;
126 dlink_list leaf_list;
127 dlink_list hub_list;
128 enum maskitem_type type;
129 bool active;
130 bool dns_failed;
131 bool dns_pending;
132 unsigned int flags;
133 unsigned int modes;
134 unsigned int port;
135 unsigned int aftype;
136 unsigned int htype;
137 unsigned int ref_count; /* Number of *LOCAL* clients using this */
138 int bits;
139 uintmax_t until; /* Hold action until this time (calendar time) */
140 uintmax_t setat;
141 struct irc_ssaddr *bind; /* ip to bind to for outgoing connect */
142 struct irc_ssaddr *addr; /* ip to connect to */
143 struct ClassItem *class; /* Class of connection */
144 char *name;
145 char *user; /* user part of user@host */
146 char *host; /* host part of user@host */
147 char *passwd;
148 char *spasswd; /* Password to send. */
149 char *reason;
150 char *certfp;
151 char *whois;
152 char *cipher_list;
153 };
154
155 struct conf_parser_context
156 {
157 unsigned int boot;
158 unsigned int pass;
159 FILE *conf_file;
160 };
161
162 struct config_general_entry
163 {
164 const char *dpath;
165 const char *mpath;
166 const char *spath;
167 const char *configfile;
168 const char *klinefile;
169 const char *xlinefile;
170 const char *dlinefile;
171 const char *resvfile;
172
173 unsigned int dline_min_cidr;
174 unsigned int dline_min_cidr6;
175 unsigned int kline_min_cidr;
176 unsigned int kline_min_cidr6;
177 unsigned int dots_in_ident;
178 unsigned int failed_oper_notice;
179 unsigned int anti_spam_exit_message_time;
180 unsigned int max_accept;
181 unsigned int max_watch;
182 unsigned int whowas_history_length;
183 unsigned int away_time;
184 unsigned int away_count;
185 unsigned int max_nick_time;
186 unsigned int max_nick_changes;
187 unsigned int ts_max_delta;
188 unsigned int ts_warn_delta;
189 unsigned int anti_nick_flood;
190 unsigned int warn_no_connect_block;
191 unsigned int invisible_on_connect;
192 unsigned int stats_e_disabled;
193 unsigned int stats_i_oper_only;
194 unsigned int stats_k_oper_only;
195 unsigned int stats_m_oper_only;
196 unsigned int stats_o_oper_only;
197 unsigned int stats_P_oper_only;
198 unsigned int stats_u_oper_only;
199 unsigned int short_motd;
200 unsigned int no_oper_flood;
201 unsigned int tkline_expire_notices;
202 unsigned int opers_bypass_callerid;
203 unsigned int pace_wait;
204 unsigned int pace_wait_simple;
205 unsigned int oper_only_umodes;
206 unsigned int oper_umodes;
207 unsigned int max_targets;
208 unsigned int caller_id_wait;
209 unsigned int min_nonwildcard;
210 unsigned int min_nonwildcard_simple;
211 unsigned int kill_chase_time_limit;
212 unsigned int default_floodcount;
213 unsigned int default_floodtime;
214 unsigned int throttle_count;
215 unsigned int throttle_time;
216 unsigned int ping_cookie;
217 unsigned int disable_auth;
218 unsigned int cycle_on_host_change;
219 };
220
221 struct config_channel_entry
222 {
223 unsigned int disable_fake_channels;
224 unsigned int invite_client_count;
225 unsigned int invite_client_time;
226 unsigned int invite_delay_channel;
227 unsigned int invite_expire_time;
228 unsigned int knock_client_count;
229 unsigned int knock_client_time;
230 unsigned int knock_delay_channel;
231 unsigned int max_invites;
232 unsigned int max_bans;
233 unsigned int max_bans_large;
234 unsigned int max_channels;
235 unsigned int default_join_flood_count;
236 unsigned int default_join_flood_time;
237 };
238
239 struct config_serverhide_entry
240 {
241 char *hidden_name;
242 char *flatten_links_file;
243 unsigned int flatten_links;
244 unsigned int flatten_links_delay;
245 unsigned int disable_remote_commands;
246 unsigned int hide_servers;
247 unsigned int hide_services;
248 unsigned int hidden;
249 unsigned int hide_server_ips;
250 };
251
252 struct config_serverinfo_entry
253 {
254 char *sid;
255 char *name;
256 char *description;
257 char *network_name;
258 char *network_desc;
259 char *rsa_private_key_file;
260 char *ssl_certificate_file;
261 char *ssl_dh_param_file;
262 char *ssl_dh_elliptic_curve;
263 char *ssl_cipher_list;
264 char *ssl_message_digest_algorithm;
265 tls_context_t tls_ctx;
266 tls_md_t message_digest_algorithm;
267 unsigned int hub;
268 unsigned int default_max_clients;
269 unsigned int max_nick_length;
270 unsigned int max_topic_length;
271 };
272
273 struct config_admin_entry
274 {
275 char *name;
276 char *description;
277 char *email;
278 };
279
280 struct config_log_entry
281 {
282 unsigned int use_logging;
283 };
284
285 struct aline_ctx
286 {
287 bool add;
288 bool simple_mask;
289 char *mask;
290 char *user;
291 char *host;
292 char *reason;
293 char *server;
294 uintmax_t duration;
295 };
296
297 extern dlink_list flatten_links;
298 extern dlink_list connect_items;
299 extern dlink_list operator_items;
300 extern struct conf_parser_context conf_parser_ctx;
301 extern struct config_log_entry ConfigLog;
302 extern struct config_general_entry ConfigGeneral;
303 extern struct config_channel_entry ConfigChannel;
304 extern struct config_serverhide_entry ConfigServerHide;
305 extern struct config_serverinfo_entry ConfigServerInfo;
306 extern struct config_admin_entry ConfigAdminInfo;
307
308 extern bool valid_wild_card_simple(const char *);
309 extern bool valid_wild_card(int, ...);
310
311 extern struct MaskItem *conf_make(enum maskitem_type);
312 extern void read_conf_files(bool);
313 extern int conf_attach(struct Client *, struct MaskItem *);
314 extern int check_client(struct Client *);
315
316
317 extern void conf_detach(struct Client *, enum maskitem_type);
318 extern struct MaskItem *find_conf_name(dlink_list *, const char *, enum maskitem_type);
319 extern int conf_connect_allowed(struct irc_ssaddr *);
320 extern const char *oper_privs_as_string(const unsigned int);
321 extern void split_nuh(struct split_nuh_item *);
322 extern struct MaskItem *operator_find(const struct Client *, const char *);
323 extern struct MaskItem *connect_find(const char *, int (*)(const char *, const char *));
324 extern void conf_free(struct MaskItem *);
325 extern void yyerror(const char *);
326 extern void conf_error_report(const char *);
327 extern void cleanup_tklines(void *);
328 extern void conf_rehash(bool);
329 extern void lookup_confhost(struct MaskItem *);
330 extern void conf_add_class_to_conf(struct MaskItem *, const char *);
331
332 extern const char *get_oper_name(const struct Client *);
333
334 /* XXX should the parse_aline stuff go into another file ?? */
335 extern bool parse_aline(const char *, struct Client *, int, char **, struct aline_ctx *);
336
337 extern uintmax_t valid_tkline(const char *, const int);
338 extern bool match_conf_password(const char *, const struct MaskItem *);
339 #endif /* INCLUDED_conf_h */

Properties

Name Value
svn:eol-style native
svn:keywords Id