]>
Commit | Line | Data |
---|---|---|
212380e3 | 1 | /* This code is in the public domain. |
212380e3 AC |
2 | */ |
3 | ||
4 | #include "stdinc.h" | |
5 | ||
6 | #ifdef HAVE_LIBCRYPTO | |
7 | #include <openssl/pem.h> | |
8 | #include <openssl/rsa.h> | |
9 | #endif | |
10 | ||
212380e3 | 11 | #include "newconf.h" |
212380e3 | 12 | #include "ircd_defs.h" |
4016731b | 13 | #include "logger.h" |
212380e3 AC |
14 | #include "s_conf.h" |
15 | #include "s_user.h" | |
16 | #include "s_newconf.h" | |
17 | #include "send.h" | |
18 | #include "setup.h" | |
19 | #include "modules.h" | |
20 | #include "listener.h" | |
21 | #include "hostmask.h" | |
22 | #include "s_serv.h" | |
212380e3 AC |
23 | #include "hash.h" |
24 | #include "cache.h" | |
25 | #include "ircd.h" | |
26 | #include "snomask.h" | |
c6d72037 | 27 | #include "sslproc.h" |
c53ca1e0 | 28 | #include "wsproc.h" |
f8606875 | 29 | #include "privilege.h" |
63eb8567 | 30 | #include "chmode.h" |
f018ed84 | 31 | #include "certfp.h" |
212380e3 AC |
32 | |
33 | #define CF_TYPE(x) ((x) & CF_MTYPE) | |
34 | ||
02270e96 | 35 | static int yy_defer_accept = 1; |
c53ca1e0 | 36 | static int yy_wsock = 0; |
02270e96 | 37 | |
212380e3 | 38 | struct TopConf *conf_cur_block; |
e12981c0 | 39 | static char *conf_cur_block_name = NULL; |
212380e3 | 40 | |
330fc5c1 | 41 | static rb_dlink_list conf_items; |
212380e3 AC |
42 | |
43 | static struct ConfItem *yy_aconf = NULL; | |
44 | ||
45 | static struct Class *yy_class = NULL; | |
46 | ||
47 | static struct remote_conf *yy_shared = NULL; | |
48 | static struct server_conf *yy_server = NULL; | |
49 | ||
330fc5c1 AC |
50 | static rb_dlink_list yy_aconf_list; |
51 | static rb_dlink_list yy_oper_list; | |
52 | static rb_dlink_list yy_shared_list; | |
53 | static rb_dlink_list yy_cluster_list; | |
212380e3 AC |
54 | static struct oper_conf *yy_oper = NULL; |
55 | ||
56 | static struct alias_entry *yy_alias = NULL; | |
57 | ||
58 | static char *yy_blacklist_host = NULL; | |
59 | static char *yy_blacklist_reason = NULL; | |
d3f6b808 | 60 | static uint8_t yy_blacklist_iptype = 0; |
50808796 | 61 | static rb_dlink_list yy_blacklist_filters = { NULL, NULL, 0 }; |
0a1e77c2 | 62 | |
8275e270 EM |
63 | static char *yy_opm_address_ipv4 = NULL; |
64 | static char *yy_opm_address_ipv6 = NULL; | |
65 | static uint16_t yy_opm_port_ipv4 = 0; | |
66 | static uint16_t yy_opm_port_ipv6 = 0; | |
9bba0f61 | 67 | static int yy_opm_timeout = 0; |
51fa2ab8 | 68 | static rb_dlink_list yy_opm_scanner_list; |
8275e270 | 69 | |
f8606875 | 70 | static char *yy_privset_extends = NULL; |
212380e3 AC |
71 | |
72 | static const char * | |
73 | conf_strtype(int type) | |
74 | { | |
dceac3e4 | 75 | switch (CF_TYPE(type)) |
212380e3 AC |
76 | { |
77 | case CF_INT: | |
78 | return "integer value"; | |
79 | case CF_STRING: | |
80 | return "unquoted string"; | |
81 | case CF_YESNO: | |
82 | return "yes/no value"; | |
83 | case CF_QSTRING: | |
84 | return "quoted string"; | |
85 | case CF_TIME: | |
86 | return "time/size value"; | |
87 | default: | |
88 | return "unknown type"; | |
89 | } | |
90 | } | |
91 | ||
92 | int | |
023c36ae | 93 | add_top_conf(const char *name, int (*sfunc) (struct TopConf *), |
212380e3 AC |
94 | int (*efunc) (struct TopConf *), struct ConfEntry *items) |
95 | { | |
96 | struct TopConf *tc; | |
97 | ||
eddc2ab6 | 98 | tc = rb_malloc(sizeof(struct TopConf)); |
212380e3 | 99 | |
d7f753cd | 100 | tc->tc_name = name; |
212380e3 AC |
101 | tc->tc_sfunc = sfunc; |
102 | tc->tc_efunc = efunc; | |
103 | tc->tc_entries = items; | |
104 | ||
330fc5c1 | 105 | rb_dlinkAddAlloc(tc, &conf_items); |
212380e3 AC |
106 | return 0; |
107 | } | |
108 | ||
109 | struct TopConf * | |
110 | find_top_conf(const char *name) | |
111 | { | |
330fc5c1 | 112 | rb_dlink_node *d; |
212380e3 AC |
113 | struct TopConf *tc; |
114 | ||
5cefa1d6 | 115 | RB_DLINK_FOREACH(d, conf_items.head) |
212380e3 AC |
116 | { |
117 | tc = d->data; | |
f956cb0f | 118 | if(rb_strcasecmp(tc->tc_name, name) == 0) |
212380e3 AC |
119 | return tc; |
120 | } | |
121 | ||
122 | return NULL; | |
123 | } | |
124 | ||
125 | ||
126 | struct ConfEntry * | |
127 | find_conf_item(const struct TopConf *top, const char *name) | |
128 | { | |
129 | struct ConfEntry *cf; | |
330fc5c1 | 130 | rb_dlink_node *d; |
212380e3 AC |
131 | |
132 | if(top->tc_entries) | |
133 | { | |
134 | int i; | |
135 | ||
136 | for(i = 0; top->tc_entries[i].cf_type; i++) | |
137 | { | |
138 | cf = &top->tc_entries[i]; | |
139 | ||
f956cb0f | 140 | if(!rb_strcasecmp(cf->cf_name, name)) |
212380e3 AC |
141 | return cf; |
142 | } | |
143 | } | |
144 | ||
5cefa1d6 | 145 | RB_DLINK_FOREACH(d, top->tc_items.head) |
212380e3 AC |
146 | { |
147 | cf = d->data; | |
f956cb0f | 148 | if(rb_strcasecmp(cf->cf_name, name) == 0) |
212380e3 AC |
149 | return cf; |
150 | } | |
151 | ||
152 | return NULL; | |
153 | } | |
154 | ||
155 | int | |
156 | remove_top_conf(char *name) | |
157 | { | |
158 | struct TopConf *tc; | |
330fc5c1 | 159 | rb_dlink_node *ptr; |
212380e3 AC |
160 | |
161 | if((tc = find_top_conf(name)) == NULL) | |
162 | return -1; | |
163 | ||
330fc5c1 | 164 | if((ptr = rb_dlinkFind(tc, &conf_items)) == NULL) |
212380e3 AC |
165 | return -1; |
166 | ||
330fc5c1 | 167 | rb_dlinkDestroy(ptr, &conf_items); |
637c4932 | 168 | rb_free(tc); |
212380e3 AC |
169 | |
170 | return 0; | |
171 | } | |
172 | ||
173 | static void | |
174 | conf_set_serverinfo_name(void *data) | |
175 | { | |
176 | if(ServerInfo.name == NULL) | |
177 | { | |
178 | const char *s; | |
179 | int dots = 0; | |
180 | ||
181 | for(s = data; *s != '\0'; s++) | |
182 | { | |
183 | if(!IsServChar(*s)) | |
184 | { | |
185 | conf_report_error("Ignoring serverinfo::name " | |
186 | "-- bogus servername."); | |
187 | return; | |
188 | } | |
189 | else if(*s == '.') | |
190 | ++dots; | |
191 | } | |
192 | ||
193 | if(!dots) | |
194 | { | |
195 | conf_report_error("Ignoring serverinfo::name -- must contain '.'"); | |
196 | return; | |
197 | } | |
198 | ||
199 | s = data; | |
200 | ||
201 | if(IsDigit(*s)) | |
202 | { | |
203 | conf_report_error("Ignoring serverinfo::name -- cannot begin with digit."); | |
204 | return; | |
205 | } | |
206 | ||
207 | /* the ircd will exit() in main() if we dont set one */ | |
208 | if(strlen(s) <= HOSTLEN) | |
47a03750 | 209 | ServerInfo.name = rb_strdup((char *) data); |
212380e3 AC |
210 | } |
211 | } | |
212 | ||
213 | static void | |
214 | conf_set_serverinfo_sid(void *data) | |
215 | { | |
216 | char *sid = data; | |
217 | ||
218 | if(ServerInfo.sid[0] == '\0') | |
219 | { | |
220 | if(!IsDigit(sid[0]) || !IsIdChar(sid[1]) || | |
221 | !IsIdChar(sid[2]) || sid[3] != '\0') | |
222 | { | |
223 | conf_report_error("Ignoring serverinfo::sid " | |
224 | "-- bogus sid."); | |
225 | return; | |
226 | } | |
227 | ||
228 | strcpy(ServerInfo.sid, sid); | |
229 | } | |
230 | } | |
231 | ||
232 | static void | |
233 | conf_set_serverinfo_network_name(void *data) | |
234 | { | |
235 | char *p; | |
236 | ||
237 | if((p = strchr((char *) data, ' '))) | |
238 | *p = '\0'; | |
239 | ||
637c4932 | 240 | rb_free(ServerInfo.network_name); |
47a03750 | 241 | ServerInfo.network_name = rb_strdup((char *) data); |
212380e3 AC |
242 | } |
243 | ||
244 | static void | |
245 | conf_set_serverinfo_vhost(void *data) | |
246 | { | |
d4214e94 SA |
247 | struct rb_sockaddr_storage addr; |
248 | ||
249 | if(rb_inet_pton_sock(data, (struct sockaddr *)&addr) <= 0 || GET_SS_FAMILY(&addr) != AF_INET) | |
212380e3 | 250 | { |
532f83a7 | 251 | conf_report_error("Invalid IPv4 address for server vhost (%s)", (char *) data); |
212380e3 AC |
252 | return; |
253 | } | |
d4214e94 SA |
254 | |
255 | ServerInfo.bind4 = addr; | |
212380e3 AC |
256 | } |
257 | ||
258 | static void | |
259 | conf_set_serverinfo_vhost6(void *data) | |
260 | { | |
d4214e94 | 261 | |
ccda6e3f | 262 | #ifdef RB_IPV6 |
d4214e94 SA |
263 | struct rb_sockaddr_storage addr; |
264 | ||
265 | if(rb_inet_pton_sock(data, (struct sockaddr *)&addr) <= 0 || GET_SS_FAMILY(&addr) != AF_INET6) | |
212380e3 | 266 | { |
532f83a7 | 267 | conf_report_error("Invalid IPv6 address for server vhost (%s)", (char *) data); |
212380e3 AC |
268 | return; |
269 | } | |
270 | ||
d4214e94 | 271 | ServerInfo.bind6 = addr; |
212380e3 AC |
272 | #else |
273 | conf_report_error("Warning -- ignoring serverinfo::vhost6 -- IPv6 support not available."); | |
274 | #endif | |
275 | } | |
276 | ||
b583faf9 AC |
277 | static void |
278 | conf_set_serverinfo_nicklen(void *data) | |
279 | { | |
7b42eab6 | 280 | ConfigFileEntry.nicklen = (*(unsigned int *) data) + 1; |
b583faf9 AC |
281 | |
282 | if (ConfigFileEntry.nicklen > NICKLEN) | |
283 | { | |
284 | conf_report_error("Warning -- ignoring serverinfo::nicklen -- provided nicklen (%u) is greater than allowed nicklen (%u)", | |
ca8ff483 | 285 | ConfigFileEntry.nicklen - 1, NICKLEN - 1); |
b583faf9 AC |
286 | ConfigFileEntry.nicklen = NICKLEN; |
287 | } | |
ca8ff483 JT |
288 | else if (ConfigFileEntry.nicklen < 9 + 1) |
289 | { | |
290 | conf_report_error("Warning -- serverinfo::nicklen is too low (%u) -- forcing 9", | |
4f0d2b58 | 291 | ConfigFileEntry.nicklen - 1); |
ca8ff483 JT |
292 | ConfigFileEntry.nicklen = 9 + 1; |
293 | } | |
b583faf9 AC |
294 | } |
295 | ||
212380e3 AC |
296 | static void |
297 | conf_set_modules_module(void *data) | |
298 | { | |
212380e3 AC |
299 | char *m_bn; |
300 | ||
b7a689d1 | 301 | m_bn = rb_basename((char *) data); |
212380e3 | 302 | |
43f45e81 | 303 | if(findmodule_byname(m_bn) == -1) |
aa483e55 | 304 | load_one_module((char *) data, MAPI_ORIGIN_EXTENSION, false); |
212380e3 | 305 | |
637c4932 | 306 | rb_free(m_bn); |
212380e3 AC |
307 | } |
308 | ||
309 | static void | |
310 | conf_set_modules_path(void *data) | |
311 | { | |
212380e3 | 312 | mod_add_path((char *) data); |
212380e3 AC |
313 | } |
314 | ||
315 | struct mode_table | |
316 | { | |
317 | const char *name; | |
318 | int mode; | |
319 | }; | |
320 | ||
321 | /* *INDENT-OFF* */ | |
322 | static struct mode_table umode_table[] = { | |
323 | {"callerid", UMODE_CALLERID }, | |
324 | {"deaf", UMODE_DEAF }, | |
325 | {"invisible", UMODE_INVISIBLE }, | |
326 | {"locops", UMODE_LOCOPS }, | |
327 | {"noforward", UMODE_NOFORWARD }, | |
328 | {"regonlymsg", UMODE_REGONLYMSG}, | |
329 | {"servnotice", UMODE_SERVNOTICE}, | |
330 | {"wallop", UMODE_WALLOP }, | |
331 | {"operwall", UMODE_OPERWALL }, | |
332 | {NULL, 0} | |
333 | }; | |
334 | ||
19c13ce5 | 335 | static struct mode_table oper_table[] = { |
212380e3 | 336 | {"encrypted", OPER_ENCRYPTED }, |
b1594414 | 337 | {"need_ssl", OPER_NEEDSSL }, |
212380e3 AC |
338 | {NULL, 0} |
339 | }; | |
340 | ||
341 | static struct mode_table auth_table[] = { | |
fbe8d087 EM |
342 | {"encrypted", CONF_FLAGS_ENCRYPTED }, |
343 | {"spoof_notice", CONF_FLAGS_SPOOF_NOTICE }, | |
344 | {"exceed_limit", CONF_FLAGS_NOLIMIT }, | |
345 | {"dnsbl_exempt", CONF_FLAGS_EXEMPTDNSBL }, | |
346 | {"proxy_exempt", CONF_FLAGS_EXEMPTPROXY }, | |
347 | {"kline_exempt", CONF_FLAGS_EXEMPTKLINE }, | |
348 | {"flood_exempt", CONF_FLAGS_EXEMPTFLOOD }, | |
349 | {"spambot_exempt", CONF_FLAGS_EXEMPTSPAMBOT }, | |
350 | {"shide_exempt", CONF_FLAGS_EXEMPTSHIDE }, | |
351 | {"jupe_exempt", CONF_FLAGS_EXEMPTJUPE }, | |
352 | {"resv_exempt", CONF_FLAGS_EXEMPTRESV }, | |
353 | {"no_tilde", CONF_FLAGS_NO_TILDE }, | |
354 | {"need_ident", CONF_FLAGS_NEED_IDENTD }, | |
355 | {"have_ident", CONF_FLAGS_NEED_IDENTD }, | |
356 | {"need_ssl", CONF_FLAGS_NEED_SSL }, | |
357 | {"need_sasl", CONF_FLAGS_NEED_SASL }, | |
358 | {"extend_chans", CONF_FLAGS_EXTEND_CHANS }, | |
212380e3 AC |
359 | {NULL, 0} |
360 | }; | |
361 | ||
362 | static struct mode_table connect_table[] = { | |
363 | { "autoconn", SERVER_AUTOCONN }, | |
364 | { "compressed", SERVER_COMPRESSED }, | |
365 | { "encrypted", SERVER_ENCRYPTED }, | |
366 | { "topicburst", SERVER_TB }, | |
c6d72037 | 367 | { "ssl", SERVER_SSL }, |
212380e3 AC |
368 | { NULL, 0 }, |
369 | }; | |
370 | ||
371 | static struct mode_table cluster_table[] = { | |
372 | { "kline", SHARED_PKLINE }, | |
373 | { "tkline", SHARED_TKLINE }, | |
374 | { "unkline", SHARED_UNKLINE }, | |
375 | { "locops", SHARED_LOCOPS }, | |
376 | { "xline", SHARED_PXLINE }, | |
377 | { "txline", SHARED_TXLINE }, | |
378 | { "unxline", SHARED_UNXLINE }, | |
379 | { "resv", SHARED_PRESV }, | |
380 | { "tresv", SHARED_TRESV }, | |
381 | { "unresv", SHARED_UNRESV }, | |
382 | { "all", CLUSTER_ALL }, | |
383 | {NULL, 0} | |
384 | }; | |
385 | ||
386 | static struct mode_table shared_table[] = | |
387 | { | |
388 | { "kline", SHARED_PKLINE|SHARED_TKLINE }, | |
389 | { "xline", SHARED_PXLINE|SHARED_TXLINE }, | |
390 | { "resv", SHARED_PRESV|SHARED_TRESV }, | |
9bba0f61 EM |
391 | { "dline", SHARED_PDLINE|SHARED_TDLINE }, |
392 | { "tdline", SHARED_TDLINE }, | |
393 | { "pdline", SHARED_PDLINE }, | |
f5cb68d5 | 394 | { "undline", SHARED_UNDLINE }, |
212380e3 AC |
395 | { "tkline", SHARED_TKLINE }, |
396 | { "unkline", SHARED_UNKLINE }, | |
397 | { "txline", SHARED_TXLINE }, | |
398 | { "unxline", SHARED_UNXLINE }, | |
399 | { "tresv", SHARED_TRESV }, | |
400 | { "unresv", SHARED_UNRESV }, | |
401 | { "locops", SHARED_LOCOPS }, | |
402 | { "rehash", SHARED_REHASH }, | |
fe749d37 | 403 | { "grant", SHARED_GRANT }, |
cc7ae51c | 404 | { "die", SHARED_DIE }, |
15feac53 | 405 | { "module", SHARED_MODULE }, |
212380e3 AC |
406 | { "all", SHARED_ALL }, |
407 | { "none", 0 }, | |
408 | {NULL, 0} | |
409 | }; | |
410 | /* *INDENT-ON* */ | |
411 | ||
412 | static int | |
413 | find_umode(struct mode_table *tab, const char *name) | |
414 | { | |
415 | int i; | |
416 | ||
417 | for (i = 0; tab[i].name; i++) | |
418 | { | |
419 | if(strcmp(tab[i].name, name) == 0) | |
420 | return tab[i].mode; | |
421 | } | |
422 | ||
423 | return -1; | |
424 | } | |
425 | ||
426 | static void | |
427 | set_modes_from_table(int *modes, const char *whatis, struct mode_table *tab, conf_parm_t * args) | |
428 | { | |
429 | for (; args; args = args->next) | |
430 | { | |
431 | const char *umode; | |
432 | int dir = 1; | |
433 | int mode; | |
434 | ||
dceac3e4 | 435 | if(CF_TYPE(args->type) != CF_STRING) |
212380e3 AC |
436 | { |
437 | conf_report_error("Warning -- %s is not a string; ignoring.", whatis); | |
438 | continue; | |
439 | } | |
440 | ||
441 | umode = args->v.string; | |
442 | ||
443 | if(*umode == '~') | |
444 | { | |
445 | dir = 0; | |
446 | umode++; | |
447 | } | |
448 | ||
449 | mode = find_umode(tab, umode); | |
450 | ||
451 | if(mode == -1) | |
452 | { | |
453 | conf_report_error("Warning -- unknown %s %s.", whatis, args->v.string); | |
454 | continue; | |
455 | } | |
456 | ||
457 | if(mode) | |
458 | { | |
459 | if(dir) | |
460 | *modes |= mode; | |
461 | else | |
462 | *modes &= ~mode; | |
463 | } | |
464 | else | |
465 | *modes = 0; | |
466 | } | |
467 | } | |
468 | ||
f8606875 AC |
469 | static void |
470 | conf_set_privset_extends(void *data) | |
471 | { | |
472 | yy_privset_extends = rb_strdup((char *) data); | |
473 | } | |
474 | ||
475 | static void | |
476 | conf_set_privset_privs(void *data) | |
477 | { | |
478 | char *privs = NULL; | |
479 | conf_parm_t *args = data; | |
480 | ||
481 | for (; args; args = args->next) | |
482 | { | |
483 | if (privs == NULL) | |
484 | privs = rb_strdup(args->v.string); | |
485 | else | |
486 | { | |
487 | char *privs_old = privs; | |
488 | ||
489 | privs = rb_malloc(strlen(privs_old) + 1 + strlen(args->v.string) + 1); | |
065f67db | 490 | strcpy(privs, privs_old); |
f8606875 AC |
491 | strcat(privs, " "); |
492 | strcat(privs, args->v.string); | |
493 | ||
494 | rb_free(privs_old); | |
495 | } | |
496 | } | |
497 | ||
498 | if (privs) | |
499 | { | |
500 | if (yy_privset_extends) | |
501 | { | |
502 | struct PrivilegeSet *set = privilegeset_get(yy_privset_extends); | |
503 | ||
504 | if (!set) | |
505 | { | |
49b0375d | 506 | conf_report_error("Warning -- unknown parent privilege set %s for %s; assuming defaults", yy_privset_extends, conf_cur_block_name); |
f8606875 | 507 | |
49b0375d | 508 | set = privilegeset_get("default"); |
f8606875 AC |
509 | } |
510 | ||
511 | privilegeset_extend(set, conf_cur_block_name != NULL ? conf_cur_block_name : "<unknown>", privs, 0); | |
512 | ||
513 | rb_free(yy_privset_extends); | |
514 | yy_privset_extends = NULL; | |
515 | } | |
516 | else | |
517 | privilegeset_set_new(conf_cur_block_name != NULL ? conf_cur_block_name : "<unknown>", privs, 0); | |
518 | ||
519 | rb_free(privs); | |
520 | } | |
521 | } | |
522 | ||
212380e3 AC |
523 | static int |
524 | conf_begin_oper(struct TopConf *tc) | |
525 | { | |
330fc5c1 | 526 | rb_dlink_node *ptr; |
637c4932 | 527 | rb_dlink_node *next_ptr; |
212380e3 AC |
528 | |
529 | if(yy_oper != NULL) | |
530 | { | |
531 | free_oper_conf(yy_oper); | |
532 | yy_oper = NULL; | |
533 | } | |
534 | ||
637c4932 | 535 | RB_DLINK_FOREACH_SAFE(ptr, next_ptr, yy_oper_list.head) |
212380e3 AC |
536 | { |
537 | free_oper_conf(ptr->data); | |
330fc5c1 | 538 | rb_dlinkDestroy(ptr, &yy_oper_list); |
212380e3 AC |
539 | } |
540 | ||
541 | yy_oper = make_oper_conf(); | |
10847f65 | 542 | yy_oper->flags |= OPER_ENCRYPTED; |
212380e3 AC |
543 | |
544 | return 0; | |
545 | } | |
546 | ||
547 | static int | |
548 | conf_end_oper(struct TopConf *tc) | |
549 | { | |
550 | struct oper_conf *yy_tmpoper; | |
330fc5c1 | 551 | rb_dlink_node *ptr; |
637c4932 | 552 | rb_dlink_node *next_ptr; |
212380e3 AC |
553 | |
554 | if(conf_cur_block_name != NULL) | |
555 | { | |
556 | if(strlen(conf_cur_block_name) > OPERNICKLEN) | |
557 | conf_cur_block_name[OPERNICKLEN] = '\0'; | |
558 | ||
47a03750 | 559 | yy_oper->name = rb_strdup(conf_cur_block_name); |
212380e3 AC |
560 | } |
561 | ||
562 | if(EmptyString(yy_oper->name)) | |
563 | { | |
564 | conf_report_error("Ignoring operator block -- missing name."); | |
565 | return 0; | |
566 | } | |
567 | ||
568 | #ifdef HAVE_LIBCRYPTO | |
569 | if(EmptyString(yy_oper->passwd) && EmptyString(yy_oper->rsa_pubkey_file)) | |
570 | #else | |
571 | if(EmptyString(yy_oper->passwd)) | |
572 | #endif | |
573 | { | |
574 | conf_report_error("Ignoring operator block for %s -- missing password", | |
575 | yy_oper->name); | |
576 | return 0; | |
577 | } | |
578 | ||
7d5acab7 JT |
579 | |
580 | if (!yy_oper->privset) | |
581 | yy_oper->privset = privilegeset_get("default"); | |
582 | ||
212380e3 AC |
583 | /* now, yy_oper_list contains a stack of oper_conf's with just user |
584 | * and host in, yy_oper contains the rest of the information which | |
585 | * we need to copy into each element in yy_oper_list | |
586 | */ | |
637c4932 | 587 | RB_DLINK_FOREACH_SAFE(ptr, next_ptr, yy_oper_list.head) |
212380e3 AC |
588 | { |
589 | yy_tmpoper = ptr->data; | |
590 | ||
47a03750 | 591 | yy_tmpoper->name = rb_strdup(yy_oper->name); |
212380e3 AC |
592 | |
593 | /* could be an rsa key instead.. */ | |
594 | if(!EmptyString(yy_oper->passwd)) | |
47a03750 | 595 | yy_tmpoper->passwd = rb_strdup(yy_oper->passwd); |
212380e3 AC |
596 | |
597 | yy_tmpoper->flags = yy_oper->flags; | |
598 | yy_tmpoper->umodes = yy_oper->umodes; | |
599 | yy_tmpoper->snomask = yy_oper->snomask; | |
22c3b270 | 600 | yy_tmpoper->privset = yy_oper->privset; |
212380e3 AC |
601 | |
602 | #ifdef HAVE_LIBCRYPTO | |
603 | if(yy_oper->rsa_pubkey_file) | |
604 | { | |
605 | BIO *file; | |
606 | ||
607 | if((file = BIO_new_file(yy_oper->rsa_pubkey_file, "r")) == NULL) | |
608 | { | |
609 | conf_report_error("Ignoring operator block for %s -- " | |
610 | "rsa_public_key_file cant be opened", | |
611 | yy_tmpoper->name); | |
612 | return 0; | |
613 | } | |
023c36ae | 614 | |
212380e3 AC |
615 | yy_tmpoper->rsa_pubkey = |
616 | (RSA *) PEM_read_bio_RSA_PUBKEY(file, NULL, 0, NULL); | |
617 | ||
c422d2a0 | 618 | (void)BIO_set_close(file, BIO_CLOSE); |
212380e3 AC |
619 | BIO_free(file); |
620 | ||
621 | if(yy_tmpoper->rsa_pubkey == NULL) | |
622 | { | |
623 | conf_report_error("Ignoring operator block for %s -- " | |
624 | "rsa_public_key_file key invalid; check syntax", | |
625 | yy_tmpoper->name); | |
626 | return 0; | |
627 | } | |
628 | } | |
63c7a68e EM |
629 | |
630 | if(!EmptyString(yy_oper->certfp)) | |
462ae9d7 | 631 | yy_tmpoper->certfp = rb_strdup(yy_oper->certfp); |
212380e3 AC |
632 | #endif |
633 | ||
634 | /* all is ok, put it on oper_conf_list */ | |
330fc5c1 | 635 | rb_dlinkMoveNode(ptr, &yy_oper_list, &oper_conf_list); |
212380e3 AC |
636 | } |
637 | ||
638 | free_oper_conf(yy_oper); | |
639 | yy_oper = NULL; | |
640 | ||
641 | return 0; | |
642 | } | |
643 | ||
644 | static void | |
645 | conf_set_oper_flags(void *data) | |
646 | { | |
647 | conf_parm_t *args = data; | |
648 | ||
19c13ce5 | 649 | set_modes_from_table(&yy_oper->flags, "flag", oper_table, args); |
212380e3 AC |
650 | } |
651 | ||
ff31db84 AC |
652 | static void |
653 | conf_set_oper_fingerprint(void *data) | |
654 | { | |
462ae9d7 JT |
655 | if (yy_oper->certfp) |
656 | rb_free(yy_oper->certfp); | |
ff31db84 AC |
657 | yy_oper->certfp = rb_strdup((char *) data); |
658 | } | |
659 | ||
22c3b270 AC |
660 | static void |
661 | conf_set_oper_privset(void *data) | |
662 | { | |
663 | yy_oper->privset = privilegeset_get((char *) data); | |
664 | } | |
665 | ||
212380e3 AC |
666 | static void |
667 | conf_set_oper_user(void *data) | |
668 | { | |
669 | struct oper_conf *yy_tmpoper; | |
670 | char *p; | |
671 | char *host = (char *) data; | |
672 | ||
673 | yy_tmpoper = make_oper_conf(); | |
674 | ||
675 | if((p = strchr(host, '@'))) | |
676 | { | |
677 | *p++ = '\0'; | |
678 | ||
47a03750 VY |
679 | yy_tmpoper->username = rb_strdup(host); |
680 | yy_tmpoper->host = rb_strdup(p); | |
212380e3 AC |
681 | } |
682 | else | |
683 | { | |
684 | ||
47a03750 VY |
685 | yy_tmpoper->username = rb_strdup("*"); |
686 | yy_tmpoper->host = rb_strdup(host); | |
212380e3 AC |
687 | } |
688 | ||
689 | if(EmptyString(yy_tmpoper->username) || EmptyString(yy_tmpoper->host)) | |
690 | { | |
691 | conf_report_error("Ignoring user -- missing username/host"); | |
692 | free_oper_conf(yy_tmpoper); | |
693 | return; | |
694 | } | |
695 | ||
330fc5c1 | 696 | rb_dlinkAddAlloc(yy_tmpoper, &yy_oper_list); |
212380e3 AC |
697 | } |
698 | ||
699 | static void | |
700 | conf_set_oper_password(void *data) | |
701 | { | |
702 | if(yy_oper->passwd) | |
703 | { | |
704 | memset(yy_oper->passwd, 0, strlen(yy_oper->passwd)); | |
637c4932 | 705 | rb_free(yy_oper->passwd); |
212380e3 AC |
706 | } |
707 | ||
47a03750 | 708 | yy_oper->passwd = rb_strdup((char *) data); |
212380e3 AC |
709 | } |
710 | ||
711 | static void | |
712 | conf_set_oper_rsa_public_key_file(void *data) | |
713 | { | |
714 | #ifdef HAVE_LIBCRYPTO | |
637c4932 | 715 | rb_free(yy_oper->rsa_pubkey_file); |
47a03750 | 716 | yy_oper->rsa_pubkey_file = rb_strdup((char *) data); |
212380e3 AC |
717 | #else |
718 | conf_report_error("Warning -- ignoring rsa_public_key_file (OpenSSL support not available"); | |
719 | #endif | |
720 | } | |
721 | ||
722 | static void | |
723 | conf_set_oper_umodes(void *data) | |
724 | { | |
725 | set_modes_from_table(&yy_oper->umodes, "umode", umode_table, data); | |
726 | } | |
727 | ||
728 | static void | |
729 | conf_set_oper_snomask(void *data) | |
730 | { | |
731 | yy_oper->snomask = parse_snobuf_to_mask(0, (const char *) data); | |
732 | } | |
733 | ||
734 | static int | |
735 | conf_begin_class(struct TopConf *tc) | |
736 | { | |
737 | if(yy_class) | |
738 | free_class(yy_class); | |
739 | ||
740 | yy_class = make_class(); | |
741 | return 0; | |
742 | } | |
743 | ||
744 | static int | |
745 | conf_end_class(struct TopConf *tc) | |
746 | { | |
747 | if(conf_cur_block_name != NULL) | |
47a03750 | 748 | yy_class->class_name = rb_strdup(conf_cur_block_name); |
212380e3 AC |
749 | |
750 | if(EmptyString(yy_class->class_name)) | |
751 | { | |
752 | conf_report_error("Ignoring connect block -- missing name."); | |
753 | return 0; | |
754 | } | |
755 | ||
756 | add_class(yy_class); | |
757 | yy_class = NULL; | |
758 | return 0; | |
759 | } | |
760 | ||
761 | static void | |
762 | conf_set_class_ping_time(void *data) | |
763 | { | |
764 | yy_class->ping_freq = *(unsigned int *) data; | |
765 | } | |
766 | ||
767 | static void | |
e33e589c | 768 | conf_set_class_cidr_ipv4_bitlen(void *data) |
212380e3 | 769 | { |
e33e589c JT |
770 | unsigned int maxsize = 32; |
771 | if(*(unsigned int *) data > maxsize) | |
772 | conf_report_error | |
773 | ("class::cidr_ipv4_bitlen argument exceeds maxsize (%d > %d) - ignoring.", | |
774 | *(unsigned int *) data, maxsize); | |
775 | else | |
776 | yy_class->cidr_ipv4_bitlen = *(unsigned int *) data; | |
777 | ||
778 | } | |
779 | ||
ccda6e3f | 780 | #ifdef RB_IPV6 |
e33e589c JT |
781 | static void |
782 | conf_set_class_cidr_ipv6_bitlen(void *data) | |
783 | { | |
212380e3 | 784 | unsigned int maxsize = 128; |
212380e3 AC |
785 | if(*(unsigned int *) data > maxsize) |
786 | conf_report_error | |
e33e589c | 787 | ("class::cidr_ipv6_bitlen argument exceeds maxsize (%d > %d) - ignoring.", |
212380e3 AC |
788 | *(unsigned int *) data, maxsize); |
789 | else | |
e33e589c | 790 | yy_class->cidr_ipv6_bitlen = *(unsigned int *) data; |
212380e3 AC |
791 | |
792 | } | |
e33e589c JT |
793 | #endif |
794 | ||
212380e3 AC |
795 | static void |
796 | conf_set_class_number_per_cidr(void *data) | |
797 | { | |
798 | yy_class->cidr_amount = *(unsigned int *) data; | |
799 | } | |
800 | ||
801 | static void | |
802 | conf_set_class_number_per_ip(void *data) | |
803 | { | |
804 | yy_class->max_local = *(unsigned int *) data; | |
805 | } | |
806 | ||
807 | ||
808 | static void | |
809 | conf_set_class_number_per_ip_global(void *data) | |
810 | { | |
811 | yy_class->max_global = *(unsigned int *) data; | |
812 | } | |
813 | ||
814 | static void | |
815 | conf_set_class_number_per_ident(void *data) | |
816 | { | |
817 | yy_class->max_ident = *(unsigned int *) data; | |
818 | } | |
819 | ||
820 | static void | |
821 | conf_set_class_connectfreq(void *data) | |
822 | { | |
823 | yy_class->con_freq = *(unsigned int *) data; | |
824 | } | |
825 | ||
826 | static void | |
827 | conf_set_class_max_number(void *data) | |
828 | { | |
829 | yy_class->max_total = *(unsigned int *) data; | |
830 | } | |
831 | ||
832 | static void | |
833 | conf_set_class_sendq(void *data) | |
834 | { | |
835 | yy_class->max_sendq = *(unsigned int *) data; | |
836 | } | |
837 | ||
838 | static char *listener_address; | |
839 | ||
840 | static int | |
841 | conf_begin_listen(struct TopConf *tc) | |
842 | { | |
637c4932 | 843 | rb_free(listener_address); |
212380e3 AC |
844 | listener_address = NULL; |
845 | return 0; | |
846 | } | |
847 | ||
848 | static int | |
849 | conf_end_listen(struct TopConf *tc) | |
850 | { | |
637c4932 | 851 | rb_free(listener_address); |
212380e3 AC |
852 | listener_address = NULL; |
853 | return 0; | |
854 | } | |
855 | ||
02270e96 AC |
856 | static void |
857 | conf_set_listen_defer_accept(void *data) | |
858 | { | |
859 | yy_defer_accept = *(unsigned int *) data; | |
860 | } | |
c6d72037 | 861 | |
c53ca1e0 AC |
862 | static void |
863 | conf_set_listen_wsock(void *data) | |
864 | { | |
865 | yy_wsock = *(unsigned int *) data; | |
866 | } | |
867 | ||
212380e3 | 868 | static void |
c6d72037 | 869 | conf_set_listen_port_both(void *data, int ssl) |
212380e3 AC |
870 | { |
871 | conf_parm_t *args = data; | |
872 | for (; args; args = args->next) | |
873 | { | |
dceac3e4 | 874 | if(CF_TYPE(args->type) != CF_INT) |
212380e3 AC |
875 | { |
876 | conf_report_error | |
877 | ("listener::port argument is not an integer " "-- ignoring."); | |
878 | continue; | |
879 | } | |
880 | if(listener_address == NULL) | |
881 | { | |
35f284c2 AC |
882 | if (!ssl) |
883 | { | |
fed4fc59 | 884 | conf_report_warning("listener 'ANY/%d': support for plaintext listeners may be removed in a future release per RFCs 7194 & 7258. " |
d84acbce | 885 | "It is suggested that users be migrated to SSL/TLS connections.", args->v.number); |
35f284c2 | 886 | } |
c53ca1e0 | 887 | add_listener(args->v.number, listener_address, AF_INET, ssl, ssl || yy_defer_accept, yy_wsock); |
ccda6e3f | 888 | #ifdef RB_IPV6 |
c53ca1e0 | 889 | add_listener(args->v.number, listener_address, AF_INET6, ssl, ssl || yy_defer_accept, yy_wsock); |
212380e3 AC |
890 | #endif |
891 | } | |
892 | else | |
893 | { | |
894 | int family; | |
ccda6e3f | 895 | #ifdef RB_IPV6 |
212380e3 AC |
896 | if(strchr(listener_address, ':') != NULL) |
897 | family = AF_INET6; | |
023c36ae | 898 | else |
212380e3 AC |
899 | #endif |
900 | family = AF_INET; | |
023c36ae | 901 | |
35f284c2 AC |
902 | if (!ssl) |
903 | { | |
fed4fc59 | 904 | conf_report_warning("listener '%s/%d': support for plaintext listeners may be removed in a future release per RFCs 7194 & 7258. " |
d84acbce | 905 | "It is suggested that users be migrated to SSL/TLS connections.", listener_address, args->v.number); |
35f284c2 | 906 | } |
023c36ae | 907 | |
c53ca1e0 | 908 | add_listener(args->v.number, listener_address, family, ssl, ssl || yy_defer_accept, yy_wsock); |
212380e3 | 909 | } |
212380e3 AC |
910 | } |
911 | } | |
912 | ||
8bd5767b JT |
913 | static void |
914 | conf_set_listen_port(void *data) | |
915 | { | |
916 | conf_set_listen_port_both(data, 0); | |
917 | } | |
918 | ||
919 | static void | |
920 | conf_set_listen_sslport(void *data) | |
921 | { | |
922 | conf_set_listen_port_both(data, 1); | |
c6d72037 VY |
923 | } |
924 | ||
212380e3 AC |
925 | static void |
926 | conf_set_listen_address(void *data) | |
927 | { | |
637c4932 | 928 | rb_free(listener_address); |
47a03750 | 929 | listener_address = rb_strdup(data); |
212380e3 AC |
930 | } |
931 | ||
932 | static int | |
933 | conf_begin_auth(struct TopConf *tc) | |
934 | { | |
330fc5c1 | 935 | rb_dlink_node *ptr; |
637c4932 | 936 | rb_dlink_node *next_ptr; |
212380e3 AC |
937 | |
938 | if(yy_aconf) | |
939 | free_conf(yy_aconf); | |
940 | ||
637c4932 | 941 | RB_DLINK_FOREACH_SAFE(ptr, next_ptr, yy_aconf_list.head) |
212380e3 AC |
942 | { |
943 | free_conf(ptr->data); | |
330fc5c1 | 944 | rb_dlinkDestroy(ptr, &yy_aconf_list); |
212380e3 AC |
945 | } |
946 | ||
947 | yy_aconf = make_conf(); | |
948 | yy_aconf->status = CONF_CLIENT; | |
949 | ||
950 | return 0; | |
951 | } | |
952 | ||
953 | static int | |
954 | conf_end_auth(struct TopConf *tc) | |
955 | { | |
3d1f32c0 | 956 | struct ConfItem *yy_tmp, *found_conf; |
330fc5c1 | 957 | rb_dlink_node *ptr; |
637c4932 | 958 | rb_dlink_node *next_ptr; |
212380e3 | 959 | |
27f616dd JT |
960 | if(EmptyString(yy_aconf->info.name)) |
961 | yy_aconf->info.name = rb_strdup("NOMATCH"); | |
212380e3 AC |
962 | |
963 | /* didnt even get one ->host? */ | |
964 | if(EmptyString(yy_aconf->host)) | |
965 | { | |
966 | conf_report_error("Ignoring auth block -- missing user@host"); | |
967 | return 0; | |
968 | } | |
969 | ||
970 | /* so the stacking works in order.. */ | |
971 | collapse(yy_aconf->user); | |
972 | collapse(yy_aconf->host); | |
973 | conf_add_class_to_conf(yy_aconf); | |
3d1f32c0 | 974 | if ((found_conf = find_exact_conf_by_address("*", CONF_CLIENT, "*")) && found_conf->spasswd == NULL) |
6e5e2b00 | 975 | conf_report_error("Ignoring redundant auth block (after *@*)"); |
3d1f32c0 | 976 | else if ((found_conf = find_exact_conf_by_address(yy_aconf->host, CONF_CLIENT, yy_aconf->user)) && |
5f2df251 | 977 | (!found_conf->spasswd || (yy_aconf->spasswd && |
3d1f32c0 | 978 | 0 == irccmp(found_conf->spasswd, yy_aconf->spasswd)))) |
6e5e2b00 JT |
979 | conf_report_error("Ignoring duplicate auth block for %s@%s", |
980 | yy_aconf->user, yy_aconf->host); | |
981 | else | |
982 | add_conf_by_address(yy_aconf->host, CONF_CLIENT, yy_aconf->user, yy_aconf->spasswd, yy_aconf); | |
212380e3 | 983 | |
637c4932 | 984 | RB_DLINK_FOREACH_SAFE(ptr, next_ptr, yy_aconf_list.head) |
212380e3 AC |
985 | { |
986 | yy_tmp = ptr->data; | |
987 | ||
988 | if(yy_aconf->passwd) | |
47a03750 | 989 | yy_tmp->passwd = rb_strdup(yy_aconf->passwd); |
212380e3 | 990 | |
40c1fd47 VY |
991 | if(yy_aconf->spasswd) |
992 | yy_tmp->spasswd = rb_strdup(yy_aconf->spasswd); | |
023c36ae | 993 | |
212380e3 | 994 | /* this will always exist.. */ |
27f616dd | 995 | yy_tmp->info.name = rb_strdup(yy_aconf->info.name); |
212380e3 AC |
996 | |
997 | if(yy_aconf->className) | |
47a03750 | 998 | yy_tmp->className = rb_strdup(yy_aconf->className); |
212380e3 AC |
999 | |
1000 | yy_tmp->flags = yy_aconf->flags; | |
1001 | yy_tmp->port = yy_aconf->port; | |
1002 | ||
1003 | collapse(yy_tmp->user); | |
1004 | collapse(yy_tmp->host); | |
1005 | ||
1006 | conf_add_class_to_conf(yy_tmp); | |
1007 | ||
0c2ea0c3 | 1008 | if ((found_conf = find_exact_conf_by_address("*", CONF_CLIENT, "*")) && found_conf->spasswd == NULL) |
6e5e2b00 | 1009 | conf_report_error("Ignoring redundant auth block (after *@*)"); |
0c2ea0c3 JT |
1010 | else if ((found_conf = find_exact_conf_by_address(yy_tmp->host, CONF_CLIENT, yy_tmp->user)) && |
1011 | (!found_conf->spasswd || (yy_tmp->spasswd && | |
1012 | 0 == irccmp(found_conf->spasswd, yy_tmp->spasswd)))) | |
6e5e2b00 JT |
1013 | conf_report_error("Ignoring duplicate auth block for %s@%s", |
1014 | yy_tmp->user, yy_tmp->host); | |
1015 | else | |
1016 | add_conf_by_address(yy_tmp->host, CONF_CLIENT, yy_tmp->user, yy_tmp->spasswd, yy_tmp); | |
330fc5c1 | 1017 | rb_dlinkDestroy(ptr, &yy_aconf_list); |
212380e3 AC |
1018 | } |
1019 | ||
1020 | yy_aconf = NULL; | |
1021 | return 0; | |
1022 | } | |
1023 | ||
1024 | static void | |
1025 | conf_set_auth_user(void *data) | |
1026 | { | |
1027 | struct ConfItem *yy_tmp; | |
1028 | char *p; | |
1029 | ||
1030 | /* The first user= line doesn't allocate a new conf */ | |
1031 | if(!EmptyString(yy_aconf->host)) | |
1032 | { | |
1033 | yy_tmp = make_conf(); | |
1034 | yy_tmp->status = CONF_CLIENT; | |
1035 | } | |
1036 | else | |
1037 | yy_tmp = yy_aconf; | |
1038 | ||
1039 | if((p = strchr(data, '@'))) | |
1040 | { | |
1041 | *p++ = '\0'; | |
1042 | ||
47a03750 VY |
1043 | yy_tmp->user = rb_strdup(data); |
1044 | yy_tmp->host = rb_strdup(p); | |
212380e3 AC |
1045 | } |
1046 | else | |
1047 | { | |
47a03750 VY |
1048 | yy_tmp->user = rb_strdup("*"); |
1049 | yy_tmp->host = rb_strdup(data); | |
212380e3 AC |
1050 | } |
1051 | ||
1052 | if(yy_aconf != yy_tmp) | |
330fc5c1 | 1053 | rb_dlinkAddAlloc(yy_tmp, &yy_aconf_list); |
212380e3 AC |
1054 | } |
1055 | ||
40c1fd47 VY |
1056 | static void |
1057 | conf_set_auth_auth_user(void *data) | |
1058 | { | |
1059 | if(yy_aconf->spasswd) | |
1060 | memset(yy_aconf->spasswd, 0, strlen(yy_aconf->spasswd)); | |
1061 | rb_free(yy_aconf->spasswd); | |
1062 | yy_aconf->spasswd = rb_strdup(data); | |
1063 | } | |
1064 | ||
212380e3 AC |
1065 | static void |
1066 | conf_set_auth_passwd(void *data) | |
1067 | { | |
1068 | if(yy_aconf->passwd) | |
1069 | memset(yy_aconf->passwd, 0, strlen(yy_aconf->passwd)); | |
637c4932 | 1070 | rb_free(yy_aconf->passwd); |
47a03750 | 1071 | yy_aconf->passwd = rb_strdup(data); |
212380e3 AC |
1072 | } |
1073 | ||
1074 | static void | |
1075 | conf_set_auth_spoof(void *data) | |
1076 | { | |
1077 | char *p; | |
1078 | char *user = NULL; | |
1079 | char *host = NULL; | |
1080 | ||
1081 | host = data; | |
1082 | ||
1083 | /* user@host spoof */ | |
1084 | if((p = strchr(host, '@')) != NULL) | |
1085 | { | |
1086 | *p = '\0'; | |
1087 | user = data; | |
1088 | host = p+1; | |
1089 | ||
1090 | if(EmptyString(user)) | |
1091 | { | |
1092 | conf_report_error("Warning -- spoof ident empty."); | |
1093 | return; | |
1094 | } | |
1095 | ||
1096 | if(strlen(user) > USERLEN) | |
1097 | { | |
1098 | conf_report_error("Warning -- spoof ident length invalid."); | |
1099 | return; | |
1100 | } | |
1101 | ||
1102 | if(!valid_username(user)) | |
1103 | { | |
1104 | conf_report_error("Warning -- invalid spoof (ident)."); | |
1105 | return; | |
1106 | } | |
1107 | ||
1108 | /* this must be restored! */ | |
1109 | *p = '@'; | |
1110 | } | |
1111 | ||
1112 | if(EmptyString(host)) | |
1113 | { | |
1114 | conf_report_error("Warning -- spoof host empty."); | |
1115 | return; | |
1116 | } | |
1117 | ||
1118 | if(strlen(host) > HOSTLEN) | |
1119 | { | |
1120 | conf_report_error("Warning -- spoof host length invalid."); | |
1121 | return; | |
1122 | } | |
1123 | ||
1124 | if(!valid_hostname(host)) | |
1125 | { | |
1126 | conf_report_error("Warning -- invalid spoof (host)."); | |
1127 | return; | |
1128 | } | |
1129 | ||
27f616dd JT |
1130 | rb_free(yy_aconf->info.name); |
1131 | yy_aconf->info.name = rb_strdup(data); | |
212380e3 AC |
1132 | yy_aconf->flags |= CONF_FLAGS_SPOOF_IP; |
1133 | } | |
1134 | ||
1135 | static void | |
1136 | conf_set_auth_flags(void *data) | |
1137 | { | |
1138 | conf_parm_t *args = data; | |
1139 | ||
1140 | set_modes_from_table((int *) &yy_aconf->flags, "flag", auth_table, args); | |
1141 | } | |
1142 | ||
1143 | static void | |
1144 | conf_set_auth_redir_serv(void *data) | |
1145 | { | |
1146 | yy_aconf->flags |= CONF_FLAGS_REDIR; | |
27f616dd JT |
1147 | rb_free(yy_aconf->info.name); |
1148 | yy_aconf->info.name = rb_strdup(data); | |
212380e3 AC |
1149 | } |
1150 | ||
1151 | static void | |
1152 | conf_set_auth_redir_port(void *data) | |
1153 | { | |
1154 | int port = *(unsigned int *) data; | |
1155 | ||
1156 | yy_aconf->flags |= CONF_FLAGS_REDIR; | |
1157 | yy_aconf->port = port; | |
1158 | } | |
1159 | ||
1160 | static void | |
1161 | conf_set_auth_class(void *data) | |
1162 | { | |
637c4932 | 1163 | rb_free(yy_aconf->className); |
47a03750 | 1164 | yy_aconf->className = rb_strdup(data); |
212380e3 AC |
1165 | } |
1166 | ||
1167 | /* ok, shared_oper handles the stacking, shared_flags handles adding | |
1168 | * things.. so all we need to do when we start and end a shared block, is | |
1169 | * clean up anything thats been left over. | |
1170 | */ | |
1171 | static int | |
1172 | conf_cleanup_shared(struct TopConf *tc) | |
1173 | { | |
637c4932 | 1174 | rb_dlink_node *ptr, *next_ptr; |
212380e3 | 1175 | |
637c4932 | 1176 | RB_DLINK_FOREACH_SAFE(ptr, next_ptr, yy_shared_list.head) |
212380e3 AC |
1177 | { |
1178 | free_remote_conf(ptr->data); | |
330fc5c1 | 1179 | rb_dlinkDestroy(ptr, &yy_shared_list); |
212380e3 AC |
1180 | } |
1181 | ||
1182 | if(yy_shared != NULL) | |
1183 | { | |
1184 | free_remote_conf(yy_shared); | |
1185 | yy_shared = NULL; | |
1186 | } | |
1187 | ||
1188 | return 0; | |
1189 | } | |
1190 | ||
1191 | static void | |
1192 | conf_set_shared_oper(void *data) | |
1193 | { | |
1194 | conf_parm_t *args = data; | |
1195 | const char *username; | |
1196 | char *p; | |
1197 | ||
1198 | if(yy_shared != NULL) | |
1199 | free_remote_conf(yy_shared); | |
1200 | ||
1201 | yy_shared = make_remote_conf(); | |
1202 | ||
1203 | if(args->next != NULL) | |
1204 | { | |
dceac3e4 | 1205 | if(CF_TYPE(args->type) != CF_QSTRING) |
212380e3 AC |
1206 | { |
1207 | conf_report_error("Ignoring shared::oper -- server is not a qstring"); | |
1208 | return; | |
1209 | } | |
1210 | ||
47a03750 | 1211 | yy_shared->server = rb_strdup(args->v.string); |
212380e3 AC |
1212 | args = args->next; |
1213 | } | |
1214 | else | |
47a03750 | 1215 | yy_shared->server = rb_strdup("*"); |
212380e3 | 1216 | |
dceac3e4 | 1217 | if(CF_TYPE(args->type) != CF_QSTRING) |
212380e3 AC |
1218 | { |
1219 | conf_report_error("Ignoring shared::oper -- oper is not a qstring"); | |
1220 | return; | |
1221 | } | |
1222 | ||
1223 | if((p = strchr(args->v.string, '@')) == NULL) | |
1224 | { | |
1225 | conf_report_error("Ignoring shard::oper -- oper is not a user@host"); | |
1226 | return; | |
1227 | } | |
1228 | ||
1229 | username = args->v.string; | |
1230 | *p++ = '\0'; | |
1231 | ||
1232 | if(EmptyString(p)) | |
47a03750 | 1233 | yy_shared->host = rb_strdup("*"); |
212380e3 | 1234 | else |
47a03750 | 1235 | yy_shared->host = rb_strdup(p); |
212380e3 AC |
1236 | |
1237 | if(EmptyString(username)) | |
47a03750 | 1238 | yy_shared->username = rb_strdup("*"); |
212380e3 | 1239 | else |
47a03750 | 1240 | yy_shared->username = rb_strdup(username); |
212380e3 | 1241 | |
330fc5c1 | 1242 | rb_dlinkAddAlloc(yy_shared, &yy_shared_list); |
212380e3 AC |
1243 | yy_shared = NULL; |
1244 | } | |
1245 | ||
1246 | static void | |
1247 | conf_set_shared_flags(void *data) | |
1248 | { | |
1249 | conf_parm_t *args = data; | |
1250 | int flags = 0; | |
637c4932 | 1251 | rb_dlink_node *ptr, *next_ptr; |
212380e3 AC |
1252 | |
1253 | if(yy_shared != NULL) | |
1254 | free_remote_conf(yy_shared); | |
1255 | ||
1256 | set_modes_from_table(&flags, "flag", shared_table, args); | |
1257 | ||
637c4932 | 1258 | RB_DLINK_FOREACH_SAFE(ptr, next_ptr, yy_shared_list.head) |
212380e3 AC |
1259 | { |
1260 | yy_shared = ptr->data; | |
1261 | ||
1262 | yy_shared->flags = flags; | |
330fc5c1 AC |
1263 | rb_dlinkDestroy(ptr, &yy_shared_list); |
1264 | rb_dlinkAddTail(yy_shared, &yy_shared->node, &shared_conf_list); | |
212380e3 AC |
1265 | } |
1266 | ||
1267 | yy_shared = NULL; | |
1268 | } | |
1269 | ||
1270 | static int | |
1271 | conf_begin_connect(struct TopConf *tc) | |
1272 | { | |
1273 | if(yy_server) | |
1274 | free_server_conf(yy_server); | |
1275 | ||
1276 | yy_server = make_server_conf(); | |
1277 | yy_server->port = PORTNUM; | |
5aa453a4 | 1278 | yy_server->flags |= SERVER_TB; |
212380e3 AC |
1279 | |
1280 | if(conf_cur_block_name != NULL) | |
47a03750 | 1281 | yy_server->name = rb_strdup(conf_cur_block_name); |
212380e3 AC |
1282 | |
1283 | return 0; | |
1284 | } | |
1285 | ||
1286 | static int | |
1287 | conf_end_connect(struct TopConf *tc) | |
1288 | { | |
1289 | if(EmptyString(yy_server->name)) | |
1290 | { | |
1291 | conf_report_error("Ignoring connect block -- missing name."); | |
1292 | return 0; | |
1293 | } | |
1294 | ||
1295 | if(ServerInfo.name != NULL && !irccmp(ServerInfo.name, yy_server->name)) | |
1296 | { | |
1297 | conf_report_error("Ignoring connect block for %s -- name is equal to my own name.", | |
1298 | yy_server->name); | |
1299 | return 0; | |
1300 | } | |
1301 | ||
ff0cc1e6 | 1302 | if((EmptyString(yy_server->passwd) || EmptyString(yy_server->spasswd)) && EmptyString(yy_server->certfp)) |
212380e3 | 1303 | { |
c8f26906 | 1304 | conf_report_error("Ignoring connect block for %s -- no fingerprint or password credentials provided.", |
212380e3 AC |
1305 | yy_server->name); |
1306 | return 0; | |
1307 | } | |
1308 | ||
f61d0961 SA |
1309 | if((yy_server->flags & SERVER_SSL) && EmptyString(yy_server->certfp)) |
1310 | { | |
1311 | conf_report_error("Ignoring connect block for %s -- no fingerprint provided for SSL connection.", | |
1312 | yy_server->name); | |
1313 | return 0; | |
1314 | } | |
1315 | ||
d4214e94 SA |
1316 | if(EmptyString(yy_server->connect_host) |
1317 | && GET_SS_FAMILY(&yy_server->connect4) != AF_INET | |
1318 | #ifdef RB_IPV6 | |
1319 | && GET_SS_FAMILY(&yy_server->connect6) != AF_INET6 | |
1320 | #endif | |
1321 | ) | |
212380e3 AC |
1322 | { |
1323 | conf_report_error("Ignoring connect block for %s -- missing host.", | |
1324 | yy_server->name); | |
1325 | return 0; | |
1326 | } | |
1327 | ||
1328 | #ifndef HAVE_LIBZ | |
1329 | if(ServerConfCompressed(yy_server)) | |
1330 | { | |
1331 | conf_report_error("Ignoring connect::flags::compressed -- zlib not available."); | |
1332 | yy_server->flags &= ~SERVER_COMPRESSED; | |
1333 | } | |
1334 | #endif | |
1335 | ||
1336 | add_server_conf(yy_server); | |
330fc5c1 | 1337 | rb_dlinkAdd(yy_server, &yy_server->node, &server_conf_list); |
212380e3 AC |
1338 | |
1339 | yy_server = NULL; | |
1340 | return 0; | |
1341 | } | |
1342 | ||
1343 | static void | |
1344 | conf_set_connect_host(void *data) | |
1345 | { | |
d4214e94 SA |
1346 | struct rb_sockaddr_storage addr; |
1347 | ||
1348 | if(rb_inet_pton_sock(data, (struct sockaddr *)&addr) <= 0) | |
1349 | { | |
1350 | rb_free(yy_server->connect_host); | |
1351 | yy_server->connect_host = rb_strdup(data); | |
1352 | } | |
1353 | else if(GET_SS_FAMILY(&addr) == AF_INET) | |
1354 | { | |
1355 | yy_server->connect4 = addr; | |
1356 | } | |
1357 | #ifdef RB_IPV6 | |
1358 | else if(GET_SS_FAMILY(&addr) == AF_INET6) | |
1359 | { | |
1360 | yy_server->connect6 = addr; | |
1361 | } | |
1362 | #endif | |
1363 | else | |
1364 | { | |
1365 | conf_report_error("Unsupported IP address for server connect host (%s)", | |
1366 | (char *)data); | |
1367 | return; | |
1368 | } | |
212380e3 AC |
1369 | } |
1370 | ||
1371 | static void | |
1372 | conf_set_connect_vhost(void *data) | |
1373 | { | |
d4214e94 SA |
1374 | struct rb_sockaddr_storage addr; |
1375 | ||
1376 | if(rb_inet_pton_sock(data, (struct sockaddr *)&addr) <= 0) | |
1377 | { | |
1378 | rb_free(yy_server->bind_host); | |
1379 | yy_server->bind_host = rb_strdup(data); | |
1380 | } | |
1381 | else if(GET_SS_FAMILY(&addr) == AF_INET) | |
212380e3 | 1382 | { |
d4214e94 SA |
1383 | yy_server->bind4 = addr; |
1384 | } | |
1385 | #ifdef RB_IPV6 | |
1386 | else if(GET_SS_FAMILY(&addr) == AF_INET6) | |
1387 | { | |
1388 | yy_server->bind6 = addr; | |
1389 | } | |
1390 | #endif | |
1391 | else | |
1392 | { | |
1393 | conf_report_error("Unsupported IP address for server connect vhost (%s)", | |
1394 | (char *)data); | |
212380e3 AC |
1395 | return; |
1396 | } | |
212380e3 AC |
1397 | } |
1398 | ||
1399 | static void | |
1400 | conf_set_connect_send_password(void *data) | |
1401 | { | |
1402 | if(yy_server->spasswd) | |
1403 | { | |
1404 | memset(yy_server->spasswd, 0, strlen(yy_server->spasswd)); | |
637c4932 | 1405 | rb_free(yy_server->spasswd); |
212380e3 AC |
1406 | } |
1407 | ||
47a03750 | 1408 | yy_server->spasswd = rb_strdup(data); |
212380e3 AC |
1409 | } |
1410 | ||
1411 | static void | |
1412 | conf_set_connect_accept_password(void *data) | |
1413 | { | |
1414 | if(yy_server->passwd) | |
1415 | { | |
1416 | memset(yy_server->passwd, 0, strlen(yy_server->passwd)); | |
637c4932 | 1417 | rb_free(yy_server->passwd); |
212380e3 | 1418 | } |
47a03750 | 1419 | yy_server->passwd = rb_strdup(data); |
212380e3 AC |
1420 | } |
1421 | ||
ff0cc1e6 AC |
1422 | static void |
1423 | conf_set_connect_fingerprint(void *data) | |
1424 | { | |
462ae9d7 JT |
1425 | if (yy_server->certfp) |
1426 | rb_free(yy_server->certfp); | |
ff0cc1e6 AC |
1427 | yy_server->certfp = rb_strdup((char *) data); |
1428 | ||
1429 | /* force SSL to be enabled if fingerprint is enabled. */ | |
1430 | yy_server->flags |= SERVER_SSL; | |
1431 | } | |
1432 | ||
212380e3 AC |
1433 | static void |
1434 | conf_set_connect_port(void *data) | |
1435 | { | |
1436 | int port = *(unsigned int *) data; | |
1437 | ||
1438 | if(port < 1) | |
1439 | port = PORTNUM; | |
1440 | ||
1441 | yy_server->port = port; | |
1442 | } | |
1443 | ||
1444 | static void | |
1445 | conf_set_connect_aftype(void *data) | |
1446 | { | |
1447 | char *aft = data; | |
1448 | ||
f956cb0f | 1449 | if(rb_strcasecmp(aft, "ipv4") == 0) |
212380e3 | 1450 | yy_server->aftype = AF_INET; |
ccda6e3f | 1451 | #ifdef RB_IPV6 |
f956cb0f | 1452 | else if(rb_strcasecmp(aft, "ipv6") == 0) |
212380e3 AC |
1453 | yy_server->aftype = AF_INET6; |
1454 | #endif | |
1455 | else | |
1456 | conf_report_error("connect::aftype '%s' is unknown.", aft); | |
1457 | } | |
1458 | ||
1459 | static void | |
1460 | conf_set_connect_flags(void *data) | |
1461 | { | |
1462 | conf_parm_t *args = data; | |
1463 | ||
1464 | /* note, we allow them to set compressed, then remove it later if | |
1465 | * they do and LIBZ isnt available | |
1466 | */ | |
1467 | set_modes_from_table(&yy_server->flags, "flag", connect_table, args); | |
1468 | } | |
1469 | ||
1470 | static void | |
1471 | conf_set_connect_hub_mask(void *data) | |
1472 | { | |
1473 | struct remote_conf *yy_hub; | |
1474 | ||
1475 | if(EmptyString(yy_server->name)) | |
1476 | return; | |
1477 | ||
1478 | yy_hub = make_remote_conf(); | |
1479 | yy_hub->flags = CONF_HUB; | |
1480 | ||
47a03750 VY |
1481 | yy_hub->host = rb_strdup(data); |
1482 | yy_hub->server = rb_strdup(yy_server->name); | |
330fc5c1 | 1483 | rb_dlinkAdd(yy_hub, &yy_hub->node, &hubleaf_conf_list); |
212380e3 AC |
1484 | } |
1485 | ||
1486 | static void | |
1487 | conf_set_connect_leaf_mask(void *data) | |
1488 | { | |
1489 | struct remote_conf *yy_leaf; | |
1490 | ||
1491 | if(EmptyString(yy_server->name)) | |
1492 | return; | |
1493 | ||
1494 | yy_leaf = make_remote_conf(); | |
1495 | yy_leaf->flags = CONF_LEAF; | |
1496 | ||
47a03750 VY |
1497 | yy_leaf->host = rb_strdup(data); |
1498 | yy_leaf->server = rb_strdup(yy_server->name); | |
330fc5c1 | 1499 | rb_dlinkAdd(yy_leaf, &yy_leaf->node, &hubleaf_conf_list); |
212380e3 AC |
1500 | } |
1501 | ||
1502 | static void | |
1503 | conf_set_connect_class(void *data) | |
1504 | { | |
637c4932 | 1505 | rb_free(yy_server->class_name); |
47a03750 | 1506 | yy_server->class_name = rb_strdup(data); |
212380e3 AC |
1507 | } |
1508 | ||
1509 | static void | |
1510 | conf_set_exempt_ip(void *data) | |
1511 | { | |
1512 | struct ConfItem *yy_tmp; | |
1513 | ||
1514 | if(parse_netmask(data, NULL, NULL) == HM_HOST) | |
1515 | { | |
1516 | conf_report_error("Ignoring exempt -- invalid exempt::ip."); | |
1517 | return; | |
1518 | } | |
1519 | ||
1520 | yy_tmp = make_conf(); | |
47a03750 VY |
1521 | yy_tmp->passwd = rb_strdup("*"); |
1522 | yy_tmp->host = rb_strdup(data); | |
212380e3 | 1523 | yy_tmp->status = CONF_EXEMPTDLINE; |
40c1fd47 | 1524 | add_conf_by_address(yy_tmp->host, CONF_EXEMPTDLINE, NULL, NULL, yy_tmp); |
212380e3 AC |
1525 | } |
1526 | ||
1527 | static int | |
1528 | conf_cleanup_cluster(struct TopConf *tc) | |
1529 | { | |
637c4932 | 1530 | rb_dlink_node *ptr, *next_ptr; |
212380e3 | 1531 | |
637c4932 | 1532 | RB_DLINK_FOREACH_SAFE(ptr, next_ptr, yy_cluster_list.head) |
212380e3 AC |
1533 | { |
1534 | free_remote_conf(ptr->data); | |
330fc5c1 | 1535 | rb_dlinkDestroy(ptr, &yy_cluster_list); |
212380e3 AC |
1536 | } |
1537 | ||
1538 | if(yy_shared != NULL) | |
1539 | { | |
1540 | free_remote_conf(yy_shared); | |
1541 | yy_shared = NULL; | |
1542 | } | |
1543 | ||
1544 | return 0; | |
1545 | } | |
1546 | ||
1547 | static void | |
1548 | conf_set_cluster_name(void *data) | |
1549 | { | |
1550 | if(yy_shared != NULL) | |
1551 | free_remote_conf(yy_shared); | |
1552 | ||
1553 | yy_shared = make_remote_conf(); | |
47a03750 | 1554 | yy_shared->server = rb_strdup(data); |
330fc5c1 | 1555 | rb_dlinkAddAlloc(yy_shared, &yy_cluster_list); |
212380e3 AC |
1556 | |
1557 | yy_shared = NULL; | |
1558 | } | |
1559 | ||
1560 | static void | |
1561 | conf_set_cluster_flags(void *data) | |
1562 | { | |
1563 | conf_parm_t *args = data; | |
1564 | int flags = 0; | |
637c4932 | 1565 | rb_dlink_node *ptr, *next_ptr; |
212380e3 AC |
1566 | |
1567 | if(yy_shared != NULL) | |
1568 | free_remote_conf(yy_shared); | |
1569 | ||
1570 | set_modes_from_table(&flags, "flag", cluster_table, args); | |
1571 | ||
637c4932 | 1572 | RB_DLINK_FOREACH_SAFE(ptr, next_ptr, yy_cluster_list.head) |
212380e3 AC |
1573 | { |
1574 | yy_shared = ptr->data; | |
1575 | yy_shared->flags = flags; | |
330fc5c1 AC |
1576 | rb_dlinkAddTail(yy_shared, &yy_shared->node, &cluster_conf_list); |
1577 | rb_dlinkDestroy(ptr, &yy_cluster_list); | |
212380e3 AC |
1578 | } |
1579 | ||
1580 | yy_shared = NULL; | |
1581 | } | |
1582 | ||
1583 | static void | |
1584 | conf_set_general_havent_read_conf(void *data) | |
1585 | { | |
1586 | if(*(unsigned int *) data) | |
1587 | { | |
1588 | conf_report_error("You haven't read your config file properly."); | |
1589 | conf_report_error | |
1590 | ("There is a line in the example conf that will kill your server if not removed."); | |
1591 | conf_report_error | |
1592 | ("Consider actually reading/editing the conf file, and removing this line."); | |
1593 | if (!testing_conf) | |
1594 | exit(0); | |
1595 | } | |
1596 | } | |
1597 | ||
1598 | static void | |
1599 | conf_set_general_hide_error_messages(void *data) | |
1600 | { | |
1601 | char *val = data; | |
1602 | ||
f956cb0f | 1603 | if(rb_strcasecmp(val, "yes") == 0) |
212380e3 | 1604 | ConfigFileEntry.hide_error_messages = 2; |
f956cb0f | 1605 | else if(rb_strcasecmp(val, "opers") == 0) |
212380e3 | 1606 | ConfigFileEntry.hide_error_messages = 1; |
f956cb0f | 1607 | else if(rb_strcasecmp(val, "no") == 0) |
212380e3 AC |
1608 | ConfigFileEntry.hide_error_messages = 0; |
1609 | else | |
1610 | conf_report_error("Invalid setting '%s' for general::hide_error_messages.", val); | |
1611 | } | |
1612 | ||
1613 | static void | |
1614 | conf_set_general_kline_delay(void *data) | |
1615 | { | |
1616 | ConfigFileEntry.kline_delay = *(unsigned int *) data; | |
1617 | ||
1618 | /* THIS MUST BE HERE to stop us being unable to check klines */ | |
f66f0baa | 1619 | kline_queued = false; |
212380e3 AC |
1620 | } |
1621 | ||
1622 | static void | |
1623 | conf_set_general_stats_k_oper_only(void *data) | |
1624 | { | |
1625 | char *val = data; | |
1626 | ||
f956cb0f | 1627 | if(rb_strcasecmp(val, "yes") == 0) |
212380e3 | 1628 | ConfigFileEntry.stats_k_oper_only = 2; |
f956cb0f | 1629 | else if(rb_strcasecmp(val, "masked") == 0) |
212380e3 | 1630 | ConfigFileEntry.stats_k_oper_only = 1; |
f956cb0f | 1631 | else if(rb_strcasecmp(val, "no") == 0) |
212380e3 AC |
1632 | ConfigFileEntry.stats_k_oper_only = 0; |
1633 | else | |
1634 | conf_report_error("Invalid setting '%s' for general::stats_k_oper_only.", val); | |
1635 | } | |
1636 | ||
1637 | static void | |
1638 | conf_set_general_stats_i_oper_only(void *data) | |
1639 | { | |
1640 | char *val = data; | |
1641 | ||
f956cb0f | 1642 | if(rb_strcasecmp(val, "yes") == 0) |
212380e3 | 1643 | ConfigFileEntry.stats_i_oper_only = 2; |
f956cb0f | 1644 | else if(rb_strcasecmp(val, "masked") == 0) |
212380e3 | 1645 | ConfigFileEntry.stats_i_oper_only = 1; |
f956cb0f | 1646 | else if(rb_strcasecmp(val, "no") == 0) |
212380e3 AC |
1647 | ConfigFileEntry.stats_i_oper_only = 0; |
1648 | else | |
1649 | conf_report_error("Invalid setting '%s' for general::stats_i_oper_only.", val); | |
1650 | } | |
1651 | ||
1652 | static void | |
1653 | conf_set_general_compression_level(void *data) | |
1654 | { | |
1655 | #ifdef HAVE_LIBZ | |
1656 | ConfigFileEntry.compression_level = *(unsigned int *) data; | |
1657 | ||
1658 | if((ConfigFileEntry.compression_level < 1) || (ConfigFileEntry.compression_level > 9)) | |
1659 | { | |
1660 | conf_report_error | |
1661 | ("Invalid general::compression_level %d -- using default.", | |
1662 | ConfigFileEntry.compression_level); | |
1663 | ConfigFileEntry.compression_level = 0; | |
1664 | } | |
1665 | #else | |
1666 | conf_report_error("Ignoring general::compression_level -- zlib not available."); | |
1667 | #endif | |
1668 | } | |
1669 | ||
1670 | static void | |
1671 | conf_set_general_default_umodes(void *data) | |
1672 | { | |
1673 | char *pm; | |
1674 | int what = MODE_ADD, flag; | |
1675 | ||
1676 | ConfigFileEntry.default_umodes = 0; | |
1677 | for (pm = (char *) data; *pm; pm++) | |
1678 | { | |
1679 | switch (*pm) | |
1680 | { | |
1681 | case '+': | |
1682 | what = MODE_ADD; | |
1683 | break; | |
1684 | case '-': | |
1685 | what = MODE_DEL; | |
1686 | break; | |
1687 | ||
1688 | /* don't allow +o */ | |
1689 | case 'o': | |
1690 | case 'S': | |
5fabe513 | 1691 | case 'Z': |
212380e3 AC |
1692 | case ' ': |
1693 | break; | |
1694 | ||
1695 | default: | |
1696 | if ((flag = user_modes[(unsigned char) *pm])) | |
1697 | { | |
1698 | /* Proper value has probably not yet been set | |
1699 | * so don't check oper_only_umodes -- jilles */ | |
1700 | if (what == MODE_ADD) | |
1701 | ConfigFileEntry.default_umodes |= flag; | |
1702 | else | |
1703 | ConfigFileEntry.default_umodes &= ~flag; | |
1704 | } | |
1705 | break; | |
1706 | } | |
023c36ae | 1707 | } |
212380e3 AC |
1708 | } |
1709 | ||
1710 | static void | |
1711 | conf_set_general_oper_umodes(void *data) | |
1712 | { | |
1713 | set_modes_from_table(&ConfigFileEntry.oper_umodes, "umode", umode_table, data); | |
1714 | } | |
1715 | ||
13d8f0ed AC |
1716 | static void |
1717 | conf_set_general_certfp_method(void *data) | |
1718 | { | |
1719 | char *method = data; | |
1720 | ||
f018ed84 | 1721 | if (!rb_strcasecmp(method, CERTFP_NAME_CERT_SHA1)) |
cf430c1a | 1722 | ConfigFileEntry.certfp_method = RB_SSL_CERTFP_METH_CERT_SHA1; |
f018ed84 | 1723 | else if (!rb_strcasecmp(method, CERTFP_NAME_CERT_SHA256)) |
cf430c1a | 1724 | ConfigFileEntry.certfp_method = RB_SSL_CERTFP_METH_CERT_SHA256; |
f018ed84 | 1725 | else if (!rb_strcasecmp(method, CERTFP_NAME_CERT_SHA512)) |
cf430c1a | 1726 | ConfigFileEntry.certfp_method = RB_SSL_CERTFP_METH_CERT_SHA512; |
f018ed84 | 1727 | else if (!rb_strcasecmp(method, CERTFP_NAME_SPKI_SHA256)) |
cf430c1a | 1728 | ConfigFileEntry.certfp_method = RB_SSL_CERTFP_METH_SPKI_SHA256; |
f018ed84 | 1729 | else if (!rb_strcasecmp(method, CERTFP_NAME_SPKI_SHA512)) |
cf430c1a | 1730 | ConfigFileEntry.certfp_method = RB_SSL_CERTFP_METH_SPKI_SHA512; |
13d8f0ed AC |
1731 | else |
1732 | { | |
cf430c1a | 1733 | ConfigFileEntry.certfp_method = RB_SSL_CERTFP_METH_CERT_SHA1; |
13d8f0ed AC |
1734 | conf_report_error("Ignoring general::certfp_method -- bogus certfp method %s", method); |
1735 | } | |
1736 | } | |
1737 | ||
212380e3 AC |
1738 | static void |
1739 | conf_set_general_oper_only_umodes(void *data) | |
1740 | { | |
1741 | set_modes_from_table(&ConfigFileEntry.oper_only_umodes, "umode", umode_table, data); | |
1742 | } | |
1743 | ||
1744 | static void | |
1745 | conf_set_general_oper_snomask(void *data) | |
1746 | { | |
1747 | char *pm; | |
1748 | int what = MODE_ADD, flag; | |
1749 | ||
1750 | ConfigFileEntry.oper_snomask = 0; | |
1751 | for (pm = (char *) data; *pm; pm++) | |
1752 | { | |
1753 | switch (*pm) | |
1754 | { | |
1755 | case '+': | |
1756 | what = MODE_ADD; | |
1757 | break; | |
1758 | case '-': | |
1759 | what = MODE_DEL; | |
1760 | break; | |
1761 | ||
1762 | default: | |
1763 | if ((flag = snomask_modes[(unsigned char) *pm])) | |
1764 | { | |
1765 | if (what == MODE_ADD) | |
1766 | ConfigFileEntry.oper_snomask |= flag; | |
1767 | else | |
1768 | ConfigFileEntry.oper_snomask &= ~flag; | |
1769 | } | |
1770 | break; | |
1771 | } | |
1772 | } | |
1773 | } | |
1774 | ||
1775 | static void | |
1776 | conf_set_serverhide_links_delay(void *data) | |
1777 | { | |
1778 | int val = *(unsigned int *) data; | |
1779 | ||
212380e3 AC |
1780 | ConfigServerHide.links_delay = val; |
1781 | } | |
1782 | ||
212380e3 AC |
1783 | static void |
1784 | conf_set_service_name(void *data) | |
1785 | { | |
212380e3 AC |
1786 | const char *s; |
1787 | char *tmp; | |
1788 | int dots = 0; | |
1789 | ||
1790 | for(s = data; *s != '\0'; s++) | |
1791 | { | |
1792 | if(!IsServChar(*s)) | |
1793 | { | |
1794 | conf_report_error("Ignoring service::name " | |
1795 | "-- bogus servername."); | |
1796 | return; | |
1797 | } | |
1798 | else if(*s == '.') | |
1799 | dots++; | |
1800 | } | |
1801 | ||
1802 | if(!dots) | |
1803 | { | |
1804 | conf_report_error("Ignoring service::name -- must contain '.'"); | |
1805 | return; | |
1806 | } | |
1807 | ||
47a03750 | 1808 | tmp = rb_strdup(data); |
330fc5c1 | 1809 | rb_dlinkAddAlloc(tmp, &service_list); |
212380e3 AC |
1810 | } |
1811 | ||
212380e3 AC |
1812 | static int |
1813 | conf_begin_alias(struct TopConf *tc) | |
1814 | { | |
eddc2ab6 | 1815 | yy_alias = rb_malloc(sizeof(struct alias_entry)); |
212380e3 AC |
1816 | |
1817 | if (conf_cur_block_name != NULL) | |
47a03750 | 1818 | yy_alias->name = rb_strdup(conf_cur_block_name); |
212380e3 AC |
1819 | |
1820 | yy_alias->flags = 0; | |
212380e3 AC |
1821 | |
1822 | return 0; | |
1823 | } | |
1824 | ||
1825 | static int | |
1826 | conf_end_alias(struct TopConf *tc) | |
1827 | { | |
212380e3 AC |
1828 | if (yy_alias == NULL) |
1829 | return -1; | |
1830 | ||
1831 | if (yy_alias->name == NULL) | |
1832 | { | |
1833 | conf_report_error("Ignoring alias -- must have a name."); | |
1834 | ||
637c4932 | 1835 | rb_free(yy_alias); |
212380e3 AC |
1836 | |
1837 | return -1; | |
1838 | } | |
1839 | ||
1840 | if (yy_alias->target == NULL) | |
1841 | { | |
1842 | conf_report_error("Ignoring alias -- must have a target."); | |
1843 | ||
637c4932 | 1844 | rb_free(yy_alias); |
212380e3 AC |
1845 | |
1846 | return -1; | |
1847 | } | |
1848 | ||
a4bf26dd | 1849 | rb_dictionary_add(alias_dict, yy_alias->name, yy_alias); |
212380e3 AC |
1850 | |
1851 | return 0; | |
1852 | } | |
1853 | ||
1854 | static void | |
1855 | conf_set_alias_name(void *data) | |
1856 | { | |
1857 | if (data == NULL || yy_alias == NULL) /* this shouldn't ever happen */ | |
1858 | return; | |
1859 | ||
47a03750 | 1860 | yy_alias->name = rb_strdup(data); |
212380e3 AC |
1861 | } |
1862 | ||
1863 | static void | |
1864 | conf_set_alias_target(void *data) | |
1865 | { | |
1866 | if (data == NULL || yy_alias == NULL) /* this shouldn't ever happen */ | |
1867 | return; | |
1868 | ||
47a03750 | 1869 | yy_alias->target = rb_strdup(data); |
212380e3 AC |
1870 | } |
1871 | ||
63eb8567 AC |
1872 | static void |
1873 | conf_set_channel_autochanmodes(void *data) | |
1874 | { | |
1875 | char *pm; | |
1876 | int what = MODE_ADD; | |
1877 | ||
1878 | ConfigChannel.autochanmodes = 0; | |
1879 | for (pm = (char *) data; *pm; pm++) | |
1880 | { | |
1881 | switch (*pm) | |
1882 | { | |
1883 | case '+': | |
1884 | what = MODE_ADD; | |
1885 | break; | |
1886 | case '-': | |
1887 | what = MODE_DEL; | |
1888 | break; | |
1889 | ||
1890 | default: | |
1891 | if (chmode_table[(unsigned char) *pm].set_func == chm_simple) | |
1892 | { | |
1893 | if (what == MODE_ADD) | |
1894 | ConfigChannel.autochanmodes |= chmode_table[(unsigned char) *pm].mode_type; | |
1895 | else | |
1896 | ConfigChannel.autochanmodes &= ~chmode_table[(unsigned char) *pm].mode_type; | |
1897 | } | |
1898 | else | |
1899 | { | |
4952e40b | 1900 | conf_report_error("channel::autochanmodes -- Invalid channel mode %c", *pm); |
63eb8567 AC |
1901 | continue; |
1902 | } | |
1903 | break; | |
1904 | } | |
1905 | } | |
1906 | } | |
1907 | ||
3c93d380 EM |
1908 | /* XXX for below */ |
1909 | static void conf_set_blacklist_reason(void *data); | |
1910 | ||
d3f6b808 EM |
1911 | #define IPTYPE_IPV4 1 |
1912 | #define IPTYPE_IPV6 2 | |
1913 | ||
212380e3 AC |
1914 | static void |
1915 | conf_set_blacklist_host(void *data) | |
1916 | { | |
3c93d380 EM |
1917 | if (yy_blacklist_host) |
1918 | { | |
1919 | conf_report_error("blacklist::host %s overlaps existing host %s", | |
1920 | (char *)data, yy_blacklist_host); | |
1921 | ||
1922 | /* Cleanup */ | |
1923 | conf_set_blacklist_reason(NULL); | |
1924 | return; | |
1925 | } | |
1926 | ||
d3f6b808 | 1927 | yy_blacklist_iptype |= IPTYPE_IPV4; |
47a03750 | 1928 | yy_blacklist_host = rb_strdup(data); |
212380e3 AC |
1929 | } |
1930 | ||
0a1e77c2 EM |
1931 | static void |
1932 | conf_set_blacklist_type(void *data) | |
1933 | { | |
1934 | conf_parm_t *args = data; | |
1935 | ||
1936 | /* Don't assume we have either if we got here */ | |
d3f6b808 | 1937 | yy_blacklist_iptype = 0; |
0a1e77c2 EM |
1938 | |
1939 | for (; args; args = args->next) | |
1940 | { | |
f956cb0f | 1941 | if (!rb_strcasecmp(args->v.string, "ipv4")) |
d3f6b808 | 1942 | yy_blacklist_iptype |= IPTYPE_IPV4; |
f956cb0f | 1943 | else if (!rb_strcasecmp(args->v.string, "ipv6")) |
d3f6b808 | 1944 | yy_blacklist_iptype |= IPTYPE_IPV6; |
0a1e77c2 EM |
1945 | else |
1946 | conf_report_error("blacklist::type has unknown address family %s", | |
1947 | args->v.string); | |
1948 | } | |
1949 | ||
1950 | /* If we have neither, just default to IPv4 */ | |
d3f6b808 | 1951 | if (!yy_blacklist_iptype) |
0a1e77c2 | 1952 | { |
3fe0efd5 | 1953 | conf_report_warning("blacklist::type has neither IPv4 nor IPv6 (defaulting to IPv4)"); |
d3f6b808 | 1954 | yy_blacklist_iptype = IPTYPE_IPV4; |
0a1e77c2 EM |
1955 | } |
1956 | } | |
1957 | ||
3c93d380 EM |
1958 | static void |
1959 | conf_set_blacklist_matches(void *data) | |
1960 | { | |
1961 | conf_parm_t *args = data; | |
d3f6b808 | 1962 | enum filter_t { FILTER_NONE, FILTER_ALL, FILTER_LAST }; |
3c93d380 EM |
1963 | |
1964 | for (; args; args = args->next) | |
1965 | { | |
3c93d380 EM |
1966 | char *str = args->v.string; |
1967 | char *p; | |
d3f6b808 | 1968 | enum filter_t type = FILTER_LAST; |
3c93d380 EM |
1969 | |
1970 | if (CF_TYPE(args->type) != CF_QSTRING) | |
1971 | { | |
1972 | conf_report_error("blacklist::matches -- must be quoted string"); | |
1973 | continue; | |
1974 | } | |
1975 | ||
1976 | if (str == NULL) | |
1977 | { | |
1978 | conf_report_error("blacklist::matches -- invalid entry"); | |
1979 | continue; | |
1980 | } | |
1981 | ||
1982 | if (strlen(str) > HOSTIPLEN) | |
1983 | { | |
1984 | conf_report_error("blacklist::matches has an entry too long: %s", | |
1985 | str); | |
1986 | continue; | |
1987 | } | |
1988 | ||
1989 | for (p = str; *p != '\0'; p++) | |
1990 | { | |
1991 | /* Check for validity */ | |
1992 | if (*p == '.') | |
d3f6b808 EM |
1993 | type = FILTER_ALL; |
1994 | else if (!isdigit((unsigned char)*p)) | |
3c93d380 EM |
1995 | { |
1996 | conf_report_error("blacklist::matches has invalid IP match entry %s", | |
1997 | str); | |
d3f6b808 | 1998 | type = FILTER_NONE; |
3c93d380 EM |
1999 | break; |
2000 | } | |
2001 | } | |
2002 | ||
d3f6b808 | 2003 | if (type == FILTER_ALL) |
3c93d380 EM |
2004 | { |
2005 | /* Basic IP sanity check */ | |
2006 | struct rb_sockaddr_storage tmp; | |
2007 | if (rb_inet_pton(AF_INET, str, &tmp) <= 0) | |
2008 | { | |
2009 | conf_report_error("blacklist::matches has invalid IP match entry %s", | |
2010 | str); | |
2011 | continue; | |
2012 | } | |
2013 | } | |
d3f6b808 | 2014 | else if (type == FILTER_LAST) |
3c93d380 EM |
2015 | { |
2016 | /* Verify it's the correct length */ | |
2017 | if (strlen(str) > 3) | |
2018 | { | |
2019 | conf_report_error("blacklist::matches has invalid octet match entry %s", | |
2020 | str); | |
2021 | continue; | |
2022 | } | |
2023 | } | |
2024 | else | |
2025 | { | |
2026 | continue; /* Invalid entry */ | |
2027 | } | |
2028 | ||
d3f6b808 | 2029 | rb_dlinkAddAlloc(rb_strdup(str), &yy_blacklist_filters); |
3c93d380 EM |
2030 | } |
2031 | } | |
2032 | ||
212380e3 AC |
2033 | static void |
2034 | conf_set_blacklist_reason(void *data) | |
2035 | { | |
3c93d380 | 2036 | rb_dlink_node *ptr, *nptr; |
212380e3 | 2037 | |
2196b182 | 2038 | if (yy_blacklist_host && data) |
212380e3 | 2039 | { |
2196b182 | 2040 | yy_blacklist_reason = rb_strdup(data); |
835d456c | 2041 | if (yy_blacklist_iptype & IPTYPE_IPV6) |
0a1e77c2 | 2042 | { |
a6a30cc7 | 2043 | /* Make sure things fit (magic number 64 = alnum count + dots) |
771dcfad EM |
2044 | * Example: 1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa |
2045 | */ | |
0a1e77c2 EM |
2046 | if ((64 + strlen(yy_blacklist_host)) > IRCD_RES_HOSTLEN) |
2047 | { | |
2048 | conf_report_error("blacklist::host %s results in IPv6 queries that are too long", | |
2049 | yy_blacklist_host); | |
2050 | goto cleanup_bl; | |
2051 | } | |
2052 | } | |
2053 | /* Avoid doing redundant check, IPv6 is bigger than IPv4 --Elizabeth */ | |
d3f6b808 | 2054 | if ((yy_blacklist_iptype & IPTYPE_IPV4) && !(yy_blacklist_iptype & IPTYPE_IPV6)) |
0a1e77c2 | 2055 | { |
a6a30cc7 EM |
2056 | /* Make sure things fit for worst case (magic number 16 = number of nums + dots) |
2057 | * Example: 127.127.127.127.in-addr.arpa | |
771dcfad | 2058 | */ |
0a1e77c2 EM |
2059 | if ((16 + strlen(yy_blacklist_host)) > IRCD_RES_HOSTLEN) |
2060 | { | |
2061 | conf_report_error("blacklist::host %s results in IPv4 queries that are too long", | |
2062 | yy_blacklist_host); | |
2063 | goto cleanup_bl; | |
2064 | } | |
2065 | } | |
2066 | ||
d3f6b808 | 2067 | add_blacklist(yy_blacklist_host, yy_blacklist_reason, yy_blacklist_iptype, &yy_blacklist_filters); |
3c93d380 | 2068 | } |
0a1e77c2 EM |
2069 | |
2070 | cleanup_bl: | |
d3f6b808 | 2071 | RB_DLINK_FOREACH_SAFE(ptr, nptr, yy_blacklist_filters.head) |
e232f35c | 2072 | { |
d3f6b808 EM |
2073 | rb_free(ptr->data); |
2074 | rb_dlinkDestroy(ptr, &yy_blacklist_filters); | |
212380e3 | 2075 | } |
3c93d380 | 2076 | |
d3f6b808 EM |
2077 | yy_blacklist_filters = (rb_dlink_list){ NULL, NULL, 0 }; |
2078 | ||
3c93d380 EM |
2079 | rb_free(yy_blacklist_host); |
2080 | rb_free(yy_blacklist_reason); | |
2081 | yy_blacklist_host = NULL; | |
2082 | yy_blacklist_reason = NULL; | |
d3f6b808 | 2083 | yy_blacklist_iptype = 0; |
212380e3 AC |
2084 | } |
2085 | ||
51fa2ab8 EM |
2086 | |
2087 | struct opm_scanner | |
2088 | { | |
2089 | const char *type; | |
2090 | uint16_t port; | |
2091 | ||
2092 | rb_dlink_node node; | |
2093 | }; | |
2094 | ||
8275e270 EM |
2095 | static int |
2096 | conf_begin_opm(struct TopConf *tc) | |
2097 | { | |
2098 | yy_opm_address_ipv4 = yy_opm_address_ipv6 = NULL; | |
9bba0f61 | 2099 | yy_opm_port_ipv4 = yy_opm_port_ipv6 = yy_opm_timeout = 0; |
5c5296c8 | 2100 | delete_opm_proxy_scanner_all(); |
5e9a3f86 | 2101 | delete_opm_listener_all(); |
8275e270 EM |
2102 | return 0; |
2103 | } | |
2104 | ||
2105 | static int | |
2106 | conf_end_opm(struct TopConf *tc) | |
2107 | { | |
51fa2ab8 EM |
2108 | rb_dlink_node *ptr, *nptr; |
2109 | bool fail = false; | |
2110 | ||
ffa79a95 | 2111 | if(rb_dlink_list_length(&yy_opm_scanner_list) == 0) |
51fa2ab8 | 2112 | { |
c1f4db3f | 2113 | conf_report_error("No opm scanners configured -- disabling opm."); |
51fa2ab8 EM |
2114 | fail = true; |
2115 | goto end; | |
2116 | } | |
2117 | ||
8275e270 EM |
2118 | if(yy_opm_port_ipv4 > 0) |
2119 | { | |
2120 | if(yy_opm_address_ipv4 != NULL) | |
5e9a3f86 | 2121 | conf_create_opm_listener(yy_opm_address_ipv4, yy_opm_port_ipv4); |
8275e270 EM |
2122 | else |
2123 | { | |
2124 | char ip[HOSTIPLEN]; | |
d4214e94 | 2125 | if(!rb_inet_ntop_sock((struct sockaddr *)&ServerInfo.bind4, ip, sizeof(ip))) |
8275e270 | 2126 | conf_report_error("No opm::listen_ipv4 nor serverinfo::vhost directive; cannot listen on IPv4"); |
8275e270 | 2127 | else |
5e9a3f86 | 2128 | conf_create_opm_listener(ip, yy_opm_port_ipv4); |
8275e270 EM |
2129 | } |
2130 | } | |
2131 | ||
2132 | if(yy_opm_port_ipv6 > 0) | |
2133 | { | |
2134 | if(yy_opm_address_ipv6 != NULL) | |
5e9a3f86 | 2135 | conf_create_opm_listener(yy_opm_address_ipv6, yy_opm_port_ipv6); |
8275e270 EM |
2136 | else |
2137 | { | |
2138 | char ip[HOSTIPLEN]; | |
d4214e94 | 2139 | if(!rb_inet_ntop_sock((struct sockaddr *)&ServerInfo.bind6, ip, sizeof(ip))) |
8275e270 | 2140 | conf_report_error("No opm::listen_ipv6 nor serverinfo::vhost directive; cannot listen on IPv6"); |
8275e270 | 2141 | else |
5e9a3f86 | 2142 | conf_create_opm_listener(ip, yy_opm_port_ipv6); |
8275e270 EM |
2143 | } |
2144 | } | |
2145 | ||
51fa2ab8 EM |
2146 | /* If there's no listeners... */ |
2147 | fail = (yy_opm_port_ipv4 == 0 || yy_opm_port_ipv6 == 0); | |
c1f4db3f | 2148 | if(!fail && yy_opm_timeout > 0 && yy_opm_timeout < 60) |
9bba0f61 EM |
2149 | /* Send timeout */ |
2150 | set_authd_timeout("opm_timeout", yy_opm_timeout); | |
c1f4db3f EM |
2151 | else if(fail) |
2152 | conf_report_error("No opm listeners -- disabling"); | |
2153 | else if(yy_opm_timeout <= 0 || yy_opm_timeout >= 60) | |
2154 | conf_report_error("opm::timeout value is invalid -- ignoring"); | |
9bba0f61 | 2155 | |
51fa2ab8 EM |
2156 | end: |
2157 | RB_DLINK_FOREACH_SAFE(ptr, nptr, yy_opm_scanner_list.head) | |
2158 | { | |
2159 | struct opm_scanner *scanner = ptr->data; | |
2160 | ||
2161 | if(!fail) | |
2162 | create_opm_proxy_scanner(scanner->type, scanner->port); | |
2163 | ||
2164 | rb_dlinkDelete(&scanner->node, &yy_opm_scanner_list); | |
2165 | rb_free(scanner); | |
2166 | } | |
2167 | ||
34bc7cae EM |
2168 | if(!fail) |
2169 | opm_check_enable(true); | |
2170 | ||
8275e270 EM |
2171 | rb_free(yy_opm_address_ipv4); |
2172 | rb_free(yy_opm_address_ipv6); | |
2173 | return 0; | |
2174 | } | |
2175 | ||
9bba0f61 EM |
2176 | static void |
2177 | conf_set_opm_timeout(void *data) | |
2178 | { | |
2179 | int timeout = *((int *)data); | |
2180 | ||
2181 | if(timeout <= 0 || timeout > 60) | |
2182 | { | |
2183 | conf_report_error("opm::timeout value %d is bogus, ignoring", timeout); | |
2184 | return; | |
2185 | } | |
2186 | ||
2187 | yy_opm_timeout = timeout; | |
2188 | } | |
51fa2ab8 | 2189 | |
8275e270 | 2190 | static void |
51fa2ab8 | 2191 | conf_set_opm_listen_address_both(void *data, bool ipv6) |
8275e270 EM |
2192 | { |
2193 | struct rb_sockaddr_storage addr; | |
51fa2ab8 | 2194 | const char *confstr = (ipv6 ? "opm::listen_ipv6" : "opm::listen_ipv4"); |
8275e270 EM |
2195 | char *ip = data; |
2196 | ||
8275e270 EM |
2197 | if(!rb_inet_pton_sock(ip, (struct sockaddr *)&addr)) |
2198 | { | |
51fa2ab8 | 2199 | conf_report_error("%s is an invalid address: %s", confstr, ip); |
8275e270 EM |
2200 | return; |
2201 | } | |
2202 | ||
51fa2ab8 | 2203 | if(ipv6) |
8275e270 | 2204 | { |
51fa2ab8 EM |
2205 | #ifdef RB_IPV6 |
2206 | if(GET_SS_FAMILY(&addr) != AF_INET6) | |
2207 | { | |
2208 | conf_report_error("%s is of the wrong address type: %s", confstr, ip); | |
2209 | return; | |
2210 | } | |
2211 | ||
2212 | if(yy_opm_address_ipv6 != NULL) | |
2213 | { | |
2214 | conf_report_error("%s overwrites previous address %s", confstr, ip); | |
2215 | return; | |
2216 | } | |
2217 | ||
2218 | yy_opm_address_ipv6 = rb_strdup(ip); | |
2219 | #else | |
2220 | conf_report_error("%s requires IPv6 support in your ircd", confstr, ip); | |
8275e270 | 2221 | return; |
8275e270 | 2222 | #endif |
51fa2ab8 EM |
2223 | } |
2224 | else | |
8275e270 | 2225 | { |
51fa2ab8 EM |
2226 | if(GET_SS_FAMILY(&addr) != AF_INET) |
2227 | { | |
2228 | conf_report_error("%s is of the wrong address type: %s", confstr, ip); | |
2229 | return; | |
2230 | } | |
2231 | ||
2232 | if(yy_opm_address_ipv4 != NULL) | |
2233 | { | |
2234 | conf_report_error("%s overwrites previous address %s", confstr, ip); | |
2235 | return; | |
2236 | } | |
2237 | ||
2238 | yy_opm_address_ipv4 = rb_strdup(ip); | |
8275e270 | 2239 | } |
51fa2ab8 | 2240 | } |
8275e270 | 2241 | |
51fa2ab8 EM |
2242 | static void |
2243 | conf_set_opm_listen_address_ipv4(void *data) | |
2244 | { | |
2245 | conf_set_opm_listen_address_both(data, false); | |
8275e270 EM |
2246 | } |
2247 | ||
2248 | static void | |
2249 | conf_set_opm_listen_address_ipv6(void *data) | |
2250 | { | |
51fa2ab8 EM |
2251 | conf_set_opm_listen_address_both(data, true); |
2252 | } | |
8275e270 | 2253 | |
51fa2ab8 EM |
2254 | static void |
2255 | conf_set_opm_listen_port_both(void *data, bool ipv6) | |
2256 | { | |
2257 | int port = *((int *)data); | |
2258 | const char *confstr = (ipv6 ? "opm::port_ipv6" : "opm::port_ipv4"); | |
8275e270 | 2259 | |
51fa2ab8 EM |
2260 | #ifndef RB_IPV6 |
2261 | if(ipv6) | |
8275e270 | 2262 | { |
51fa2ab8 | 2263 | conf_report_error("%s requires IPv6 support in your ircd", confstr); |
8275e270 EM |
2264 | return; |
2265 | } | |
51fa2ab8 | 2266 | #endif |
8275e270 | 2267 | |
51fa2ab8 | 2268 | if(port > 65535 || port <= 0) |
8275e270 | 2269 | { |
51fa2ab8 | 2270 | conf_report_error("%s is out of range: %d", confstr, port); |
8275e270 EM |
2271 | return; |
2272 | } | |
2273 | ||
51fa2ab8 | 2274 | if(ipv6) |
8275e270 | 2275 | { |
51fa2ab8 EM |
2276 | if(yy_opm_port_ipv4) |
2277 | { | |
2278 | conf_report_error("%s overwrites existing port %hu", | |
2279 | confstr, yy_opm_port_ipv4); | |
2280 | return; | |
2281 | } | |
2282 | ||
2283 | yy_opm_port_ipv4 = port; | |
8275e270 | 2284 | } |
51fa2ab8 EM |
2285 | else |
2286 | { | |
2287 | if(yy_opm_port_ipv6) | |
2288 | { | |
2289 | conf_report_error("%s overwrites existing port %hu", | |
2290 | confstr, yy_opm_port_ipv6); | |
2291 | return; | |
2292 | } | |
8275e270 | 2293 | |
51fa2ab8 EM |
2294 | yy_opm_port_ipv6 = port; |
2295 | } | |
8275e270 EM |
2296 | } |
2297 | ||
2298 | static void | |
2299 | conf_set_opm_listen_port_ipv4(void *data) | |
2300 | { | |
51fa2ab8 | 2301 | conf_set_opm_listen_port_both(data, false); |
8275e270 EM |
2302 | } |
2303 | ||
2304 | static void | |
2305 | conf_set_opm_listen_port_ipv6(void *data) | |
2306 | { | |
51fa2ab8 | 2307 | conf_set_opm_listen_port_both(data, true); |
8275e270 EM |
2308 | } |
2309 | ||
2310 | static void | |
2311 | conf_set_opm_listen_port(void *data) | |
2312 | { | |
51fa2ab8 EM |
2313 | conf_set_opm_listen_port_both(data, true); |
2314 | conf_set_opm_listen_port_both(data, false); | |
2315 | } | |
8275e270 | 2316 | |
51fa2ab8 EM |
2317 | static void |
2318 | conf_set_opm_scan_ports_all(void *data, const char *node, const char *type) | |
2319 | { | |
2320 | conf_parm_t *args = data; | |
2321 | for (; args; args = args->next) | |
8275e270 | 2322 | { |
51fa2ab8 EM |
2323 | rb_dlink_node *ptr; |
2324 | bool dup = false; | |
8275e270 | 2325 | |
51fa2ab8 EM |
2326 | if(CF_TYPE(args->type) != CF_INT) |
2327 | { | |
2328 | conf_report_error("%s argument is not an integer -- ignoring.", node); | |
2329 | continue; | |
2330 | } | |
5e9a3f86 | 2331 | |
51fa2ab8 EM |
2332 | if(args->v.number > 65535 || args->v.number <= 0) |
2333 | { | |
2334 | conf_report_error("%s argument is not an integer between 1 and 65535 -- ignoring.", node); | |
2335 | continue; | |
2336 | } | |
8275e270 | 2337 | |
51fa2ab8 EM |
2338 | /* Check for duplicates */ |
2339 | RB_DLINK_FOREACH(ptr, yy_opm_scanner_list.head) | |
2340 | { | |
2341 | struct opm_scanner *scanner = ptr->data; | |
2342 | ||
2343 | if(scanner->port == args->v.number && strcmp(type, scanner->type) == 0) | |
2344 | { | |
2345 | conf_report_error("%s argument is duplicate", node); | |
2346 | dup = true; | |
2347 | break; | |
2348 | } | |
2349 | } | |
2350 | ||
2351 | if(!dup) | |
2352 | { | |
2353 | struct opm_scanner *scanner = rb_malloc(sizeof(struct opm_scanner)); | |
2354 | scanner->port = args->v.number; | |
2355 | scanner->type = type; | |
2356 | rb_dlinkAdd(scanner, &scanner->node, &yy_opm_scanner_list); | |
2357 | } | |
8275e270 | 2358 | } |
51fa2ab8 | 2359 | } |
8275e270 | 2360 | |
51fa2ab8 EM |
2361 | static void |
2362 | conf_set_opm_scan_ports_socks4(void *data) | |
2363 | { | |
2364 | conf_set_opm_scan_ports_all(data, "opm::socks4_ports", "socks4"); | |
2365 | } | |
8275e270 | 2366 | |
51fa2ab8 EM |
2367 | static void |
2368 | conf_set_opm_scan_ports_socks5(void *data) | |
2369 | { | |
2370 | conf_set_opm_scan_ports_all(data, "opm::socks5_ports", "socks5"); | |
8275e270 EM |
2371 | } |
2372 | ||
fabe8b94 EM |
2373 | static void |
2374 | conf_set_opm_scan_ports_httpconnect(void *data) | |
2375 | { | |
2376 | conf_set_opm_scan_ports_all(data, "opm::httpconnect_ports", "httpconnect"); | |
2377 | } | |
2378 | ||
eb0814b3 EM |
2379 | static void |
2380 | conf_set_opm_scan_ports_httpsconnect(void *data) | |
2381 | { | |
2382 | conf_set_opm_scan_ports_all(data, "opm::httpsconnect_ports", "httpsconnect"); | |
2383 | } | |
2384 | ||
212380e3 AC |
2385 | /* public functions */ |
2386 | ||
2387 | ||
2388 | void | |
2389 | conf_report_error(const char *fmt, ...) | |
2390 | { | |
2391 | va_list ap; | |
82236a2a | 2392 | char msg[BUFSIZE + 1] = { 0 }; |
212380e3 AC |
2393 | |
2394 | va_start(ap, fmt); | |
82236a2a | 2395 | vsnprintf(msg, BUFSIZE, fmt, ap); |
212380e3 AC |
2396 | va_end(ap); |
2397 | ||
2398 | if (testing_conf) | |
2399 | { | |
2400 | fprintf(stderr, "\"%s\", line %d: %s\n", current_file, lineno + 1, msg); | |
2401 | return; | |
2402 | } | |
2403 | ||
2404 | ierror("\"%s\", line %d: %s", current_file, lineno + 1, msg); | |
d84acbce AC |
2405 | sendto_realops_snomask(SNO_GENERAL, L_ALL, "error: \"%s\", line %d: %s", current_file, lineno + 1, msg); |
2406 | } | |
2407 | ||
2408 | void | |
2409 | conf_report_warning(const char *fmt, ...) | |
2410 | { | |
2411 | va_list ap; | |
82236a2a | 2412 | char msg[BUFSIZE + 1] = { 0 }; |
d84acbce AC |
2413 | |
2414 | va_start(ap, fmt); | |
82236a2a | 2415 | vsnprintf(msg, BUFSIZE, fmt, ap); |
d84acbce AC |
2416 | va_end(ap); |
2417 | ||
2418 | if (testing_conf) | |
2419 | { | |
2420 | fprintf(stderr, "\"%s\", line %d: %s\n", current_file, lineno + 1, msg); | |
2421 | return; | |
2422 | } | |
2423 | ||
2424 | iwarn("\"%s\", line %d: %s", current_file, lineno + 1, msg); | |
2425 | sendto_realops_snomask(SNO_GENERAL, L_ALL, "warning: \"%s\", line %d: %s", current_file, lineno + 1, msg); | |
212380e3 AC |
2426 | } |
2427 | ||
2428 | int | |
2429 | conf_start_block(char *block, char *name) | |
2430 | { | |
2431 | if((conf_cur_block = find_top_conf(block)) == NULL) | |
2432 | { | |
2433 | conf_report_error("Configuration block '%s' is not defined.", block); | |
2434 | return -1; | |
2435 | } | |
2436 | ||
2437 | if(name) | |
47a03750 | 2438 | conf_cur_block_name = rb_strdup(name); |
212380e3 AC |
2439 | else |
2440 | conf_cur_block_name = NULL; | |
2441 | ||
2442 | if(conf_cur_block->tc_sfunc) | |
2443 | if(conf_cur_block->tc_sfunc(conf_cur_block) < 0) | |
2444 | return -1; | |
2445 | ||
2446 | return 0; | |
2447 | } | |
2448 | ||
2449 | int | |
2450 | conf_end_block(struct TopConf *tc) | |
2451 | { | |
e12981c0 | 2452 | int ret = 0; |
212380e3 | 2453 | if(tc->tc_efunc) |
e12981c0 | 2454 | ret = tc->tc_efunc(tc); |
212380e3 | 2455 | |
637c4932 | 2456 | rb_free(conf_cur_block_name); |
e12981c0 KB |
2457 | conf_cur_block_name = NULL; |
2458 | return ret; | |
212380e3 AC |
2459 | } |
2460 | ||
2461 | static void | |
2462 | conf_set_generic_int(void *data, void *location) | |
2463 | { | |
2464 | *((int *) location) = *((unsigned int *) data); | |
2465 | } | |
2466 | ||
2467 | static void | |
2468 | conf_set_generic_string(void *data, int len, void *location) | |
2469 | { | |
2470 | char **loc = location; | |
2471 | char *input = data; | |
2472 | ||
2e819b6b | 2473 | if(len && strlen(input) > (unsigned int)len) |
212380e3 AC |
2474 | input[len] = '\0'; |
2475 | ||
637c4932 | 2476 | rb_free(*loc); |
47a03750 | 2477 | *loc = rb_strdup(input); |
212380e3 AC |
2478 | } |
2479 | ||
2480 | int | |
dceac3e4 | 2481 | conf_call_set(struct TopConf *tc, char *item, conf_parm_t * value) |
212380e3 AC |
2482 | { |
2483 | struct ConfEntry *cf; | |
2484 | conf_parm_t *cp; | |
2485 | ||
2486 | if(!tc) | |
2487 | return -1; | |
2488 | ||
2489 | if((cf = find_conf_item(tc, item)) == NULL) | |
2490 | { | |
2491 | conf_report_error | |
ffa79a95 | 2492 | ("Non-existent configuration setting %s::%s.", tc->tc_name, (char *) item); |
212380e3 AC |
2493 | return -1; |
2494 | } | |
2495 | ||
2496 | /* if it takes one thing, make sure they only passed one thing, | |
2497 | and handle as needed. */ | |
ed45dfe6 | 2498 | if((value->v.list->type & CF_FLIST) && !(cf->cf_type & CF_FLIST)) |
212380e3 AC |
2499 | { |
2500 | conf_report_error | |
2501 | ("Option %s::%s does not take a list of values.", tc->tc_name, item); | |
2502 | return -1; | |
2503 | } | |
2504 | ||
2505 | cp = value->v.list; | |
2506 | ||
2507 | ||
2508 | if(CF_TYPE(value->v.list->type) != CF_TYPE(cf->cf_type)) | |
2509 | { | |
023c36ae | 2510 | /* if it expects a string value, but we got a yesno, |
212380e3 AC |
2511 | * convert it back |
2512 | */ | |
2513 | if((CF_TYPE(value->v.list->type) == CF_YESNO) && | |
2514 | (CF_TYPE(cf->cf_type) == CF_STRING)) | |
2515 | { | |
2516 | value->v.list->type = CF_STRING; | |
2517 | ||
2518 | if(cp->v.number == 1) | |
47a03750 | 2519 | cp->v.string = rb_strdup("yes"); |
212380e3 | 2520 | else |
47a03750 | 2521 | cp->v.string = rb_strdup("no"); |
212380e3 AC |
2522 | } |
2523 | ||
2524 | /* maybe it's a CF_TIME and they passed CF_INT -- | |
2525 | should still be valid */ | |
2526 | else if(!((CF_TYPE(value->v.list->type) == CF_INT) && | |
2527 | (CF_TYPE(cf->cf_type) == CF_TIME))) | |
2528 | { | |
2529 | conf_report_error | |
2530 | ("Wrong type for %s::%s (expected %s, got %s)", | |
2531 | tc->tc_name, (char *) item, | |
2532 | conf_strtype(cf->cf_type), conf_strtype(value->v.list->type)); | |
2533 | return -1; | |
2534 | } | |
2535 | } | |
2536 | ||
2537 | if(cf->cf_type & CF_FLIST) | |
2538 | { | |
2539 | #if 0 | |
2540 | if(cf->cf_arg) | |
2541 | conf_set_generic_list(value->v.list, cf->cf_arg); | |
2542 | else | |
2543 | #endif | |
2544 | /* just pass it the extended argument list */ | |
2545 | cf->cf_func(value->v.list); | |
2546 | } | |
2547 | else | |
2548 | { | |
2549 | /* it's old-style, needs only one arg */ | |
2550 | switch (cf->cf_type) | |
2551 | { | |
2552 | case CF_INT: | |
2553 | case CF_TIME: | |
2554 | case CF_YESNO: | |
2555 | if(cf->cf_arg) | |
2556 | conf_set_generic_int(&cp->v.number, cf->cf_arg); | |
2557 | else | |
2558 | cf->cf_func(&cp->v.number); | |
2559 | break; | |
2560 | case CF_STRING: | |
2561 | case CF_QSTRING: | |
2562 | if(EmptyString(cp->v.string)) | |
2563 | conf_report_error("Ignoring %s::%s -- empty field", | |
2564 | tc->tc_name, item); | |
2565 | else if(cf->cf_arg) | |
2566 | conf_set_generic_string(cp->v.string, cf->cf_len, cf->cf_arg); | |
2567 | else | |
2568 | cf->cf_func(cp->v.string); | |
2569 | break; | |
2570 | } | |
2571 | } | |
2572 | ||
2573 | ||
2574 | return 0; | |
2575 | } | |
2576 | ||
2577 | int | |
2578 | add_conf_item(const char *topconf, const char *name, int type, void (*func) (void *)) | |
2579 | { | |
2580 | struct TopConf *tc; | |
2581 | struct ConfEntry *cf; | |
2582 | ||
2583 | if((tc = find_top_conf(topconf)) == NULL) | |
2584 | return -1; | |
2585 | ||
12edf3e3 | 2586 | if(find_conf_item(tc, name) != NULL) |
212380e3 AC |
2587 | return -1; |
2588 | ||
eddc2ab6 | 2589 | cf = rb_malloc(sizeof(struct ConfEntry)); |
212380e3 | 2590 | |
d7f753cd | 2591 | cf->cf_name = name; |
212380e3 AC |
2592 | cf->cf_type = type; |
2593 | cf->cf_func = func; | |
2594 | cf->cf_arg = NULL; | |
2595 | ||
330fc5c1 | 2596 | rb_dlinkAddAlloc(cf, &tc->tc_items); |
212380e3 AC |
2597 | |
2598 | return 0; | |
2599 | } | |
2600 | ||
2601 | int | |
2602 | remove_conf_item(const char *topconf, const char *name) | |
2603 | { | |
2604 | struct TopConf *tc; | |
2605 | struct ConfEntry *cf; | |
330fc5c1 | 2606 | rb_dlink_node *ptr; |
212380e3 AC |
2607 | |
2608 | if((tc = find_top_conf(topconf)) == NULL) | |
2609 | return -1; | |
2610 | ||
2611 | if((cf = find_conf_item(tc, name)) == NULL) | |
2612 | return -1; | |
2613 | ||
330fc5c1 | 2614 | if((ptr = rb_dlinkFind(cf, &tc->tc_items)) == NULL) |
212380e3 AC |
2615 | return -1; |
2616 | ||
330fc5c1 | 2617 | rb_dlinkDestroy(ptr, &tc->tc_items); |
637c4932 | 2618 | rb_free(cf); |
212380e3 AC |
2619 | |
2620 | return 0; | |
2621 | } | |
2622 | ||
2623 | /* *INDENT-OFF* */ | |
2624 | static struct ConfEntry conf_serverinfo_table[] = | |
2625 | { | |
2626 | { "description", CF_QSTRING, NULL, 0, &ServerInfo.description }, | |
212380e3 AC |
2627 | |
2628 | { "network_name", CF_QSTRING, conf_set_serverinfo_network_name, 0, NULL }, | |
2629 | { "name", CF_QSTRING, conf_set_serverinfo_name, 0, NULL }, | |
2630 | { "sid", CF_QSTRING, conf_set_serverinfo_sid, 0, NULL }, | |
2631 | { "vhost", CF_QSTRING, conf_set_serverinfo_vhost, 0, NULL }, | |
2632 | { "vhost6", CF_QSTRING, conf_set_serverinfo_vhost6, 0, NULL }, | |
2633 | ||
8bd5767b JT |
2634 | { "ssl_private_key", CF_QSTRING, NULL, 0, &ServerInfo.ssl_private_key }, |
2635 | { "ssl_ca_cert", CF_QSTRING, NULL, 0, &ServerInfo.ssl_ca_cert }, | |
023c36ae | 2636 | { "ssl_cert", CF_QSTRING, NULL, 0, &ServerInfo.ssl_cert }, |
8bd5767b | 2637 | { "ssl_dh_params", CF_QSTRING, NULL, 0, &ServerInfo.ssl_dh_params }, |
c1725bda | 2638 | { "ssl_cipher_list", CF_QSTRING, NULL, 0, &ServerInfo.ssl_cipher_list }, |
c6d72037 VY |
2639 | { "ssld_count", CF_INT, NULL, 0, &ServerInfo.ssld_count }, |
2640 | ||
101db4c4 | 2641 | { "default_max_clients",CF_INT, NULL, 0, &ServerInfo.default_max_clients }, |
c2d96fcb | 2642 | |
b583faf9 AC |
2643 | { "nicklen", CF_INT, conf_set_serverinfo_nicklen, 0, NULL }, |
2644 | ||
212380e3 AC |
2645 | { "\0", 0, NULL, 0, NULL } |
2646 | }; | |
2647 | ||
2648 | static struct ConfEntry conf_admin_table[] = | |
2649 | { | |
2650 | { "name", CF_QSTRING, NULL, 200, &AdminInfo.name }, | |
2651 | { "description",CF_QSTRING, NULL, 200, &AdminInfo.description }, | |
2652 | { "email", CF_QSTRING, NULL, 200, &AdminInfo.email }, | |
2653 | { "\0", 0, NULL, 0, NULL } | |
2654 | }; | |
2655 | ||
2656 | static struct ConfEntry conf_log_table[] = | |
2657 | { | |
d74fa5b5 JT |
2658 | { "fname_userlog", CF_QSTRING, NULL, PATH_MAX, &ConfigFileEntry.fname_userlog }, |
2659 | { "fname_fuserlog", CF_QSTRING, NULL, PATH_MAX, &ConfigFileEntry.fname_fuserlog }, | |
2660 | { "fname_operlog", CF_QSTRING, NULL, PATH_MAX, &ConfigFileEntry.fname_operlog }, | |
2661 | { "fname_foperlog", CF_QSTRING, NULL, PATH_MAX, &ConfigFileEntry.fname_foperlog }, | |
2662 | { "fname_serverlog", CF_QSTRING, NULL, PATH_MAX, &ConfigFileEntry.fname_serverlog }, | |
2663 | { "fname_killlog", CF_QSTRING, NULL, PATH_MAX, &ConfigFileEntry.fname_killlog }, | |
2664 | { "fname_klinelog", CF_QSTRING, NULL, PATH_MAX, &ConfigFileEntry.fname_klinelog }, | |
2665 | { "fname_operspylog", CF_QSTRING, NULL, PATH_MAX, &ConfigFileEntry.fname_operspylog }, | |
2666 | { "fname_ioerrorlog", CF_QSTRING, NULL, PATH_MAX, &ConfigFileEntry.fname_ioerrorlog }, | |
212380e3 AC |
2667 | { "\0", 0, NULL, 0, NULL } |
2668 | }; | |
2669 | ||
2670 | static struct ConfEntry conf_operator_table[] = | |
2671 | { | |
2672 | { "rsa_public_key_file", CF_QSTRING, conf_set_oper_rsa_public_key_file, 0, NULL }, | |
2673 | { "flags", CF_STRING | CF_FLIST, conf_set_oper_flags, 0, NULL }, | |
2674 | { "umodes", CF_STRING | CF_FLIST, conf_set_oper_umodes, 0, NULL }, | |
22c3b270 | 2675 | { "privset", CF_QSTRING, conf_set_oper_privset, 0, NULL }, |
212380e3 AC |
2676 | { "snomask", CF_QSTRING, conf_set_oper_snomask, 0, NULL }, |
2677 | { "user", CF_QSTRING, conf_set_oper_user, 0, NULL }, | |
2678 | { "password", CF_QSTRING, conf_set_oper_password, 0, NULL }, | |
ff31db84 | 2679 | { "fingerprint", CF_QSTRING, conf_set_oper_fingerprint, 0, NULL }, |
212380e3 AC |
2680 | { "\0", 0, NULL, 0, NULL } |
2681 | }; | |
2682 | ||
f8606875 AC |
2683 | static struct ConfEntry conf_privset_table[] = |
2684 | { | |
2685 | { "extends", CF_QSTRING, conf_set_privset_extends, 0, NULL }, | |
2686 | { "privs", CF_STRING | CF_FLIST, conf_set_privset_privs, 0, NULL }, | |
2687 | { "\0", 0, NULL, 0, NULL } | |
2688 | }; | |
2689 | ||
212380e3 AC |
2690 | static struct ConfEntry conf_class_table[] = |
2691 | { | |
2692 | { "ping_time", CF_TIME, conf_set_class_ping_time, 0, NULL }, | |
e33e589c JT |
2693 | { "cidr_ipv4_bitlen", CF_INT, conf_set_class_cidr_ipv4_bitlen, 0, NULL }, |
2694 | #ifdef RB_IPV6 | |
2695 | { "cidr_ipv6_bitlen", CF_INT, conf_set_class_cidr_ipv6_bitlen, 0, NULL }, | |
2696 | #endif | |
212380e3 AC |
2697 | { "number_per_cidr", CF_INT, conf_set_class_number_per_cidr, 0, NULL }, |
2698 | { "number_per_ip", CF_INT, conf_set_class_number_per_ip, 0, NULL }, | |
2699 | { "number_per_ip_global", CF_INT,conf_set_class_number_per_ip_global, 0, NULL }, | |
2700 | { "number_per_ident", CF_INT, conf_set_class_number_per_ident, 0, NULL }, | |
2701 | { "connectfreq", CF_TIME, conf_set_class_connectfreq, 0, NULL }, | |
2702 | { "max_number", CF_INT, conf_set_class_max_number, 0, NULL }, | |
2703 | { "sendq", CF_TIME, conf_set_class_sendq, 0, NULL }, | |
2704 | { "\0", 0, NULL, 0, NULL } | |
2705 | }; | |
2706 | ||
2707 | static struct ConfEntry conf_auth_table[] = | |
2708 | { | |
2709 | { "user", CF_QSTRING, conf_set_auth_user, 0, NULL }, | |
40c1fd47 | 2710 | { "auth_user", CF_QSTRING, conf_set_auth_auth_user, 0, NULL }, |
212380e3 AC |
2711 | { "password", CF_QSTRING, conf_set_auth_passwd, 0, NULL }, |
2712 | { "class", CF_QSTRING, conf_set_auth_class, 0, NULL }, | |
2713 | { "spoof", CF_QSTRING, conf_set_auth_spoof, 0, NULL }, | |
2714 | { "redirserv", CF_QSTRING, conf_set_auth_redir_serv, 0, NULL }, | |
2715 | { "redirport", CF_INT, conf_set_auth_redir_port, 0, NULL }, | |
2716 | { "flags", CF_STRING | CF_FLIST, conf_set_auth_flags, 0, NULL }, | |
2717 | { "\0", 0, NULL, 0, NULL } | |
2718 | }; | |
2719 | ||
2720 | static struct ConfEntry conf_connect_table[] = | |
2721 | { | |
2722 | { "send_password", CF_QSTRING, conf_set_connect_send_password, 0, NULL }, | |
2723 | { "accept_password", CF_QSTRING, conf_set_connect_accept_password, 0, NULL }, | |
ff0cc1e6 | 2724 | { "fingerprint", CF_QSTRING, conf_set_connect_fingerprint, 0, NULL }, |
212380e3 AC |
2725 | { "flags", CF_STRING | CF_FLIST, conf_set_connect_flags, 0, NULL }, |
2726 | { "host", CF_QSTRING, conf_set_connect_host, 0, NULL }, | |
2727 | { "vhost", CF_QSTRING, conf_set_connect_vhost, 0, NULL }, | |
2728 | { "port", CF_INT, conf_set_connect_port, 0, NULL }, | |
2729 | { "aftype", CF_STRING, conf_set_connect_aftype, 0, NULL }, | |
2730 | { "hub_mask", CF_QSTRING, conf_set_connect_hub_mask, 0, NULL }, | |
2731 | { "leaf_mask", CF_QSTRING, conf_set_connect_leaf_mask, 0, NULL }, | |
2732 | { "class", CF_QSTRING, conf_set_connect_class, 0, NULL }, | |
2733 | { "\0", 0, NULL, 0, NULL } | |
2734 | }; | |
2735 | ||
2736 | static struct ConfEntry conf_general_table[] = | |
2737 | { | |
2738 | { "oper_only_umodes", CF_STRING | CF_FLIST, conf_set_general_oper_only_umodes, 0, NULL }, | |
2739 | { "oper_umodes", CF_STRING | CF_FLIST, conf_set_general_oper_umodes, 0, NULL }, | |
2740 | { "oper_snomask", CF_QSTRING, conf_set_general_oper_snomask, 0, NULL }, | |
2741 | { "compression_level", CF_INT, conf_set_general_compression_level, 0, NULL }, | |
2742 | { "havent_read_conf", CF_YESNO, conf_set_general_havent_read_conf, 0, NULL }, | |
2743 | { "hide_error_messages",CF_STRING, conf_set_general_hide_error_messages,0, NULL }, | |
2744 | { "kline_delay", CF_TIME, conf_set_general_kline_delay, 0, NULL }, | |
2745 | { "stats_k_oper_only", CF_STRING, conf_set_general_stats_k_oper_only, 0, NULL }, | |
2746 | { "stats_i_oper_only", CF_STRING, conf_set_general_stats_i_oper_only, 0, NULL }, | |
2747 | { "default_umodes", CF_QSTRING, conf_set_general_default_umodes, 0, NULL }, | |
2748 | ||
2749 | { "default_operstring", CF_QSTRING, NULL, REALLEN, &ConfigFileEntry.default_operstring }, | |
2750 | { "default_adminstring",CF_QSTRING, NULL, REALLEN, &ConfigFileEntry.default_adminstring }, | |
2751 | { "servicestring", CF_QSTRING, NULL, REALLEN, &ConfigFileEntry.servicestring }, | |
212380e3 AC |
2752 | { "kline_reason", CF_QSTRING, NULL, REALLEN, &ConfigFileEntry.kline_reason }, |
2753 | { "identify_service", CF_QSTRING, NULL, REALLEN, &ConfigFileEntry.identifyservice }, | |
2754 | { "identify_command", CF_QSTRING, NULL, REALLEN, &ConfigFileEntry.identifycommand }, | |
7d33cce8 | 2755 | { "sasl_service", CF_QSTRING, NULL, REALLEN, &ConfigFileEntry.sasl_service }, |
212380e3 AC |
2756 | |
2757 | { "anti_spam_exit_message_time", CF_TIME, NULL, 0, &ConfigFileEntry.anti_spam_exit_message_time }, | |
2758 | { "disable_fake_channels", CF_YESNO, NULL, 0, &ConfigFileEntry.disable_fake_channels }, | |
2759 | { "min_nonwildcard_simple", CF_INT, NULL, 0, &ConfigFileEntry.min_nonwildcard_simple }, | |
2760 | { "non_redundant_klines", CF_YESNO, NULL, 0, &ConfigFileEntry.non_redundant_klines }, | |
2761 | { "tkline_expire_notices", CF_YESNO, NULL, 0, &ConfigFileEntry.tkline_expire_notices }, | |
2762 | ||
2763 | { "anti_nick_flood", CF_YESNO, NULL, 0, &ConfigFileEntry.anti_nick_flood }, | |
2764 | { "burst_away", CF_YESNO, NULL, 0, &ConfigFileEntry.burst_away }, | |
2765 | { "caller_id_wait", CF_TIME, NULL, 0, &ConfigFileEntry.caller_id_wait }, | |
2766 | { "client_exit", CF_YESNO, NULL, 0, &ConfigFileEntry.client_exit }, | |
212380e3 | 2767 | { "collision_fnc", CF_YESNO, NULL, 0, &ConfigFileEntry.collision_fnc }, |
330692a1 | 2768 | { "resv_fnc", CF_YESNO, NULL, 0, &ConfigFileEntry.resv_fnc }, |
212380e3 AC |
2769 | { "connect_timeout", CF_TIME, NULL, 0, &ConfigFileEntry.connect_timeout }, |
2770 | { "default_floodcount", CF_INT, NULL, 0, &ConfigFileEntry.default_floodcount }, | |
944b0584 | 2771 | { "default_ident_timeout", CF_INT, NULL, 0, &ConfigFileEntry.default_ident_timeout }, |
212380e3 | 2772 | { "disable_auth", CF_YESNO, NULL, 0, &ConfigFileEntry.disable_auth }, |
212380e3 AC |
2773 | { "dots_in_ident", CF_INT, NULL, 0, &ConfigFileEntry.dots_in_ident }, |
2774 | { "failed_oper_notice", CF_YESNO, NULL, 0, &ConfigFileEntry.failed_oper_notice }, | |
212380e3 | 2775 | { "global_snotices", CF_YESNO, NULL, 0, &ConfigFileEntry.global_snotices }, |
212380e3 AC |
2776 | { "hide_spoof_ips", CF_YESNO, NULL, 0, &ConfigFileEntry.hide_spoof_ips }, |
2777 | { "dline_with_reason", CF_YESNO, NULL, 0, &ConfigFileEntry.dline_with_reason }, | |
2778 | { "kline_with_reason", CF_YESNO, NULL, 0, &ConfigFileEntry.kline_with_reason }, | |
2779 | { "map_oper_only", CF_YESNO, NULL, 0, &ConfigFileEntry.map_oper_only }, | |
2780 | { "max_accept", CF_INT, NULL, 0, &ConfigFileEntry.max_accept }, | |
2781 | { "max_monitor", CF_INT, NULL, 0, &ConfigFileEntry.max_monitor }, | |
2782 | { "max_nick_time", CF_TIME, NULL, 0, &ConfigFileEntry.max_nick_time }, | |
2783 | { "max_nick_changes", CF_INT, NULL, 0, &ConfigFileEntry.max_nick_changes }, | |
2784 | { "max_targets", CF_INT, NULL, 0, &ConfigFileEntry.max_targets }, | |
2785 | { "min_nonwildcard", CF_INT, NULL, 0, &ConfigFileEntry.min_nonwildcard }, | |
2786 | { "nick_delay", CF_TIME, NULL, 0, &ConfigFileEntry.nick_delay }, | |
2787 | { "no_oper_flood", CF_YESNO, NULL, 0, &ConfigFileEntry.no_oper_flood }, | |
2788 | { "operspy_admin_only", CF_YESNO, NULL, 0, &ConfigFileEntry.operspy_admin_only }, | |
2789 | { "operspy_dont_care_user_info", CF_YESNO, NULL, 0, &ConfigFileEntry.operspy_dont_care_user_info }, | |
2790 | { "pace_wait", CF_TIME, NULL, 0, &ConfigFileEntry.pace_wait }, | |
2791 | { "pace_wait_simple", CF_TIME, NULL, 0, &ConfigFileEntry.pace_wait_simple }, | |
2792 | { "ping_cookie", CF_YESNO, NULL, 0, &ConfigFileEntry.ping_cookie }, | |
2793 | { "reject_after_count", CF_INT, NULL, 0, &ConfigFileEntry.reject_after_count }, | |
2794 | { "reject_ban_time", CF_TIME, NULL, 0, &ConfigFileEntry.reject_ban_time }, | |
2795 | { "reject_duration", CF_TIME, NULL, 0, &ConfigFileEntry.reject_duration }, | |
43946961 JT |
2796 | { "throttle_count", CF_INT, NULL, 0, &ConfigFileEntry.throttle_count }, |
2797 | { "throttle_duration", CF_TIME, NULL, 0, &ConfigFileEntry.throttle_duration }, | |
212380e3 AC |
2798 | { "short_motd", CF_YESNO, NULL, 0, &ConfigFileEntry.short_motd }, |
2799 | { "stats_c_oper_only", CF_YESNO, NULL, 0, &ConfigFileEntry.stats_c_oper_only }, | |
2800 | { "stats_e_disabled", CF_YESNO, NULL, 0, &ConfigFileEntry.stats_e_disabled }, | |
2801 | { "stats_h_oper_only", CF_YESNO, NULL, 0, &ConfigFileEntry.stats_h_oper_only }, | |
2802 | { "stats_o_oper_only", CF_YESNO, NULL, 0, &ConfigFileEntry.stats_o_oper_only }, | |
2803 | { "stats_P_oper_only", CF_YESNO, NULL, 0, &ConfigFileEntry.stats_P_oper_only }, | |
2804 | { "stats_y_oper_only", CF_YESNO, NULL, 0, &ConfigFileEntry.stats_y_oper_only }, | |
2805 | { "target_change", CF_YESNO, NULL, 0, &ConfigFileEntry.target_change }, | |
2806 | { "ts_max_delta", CF_TIME, NULL, 0, &ConfigFileEntry.ts_max_delta }, | |
212380e3 AC |
2807 | { "ts_warn_delta", CF_TIME, NULL, 0, &ConfigFileEntry.ts_warn_delta }, |
2808 | { "use_whois_actually", CF_YESNO, NULL, 0, &ConfigFileEntry.use_whois_actually }, | |
2809 | { "warn_no_nline", CF_YESNO, NULL, 0, &ConfigFileEntry.warn_no_nline }, | |
1702b694 | 2810 | { "use_propagated_bans",CF_YESNO, NULL, 0, &ConfigFileEntry.use_propagated_bans }, |
e6e54763 SB |
2811 | { "client_flood_max_lines", CF_INT, NULL, 0, &ConfigFileEntry.client_flood_max_lines }, |
2812 | { "client_flood_burst_rate", CF_INT, NULL, 0, &ConfigFileEntry.client_flood_burst_rate }, | |
2813 | { "client_flood_burst_max", CF_INT, NULL, 0, &ConfigFileEntry.client_flood_burst_max }, | |
2814 | { "client_flood_message_num", CF_INT, NULL, 0, &ConfigFileEntry.client_flood_message_num }, | |
2815 | { "client_flood_message_time", CF_INT, NULL, 0, &ConfigFileEntry.client_flood_message_time }, | |
e88a1f1b | 2816 | { "max_ratelimit_tokens", CF_INT, NULL, 0, &ConfigFileEntry.max_ratelimit_tokens }, |
d42e6915 | 2817 | { "away_interval", CF_INT, NULL, 0, &ConfigFileEntry.away_interval }, |
71c95533 | 2818 | { "hide_opers_in_whois", CF_YESNO, NULL, 0, &ConfigFileEntry.hide_opers_in_whois }, |
13d8f0ed | 2819 | { "certfp_method", CF_STRING, conf_set_general_certfp_method, 0, NULL }, |
212380e3 AC |
2820 | { "\0", 0, NULL, 0, NULL } |
2821 | }; | |
2822 | ||
2823 | static struct ConfEntry conf_channel_table[] = | |
2824 | { | |
2825 | { "default_split_user_count", CF_INT, NULL, 0, &ConfigChannel.default_split_user_count }, | |
2826 | { "default_split_server_count", CF_INT, NULL, 0, &ConfigChannel.default_split_server_count }, | |
2827 | { "burst_topicwho", CF_YESNO, NULL, 0, &ConfigChannel.burst_topicwho }, | |
212380e3 AC |
2828 | { "kick_on_split_riding", CF_YESNO, NULL, 0, &ConfigChannel.kick_on_split_riding }, |
2829 | { "knock_delay", CF_TIME, NULL, 0, &ConfigChannel.knock_delay }, | |
2830 | { "knock_delay_channel",CF_TIME, NULL, 0, &ConfigChannel.knock_delay_channel }, | |
2831 | { "max_bans", CF_INT, NULL, 0, &ConfigChannel.max_bans }, | |
2832 | { "max_bans_large", CF_INT, NULL, 0, &ConfigChannel.max_bans_large }, | |
2833 | { "max_chans_per_user", CF_INT, NULL, 0, &ConfigChannel.max_chans_per_user }, | |
a4721f5e | 2834 | { "max_chans_per_user_large", CF_INT, NULL, 0, &ConfigChannel.max_chans_per_user_large }, |
212380e3 AC |
2835 | { "no_create_on_split", CF_YESNO, NULL, 0, &ConfigChannel.no_create_on_split }, |
2836 | { "no_join_on_split", CF_YESNO, NULL, 0, &ConfigChannel.no_join_on_split }, | |
6865c0b0 | 2837 | { "only_ascii_channels", CF_YESNO, NULL, 0, &ConfigChannel.only_ascii_channels }, |
212380e3 AC |
2838 | { "use_except", CF_YESNO, NULL, 0, &ConfigChannel.use_except }, |
2839 | { "use_invex", CF_YESNO, NULL, 0, &ConfigChannel.use_invex }, | |
2da6f6eb | 2840 | { "use_forward", CF_YESNO, NULL, 0, &ConfigChannel.use_forward }, |
212380e3 | 2841 | { "use_knock", CF_YESNO, NULL, 0, &ConfigChannel.use_knock }, |
c2c25552 | 2842 | { "resv_forcepart", CF_YESNO, NULL, 0, &ConfigChannel.resv_forcepart }, |
717238d2 | 2843 | { "channel_target_change", CF_YESNO, NULL, 0, &ConfigChannel.channel_target_change }, |
341f971e | 2844 | { "disable_local_channels", CF_YESNO, NULL, 0, &ConfigChannel.disable_local_channels }, |
63eb8567 | 2845 | { "autochanmodes", CF_QSTRING, conf_set_channel_autochanmodes, 0, NULL }, |
d513218a | 2846 | { "displayed_usercount", CF_INT, NULL, 0, &ConfigChannel.displayed_usercount }, |
14482679 | 2847 | { "strip_topic_colors", CF_YESNO, NULL, 0, &ConfigChannel.strip_topic_colors }, |
212380e3 AC |
2848 | { "\0", 0, NULL, 0, NULL } |
2849 | }; | |
2850 | ||
2851 | static struct ConfEntry conf_serverhide_table[] = | |
2852 | { | |
2853 | { "disable_hidden", CF_YESNO, NULL, 0, &ConfigServerHide.disable_hidden }, | |
2854 | { "flatten_links", CF_YESNO, NULL, 0, &ConfigServerHide.flatten_links }, | |
2855 | { "hidden", CF_YESNO, NULL, 0, &ConfigServerHide.hidden }, | |
2856 | { "links_delay", CF_TIME, conf_set_serverhide_links_delay, 0, NULL }, | |
2857 | { "\0", 0, NULL, 0, NULL } | |
2858 | }; | |
2859 | /* *INDENT-ON* */ | |
2860 | ||
2861 | void | |
2862 | newconf_init() | |
2863 | { | |
2864 | add_top_conf("modules", NULL, NULL, NULL); | |
2865 | add_conf_item("modules", "path", CF_QSTRING, conf_set_modules_path); | |
2866 | add_conf_item("modules", "module", CF_QSTRING, conf_set_modules_module); | |
2867 | ||
2868 | add_top_conf("serverinfo", NULL, NULL, conf_serverinfo_table); | |
2869 | add_top_conf("admin", NULL, NULL, conf_admin_table); | |
2870 | add_top_conf("log", NULL, NULL, conf_log_table); | |
2871 | add_top_conf("operator", conf_begin_oper, conf_end_oper, conf_operator_table); | |
2872 | add_top_conf("class", conf_begin_class, conf_end_class, conf_class_table); | |
f8606875 | 2873 | add_top_conf("privset", NULL, NULL, conf_privset_table); |
212380e3 AC |
2874 | |
2875 | add_top_conf("listen", conf_begin_listen, conf_end_listen, NULL); | |
02270e96 | 2876 | add_conf_item("listen", "defer_accept", CF_YESNO, conf_set_listen_defer_accept); |
c53ca1e0 | 2877 | add_conf_item("listen", "wsock", CF_YESNO, conf_set_listen_wsock); |
212380e3 | 2878 | add_conf_item("listen", "port", CF_INT | CF_FLIST, conf_set_listen_port); |
c6d72037 | 2879 | add_conf_item("listen", "sslport", CF_INT | CF_FLIST, conf_set_listen_sslport); |
212380e3 AC |
2880 | add_conf_item("listen", "ip", CF_QSTRING, conf_set_listen_address); |
2881 | add_conf_item("listen", "host", CF_QSTRING, conf_set_listen_address); | |
2882 | ||
2883 | add_top_conf("auth", conf_begin_auth, conf_end_auth, conf_auth_table); | |
2884 | ||
2885 | add_top_conf("shared", conf_cleanup_shared, conf_cleanup_shared, NULL); | |
dceac3e4 | 2886 | add_conf_item("shared", "oper", CF_QSTRING | CF_FLIST, conf_set_shared_oper); |
212380e3 AC |
2887 | add_conf_item("shared", "flags", CF_STRING | CF_FLIST, conf_set_shared_flags); |
2888 | ||
2889 | add_top_conf("connect", conf_begin_connect, conf_end_connect, conf_connect_table); | |
2890 | ||
2891 | add_top_conf("exempt", NULL, NULL, NULL); | |
2892 | add_conf_item("exempt", "ip", CF_QSTRING, conf_set_exempt_ip); | |
2893 | ||
2894 | add_top_conf("cluster", conf_cleanup_cluster, conf_cleanup_cluster, NULL); | |
2895 | add_conf_item("cluster", "name", CF_QSTRING, conf_set_cluster_name); | |
2896 | add_conf_item("cluster", "flags", CF_STRING | CF_FLIST, conf_set_cluster_flags); | |
2897 | ||
2898 | add_top_conf("general", NULL, NULL, conf_general_table); | |
2899 | add_top_conf("channel", NULL, NULL, conf_channel_table); | |
2900 | add_top_conf("serverhide", NULL, NULL, conf_serverhide_table); | |
2901 | ||
c46a4ecd | 2902 | add_top_conf("service", NULL, NULL, NULL); |
212380e3 AC |
2903 | add_conf_item("service", "name", CF_QSTRING, conf_set_service_name); |
2904 | ||
2905 | add_top_conf("alias", conf_begin_alias, conf_end_alias, NULL); | |
2906 | add_conf_item("alias", "name", CF_QSTRING, conf_set_alias_name); | |
2907 | add_conf_item("alias", "target", CF_QSTRING, conf_set_alias_target); | |
2908 | ||
2909 | add_top_conf("blacklist", NULL, NULL, NULL); | |
2910 | add_conf_item("blacklist", "host", CF_QSTRING, conf_set_blacklist_host); | |
0a1e77c2 | 2911 | add_conf_item("blacklist", "type", CF_STRING | CF_FLIST, conf_set_blacklist_type); |
3c93d380 | 2912 | add_conf_item("blacklist", "matches", CF_QSTRING | CF_FLIST, conf_set_blacklist_matches); |
212380e3 | 2913 | add_conf_item("blacklist", "reject_reason", CF_QSTRING, conf_set_blacklist_reason); |
8275e270 EM |
2914 | |
2915 | add_top_conf("opm", conf_begin_opm, conf_end_opm, NULL); | |
9bba0f61 | 2916 | add_conf_item("opm", "timeout", CF_INT, conf_set_opm_timeout); |
8275e270 | 2917 | add_conf_item("opm", "listen_ipv4", CF_QSTRING, conf_set_opm_listen_address_ipv4); |
8275e270 | 2918 | add_conf_item("opm", "listen_ipv6", CF_QSTRING, conf_set_opm_listen_address_ipv6); |
51fa2ab8 | 2919 | add_conf_item("opm", "port_v4", CF_INT, conf_set_opm_listen_port_ipv4); |
8275e270 EM |
2920 | add_conf_item("opm", "port_v6", CF_INT, conf_set_opm_listen_port_ipv6); |
2921 | add_conf_item("opm", "listen_port", CF_INT, conf_set_opm_listen_port); | |
51fa2ab8 EM |
2922 | add_conf_item("opm", "socks4_ports", CF_INT | CF_FLIST, conf_set_opm_scan_ports_socks4); |
2923 | add_conf_item("opm", "socks5_ports", CF_INT | CF_FLIST, conf_set_opm_scan_ports_socks5); | |
fabe8b94 | 2924 | add_conf_item("opm", "httpconnect_ports", CF_INT | CF_FLIST, conf_set_opm_scan_ports_httpconnect); |
eb0814b3 | 2925 | add_conf_item("opm", "httpsconnect_ports", CF_INT | CF_FLIST, conf_set_opm_scan_ports_httpsconnect); |
212380e3 | 2926 | } |