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