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