]> jfr.im git - irc/rqf/shadowircd.git/blob - src/newconf.c
Cleaned up ircd.c a bit and added additional check to ircd_die_cb()
[irc/rqf/shadowircd.git] / src / newconf.c
1 /* This code is in the public domain.
2 * $Id: newconf.c 3550 2007-08-09 06:47:26Z nenolod $
3 */
4
5 #include "stdinc.h"
6
7 #ifdef HAVE_LIBCRYPTO
8 #include <openssl/pem.h>
9 #include <openssl/rsa.h>
10 #endif
11
12 #include "newconf.h"
13 #include "ircd_defs.h"
14 #include "sprintf_irc.h"
15 #include "common.h"
16 #include "logger.h"
17 #include "s_conf.h"
18 #include "s_user.h"
19 #include "s_newconf.h"
20 #include "send.h"
21 #include "setup.h"
22 #include "modules.h"
23 #include "listener.h"
24 #include "hostmask.h"
25 #include "s_serv.h"
26 #include "hash.h"
27 #include "cache.h"
28 #include "ircd.h"
29 #include "snomask.h"
30 #include "blacklist.h"
31 #include "sslproc.h"
32
33 #define CF_TYPE(x) ((x) & CF_MTYPE)
34
35 struct TopConf *conf_cur_block;
36 static char *conf_cur_block_name;
37
38 static rb_dlink_list conf_items;
39
40 static struct ConfItem *yy_aconf = NULL;
41
42 static struct Class *yy_class = NULL;
43
44 static struct remote_conf *yy_shared = NULL;
45 static struct server_conf *yy_server = NULL;
46
47 static rb_dlink_list yy_aconf_list;
48 static rb_dlink_list yy_oper_list;
49 static rb_dlink_list yy_shared_list;
50 static rb_dlink_list yy_cluster_list;
51 static struct oper_conf *yy_oper = NULL;
52
53 static struct alias_entry *yy_alias = NULL;
54
55 static char *yy_blacklist_host = NULL;
56 static char *yy_blacklist_reason = NULL;
57
58 static const char *
59 conf_strtype(int type)
60 {
61 switch (type & CF_MTYPE)
62 {
63 case CF_INT:
64 return "integer value";
65 case CF_STRING:
66 return "unquoted string";
67 case CF_YESNO:
68 return "yes/no value";
69 case CF_QSTRING:
70 return "quoted string";
71 case CF_TIME:
72 return "time/size value";
73 default:
74 return "unknown type";
75 }
76 }
77
78 int
79 add_top_conf(const char *name, int (*sfunc) (struct TopConf *),
80 int (*efunc) (struct TopConf *), struct ConfEntry *items)
81 {
82 struct TopConf *tc;
83
84 tc = rb_malloc(sizeof(struct TopConf));
85
86 tc->tc_name = name;
87 tc->tc_sfunc = sfunc;
88 tc->tc_efunc = efunc;
89 tc->tc_entries = items;
90
91 rb_dlinkAddAlloc(tc, &conf_items);
92 return 0;
93 }
94
95 struct TopConf *
96 find_top_conf(const char *name)
97 {
98 rb_dlink_node *d;
99 struct TopConf *tc;
100
101 RB_DLINK_FOREACH(d, conf_items.head)
102 {
103 tc = d->data;
104 if(strcasecmp(tc->tc_name, name) == 0)
105 return tc;
106 }
107
108 return NULL;
109 }
110
111
112 struct ConfEntry *
113 find_conf_item(const struct TopConf *top, const char *name)
114 {
115 struct ConfEntry *cf;
116 rb_dlink_node *d;
117
118 if(top->tc_entries)
119 {
120 int i;
121
122 for(i = 0; top->tc_entries[i].cf_type; i++)
123 {
124 cf = &top->tc_entries[i];
125
126 if(!strcasecmp(cf->cf_name, name))
127 return cf;
128 }
129 }
130
131 RB_DLINK_FOREACH(d, top->tc_items.head)
132 {
133 cf = d->data;
134 if(strcasecmp(cf->cf_name, name) == 0)
135 return cf;
136 }
137
138 return NULL;
139 }
140
141 int
142 remove_top_conf(char *name)
143 {
144 struct TopConf *tc;
145 rb_dlink_node *ptr;
146
147 if((tc = find_top_conf(name)) == NULL)
148 return -1;
149
150 if((ptr = rb_dlinkFind(tc, &conf_items)) == NULL)
151 return -1;
152
153 rb_dlinkDestroy(ptr, &conf_items);
154 rb_free(tc);
155
156 return 0;
157 }
158
159 static void
160 conf_set_serverinfo_name(void *data)
161 {
162 if(ServerInfo.name == NULL)
163 {
164 const char *s;
165 int dots = 0;
166
167 for(s = data; *s != '\0'; s++)
168 {
169 if(!IsServChar(*s))
170 {
171 conf_report_error("Ignoring serverinfo::name "
172 "-- bogus servername.");
173 return;
174 }
175 else if(*s == '.')
176 ++dots;
177 }
178
179 if(!dots)
180 {
181 conf_report_error("Ignoring serverinfo::name -- must contain '.'");
182 return;
183 }
184
185 s = data;
186
187 if(IsDigit(*s))
188 {
189 conf_report_error("Ignoring serverinfo::name -- cannot begin with digit.");
190 return;
191 }
192
193 /* the ircd will exit() in main() if we dont set one */
194 if(strlen(s) <= HOSTLEN)
195 ServerInfo.name = rb_strdup((char *) data);
196 }
197 }
198
199 static void
200 conf_set_serverinfo_sid(void *data)
201 {
202 char *sid = data;
203
204 if(ServerInfo.sid[0] == '\0')
205 {
206 if(!IsDigit(sid[0]) || !IsIdChar(sid[1]) ||
207 !IsIdChar(sid[2]) || sid[3] != '\0')
208 {
209 conf_report_error("Ignoring serverinfo::sid "
210 "-- bogus sid.");
211 return;
212 }
213
214 strcpy(ServerInfo.sid, sid);
215 }
216 }
217
218 static void
219 conf_set_serverinfo_network_name(void *data)
220 {
221 char *p;
222
223 if((p = strchr((char *) data, ' ')))
224 *p = '\0';
225
226 rb_free(ServerInfo.network_name);
227 ServerInfo.network_name = rb_strdup((char *) data);
228 }
229
230 static void
231 conf_set_serverinfo_vhost(void *data)
232 {
233 if(inetpton(AF_INET, (char *) data, &ServerInfo.ip.sin_addr) <= 0)
234 {
235 conf_report_error("Invalid netmask for server IPv4 vhost (%s)", (char *) data);
236 return;
237 }
238 ServerInfo.ip.sin_family = AF_INET;
239 ServerInfo.specific_ipv4_vhost = 1;
240 }
241
242 static void
243 conf_set_serverinfo_vhost6(void *data)
244 {
245 #ifdef RB_IPV6
246 if(inetpton(AF_INET6, (char *) data, &ServerInfo.ip6.sin6_addr) <= 0)
247 {
248 conf_report_error("Invalid netmask for server IPv6 vhost (%s)", (char *) data);
249 return;
250 }
251
252 ServerInfo.specific_ipv6_vhost = 1;
253 ServerInfo.ip6.sin6_family = AF_INET6;
254 #else
255 conf_report_error("Warning -- ignoring serverinfo::vhost6 -- IPv6 support not available.");
256 #endif
257 }
258
259 static void
260 conf_set_modules_module(void *data)
261 {
262 #ifndef STATIC_MODULES
263 char *m_bn;
264
265 m_bn = irc_basename((char *) data);
266
267 if(findmodule_byname(m_bn) != -1)
268 return;
269
270 load_one_module((char *) data, 0);
271
272 rb_free(m_bn);
273 #else
274 conf_report_error("Ignoring modules::module -- loadable module support not present.");
275 #endif
276 }
277
278 static void
279 conf_set_modules_path(void *data)
280 {
281 #ifndef STATIC_MODULES
282 mod_add_path((char *) data);
283 #else
284 conf_report_error("Ignoring modules::path -- loadable module support not present.");
285 #endif
286 }
287
288 struct mode_table
289 {
290 const char *name;
291 int mode;
292 };
293
294 /* *INDENT-OFF* */
295 static struct mode_table umode_table[] = {
296 {"callerid", UMODE_CALLERID },
297 {"deaf", UMODE_DEAF },
298 {"invisible", UMODE_INVISIBLE },
299 {"locops", UMODE_LOCOPS },
300 {"noforward", UMODE_NOFORWARD },
301 {"regonlymsg", UMODE_REGONLYMSG},
302 {"servnotice", UMODE_SERVNOTICE},
303 {"wallop", UMODE_WALLOP },
304 {"operwall", UMODE_OPERWALL },
305 {NULL, 0}
306 };
307
308 static struct mode_table oper_table[] = {
309 {"encrypted", OPER_ENCRYPTED },
310 {"local_kill", OPER_LOCKILL },
311 {"global_kill", OPER_GLOBKILL|OPER_LOCKILL },
312 {"remote", OPER_REMOTE },
313 {"kline", OPER_KLINE },
314 {"unkline", OPER_UNKLINE },
315 {"gline", OPER_GLINE },
316 {"nick_changes", OPER_NICKS },
317 {"rehash", OPER_REHASH },
318 {"die", OPER_DIE },
319 {"admin", OPER_ADMIN },
320 {"hidden_admin", OPER_HADMIN },
321 {"xline", OPER_XLINE },
322 {"resv", OPER_RESV },
323 {"operwall", OPER_OPERWALL },
324 {"oper_spy", OPER_SPY },
325 {"hidden_oper", OPER_INVIS },
326 {"remoteban", OPER_REMOTEBAN },
327 {"mass_notice", OPER_MASSNOTICE },
328 {NULL, 0}
329 };
330
331 static struct mode_table auth_table[] = {
332 {"encrypted", CONF_FLAGS_ENCRYPTED },
333 {"spoof_notice", CONF_FLAGS_SPOOF_NOTICE },
334 {"exceed_limit", CONF_FLAGS_NOLIMIT },
335 {"dnsbl_exempt", CONF_FLAGS_EXEMPTDNSBL },
336 {"kline_exempt", CONF_FLAGS_EXEMPTKLINE },
337 {"gline_exempt", CONF_FLAGS_EXEMPTGLINE },
338 {"flood_exempt", CONF_FLAGS_EXEMPTFLOOD },
339 {"spambot_exempt", CONF_FLAGS_EXEMPTSPAMBOT },
340 {"shide_exempt", CONF_FLAGS_EXEMPTSHIDE },
341 {"jupe_exempt", CONF_FLAGS_EXEMPTJUPE },
342 {"resv_exempt", CONF_FLAGS_EXEMPTRESV },
343 {"no_tilde", CONF_FLAGS_NO_TILDE },
344 {"need_ident", CONF_FLAGS_NEED_IDENTD },
345 {"have_ident", CONF_FLAGS_NEED_IDENTD },
346 {"need_sasl", CONF_FLAGS_NEED_SASL },
347 {NULL, 0}
348 };
349
350 static struct mode_table connect_table[] = {
351 { "autoconn", SERVER_AUTOCONN },
352 { "compressed", SERVER_COMPRESSED },
353 { "encrypted", SERVER_ENCRYPTED },
354 { "topicburst", SERVER_TB },
355 { "ssl", SERVER_SSL },
356 { NULL, 0 },
357 };
358
359 static struct mode_table cluster_table[] = {
360 { "kline", SHARED_PKLINE },
361 { "tkline", SHARED_TKLINE },
362 { "unkline", SHARED_UNKLINE },
363 { "locops", SHARED_LOCOPS },
364 { "xline", SHARED_PXLINE },
365 { "txline", SHARED_TXLINE },
366 { "unxline", SHARED_UNXLINE },
367 { "resv", SHARED_PRESV },
368 { "tresv", SHARED_TRESV },
369 { "unresv", SHARED_UNRESV },
370 { "all", CLUSTER_ALL },
371 {NULL, 0}
372 };
373
374 static struct mode_table shared_table[] =
375 {
376 { "kline", SHARED_PKLINE|SHARED_TKLINE },
377 { "xline", SHARED_PXLINE|SHARED_TXLINE },
378 { "resv", SHARED_PRESV|SHARED_TRESV },
379 { "tkline", SHARED_TKLINE },
380 { "unkline", SHARED_UNKLINE },
381 { "txline", SHARED_TXLINE },
382 { "unxline", SHARED_UNXLINE },
383 { "tresv", SHARED_TRESV },
384 { "unresv", SHARED_UNRESV },
385 { "locops", SHARED_LOCOPS },
386 { "rehash", SHARED_REHASH },
387 { "all", SHARED_ALL },
388 { "none", 0 },
389 {NULL, 0}
390 };
391 /* *INDENT-ON* */
392
393 static int
394 find_umode(struct mode_table *tab, const char *name)
395 {
396 int i;
397
398 for (i = 0; tab[i].name; i++)
399 {
400 if(strcmp(tab[i].name, name) == 0)
401 return tab[i].mode;
402 }
403
404 return -1;
405 }
406
407 static void
408 set_modes_from_table(int *modes, const char *whatis, struct mode_table *tab, conf_parm_t * args)
409 {
410 for (; args; args = args->next)
411 {
412 const char *umode;
413 int dir = 1;
414 int mode;
415
416 if((args->type & CF_MTYPE) != CF_STRING)
417 {
418 conf_report_error("Warning -- %s is not a string; ignoring.", whatis);
419 continue;
420 }
421
422 umode = args->v.string;
423
424 if(*umode == '~')
425 {
426 dir = 0;
427 umode++;
428 }
429
430 mode = find_umode(tab, umode);
431
432 if(mode == -1)
433 {
434 conf_report_error("Warning -- unknown %s %s.", whatis, args->v.string);
435 continue;
436 }
437
438 if(mode)
439 {
440 if(dir)
441 *modes |= mode;
442 else
443 *modes &= ~mode;
444 }
445 else
446 *modes = 0;
447 }
448 }
449
450 static int
451 conf_begin_oper(struct TopConf *tc)
452 {
453 rb_dlink_node *ptr;
454 rb_dlink_node *next_ptr;
455
456 if(yy_oper != NULL)
457 {
458 free_oper_conf(yy_oper);
459 yy_oper = NULL;
460 }
461
462 RB_DLINK_FOREACH_SAFE(ptr, next_ptr, yy_oper_list.head)
463 {
464 free_oper_conf(ptr->data);
465 rb_dlinkDestroy(ptr, &yy_oper_list);
466 }
467
468 yy_oper = make_oper_conf();
469 yy_oper->flags |= OPER_ENCRYPTED|OPER_RESV|OPER_OPERWALL|OPER_REMOTEBAN|OPER_MASSNOTICE;
470
471 return 0;
472 }
473
474 static int
475 conf_end_oper(struct TopConf *tc)
476 {
477 struct oper_conf *yy_tmpoper;
478 rb_dlink_node *ptr;
479 rb_dlink_node *next_ptr;
480
481 if(conf_cur_block_name != NULL)
482 {
483 if(strlen(conf_cur_block_name) > OPERNICKLEN)
484 conf_cur_block_name[OPERNICKLEN] = '\0';
485
486 yy_oper->name = rb_strdup(conf_cur_block_name);
487 }
488
489 if(EmptyString(yy_oper->name))
490 {
491 conf_report_error("Ignoring operator block -- missing name.");
492 return 0;
493 }
494
495 #ifdef HAVE_LIBCRYPTO
496 if(EmptyString(yy_oper->passwd) && EmptyString(yy_oper->rsa_pubkey_file))
497 #else
498 if(EmptyString(yy_oper->passwd))
499 #endif
500 {
501 conf_report_error("Ignoring operator block for %s -- missing password",
502 yy_oper->name);
503 return 0;
504 }
505
506 /* now, yy_oper_list contains a stack of oper_conf's with just user
507 * and host in, yy_oper contains the rest of the information which
508 * we need to copy into each element in yy_oper_list
509 */
510 RB_DLINK_FOREACH_SAFE(ptr, next_ptr, yy_oper_list.head)
511 {
512 yy_tmpoper = ptr->data;
513
514 yy_tmpoper->name = rb_strdup(yy_oper->name);
515
516 /* could be an rsa key instead.. */
517 if(!EmptyString(yy_oper->passwd))
518 yy_tmpoper->passwd = rb_strdup(yy_oper->passwd);
519
520 yy_tmpoper->flags = yy_oper->flags;
521 yy_tmpoper->umodes = yy_oper->umodes;
522 yy_tmpoper->snomask = yy_oper->snomask;
523
524 #ifdef HAVE_LIBCRYPTO
525 if(yy_oper->rsa_pubkey_file)
526 {
527 BIO *file;
528
529 if((file = BIO_new_file(yy_oper->rsa_pubkey_file, "r")) == NULL)
530 {
531 conf_report_error("Ignoring operator block for %s -- "
532 "rsa_public_key_file cant be opened",
533 yy_tmpoper->name);
534 return 0;
535 }
536
537 yy_tmpoper->rsa_pubkey =
538 (RSA *) PEM_read_bio_RSA_PUBKEY(file, NULL, 0, NULL);
539
540 (void)BIO_set_close(file, BIO_CLOSE);
541 BIO_free(file);
542
543 if(yy_tmpoper->rsa_pubkey == NULL)
544 {
545 conf_report_error("Ignoring operator block for %s -- "
546 "rsa_public_key_file key invalid; check syntax",
547 yy_tmpoper->name);
548 return 0;
549 }
550 }
551 #endif
552
553 /* all is ok, put it on oper_conf_list */
554 rb_dlinkMoveNode(ptr, &yy_oper_list, &oper_conf_list);
555 }
556
557 free_oper_conf(yy_oper);
558 yy_oper = NULL;
559
560 return 0;
561 }
562
563 static void
564 conf_set_oper_flags(void *data)
565 {
566 conf_parm_t *args = data;
567
568 set_modes_from_table(&yy_oper->flags, "flag", oper_table, args);
569 }
570
571 static void
572 conf_set_oper_user(void *data)
573 {
574 struct oper_conf *yy_tmpoper;
575 char *p;
576 char *host = (char *) data;
577
578 yy_tmpoper = make_oper_conf();
579
580 if((p = strchr(host, '@')))
581 {
582 *p++ = '\0';
583
584 yy_tmpoper->username = rb_strdup(host);
585 yy_tmpoper->host = rb_strdup(p);
586 }
587 else
588 {
589
590 yy_tmpoper->username = rb_strdup("*");
591 yy_tmpoper->host = rb_strdup(host);
592 }
593
594 if(EmptyString(yy_tmpoper->username) || EmptyString(yy_tmpoper->host))
595 {
596 conf_report_error("Ignoring user -- missing username/host");
597 free_oper_conf(yy_tmpoper);
598 return;
599 }
600
601 rb_dlinkAddAlloc(yy_tmpoper, &yy_oper_list);
602 }
603
604 static void
605 conf_set_oper_password(void *data)
606 {
607 if(yy_oper->passwd)
608 {
609 memset(yy_oper->passwd, 0, strlen(yy_oper->passwd));
610 rb_free(yy_oper->passwd);
611 }
612
613 yy_oper->passwd = rb_strdup((char *) data);
614 }
615
616 static void
617 conf_set_oper_rsa_public_key_file(void *data)
618 {
619 #ifdef HAVE_LIBCRYPTO
620 rb_free(yy_oper->rsa_pubkey_file);
621 yy_oper->rsa_pubkey_file = rb_strdup((char *) data);
622 #else
623 conf_report_error("Warning -- ignoring rsa_public_key_file (OpenSSL support not available");
624 #endif
625 }
626
627 static void
628 conf_set_oper_umodes(void *data)
629 {
630 set_modes_from_table(&yy_oper->umodes, "umode", umode_table, data);
631 }
632
633 static void
634 conf_set_oper_snomask(void *data)
635 {
636 yy_oper->snomask = parse_snobuf_to_mask(0, (const char *) data);
637 }
638
639 static int
640 conf_begin_class(struct TopConf *tc)
641 {
642 if(yy_class)
643 free_class(yy_class);
644
645 yy_class = make_class();
646 return 0;
647 }
648
649 static int
650 conf_end_class(struct TopConf *tc)
651 {
652 if(conf_cur_block_name != NULL)
653 yy_class->class_name = rb_strdup(conf_cur_block_name);
654
655 if(EmptyString(yy_class->class_name))
656 {
657 conf_report_error("Ignoring connect block -- missing name.");
658 return 0;
659 }
660
661 add_class(yy_class);
662 yy_class = NULL;
663 return 0;
664 }
665
666 static void
667 conf_set_class_ping_time(void *data)
668 {
669 yy_class->ping_freq = *(unsigned int *) data;
670 }
671
672 static void
673 conf_set_class_cidr_bitlen(void *data)
674 {
675 #ifdef RB_IPV6
676 unsigned int maxsize = 128;
677 #else
678 unsigned int maxsize = 32;
679 #endif
680 if(*(unsigned int *) data > maxsize)
681 conf_report_error
682 ("class::cidr_bitlen argument exceeds maxsize (%d > %d) - ignoring.",
683 *(unsigned int *) data, maxsize);
684 else
685 yy_class->cidr_bitlen = *(unsigned int *) data;
686
687 }
688 static void
689 conf_set_class_number_per_cidr(void *data)
690 {
691 yy_class->cidr_amount = *(unsigned int *) data;
692 }
693
694 static void
695 conf_set_class_number_per_ip(void *data)
696 {
697 yy_class->max_local = *(unsigned int *) data;
698 }
699
700
701 static void
702 conf_set_class_number_per_ip_global(void *data)
703 {
704 yy_class->max_global = *(unsigned int *) data;
705 }
706
707 static void
708 conf_set_class_number_per_ident(void *data)
709 {
710 yy_class->max_ident = *(unsigned int *) data;
711 }
712
713 static void
714 conf_set_class_connectfreq(void *data)
715 {
716 yy_class->con_freq = *(unsigned int *) data;
717 }
718
719 static void
720 conf_set_class_max_number(void *data)
721 {
722 yy_class->max_total = *(unsigned int *) data;
723 }
724
725 static void
726 conf_set_class_sendq(void *data)
727 {
728 yy_class->max_sendq = *(unsigned int *) data;
729 }
730
731 static char *listener_address;
732
733 static int
734 conf_begin_listen(struct TopConf *tc)
735 {
736 rb_free(listener_address);
737 listener_address = NULL;
738 return 0;
739 }
740
741 static int
742 conf_end_listen(struct TopConf *tc)
743 {
744 rb_free(listener_address);
745 listener_address = NULL;
746 return 0;
747 }
748
749
750
751 static void
752 conf_set_listen_port_both(void *data, int ssl)
753 {
754 conf_parm_t *args = data;
755 for (; args; args = args->next)
756 {
757 if((args->type & CF_MTYPE) != CF_INT)
758 {
759 conf_report_error
760 ("listener::port argument is not an integer " "-- ignoring.");
761 continue;
762 }
763 if(listener_address == NULL)
764 {
765 add_listener(args->v.number, listener_address, AF_INET, ssl);
766 #ifdef RB_IPV6
767 add_listener(args->v.number, listener_address, AF_INET6, ssl);
768 #endif
769 }
770 else
771 {
772 int family;
773 #ifdef RB_IPV6
774 if(strchr(listener_address, ':') != NULL)
775 family = AF_INET6;
776 else
777 #endif
778 family = AF_INET;
779
780 add_listener(args->v.number, listener_address, family, ssl);
781
782 }
783
784 }
785 }
786
787 static void
788 conf_set_listen_port(void *data)
789 {
790 conf_set_listen_port_both(data, 0);
791 }
792
793 static void
794 conf_set_listen_sslport(void *data)
795 {
796 conf_set_listen_port_both(data, 1);
797 }
798
799 static void
800 conf_set_listen_address(void *data)
801 {
802 rb_free(listener_address);
803 listener_address = rb_strdup(data);
804 }
805
806 static int
807 conf_begin_auth(struct TopConf *tc)
808 {
809 rb_dlink_node *ptr;
810 rb_dlink_node *next_ptr;
811
812 if(yy_aconf)
813 free_conf(yy_aconf);
814
815 RB_DLINK_FOREACH_SAFE(ptr, next_ptr, yy_aconf_list.head)
816 {
817 free_conf(ptr->data);
818 rb_dlinkDestroy(ptr, &yy_aconf_list);
819 }
820
821 yy_aconf = make_conf();
822 yy_aconf->status = CONF_CLIENT;
823
824 return 0;
825 }
826
827 static int
828 conf_end_auth(struct TopConf *tc)
829 {
830 struct ConfItem *yy_tmp;
831 rb_dlink_node *ptr;
832 rb_dlink_node *next_ptr;
833
834 if(EmptyString(yy_aconf->name))
835 yy_aconf->name = rb_strdup("NOMATCH");
836
837 /* didnt even get one ->host? */
838 if(EmptyString(yy_aconf->host))
839 {
840 conf_report_error("Ignoring auth block -- missing user@host");
841 return 0;
842 }
843
844 /* so the stacking works in order.. */
845 collapse(yy_aconf->user);
846 collapse(yy_aconf->host);
847 conf_add_class_to_conf(yy_aconf);
848 add_conf_by_address(yy_aconf->host, CONF_CLIENT, yy_aconf->user, yy_aconf);
849
850 RB_DLINK_FOREACH_SAFE(ptr, next_ptr, yy_aconf_list.head)
851 {
852 yy_tmp = ptr->data;
853
854 if(yy_aconf->passwd)
855 yy_tmp->passwd = rb_strdup(yy_aconf->passwd);
856
857 /* this will always exist.. */
858 yy_tmp->name = rb_strdup(yy_aconf->name);
859
860 if(yy_aconf->className)
861 yy_tmp->className = rb_strdup(yy_aconf->className);
862
863 yy_tmp->flags = yy_aconf->flags;
864 yy_tmp->port = yy_aconf->port;
865
866 collapse(yy_tmp->user);
867 collapse(yy_tmp->host);
868
869 conf_add_class_to_conf(yy_tmp);
870
871 add_conf_by_address(yy_tmp->host, CONF_CLIENT, yy_tmp->user, yy_tmp);
872 rb_dlinkDestroy(ptr, &yy_aconf_list);
873 }
874
875 yy_aconf = NULL;
876 return 0;
877 }
878
879 static void
880 conf_set_auth_user(void *data)
881 {
882 struct ConfItem *yy_tmp;
883 char *p;
884
885 /* The first user= line doesn't allocate a new conf */
886 if(!EmptyString(yy_aconf->host))
887 {
888 yy_tmp = make_conf();
889 yy_tmp->status = CONF_CLIENT;
890 }
891 else
892 yy_tmp = yy_aconf;
893
894 if((p = strchr(data, '@')))
895 {
896 *p++ = '\0';
897
898 yy_tmp->user = rb_strdup(data);
899 yy_tmp->host = rb_strdup(p);
900 }
901 else
902 {
903 yy_tmp->user = rb_strdup("*");
904 yy_tmp->host = rb_strdup(data);
905 }
906
907 if(yy_aconf != yy_tmp)
908 rb_dlinkAddAlloc(yy_tmp, &yy_aconf_list);
909 }
910
911 static void
912 conf_set_auth_passwd(void *data)
913 {
914 if(yy_aconf->passwd)
915 memset(yy_aconf->passwd, 0, strlen(yy_aconf->passwd));
916 rb_free(yy_aconf->passwd);
917 yy_aconf->passwd = rb_strdup(data);
918 }
919
920 static void
921 conf_set_auth_spoof(void *data)
922 {
923 char *p;
924 char *user = NULL;
925 char *host = NULL;
926
927 host = data;
928
929 /* user@host spoof */
930 if((p = strchr(host, '@')) != NULL)
931 {
932 *p = '\0';
933 user = data;
934 host = p+1;
935
936 if(EmptyString(user))
937 {
938 conf_report_error("Warning -- spoof ident empty.");
939 return;
940 }
941
942 if(strlen(user) > USERLEN)
943 {
944 conf_report_error("Warning -- spoof ident length invalid.");
945 return;
946 }
947
948 if(!valid_username(user))
949 {
950 conf_report_error("Warning -- invalid spoof (ident).");
951 return;
952 }
953
954 /* this must be restored! */
955 *p = '@';
956 }
957
958 if(EmptyString(host))
959 {
960 conf_report_error("Warning -- spoof host empty.");
961 return;
962 }
963
964 if(strlen(host) > HOSTLEN)
965 {
966 conf_report_error("Warning -- spoof host length invalid.");
967 return;
968 }
969
970 if(!valid_hostname(host))
971 {
972 conf_report_error("Warning -- invalid spoof (host).");
973 return;
974 }
975
976 rb_free(yy_aconf->name);
977 yy_aconf->name = rb_strdup(data);
978 yy_aconf->flags |= CONF_FLAGS_SPOOF_IP;
979 }
980
981 static void
982 conf_set_auth_flags(void *data)
983 {
984 conf_parm_t *args = data;
985
986 set_modes_from_table((int *) &yy_aconf->flags, "flag", auth_table, args);
987 }
988
989 static void
990 conf_set_auth_redir_serv(void *data)
991 {
992 yy_aconf->flags |= CONF_FLAGS_REDIR;
993 rb_free(yy_aconf->name);
994 yy_aconf->name = rb_strdup(data);
995 }
996
997 static void
998 conf_set_auth_redir_port(void *data)
999 {
1000 int port = *(unsigned int *) data;
1001
1002 yy_aconf->flags |= CONF_FLAGS_REDIR;
1003 yy_aconf->port = port;
1004 }
1005
1006 static void
1007 conf_set_auth_class(void *data)
1008 {
1009 rb_free(yy_aconf->className);
1010 yy_aconf->className = rb_strdup(data);
1011 }
1012
1013 /* ok, shared_oper handles the stacking, shared_flags handles adding
1014 * things.. so all we need to do when we start and end a shared block, is
1015 * clean up anything thats been left over.
1016 */
1017 static int
1018 conf_cleanup_shared(struct TopConf *tc)
1019 {
1020 rb_dlink_node *ptr, *next_ptr;
1021
1022 RB_DLINK_FOREACH_SAFE(ptr, next_ptr, yy_shared_list.head)
1023 {
1024 free_remote_conf(ptr->data);
1025 rb_dlinkDestroy(ptr, &yy_shared_list);
1026 }
1027
1028 if(yy_shared != NULL)
1029 {
1030 free_remote_conf(yy_shared);
1031 yy_shared = NULL;
1032 }
1033
1034 return 0;
1035 }
1036
1037 static void
1038 conf_set_shared_oper(void *data)
1039 {
1040 conf_parm_t *args = data;
1041 const char *username;
1042 char *p;
1043
1044 if(yy_shared != NULL)
1045 free_remote_conf(yy_shared);
1046
1047 yy_shared = make_remote_conf();
1048
1049 if(args->next != NULL)
1050 {
1051 if((args->type & CF_MTYPE) != CF_QSTRING)
1052 {
1053 conf_report_error("Ignoring shared::oper -- server is not a qstring");
1054 return;
1055 }
1056
1057 yy_shared->server = rb_strdup(args->v.string);
1058 args = args->next;
1059 }
1060 else
1061 yy_shared->server = rb_strdup("*");
1062
1063 if((args->type & CF_MTYPE) != CF_QSTRING)
1064 {
1065 conf_report_error("Ignoring shared::oper -- oper is not a qstring");
1066 return;
1067 }
1068
1069 if((p = strchr(args->v.string, '@')) == NULL)
1070 {
1071 conf_report_error("Ignoring shard::oper -- oper is not a user@host");
1072 return;
1073 }
1074
1075 username = args->v.string;
1076 *p++ = '\0';
1077
1078 if(EmptyString(p))
1079 yy_shared->host = rb_strdup("*");
1080 else
1081 yy_shared->host = rb_strdup(p);
1082
1083 if(EmptyString(username))
1084 yy_shared->username = rb_strdup("*");
1085 else
1086 yy_shared->username = rb_strdup(username);
1087
1088 rb_dlinkAddAlloc(yy_shared, &yy_shared_list);
1089 yy_shared = NULL;
1090 }
1091
1092 static void
1093 conf_set_shared_flags(void *data)
1094 {
1095 conf_parm_t *args = data;
1096 int flags = 0;
1097 rb_dlink_node *ptr, *next_ptr;
1098
1099 if(yy_shared != NULL)
1100 free_remote_conf(yy_shared);
1101
1102 set_modes_from_table(&flags, "flag", shared_table, args);
1103
1104 RB_DLINK_FOREACH_SAFE(ptr, next_ptr, yy_shared_list.head)
1105 {
1106 yy_shared = ptr->data;
1107
1108 yy_shared->flags = flags;
1109 rb_dlinkDestroy(ptr, &yy_shared_list);
1110 rb_dlinkAddTail(yy_shared, &yy_shared->node, &shared_conf_list);
1111 }
1112
1113 yy_shared = NULL;
1114 }
1115
1116 static int
1117 conf_begin_connect(struct TopConf *tc)
1118 {
1119 if(yy_server)
1120 free_server_conf(yy_server);
1121
1122 yy_server = make_server_conf();
1123 yy_server->port = PORTNUM;
1124 yy_server->flags |= SERVER_TB;
1125
1126 if(conf_cur_block_name != NULL)
1127 yy_server->name = rb_strdup(conf_cur_block_name);
1128
1129 return 0;
1130 }
1131
1132 static int
1133 conf_end_connect(struct TopConf *tc)
1134 {
1135 if(EmptyString(yy_server->name))
1136 {
1137 conf_report_error("Ignoring connect block -- missing name.");
1138 return 0;
1139 }
1140
1141 if(ServerInfo.name != NULL && !irccmp(ServerInfo.name, yy_server->name))
1142 {
1143 conf_report_error("Ignoring connect block for %s -- name is equal to my own name.",
1144 yy_server->name);
1145 return 0;
1146 }
1147
1148 if(EmptyString(yy_server->passwd) || EmptyString(yy_server->spasswd))
1149 {
1150 conf_report_error("Ignoring connect block for %s -- missing password.",
1151 yy_server->name);
1152 return 0;
1153 }
1154
1155 if(EmptyString(yy_server->host))
1156 {
1157 conf_report_error("Ignoring connect block for %s -- missing host.",
1158 yy_server->name);
1159 return 0;
1160 }
1161
1162 #ifndef HAVE_LIBZ
1163 if(ServerConfCompressed(yy_server))
1164 {
1165 conf_report_error("Ignoring connect::flags::compressed -- zlib not available.");
1166 yy_server->flags &= ~SERVER_COMPRESSED;
1167 }
1168 #endif
1169 if(ServerConfCompressed(yy_server) && ServerConfSSL(yy_server))
1170 {
1171 conf_report_error("Ignoring compressed for connect block %s -- "
1172 "ssl and compressed are mutually exclusive (OpenSSL does its own compression)",
1173 yy_server->name);
1174 yy_server->flags &= ~SERVER_COMPRESSED;
1175 }
1176
1177 add_server_conf(yy_server);
1178 rb_dlinkAdd(yy_server, &yy_server->node, &server_conf_list);
1179
1180 yy_server = NULL;
1181 return 0;
1182 }
1183
1184 static void
1185 conf_set_connect_host(void *data)
1186 {
1187 rb_free(yy_server->host);
1188 yy_server->host = rb_strdup(data);
1189 if (strchr(yy_server->host, ':'))
1190 yy_server->aftype = AF_INET6;
1191 }
1192
1193 static void
1194 conf_set_connect_vhost(void *data)
1195 {
1196 if(inetpton_sock(data, (struct sockaddr *)&yy_server->my_ipnum) <= 0)
1197 {
1198 conf_report_error("Invalid netmask for server vhost (%s)",
1199 (char *) data);
1200 return;
1201 }
1202
1203 yy_server->flags |= SERVER_VHOSTED;
1204 }
1205
1206 static void
1207 conf_set_connect_send_password(void *data)
1208 {
1209 if(yy_server->spasswd)
1210 {
1211 memset(yy_server->spasswd, 0, strlen(yy_server->spasswd));
1212 rb_free(yy_server->spasswd);
1213 }
1214
1215 yy_server->spasswd = rb_strdup(data);
1216 }
1217
1218 static void
1219 conf_set_connect_accept_password(void *data)
1220 {
1221 if(yy_server->passwd)
1222 {
1223 memset(yy_server->passwd, 0, strlen(yy_server->passwd));
1224 rb_free(yy_server->passwd);
1225 }
1226 yy_server->passwd = rb_strdup(data);
1227 }
1228
1229 static void
1230 conf_set_connect_port(void *data)
1231 {
1232 int port = *(unsigned int *) data;
1233
1234 if(port < 1)
1235 port = PORTNUM;
1236
1237 yy_server->port = port;
1238 }
1239
1240 static void
1241 conf_set_connect_aftype(void *data)
1242 {
1243 char *aft = data;
1244
1245 if(strcasecmp(aft, "ipv4") == 0)
1246 yy_server->aftype = AF_INET;
1247 #ifdef RB_IPV6
1248 else if(strcasecmp(aft, "ipv6") == 0)
1249 yy_server->aftype = AF_INET6;
1250 #endif
1251 else
1252 conf_report_error("connect::aftype '%s' is unknown.", aft);
1253 }
1254
1255 static void
1256 conf_set_connect_flags(void *data)
1257 {
1258 conf_parm_t *args = data;
1259
1260 /* note, we allow them to set compressed, then remove it later if
1261 * they do and LIBZ isnt available
1262 */
1263 set_modes_from_table(&yy_server->flags, "flag", connect_table, args);
1264 }
1265
1266 static void
1267 conf_set_connect_hub_mask(void *data)
1268 {
1269 struct remote_conf *yy_hub;
1270
1271 if(EmptyString(yy_server->name))
1272 return;
1273
1274 yy_hub = make_remote_conf();
1275 yy_hub->flags = CONF_HUB;
1276
1277 yy_hub->host = rb_strdup(data);
1278 yy_hub->server = rb_strdup(yy_server->name);
1279 rb_dlinkAdd(yy_hub, &yy_hub->node, &hubleaf_conf_list);
1280 }
1281
1282 static void
1283 conf_set_connect_leaf_mask(void *data)
1284 {
1285 struct remote_conf *yy_leaf;
1286
1287 if(EmptyString(yy_server->name))
1288 return;
1289
1290 yy_leaf = make_remote_conf();
1291 yy_leaf->flags = CONF_LEAF;
1292
1293 yy_leaf->host = rb_strdup(data);
1294 yy_leaf->server = rb_strdup(yy_server->name);
1295 rb_dlinkAdd(yy_leaf, &yy_leaf->node, &hubleaf_conf_list);
1296 }
1297
1298 static void
1299 conf_set_connect_class(void *data)
1300 {
1301 rb_free(yy_server->class_name);
1302 yy_server->class_name = rb_strdup(data);
1303 }
1304
1305 static void
1306 conf_set_exempt_ip(void *data)
1307 {
1308 struct ConfItem *yy_tmp;
1309
1310 if(parse_netmask(data, NULL, NULL) == HM_HOST)
1311 {
1312 conf_report_error("Ignoring exempt -- invalid exempt::ip.");
1313 return;
1314 }
1315
1316 yy_tmp = make_conf();
1317 yy_tmp->passwd = rb_strdup("*");
1318 yy_tmp->host = rb_strdup(data);
1319 yy_tmp->status = CONF_EXEMPTDLINE;
1320 add_conf_by_address(yy_tmp->host, CONF_EXEMPTDLINE, NULL, yy_tmp);
1321 }
1322
1323 static int
1324 conf_cleanup_cluster(struct TopConf *tc)
1325 {
1326 rb_dlink_node *ptr, *next_ptr;
1327
1328 RB_DLINK_FOREACH_SAFE(ptr, next_ptr, yy_cluster_list.head)
1329 {
1330 free_remote_conf(ptr->data);
1331 rb_dlinkDestroy(ptr, &yy_cluster_list);
1332 }
1333
1334 if(yy_shared != NULL)
1335 {
1336 free_remote_conf(yy_shared);
1337 yy_shared = NULL;
1338 }
1339
1340 return 0;
1341 }
1342
1343 static void
1344 conf_set_cluster_name(void *data)
1345 {
1346 if(yy_shared != NULL)
1347 free_remote_conf(yy_shared);
1348
1349 yy_shared = make_remote_conf();
1350 yy_shared->server = rb_strdup(data);
1351 rb_dlinkAddAlloc(yy_shared, &yy_cluster_list);
1352
1353 yy_shared = NULL;
1354 }
1355
1356 static void
1357 conf_set_cluster_flags(void *data)
1358 {
1359 conf_parm_t *args = data;
1360 int flags = 0;
1361 rb_dlink_node *ptr, *next_ptr;
1362
1363 if(yy_shared != NULL)
1364 free_remote_conf(yy_shared);
1365
1366 set_modes_from_table(&flags, "flag", cluster_table, args);
1367
1368 RB_DLINK_FOREACH_SAFE(ptr, next_ptr, yy_cluster_list.head)
1369 {
1370 yy_shared = ptr->data;
1371 yy_shared->flags = flags;
1372 rb_dlinkAddTail(yy_shared, &yy_shared->node, &cluster_conf_list);
1373 rb_dlinkDestroy(ptr, &yy_cluster_list);
1374 }
1375
1376 yy_shared = NULL;
1377 }
1378
1379 static void
1380 conf_set_general_havent_read_conf(void *data)
1381 {
1382 if(*(unsigned int *) data)
1383 {
1384 conf_report_error("You haven't read your config file properly.");
1385 conf_report_error
1386 ("There is a line in the example conf that will kill your server if not removed.");
1387 conf_report_error
1388 ("Consider actually reading/editing the conf file, and removing this line.");
1389 if (!testing_conf)
1390 exit(0);
1391 }
1392 }
1393
1394 static void
1395 conf_set_general_hide_error_messages(void *data)
1396 {
1397 char *val = data;
1398
1399 if(strcasecmp(val, "yes") == 0)
1400 ConfigFileEntry.hide_error_messages = 2;
1401 else if(strcasecmp(val, "opers") == 0)
1402 ConfigFileEntry.hide_error_messages = 1;
1403 else if(strcasecmp(val, "no") == 0)
1404 ConfigFileEntry.hide_error_messages = 0;
1405 else
1406 conf_report_error("Invalid setting '%s' for general::hide_error_messages.", val);
1407 }
1408
1409 static void
1410 conf_set_general_kline_delay(void *data)
1411 {
1412 ConfigFileEntry.kline_delay = *(unsigned int *) data;
1413
1414 /* THIS MUST BE HERE to stop us being unable to check klines */
1415 kline_queued = 0;
1416 }
1417
1418 static void
1419 conf_set_general_stats_k_oper_only(void *data)
1420 {
1421 char *val = data;
1422
1423 if(strcasecmp(val, "yes") == 0)
1424 ConfigFileEntry.stats_k_oper_only = 2;
1425 else if(strcasecmp(val, "masked") == 0)
1426 ConfigFileEntry.stats_k_oper_only = 1;
1427 else if(strcasecmp(val, "no") == 0)
1428 ConfigFileEntry.stats_k_oper_only = 0;
1429 else
1430 conf_report_error("Invalid setting '%s' for general::stats_k_oper_only.", val);
1431 }
1432
1433 static void
1434 conf_set_general_stats_i_oper_only(void *data)
1435 {
1436 char *val = data;
1437
1438 if(strcasecmp(val, "yes") == 0)
1439 ConfigFileEntry.stats_i_oper_only = 2;
1440 else if(strcasecmp(val, "masked") == 0)
1441 ConfigFileEntry.stats_i_oper_only = 1;
1442 else if(strcasecmp(val, "no") == 0)
1443 ConfigFileEntry.stats_i_oper_only = 0;
1444 else
1445 conf_report_error("Invalid setting '%s' for general::stats_i_oper_only.", val);
1446 }
1447
1448 static void
1449 conf_set_general_compression_level(void *data)
1450 {
1451 #ifdef HAVE_LIBZ
1452 ConfigFileEntry.compression_level = *(unsigned int *) data;
1453
1454 if((ConfigFileEntry.compression_level < 1) || (ConfigFileEntry.compression_level > 9))
1455 {
1456 conf_report_error
1457 ("Invalid general::compression_level %d -- using default.",
1458 ConfigFileEntry.compression_level);
1459 ConfigFileEntry.compression_level = 0;
1460 }
1461 #else
1462 conf_report_error("Ignoring general::compression_level -- zlib not available.");
1463 #endif
1464 }
1465
1466 static void
1467 conf_set_general_default_umodes(void *data)
1468 {
1469 char *pm;
1470 int what = MODE_ADD, flag;
1471
1472 ConfigFileEntry.default_umodes = 0;
1473 for (pm = (char *) data; *pm; pm++)
1474 {
1475 switch (*pm)
1476 {
1477 case '+':
1478 what = MODE_ADD;
1479 break;
1480 case '-':
1481 what = MODE_DEL;
1482 break;
1483
1484 /* don't allow +o */
1485 case 'o':
1486 case 'S':
1487 case ' ':
1488 break;
1489
1490 default:
1491 if ((flag = user_modes[(unsigned char) *pm]))
1492 {
1493 /* Proper value has probably not yet been set
1494 * so don't check oper_only_umodes -- jilles */
1495 if (what == MODE_ADD)
1496 ConfigFileEntry.default_umodes |= flag;
1497 else
1498 ConfigFileEntry.default_umodes &= ~flag;
1499 }
1500 break;
1501 }
1502 }
1503 }
1504
1505 static void
1506 conf_set_general_oper_umodes(void *data)
1507 {
1508 set_modes_from_table(&ConfigFileEntry.oper_umodes, "umode", umode_table, data);
1509 }
1510
1511 static void
1512 conf_set_general_oper_only_umodes(void *data)
1513 {
1514 set_modes_from_table(&ConfigFileEntry.oper_only_umodes, "umode", umode_table, data);
1515 }
1516
1517 static void
1518 conf_set_general_oper_snomask(void *data)
1519 {
1520 char *pm;
1521 int what = MODE_ADD, flag;
1522
1523 ConfigFileEntry.oper_snomask = 0;
1524 for (pm = (char *) data; *pm; pm++)
1525 {
1526 switch (*pm)
1527 {
1528 case '+':
1529 what = MODE_ADD;
1530 break;
1531 case '-':
1532 what = MODE_DEL;
1533 break;
1534
1535 default:
1536 if ((flag = snomask_modes[(unsigned char) *pm]))
1537 {
1538 if (what == MODE_ADD)
1539 ConfigFileEntry.oper_snomask |= flag;
1540 else
1541 ConfigFileEntry.oper_snomask &= ~flag;
1542 }
1543 break;
1544 }
1545 }
1546 }
1547
1548 static void
1549 conf_set_serverhide_links_delay(void *data)
1550 {
1551 int val = *(unsigned int *) data;
1552
1553 ConfigServerHide.links_delay = val;
1554 }
1555
1556 static int
1557 conf_begin_service(struct TopConf *tc)
1558 {
1559 struct Client *target_p;
1560 rb_dlink_node *ptr;
1561
1562 RB_DLINK_FOREACH(ptr, global_serv_list.head)
1563 {
1564 target_p = ptr->data;
1565
1566 target_p->flags &= ~FLAGS_SERVICE;
1567 }
1568
1569 return 0;
1570 }
1571
1572 static void
1573 conf_set_service_name(void *data)
1574 {
1575 struct Client *target_p;
1576 const char *s;
1577 char *tmp;
1578 int dots = 0;
1579
1580 for(s = data; *s != '\0'; s++)
1581 {
1582 if(!IsServChar(*s))
1583 {
1584 conf_report_error("Ignoring service::name "
1585 "-- bogus servername.");
1586 return;
1587 }
1588 else if(*s == '.')
1589 dots++;
1590 }
1591
1592 if(!dots)
1593 {
1594 conf_report_error("Ignoring service::name -- must contain '.'");
1595 return;
1596 }
1597
1598 tmp = rb_strdup(data);
1599 rb_dlinkAddAlloc(tmp, &service_list);
1600
1601 if((target_p = find_server(NULL, tmp)))
1602 target_p->flags |= FLAGS_SERVICE;
1603 }
1604
1605 static int
1606 conf_begin_alias(struct TopConf *tc)
1607 {
1608 yy_alias = rb_malloc(sizeof(struct alias_entry));
1609
1610 if (conf_cur_block_name != NULL)
1611 yy_alias->name = rb_strdup(conf_cur_block_name);
1612
1613 yy_alias->flags = 0;
1614 yy_alias->hits = 0;
1615
1616 return 0;
1617 }
1618
1619 static int
1620 conf_end_alias(struct TopConf *tc)
1621 {
1622 if (yy_alias == NULL)
1623 return -1;
1624
1625 if (yy_alias->name == NULL)
1626 {
1627 conf_report_error("Ignoring alias -- must have a name.");
1628
1629 rb_free(yy_alias);
1630
1631 return -1;
1632 }
1633
1634 if (yy_alias->target == NULL)
1635 {
1636 conf_report_error("Ignoring alias -- must have a target.");
1637
1638 rb_free(yy_alias);
1639
1640 return -1;
1641 }
1642
1643 if (!alias_dict)
1644 alias_dict = irc_dictionary_create(strcasecmp);
1645
1646 irc_dictionary_add(alias_dict, yy_alias->name, yy_alias);
1647
1648 return 0;
1649 }
1650
1651 static void
1652 conf_set_alias_name(void *data)
1653 {
1654 if (data == NULL || yy_alias == NULL) /* this shouldn't ever happen */
1655 return;
1656
1657 yy_alias->name = rb_strdup(data);
1658 }
1659
1660 static void
1661 conf_set_alias_target(void *data)
1662 {
1663 if (data == NULL || yy_alias == NULL) /* this shouldn't ever happen */
1664 return;
1665
1666 yy_alias->target = rb_strdup(data);
1667 }
1668
1669 static void
1670 conf_set_blacklist_host(void *data)
1671 {
1672 yy_blacklist_host = rb_strdup(data);
1673 }
1674
1675 static void
1676 conf_set_blacklist_reason(void *data)
1677 {
1678 yy_blacklist_reason = rb_strdup(data);
1679
1680 if (yy_blacklist_host && yy_blacklist_reason)
1681 {
1682 new_blacklist(yy_blacklist_host, yy_blacklist_reason);
1683 rb_free(yy_blacklist_host);
1684 rb_free(yy_blacklist_reason);
1685 yy_blacklist_host = NULL;
1686 yy_blacklist_reason = NULL;
1687 }
1688 }
1689
1690 /* public functions */
1691
1692
1693 void
1694 conf_report_error(const char *fmt, ...)
1695 {
1696 va_list ap;
1697 char msg[IRCD_BUFSIZE + 1] = { 0 };
1698
1699 va_start(ap, fmt);
1700 rb_vsnprintf(msg, IRCD_BUFSIZE, fmt, ap);
1701 va_end(ap);
1702
1703 if (testing_conf)
1704 {
1705 fprintf(stderr, "\"%s\", line %d: %s\n", current_file, lineno + 1, msg);
1706 return;
1707 }
1708
1709 ierror("\"%s\", line %d: %s", current_file, lineno + 1, msg);
1710 sendto_realops_snomask(SNO_GENERAL, L_ALL, "\"%s\", line %d: %s", current_file, lineno + 1, msg);
1711 }
1712
1713 int
1714 conf_start_block(char *block, char *name)
1715 {
1716 if((conf_cur_block = find_top_conf(block)) == NULL)
1717 {
1718 conf_report_error("Configuration block '%s' is not defined.", block);
1719 return -1;
1720 }
1721
1722 if(name)
1723 conf_cur_block_name = rb_strdup(name);
1724 else
1725 conf_cur_block_name = NULL;
1726
1727 if(conf_cur_block->tc_sfunc)
1728 if(conf_cur_block->tc_sfunc(conf_cur_block) < 0)
1729 return -1;
1730
1731 return 0;
1732 }
1733
1734 int
1735 conf_end_block(struct TopConf *tc)
1736 {
1737 if(tc->tc_efunc)
1738 return tc->tc_efunc(tc);
1739
1740 rb_free(conf_cur_block_name);
1741 return 0;
1742 }
1743
1744 static void
1745 conf_set_generic_int(void *data, void *location)
1746 {
1747 *((int *) location) = *((unsigned int *) data);
1748 }
1749
1750 static void
1751 conf_set_generic_string(void *data, int len, void *location)
1752 {
1753 char **loc = location;
1754 char *input = data;
1755
1756 if(len && strlen(input) > len)
1757 input[len] = '\0';
1758
1759 rb_free(*loc);
1760 *loc = rb_strdup(input);
1761 }
1762
1763 int
1764 conf_call_set(struct TopConf *tc, char *item, conf_parm_t * value, int type)
1765 {
1766 struct ConfEntry *cf;
1767 conf_parm_t *cp;
1768
1769 if(!tc)
1770 return -1;
1771
1772 if((cf = find_conf_item(tc, item)) == NULL)
1773 {
1774 conf_report_error
1775 ("Non-existant configuration setting %s::%s.", tc->tc_name, (char *) item);
1776 return -1;
1777 }
1778
1779 /* if it takes one thing, make sure they only passed one thing,
1780 and handle as needed. */
1781 if(value->type & CF_FLIST && !cf->cf_type & CF_FLIST)
1782 {
1783 conf_report_error
1784 ("Option %s::%s does not take a list of values.", tc->tc_name, item);
1785 return -1;
1786 }
1787
1788 cp = value->v.list;
1789
1790
1791 if(CF_TYPE(value->v.list->type) != CF_TYPE(cf->cf_type))
1792 {
1793 /* if it expects a string value, but we got a yesno,
1794 * convert it back
1795 */
1796 if((CF_TYPE(value->v.list->type) == CF_YESNO) &&
1797 (CF_TYPE(cf->cf_type) == CF_STRING))
1798 {
1799 value->v.list->type = CF_STRING;
1800
1801 if(cp->v.number == 1)
1802 cp->v.string = rb_strdup("yes");
1803 else
1804 cp->v.string = rb_strdup("no");
1805 }
1806
1807 /* maybe it's a CF_TIME and they passed CF_INT --
1808 should still be valid */
1809 else if(!((CF_TYPE(value->v.list->type) == CF_INT) &&
1810 (CF_TYPE(cf->cf_type) == CF_TIME)))
1811 {
1812 conf_report_error
1813 ("Wrong type for %s::%s (expected %s, got %s)",
1814 tc->tc_name, (char *) item,
1815 conf_strtype(cf->cf_type), conf_strtype(value->v.list->type));
1816 return -1;
1817 }
1818 }
1819
1820 if(cf->cf_type & CF_FLIST)
1821 {
1822 #if 0
1823 if(cf->cf_arg)
1824 conf_set_generic_list(value->v.list, cf->cf_arg);
1825 else
1826 #endif
1827 /* just pass it the extended argument list */
1828 cf->cf_func(value->v.list);
1829 }
1830 else
1831 {
1832 /* it's old-style, needs only one arg */
1833 switch (cf->cf_type)
1834 {
1835 case CF_INT:
1836 case CF_TIME:
1837 case CF_YESNO:
1838 if(cf->cf_arg)
1839 conf_set_generic_int(&cp->v.number, cf->cf_arg);
1840 else
1841 cf->cf_func(&cp->v.number);
1842 break;
1843 case CF_STRING:
1844 case CF_QSTRING:
1845 if(EmptyString(cp->v.string))
1846 conf_report_error("Ignoring %s::%s -- empty field",
1847 tc->tc_name, item);
1848 else if(cf->cf_arg)
1849 conf_set_generic_string(cp->v.string, cf->cf_len, cf->cf_arg);
1850 else
1851 cf->cf_func(cp->v.string);
1852 break;
1853 }
1854 }
1855
1856
1857 return 0;
1858 }
1859
1860 int
1861 add_conf_item(const char *topconf, const char *name, int type, void (*func) (void *))
1862 {
1863 struct TopConf *tc;
1864 struct ConfEntry *cf;
1865
1866 if((tc = find_top_conf(topconf)) == NULL)
1867 return -1;
1868
1869 if((cf = find_conf_item(tc, name)) != NULL)
1870 return -1;
1871
1872 cf = rb_malloc(sizeof(struct ConfEntry));
1873
1874 cf->cf_name = name;
1875 cf->cf_type = type;
1876 cf->cf_func = func;
1877 cf->cf_arg = NULL;
1878
1879 rb_dlinkAddAlloc(cf, &tc->tc_items);
1880
1881 return 0;
1882 }
1883
1884 int
1885 remove_conf_item(const char *topconf, const char *name)
1886 {
1887 struct TopConf *tc;
1888 struct ConfEntry *cf;
1889 rb_dlink_node *ptr;
1890
1891 if((tc = find_top_conf(topconf)) == NULL)
1892 return -1;
1893
1894 if((cf = find_conf_item(tc, name)) == NULL)
1895 return -1;
1896
1897 if((ptr = rb_dlinkFind(cf, &tc->tc_items)) == NULL)
1898 return -1;
1899
1900 rb_dlinkDestroy(ptr, &tc->tc_items);
1901 rb_free(cf);
1902
1903 return 0;
1904 }
1905
1906 /* *INDENT-OFF* */
1907 static struct ConfEntry conf_serverinfo_table[] =
1908 {
1909 { "description", CF_QSTRING, NULL, 0, &ServerInfo.description },
1910 { "network_desc", CF_QSTRING, NULL, 0, &ServerInfo.network_desc },
1911 { "hub", CF_YESNO, NULL, 0, &ServerInfo.hub },
1912
1913 { "network_name", CF_QSTRING, conf_set_serverinfo_network_name, 0, NULL },
1914 { "name", CF_QSTRING, conf_set_serverinfo_name, 0, NULL },
1915 { "sid", CF_QSTRING, conf_set_serverinfo_sid, 0, NULL },
1916 { "vhost", CF_QSTRING, conf_set_serverinfo_vhost, 0, NULL },
1917 { "vhost6", CF_QSTRING, conf_set_serverinfo_vhost6, 0, NULL },
1918
1919 { "ssl_private_key", CF_QSTRING, NULL, 0, &ServerInfo.ssl_private_key },
1920 { "ssl_ca_cert", CF_QSTRING, NULL, 0, &ServerInfo.ssl_ca_cert },
1921 { "ssl_cert", CF_QSTRING, NULL, 0, &ServerInfo.ssl_cert },
1922 { "ssl_dh_params", CF_QSTRING, NULL, 0, &ServerInfo.ssl_dh_params },
1923 { "ssld_count", CF_INT, NULL, 0, &ServerInfo.ssld_count },
1924
1925 { "default_max_clients",CF_INT, NULL, 0, &ServerInfo.default_max_clients },
1926
1927 { "\0", 0, NULL, 0, NULL }
1928 };
1929
1930 static struct ConfEntry conf_admin_table[] =
1931 {
1932 { "name", CF_QSTRING, NULL, 200, &AdminInfo.name },
1933 { "description",CF_QSTRING, NULL, 200, &AdminInfo.description },
1934 { "email", CF_QSTRING, NULL, 200, &AdminInfo.email },
1935 { "\0", 0, NULL, 0, NULL }
1936 };
1937
1938 static struct ConfEntry conf_log_table[] =
1939 {
1940 { "fname_userlog", CF_QSTRING, NULL, MAXPATHLEN, &ConfigFileEntry.fname_userlog },
1941 { "fname_fuserlog", CF_QSTRING, NULL, MAXPATHLEN, &ConfigFileEntry.fname_fuserlog },
1942 { "fname_operlog", CF_QSTRING, NULL, MAXPATHLEN, &ConfigFileEntry.fname_operlog },
1943 { "fname_foperlog", CF_QSTRING, NULL, MAXPATHLEN, &ConfigFileEntry.fname_foperlog },
1944 { "fname_serverlog", CF_QSTRING, NULL, MAXPATHLEN, &ConfigFileEntry.fname_serverlog },
1945 { "fname_killlog", CF_QSTRING, NULL, MAXPATHLEN, &ConfigFileEntry.fname_killlog },
1946 { "fname_glinelog", CF_QSTRING, NULL, MAXPATHLEN, &ConfigFileEntry.fname_glinelog },
1947 { "fname_klinelog", CF_QSTRING, NULL, MAXPATHLEN, &ConfigFileEntry.fname_klinelog },
1948 { "fname_operspylog", CF_QSTRING, NULL, MAXPATHLEN, &ConfigFileEntry.fname_operspylog },
1949 { "fname_ioerrorlog", CF_QSTRING, NULL, MAXPATHLEN, &ConfigFileEntry.fname_ioerrorlog },
1950 { "\0", 0, NULL, 0, NULL }
1951 };
1952
1953 static struct ConfEntry conf_operator_table[] =
1954 {
1955 { "rsa_public_key_file", CF_QSTRING, conf_set_oper_rsa_public_key_file, 0, NULL },
1956 { "flags", CF_STRING | CF_FLIST, conf_set_oper_flags, 0, NULL },
1957 { "umodes", CF_STRING | CF_FLIST, conf_set_oper_umodes, 0, NULL },
1958 { "snomask", CF_QSTRING, conf_set_oper_snomask, 0, NULL },
1959 { "user", CF_QSTRING, conf_set_oper_user, 0, NULL },
1960 { "password", CF_QSTRING, conf_set_oper_password, 0, NULL },
1961 { "\0", 0, NULL, 0, NULL }
1962 };
1963
1964 static struct ConfEntry conf_class_table[] =
1965 {
1966 { "ping_time", CF_TIME, conf_set_class_ping_time, 0, NULL },
1967 { "cidr_bitlen", CF_INT, conf_set_class_cidr_bitlen, 0, NULL },
1968 { "number_per_cidr", CF_INT, conf_set_class_number_per_cidr, 0, NULL },
1969 { "number_per_ip", CF_INT, conf_set_class_number_per_ip, 0, NULL },
1970 { "number_per_ip_global", CF_INT,conf_set_class_number_per_ip_global, 0, NULL },
1971 { "number_per_ident", CF_INT, conf_set_class_number_per_ident, 0, NULL },
1972 { "connectfreq", CF_TIME, conf_set_class_connectfreq, 0, NULL },
1973 { "max_number", CF_INT, conf_set_class_max_number, 0, NULL },
1974 { "sendq", CF_TIME, conf_set_class_sendq, 0, NULL },
1975 { "\0", 0, NULL, 0, NULL }
1976 };
1977
1978 static struct ConfEntry conf_auth_table[] =
1979 {
1980 { "user", CF_QSTRING, conf_set_auth_user, 0, NULL },
1981 { "password", CF_QSTRING, conf_set_auth_passwd, 0, NULL },
1982 { "class", CF_QSTRING, conf_set_auth_class, 0, NULL },
1983 { "spoof", CF_QSTRING, conf_set_auth_spoof, 0, NULL },
1984 { "redirserv", CF_QSTRING, conf_set_auth_redir_serv, 0, NULL },
1985 { "redirport", CF_INT, conf_set_auth_redir_port, 0, NULL },
1986 { "flags", CF_STRING | CF_FLIST, conf_set_auth_flags, 0, NULL },
1987 { "\0", 0, NULL, 0, NULL }
1988 };
1989
1990 static struct ConfEntry conf_connect_table[] =
1991 {
1992 { "send_password", CF_QSTRING, conf_set_connect_send_password, 0, NULL },
1993 { "accept_password", CF_QSTRING, conf_set_connect_accept_password, 0, NULL },
1994 { "flags", CF_STRING | CF_FLIST, conf_set_connect_flags, 0, NULL },
1995 { "host", CF_QSTRING, conf_set_connect_host, 0, NULL },
1996 { "vhost", CF_QSTRING, conf_set_connect_vhost, 0, NULL },
1997 { "port", CF_INT, conf_set_connect_port, 0, NULL },
1998 { "aftype", CF_STRING, conf_set_connect_aftype, 0, NULL },
1999 { "hub_mask", CF_QSTRING, conf_set_connect_hub_mask, 0, NULL },
2000 { "leaf_mask", CF_QSTRING, conf_set_connect_leaf_mask, 0, NULL },
2001 { "class", CF_QSTRING, conf_set_connect_class, 0, NULL },
2002 { "\0", 0, NULL, 0, NULL }
2003 };
2004
2005 static struct ConfEntry conf_general_table[] =
2006 {
2007 { "oper_only_umodes", CF_STRING | CF_FLIST, conf_set_general_oper_only_umodes, 0, NULL },
2008 { "oper_umodes", CF_STRING | CF_FLIST, conf_set_general_oper_umodes, 0, NULL },
2009 { "oper_snomask", CF_QSTRING, conf_set_general_oper_snomask, 0, NULL },
2010 { "compression_level", CF_INT, conf_set_general_compression_level, 0, NULL },
2011 { "havent_read_conf", CF_YESNO, conf_set_general_havent_read_conf, 0, NULL },
2012 { "hide_error_messages",CF_STRING, conf_set_general_hide_error_messages,0, NULL },
2013 { "kline_delay", CF_TIME, conf_set_general_kline_delay, 0, NULL },
2014 { "stats_k_oper_only", CF_STRING, conf_set_general_stats_k_oper_only, 0, NULL },
2015 { "stats_i_oper_only", CF_STRING, conf_set_general_stats_i_oper_only, 0, NULL },
2016 { "default_umodes", CF_QSTRING, conf_set_general_default_umodes, 0, NULL },
2017
2018 { "default_operstring", CF_QSTRING, NULL, REALLEN, &ConfigFileEntry.default_operstring },
2019 { "default_adminstring",CF_QSTRING, NULL, REALLEN, &ConfigFileEntry.default_adminstring },
2020 { "servicestring", CF_QSTRING, NULL, REALLEN, &ConfigFileEntry.servicestring },
2021 { "egdpool_path", CF_QSTRING, NULL, MAXPATHLEN, &ConfigFileEntry.egdpool_path },
2022 { "kline_reason", CF_QSTRING, NULL, REALLEN, &ConfigFileEntry.kline_reason },
2023 { "identify_service", CF_QSTRING, NULL, REALLEN, &ConfigFileEntry.identifyservice },
2024 { "identify_command", CF_QSTRING, NULL, REALLEN, &ConfigFileEntry.identifycommand },
2025 { "servlink_path", CF_QSTRING, NULL, MAXPATHLEN, &ConfigFileEntry.servlink_path },
2026
2027 { "anti_spam_exit_message_time", CF_TIME, NULL, 0, &ConfigFileEntry.anti_spam_exit_message_time },
2028 { "disable_fake_channels", CF_YESNO, NULL, 0, &ConfigFileEntry.disable_fake_channels },
2029 { "min_nonwildcard_simple", CF_INT, NULL, 0, &ConfigFileEntry.min_nonwildcard_simple },
2030 { "non_redundant_klines", CF_YESNO, NULL, 0, &ConfigFileEntry.non_redundant_klines },
2031 { "tkline_expire_notices", CF_YESNO, NULL, 0, &ConfigFileEntry.tkline_expire_notices },
2032
2033 { "anti_nick_flood", CF_YESNO, NULL, 0, &ConfigFileEntry.anti_nick_flood },
2034 { "burst_away", CF_YESNO, NULL, 0, &ConfigFileEntry.burst_away },
2035 { "caller_id_wait", CF_TIME, NULL, 0, &ConfigFileEntry.caller_id_wait },
2036 { "client_exit", CF_YESNO, NULL, 0, &ConfigFileEntry.client_exit },
2037 { "client_flood", CF_INT, NULL, 0, &ConfigFileEntry.client_flood },
2038 { "collision_fnc", CF_YESNO, NULL, 0, &ConfigFileEntry.collision_fnc },
2039 { "connect_timeout", CF_TIME, NULL, 0, &ConfigFileEntry.connect_timeout },
2040 { "default_floodcount", CF_INT, NULL, 0, &ConfigFileEntry.default_floodcount },
2041 { "disable_auth", CF_YESNO, NULL, 0, &ConfigFileEntry.disable_auth },
2042 { "dots_in_ident", CF_INT, NULL, 0, &ConfigFileEntry.dots_in_ident },
2043 { "failed_oper_notice", CF_YESNO, NULL, 0, &ConfigFileEntry.failed_oper_notice },
2044 { "glines", CF_YESNO, NULL, 0, &ConfigFileEntry.glines },
2045 { "gline_min_cidr", CF_INT, NULL, 0, &ConfigFileEntry.gline_min_cidr },
2046 { "gline_min_cidr6", CF_INT, NULL, 0, &ConfigFileEntry.gline_min_cidr6 },
2047 { "gline_time", CF_TIME, NULL, 0, &ConfigFileEntry.gline_time },
2048 { "global_snotices", CF_YESNO, NULL, 0, &ConfigFileEntry.global_snotices },
2049 { "hide_spoof_ips", CF_YESNO, NULL, 0, &ConfigFileEntry.hide_spoof_ips },
2050 { "dline_with_reason", CF_YESNO, NULL, 0, &ConfigFileEntry.dline_with_reason },
2051 { "kline_with_reason", CF_YESNO, NULL, 0, &ConfigFileEntry.kline_with_reason },
2052 { "map_oper_only", CF_YESNO, NULL, 0, &ConfigFileEntry.map_oper_only },
2053 { "max_accept", CF_INT, NULL, 0, &ConfigFileEntry.max_accept },
2054 { "max_monitor", CF_INT, NULL, 0, &ConfigFileEntry.max_monitor },
2055 { "max_nick_time", CF_TIME, NULL, 0, &ConfigFileEntry.max_nick_time },
2056 { "max_nick_changes", CF_INT, NULL, 0, &ConfigFileEntry.max_nick_changes },
2057 { "max_targets", CF_INT, NULL, 0, &ConfigFileEntry.max_targets },
2058 { "max_unknown_ip", CF_INT, NULL, 0, &ConfigFileEntry.max_unknown_ip },
2059 { "min_nonwildcard", CF_INT, NULL, 0, &ConfigFileEntry.min_nonwildcard },
2060 { "nick_delay", CF_TIME, NULL, 0, &ConfigFileEntry.nick_delay },
2061 { "no_oper_flood", CF_YESNO, NULL, 0, &ConfigFileEntry.no_oper_flood },
2062 { "operspy_admin_only", CF_YESNO, NULL, 0, &ConfigFileEntry.operspy_admin_only },
2063 { "operspy_dont_care_user_info", CF_YESNO, NULL, 0, &ConfigFileEntry.operspy_dont_care_user_info },
2064 { "pace_wait", CF_TIME, NULL, 0, &ConfigFileEntry.pace_wait },
2065 { "pace_wait_simple", CF_TIME, NULL, 0, &ConfigFileEntry.pace_wait_simple },
2066 { "ping_cookie", CF_YESNO, NULL, 0, &ConfigFileEntry.ping_cookie },
2067 { "reject_after_count", CF_INT, NULL, 0, &ConfigFileEntry.reject_after_count },
2068 { "reject_ban_time", CF_TIME, NULL, 0, &ConfigFileEntry.reject_ban_time },
2069 { "reject_duration", CF_TIME, NULL, 0, &ConfigFileEntry.reject_duration },
2070 { "short_motd", CF_YESNO, NULL, 0, &ConfigFileEntry.short_motd },
2071 { "stats_c_oper_only", CF_YESNO, NULL, 0, &ConfigFileEntry.stats_c_oper_only },
2072 { "stats_e_disabled", CF_YESNO, NULL, 0, &ConfigFileEntry.stats_e_disabled },
2073 { "stats_h_oper_only", CF_YESNO, NULL, 0, &ConfigFileEntry.stats_h_oper_only },
2074 { "stats_o_oper_only", CF_YESNO, NULL, 0, &ConfigFileEntry.stats_o_oper_only },
2075 { "stats_P_oper_only", CF_YESNO, NULL, 0, &ConfigFileEntry.stats_P_oper_only },
2076 { "stats_y_oper_only", CF_YESNO, NULL, 0, &ConfigFileEntry.stats_y_oper_only },
2077 { "target_change", CF_YESNO, NULL, 0, &ConfigFileEntry.target_change },
2078 { "ts_max_delta", CF_TIME, NULL, 0, &ConfigFileEntry.ts_max_delta },
2079 { "use_egd", CF_YESNO, NULL, 0, &ConfigFileEntry.use_egd },
2080 { "ts_warn_delta", CF_TIME, NULL, 0, &ConfigFileEntry.ts_warn_delta },
2081 { "use_whois_actually", CF_YESNO, NULL, 0, &ConfigFileEntry.use_whois_actually },
2082 { "warn_no_nline", CF_YESNO, NULL, 0, &ConfigFileEntry.warn_no_nline },
2083 { "\0", 0, NULL, 0, NULL }
2084 };
2085
2086 static struct ConfEntry conf_channel_table[] =
2087 {
2088 { "default_split_user_count", CF_INT, NULL, 0, &ConfigChannel.default_split_user_count },
2089 { "default_split_server_count", CF_INT, NULL, 0, &ConfigChannel.default_split_server_count },
2090 { "burst_topicwho", CF_YESNO, NULL, 0, &ConfigChannel.burst_topicwho },
2091 { "kick_on_split_riding", CF_YESNO, NULL, 0, &ConfigChannel.kick_on_split_riding },
2092 { "knock_delay", CF_TIME, NULL, 0, &ConfigChannel.knock_delay },
2093 { "knock_delay_channel",CF_TIME, NULL, 0, &ConfigChannel.knock_delay_channel },
2094 { "max_bans", CF_INT, NULL, 0, &ConfigChannel.max_bans },
2095 { "max_bans_large", CF_INT, NULL, 0, &ConfigChannel.max_bans_large },
2096 { "max_chans_per_user", CF_INT, NULL, 0, &ConfigChannel.max_chans_per_user },
2097 { "no_create_on_split", CF_YESNO, NULL, 0, &ConfigChannel.no_create_on_split },
2098 { "no_join_on_split", CF_YESNO, NULL, 0, &ConfigChannel.no_join_on_split },
2099 { "use_except", CF_YESNO, NULL, 0, &ConfigChannel.use_except },
2100 { "use_invex", CF_YESNO, NULL, 0, &ConfigChannel.use_invex },
2101 { "use_knock", CF_YESNO, NULL, 0, &ConfigChannel.use_knock },
2102 { "use_forward", CF_YESNO, NULL, 0, &ConfigChannel.use_forward },
2103 { "\0", 0, NULL, 0, NULL }
2104 };
2105
2106 static struct ConfEntry conf_serverhide_table[] =
2107 {
2108 { "disable_hidden", CF_YESNO, NULL, 0, &ConfigServerHide.disable_hidden },
2109 { "flatten_links", CF_YESNO, NULL, 0, &ConfigServerHide.flatten_links },
2110 { "hidden", CF_YESNO, NULL, 0, &ConfigServerHide.hidden },
2111 { "links_delay", CF_TIME, conf_set_serverhide_links_delay, 0, NULL },
2112 { "\0", 0, NULL, 0, NULL }
2113 };
2114 /* *INDENT-ON* */
2115
2116 void
2117 newconf_init()
2118 {
2119 add_top_conf("modules", NULL, NULL, NULL);
2120 add_conf_item("modules", "path", CF_QSTRING, conf_set_modules_path);
2121 add_conf_item("modules", "module", CF_QSTRING, conf_set_modules_module);
2122
2123 add_top_conf("serverinfo", NULL, NULL, conf_serverinfo_table);
2124 add_top_conf("admin", NULL, NULL, conf_admin_table);
2125 add_top_conf("log", NULL, NULL, conf_log_table);
2126 add_top_conf("operator", conf_begin_oper, conf_end_oper, conf_operator_table);
2127 add_top_conf("class", conf_begin_class, conf_end_class, conf_class_table);
2128
2129 add_top_conf("listen", conf_begin_listen, conf_end_listen, NULL);
2130 add_conf_item("listen", "port", CF_INT | CF_FLIST, conf_set_listen_port);
2131 add_conf_item("listen", "sslport", CF_INT | CF_FLIST, conf_set_listen_sslport);
2132 add_conf_item("listen", "ip", CF_QSTRING, conf_set_listen_address);
2133 add_conf_item("listen", "host", CF_QSTRING, conf_set_listen_address);
2134
2135 add_top_conf("auth", conf_begin_auth, conf_end_auth, conf_auth_table);
2136
2137 add_top_conf("shared", conf_cleanup_shared, conf_cleanup_shared, NULL);
2138 add_conf_item("shared", "oper", CF_QSTRING|CF_FLIST, conf_set_shared_oper);
2139 add_conf_item("shared", "flags", CF_STRING | CF_FLIST, conf_set_shared_flags);
2140
2141 add_top_conf("connect", conf_begin_connect, conf_end_connect, conf_connect_table);
2142
2143 add_top_conf("exempt", NULL, NULL, NULL);
2144 add_conf_item("exempt", "ip", CF_QSTRING, conf_set_exempt_ip);
2145
2146 add_top_conf("cluster", conf_cleanup_cluster, conf_cleanup_cluster, NULL);
2147 add_conf_item("cluster", "name", CF_QSTRING, conf_set_cluster_name);
2148 add_conf_item("cluster", "flags", CF_STRING | CF_FLIST, conf_set_cluster_flags);
2149
2150 add_top_conf("general", NULL, NULL, conf_general_table);
2151 add_top_conf("channel", NULL, NULL, conf_channel_table);
2152 add_top_conf("serverhide", NULL, NULL, conf_serverhide_table);
2153
2154 add_top_conf("service", conf_begin_service, NULL, NULL);
2155 add_conf_item("service", "name", CF_QSTRING, conf_set_service_name);
2156
2157 add_top_conf("alias", conf_begin_alias, conf_end_alias, NULL);
2158 add_conf_item("alias", "name", CF_QSTRING, conf_set_alias_name);
2159 add_conf_item("alias", "target", CF_QSTRING, conf_set_alias_target);
2160
2161 add_top_conf("blacklist", NULL, NULL, NULL);
2162 add_conf_item("blacklist", "host", CF_QSTRING, conf_set_blacklist_host);
2163 add_conf_item("blacklist", "reject_reason", CF_QSTRING, conf_set_blacklist_reason);
2164 }