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