]>
Commit | Line | Data |
---|---|---|
212380e3 | 1 | /* This code is in the public domain. |
cda8e9b8 | 2 | * $Id: newconf.c 3550 2007-08-09 06:47:26Z nenolod $ |
212380e3 AC |
3 | */ |
4 | ||
5 | #include "stdinc.h" | |
6 | ||
7 | #ifdef HAVE_LIBCRYPTO | |
8 | #include <openssl/pem.h> | |
9 | #include <openssl/rsa.h> | |
10 | #endif | |
11 | ||
212380e3 | 12 | #include "newconf.h" |
212380e3 | 13 | #include "ircd_defs.h" |
212380e3 | 14 | #include "common.h" |
4016731b | 15 | #include "logger.h" |
212380e3 AC |
16 | #include "s_conf.h" |
17 | #include "s_user.h" | |
18 | #include "s_newconf.h" | |
19 | #include "send.h" | |
20 | #include "setup.h" | |
21 | #include "modules.h" | |
22 | #include "listener.h" | |
23 | #include "hostmask.h" | |
24 | #include "s_serv.h" | |
212380e3 AC |
25 | #include "hash.h" |
26 | #include "cache.h" | |
27 | #include "ircd.h" | |
28 | #include "snomask.h" | |
29 | #include "blacklist.h" | |
c6d72037 | 30 | #include "sslproc.h" |
212380e3 AC |
31 | |
32 | #define CF_TYPE(x) ((x) & CF_MTYPE) | |
33 | ||
34 | struct TopConf *conf_cur_block; | |
35 | static char *conf_cur_block_name; | |
36 | ||
330fc5c1 | 37 | static rb_dlink_list conf_items; |
212380e3 AC |
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 | ||
330fc5c1 AC |
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; | |
212380e3 AC |
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 | ||
eddc2ab6 | 83 | tc = rb_malloc(sizeof(struct TopConf)); |
212380e3 | 84 | |
d7f753cd | 85 | tc->tc_name = name; |
212380e3 AC |
86 | tc->tc_sfunc = sfunc; |
87 | tc->tc_efunc = efunc; | |
88 | tc->tc_entries = items; | |
89 | ||
330fc5c1 | 90 | rb_dlinkAddAlloc(tc, &conf_items); |
212380e3 AC |
91 | return 0; |
92 | } | |
93 | ||
94 | struct TopConf * | |
95 | find_top_conf(const char *name) | |
96 | { | |
330fc5c1 | 97 | rb_dlink_node *d; |
212380e3 AC |
98 | struct TopConf *tc; |
99 | ||
5cefa1d6 | 100 | RB_DLINK_FOREACH(d, conf_items.head) |
212380e3 AC |
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; | |
330fc5c1 | 115 | rb_dlink_node *d; |
212380e3 AC |
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 | ||
5cefa1d6 | 130 | RB_DLINK_FOREACH(d, top->tc_items.head) |
212380e3 AC |
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; | |
330fc5c1 | 144 | rb_dlink_node *ptr; |
212380e3 AC |
145 | |
146 | if((tc = find_top_conf(name)) == NULL) | |
147 | return -1; | |
148 | ||
330fc5c1 | 149 | if((ptr = rb_dlinkFind(tc, &conf_items)) == NULL) |
212380e3 AC |
150 | return -1; |
151 | ||
330fc5c1 | 152 | rb_dlinkDestroy(ptr, &conf_items); |
637c4932 | 153 | rb_free(tc); |
212380e3 AC |
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) | |
47a03750 | 194 | ServerInfo.name = rb_strdup((char *) data); |
212380e3 AC |
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 | ||
637c4932 | 225 | rb_free(ServerInfo.network_name); |
47a03750 | 226 | ServerInfo.network_name = rb_strdup((char *) data); |
212380e3 AC |
227 | } |
228 | ||
229 | static void | |
230 | conf_set_serverinfo_vhost(void *data) | |
231 | { | |
caa4d9d2 | 232 | if(rb_inet_pton(AF_INET, (char *) data, &ServerInfo.ip.sin_addr) <= 0) |
212380e3 AC |
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 | { | |
ccda6e3f | 244 | #ifdef RB_IPV6 |
caa4d9d2 | 245 | if(rb_inet_pton(AF_INET6, (char *) data, &ServerInfo.ip6.sin6_addr) <= 0) |
212380e3 AC |
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 | ||
637c4932 | 271 | rb_free(m_bn); |
212380e3 AC |
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 | ||
19c13ce5 | 307 | static struct mode_table oper_table[] = { |
212380e3 AC |
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 }, | |
212380e3 AC |
314 | {"nick_changes", OPER_NICKS }, |
315 | {"rehash", OPER_REHASH }, | |
316 | {"die", OPER_DIE }, | |
317 | {"admin", OPER_ADMIN }, | |
318 | {"hidden_admin", OPER_HADMIN }, | |
319 | {"xline", OPER_XLINE }, | |
1ebe6ffc | 320 | {"resv", OPER_RESV }, |
212380e3 AC |
321 | {"operwall", OPER_OPERWALL }, |
322 | {"oper_spy", OPER_SPY }, | |
323 | {"hidden_oper", OPER_INVIS }, | |
324 | {"remoteban", OPER_REMOTEBAN }, | |
a6f4368b | 325 | {"mass_notice", OPER_MASSNOTICE }, |
212380e3 AC |
326 | {NULL, 0} |
327 | }; | |
328 | ||
329 | static struct mode_table auth_table[] = { | |
330 | {"encrypted", CONF_FLAGS_ENCRYPTED }, | |
331 | {"spoof_notice", CONF_FLAGS_SPOOF_NOTICE }, | |
332 | {"exceed_limit", CONF_FLAGS_NOLIMIT }, | |
333 | {"dnsbl_exempt", CONF_FLAGS_EXEMPTDNSBL }, | |
334 | {"kline_exempt", CONF_FLAGS_EXEMPTKLINE }, | |
212380e3 AC |
335 | {"flood_exempt", CONF_FLAGS_EXEMPTFLOOD }, |
336 | {"spambot_exempt", CONF_FLAGS_EXEMPTSPAMBOT }, | |
337 | {"shide_exempt", CONF_FLAGS_EXEMPTSHIDE }, | |
338 | {"jupe_exempt", CONF_FLAGS_EXEMPTJUPE }, | |
339 | {"resv_exempt", CONF_FLAGS_EXEMPTRESV }, | |
340 | {"no_tilde", CONF_FLAGS_NO_TILDE }, | |
341 | {"need_ident", CONF_FLAGS_NEED_IDENTD }, | |
342 | {"have_ident", CONF_FLAGS_NEED_IDENTD }, | |
343 | {"need_sasl", CONF_FLAGS_NEED_SASL }, | |
344 | {NULL, 0} | |
345 | }; | |
346 | ||
347 | static struct mode_table connect_table[] = { | |
348 | { "autoconn", SERVER_AUTOCONN }, | |
349 | { "compressed", SERVER_COMPRESSED }, | |
350 | { "encrypted", SERVER_ENCRYPTED }, | |
351 | { "topicburst", SERVER_TB }, | |
c6d72037 | 352 | { "ssl", SERVER_SSL }, |
212380e3 AC |
353 | { NULL, 0 }, |
354 | }; | |
355 | ||
356 | static struct mode_table cluster_table[] = { | |
357 | { "kline", SHARED_PKLINE }, | |
358 | { "tkline", SHARED_TKLINE }, | |
359 | { "unkline", SHARED_UNKLINE }, | |
360 | { "locops", SHARED_LOCOPS }, | |
361 | { "xline", SHARED_PXLINE }, | |
362 | { "txline", SHARED_TXLINE }, | |
363 | { "unxline", SHARED_UNXLINE }, | |
364 | { "resv", SHARED_PRESV }, | |
365 | { "tresv", SHARED_TRESV }, | |
366 | { "unresv", SHARED_UNRESV }, | |
367 | { "all", CLUSTER_ALL }, | |
368 | {NULL, 0} | |
369 | }; | |
370 | ||
371 | static struct mode_table shared_table[] = | |
372 | { | |
373 | { "kline", SHARED_PKLINE|SHARED_TKLINE }, | |
374 | { "xline", SHARED_PXLINE|SHARED_TXLINE }, | |
375 | { "resv", SHARED_PRESV|SHARED_TRESV }, | |
f5cb68d5 VY |
376 | { "dline", SHARED_PDLINE|SHARED_TDLINE }, |
377 | { "tdline", SHARED_TDLINE }, | |
378 | { "pdline", SHARED_PDLINE }, | |
379 | { "undline", SHARED_UNDLINE }, | |
212380e3 AC |
380 | { "tkline", SHARED_TKLINE }, |
381 | { "unkline", SHARED_UNKLINE }, | |
382 | { "txline", SHARED_TXLINE }, | |
383 | { "unxline", SHARED_UNXLINE }, | |
384 | { "tresv", SHARED_TRESV }, | |
385 | { "unresv", SHARED_UNRESV }, | |
386 | { "locops", SHARED_LOCOPS }, | |
387 | { "rehash", SHARED_REHASH }, | |
388 | { "all", SHARED_ALL }, | |
389 | { "none", 0 }, | |
390 | {NULL, 0} | |
391 | }; | |
392 | /* *INDENT-ON* */ | |
393 | ||
394 | static int | |
395 | find_umode(struct mode_table *tab, const char *name) | |
396 | { | |
397 | int i; | |
398 | ||
399 | for (i = 0; tab[i].name; i++) | |
400 | { | |
401 | if(strcmp(tab[i].name, name) == 0) | |
402 | return tab[i].mode; | |
403 | } | |
404 | ||
405 | return -1; | |
406 | } | |
407 | ||
408 | static void | |
409 | set_modes_from_table(int *modes, const char *whatis, struct mode_table *tab, conf_parm_t * args) | |
410 | { | |
411 | for (; args; args = args->next) | |
412 | { | |
413 | const char *umode; | |
414 | int dir = 1; | |
415 | int mode; | |
416 | ||
417 | if((args->type & CF_MTYPE) != CF_STRING) | |
418 | { | |
419 | conf_report_error("Warning -- %s is not a string; ignoring.", whatis); | |
420 | continue; | |
421 | } | |
422 | ||
423 | umode = args->v.string; | |
424 | ||
425 | if(*umode == '~') | |
426 | { | |
427 | dir = 0; | |
428 | umode++; | |
429 | } | |
430 | ||
431 | mode = find_umode(tab, umode); | |
432 | ||
433 | if(mode == -1) | |
434 | { | |
435 | conf_report_error("Warning -- unknown %s %s.", whatis, args->v.string); | |
436 | continue; | |
437 | } | |
438 | ||
439 | if(mode) | |
440 | { | |
441 | if(dir) | |
442 | *modes |= mode; | |
443 | else | |
444 | *modes &= ~mode; | |
445 | } | |
446 | else | |
447 | *modes = 0; | |
448 | } | |
449 | } | |
450 | ||
451 | static int | |
452 | conf_begin_oper(struct TopConf *tc) | |
453 | { | |
330fc5c1 | 454 | rb_dlink_node *ptr; |
637c4932 | 455 | rb_dlink_node *next_ptr; |
212380e3 AC |
456 | |
457 | if(yy_oper != NULL) | |
458 | { | |
459 | free_oper_conf(yy_oper); | |
460 | yy_oper = NULL; | |
461 | } | |
462 | ||
637c4932 | 463 | RB_DLINK_FOREACH_SAFE(ptr, next_ptr, yy_oper_list.head) |
212380e3 AC |
464 | { |
465 | free_oper_conf(ptr->data); | |
330fc5c1 | 466 | rb_dlinkDestroy(ptr, &yy_oper_list); |
212380e3 AC |
467 | } |
468 | ||
469 | yy_oper = make_oper_conf(); | |
a6f4368b | 470 | yy_oper->flags |= OPER_ENCRYPTED|OPER_RESV|OPER_OPERWALL|OPER_REMOTEBAN|OPER_MASSNOTICE; |
212380e3 AC |
471 | |
472 | return 0; | |
473 | } | |
474 | ||
475 | static int | |
476 | conf_end_oper(struct TopConf *tc) | |
477 | { | |
478 | struct oper_conf *yy_tmpoper; | |
330fc5c1 | 479 | rb_dlink_node *ptr; |
637c4932 | 480 | rb_dlink_node *next_ptr; |
212380e3 AC |
481 | |
482 | if(conf_cur_block_name != NULL) | |
483 | { | |
484 | if(strlen(conf_cur_block_name) > OPERNICKLEN) | |
485 | conf_cur_block_name[OPERNICKLEN] = '\0'; | |
486 | ||
47a03750 | 487 | yy_oper->name = rb_strdup(conf_cur_block_name); |
212380e3 AC |
488 | } |
489 | ||
490 | if(EmptyString(yy_oper->name)) | |
491 | { | |
492 | conf_report_error("Ignoring operator block -- missing name."); | |
493 | return 0; | |
494 | } | |
495 | ||
496 | #ifdef HAVE_LIBCRYPTO | |
497 | if(EmptyString(yy_oper->passwd) && EmptyString(yy_oper->rsa_pubkey_file)) | |
498 | #else | |
499 | if(EmptyString(yy_oper->passwd)) | |
500 | #endif | |
501 | { | |
502 | conf_report_error("Ignoring operator block for %s -- missing password", | |
503 | yy_oper->name); | |
504 | return 0; | |
505 | } | |
506 | ||
507 | /* now, yy_oper_list contains a stack of oper_conf's with just user | |
508 | * and host in, yy_oper contains the rest of the information which | |
509 | * we need to copy into each element in yy_oper_list | |
510 | */ | |
637c4932 | 511 | RB_DLINK_FOREACH_SAFE(ptr, next_ptr, yy_oper_list.head) |
212380e3 AC |
512 | { |
513 | yy_tmpoper = ptr->data; | |
514 | ||
47a03750 | 515 | yy_tmpoper->name = rb_strdup(yy_oper->name); |
212380e3 AC |
516 | |
517 | /* could be an rsa key instead.. */ | |
518 | if(!EmptyString(yy_oper->passwd)) | |
47a03750 | 519 | yy_tmpoper->passwd = rb_strdup(yy_oper->passwd); |
212380e3 AC |
520 | |
521 | yy_tmpoper->flags = yy_oper->flags; | |
522 | yy_tmpoper->umodes = yy_oper->umodes; | |
523 | yy_tmpoper->snomask = yy_oper->snomask; | |
524 | ||
525 | #ifdef HAVE_LIBCRYPTO | |
526 | if(yy_oper->rsa_pubkey_file) | |
527 | { | |
528 | BIO *file; | |
529 | ||
530 | if((file = BIO_new_file(yy_oper->rsa_pubkey_file, "r")) == NULL) | |
531 | { | |
532 | conf_report_error("Ignoring operator block for %s -- " | |
533 | "rsa_public_key_file cant be opened", | |
534 | yy_tmpoper->name); | |
535 | return 0; | |
536 | } | |
537 | ||
538 | yy_tmpoper->rsa_pubkey = | |
539 | (RSA *) PEM_read_bio_RSA_PUBKEY(file, NULL, 0, NULL); | |
540 | ||
c422d2a0 | 541 | (void)BIO_set_close(file, BIO_CLOSE); |
212380e3 AC |
542 | BIO_free(file); |
543 | ||
544 | if(yy_tmpoper->rsa_pubkey == NULL) | |
545 | { | |
546 | conf_report_error("Ignoring operator block for %s -- " | |
547 | "rsa_public_key_file key invalid; check syntax", | |
548 | yy_tmpoper->name); | |
549 | return 0; | |
550 | } | |
551 | } | |
552 | #endif | |
553 | ||
554 | /* all is ok, put it on oper_conf_list */ | |
330fc5c1 | 555 | rb_dlinkMoveNode(ptr, &yy_oper_list, &oper_conf_list); |
212380e3 AC |
556 | } |
557 | ||
558 | free_oper_conf(yy_oper); | |
559 | yy_oper = NULL; | |
560 | ||
561 | return 0; | |
562 | } | |
563 | ||
564 | static void | |
565 | conf_set_oper_flags(void *data) | |
566 | { | |
567 | conf_parm_t *args = data; | |
568 | ||
19c13ce5 | 569 | set_modes_from_table(&yy_oper->flags, "flag", oper_table, args); |
212380e3 AC |
570 | } |
571 | ||
572 | static void | |
573 | conf_set_oper_user(void *data) | |
574 | { | |
575 | struct oper_conf *yy_tmpoper; | |
576 | char *p; | |
577 | char *host = (char *) data; | |
578 | ||
579 | yy_tmpoper = make_oper_conf(); | |
580 | ||
581 | if((p = strchr(host, '@'))) | |
582 | { | |
583 | *p++ = '\0'; | |
584 | ||
47a03750 VY |
585 | yy_tmpoper->username = rb_strdup(host); |
586 | yy_tmpoper->host = rb_strdup(p); | |
212380e3 AC |
587 | } |
588 | else | |
589 | { | |
590 | ||
47a03750 VY |
591 | yy_tmpoper->username = rb_strdup("*"); |
592 | yy_tmpoper->host = rb_strdup(host); | |
212380e3 AC |
593 | } |
594 | ||
595 | if(EmptyString(yy_tmpoper->username) || EmptyString(yy_tmpoper->host)) | |
596 | { | |
597 | conf_report_error("Ignoring user -- missing username/host"); | |
598 | free_oper_conf(yy_tmpoper); | |
599 | return; | |
600 | } | |
601 | ||
330fc5c1 | 602 | rb_dlinkAddAlloc(yy_tmpoper, &yy_oper_list); |
212380e3 AC |
603 | } |
604 | ||
605 | static void | |
606 | conf_set_oper_password(void *data) | |
607 | { | |
608 | if(yy_oper->passwd) | |
609 | { | |
610 | memset(yy_oper->passwd, 0, strlen(yy_oper->passwd)); | |
637c4932 | 611 | rb_free(yy_oper->passwd); |
212380e3 AC |
612 | } |
613 | ||
47a03750 | 614 | yy_oper->passwd = rb_strdup((char *) data); |
212380e3 AC |
615 | } |
616 | ||
617 | static void | |
618 | conf_set_oper_rsa_public_key_file(void *data) | |
619 | { | |
620 | #ifdef HAVE_LIBCRYPTO | |
637c4932 | 621 | rb_free(yy_oper->rsa_pubkey_file); |
47a03750 | 622 | yy_oper->rsa_pubkey_file = rb_strdup((char *) data); |
212380e3 AC |
623 | #else |
624 | conf_report_error("Warning -- ignoring rsa_public_key_file (OpenSSL support not available"); | |
625 | #endif | |
626 | } | |
627 | ||
628 | static void | |
629 | conf_set_oper_umodes(void *data) | |
630 | { | |
631 | set_modes_from_table(&yy_oper->umodes, "umode", umode_table, data); | |
632 | } | |
633 | ||
634 | static void | |
635 | conf_set_oper_snomask(void *data) | |
636 | { | |
637 | yy_oper->snomask = parse_snobuf_to_mask(0, (const char *) data); | |
638 | } | |
639 | ||
640 | static int | |
641 | conf_begin_class(struct TopConf *tc) | |
642 | { | |
643 | if(yy_class) | |
644 | free_class(yy_class); | |
645 | ||
646 | yy_class = make_class(); | |
647 | return 0; | |
648 | } | |
649 | ||
650 | static int | |
651 | conf_end_class(struct TopConf *tc) | |
652 | { | |
653 | if(conf_cur_block_name != NULL) | |
47a03750 | 654 | yy_class->class_name = rb_strdup(conf_cur_block_name); |
212380e3 AC |
655 | |
656 | if(EmptyString(yy_class->class_name)) | |
657 | { | |
658 | conf_report_error("Ignoring connect block -- missing name."); | |
659 | return 0; | |
660 | } | |
661 | ||
662 | add_class(yy_class); | |
663 | yy_class = NULL; | |
664 | return 0; | |
665 | } | |
666 | ||
667 | static void | |
668 | conf_set_class_ping_time(void *data) | |
669 | { | |
670 | yy_class->ping_freq = *(unsigned int *) data; | |
671 | } | |
672 | ||
673 | static void | |
674 | conf_set_class_cidr_bitlen(void *data) | |
675 | { | |
ccda6e3f | 676 | #ifdef RB_IPV6 |
212380e3 AC |
677 | unsigned int maxsize = 128; |
678 | #else | |
679 | unsigned int maxsize = 32; | |
680 | #endif | |
681 | if(*(unsigned int *) data > maxsize) | |
682 | conf_report_error | |
683 | ("class::cidr_bitlen argument exceeds maxsize (%d > %d) - ignoring.", | |
684 | *(unsigned int *) data, maxsize); | |
685 | else | |
686 | yy_class->cidr_bitlen = *(unsigned int *) data; | |
687 | ||
688 | } | |
689 | static void | |
690 | conf_set_class_number_per_cidr(void *data) | |
691 | { | |
692 | yy_class->cidr_amount = *(unsigned int *) data; | |
693 | } | |
694 | ||
695 | static void | |
696 | conf_set_class_number_per_ip(void *data) | |
697 | { | |
698 | yy_class->max_local = *(unsigned int *) data; | |
699 | } | |
700 | ||
701 | ||
702 | static void | |
703 | conf_set_class_number_per_ip_global(void *data) | |
704 | { | |
705 | yy_class->max_global = *(unsigned int *) data; | |
706 | } | |
707 | ||
708 | static void | |
709 | conf_set_class_number_per_ident(void *data) | |
710 | { | |
711 | yy_class->max_ident = *(unsigned int *) data; | |
712 | } | |
713 | ||
714 | static void | |
715 | conf_set_class_connectfreq(void *data) | |
716 | { | |
717 | yy_class->con_freq = *(unsigned int *) data; | |
718 | } | |
719 | ||
720 | static void | |
721 | conf_set_class_max_number(void *data) | |
722 | { | |
723 | yy_class->max_total = *(unsigned int *) data; | |
724 | } | |
725 | ||
726 | static void | |
727 | conf_set_class_sendq(void *data) | |
728 | { | |
729 | yy_class->max_sendq = *(unsigned int *) data; | |
730 | } | |
731 | ||
732 | static char *listener_address; | |
733 | ||
734 | static int | |
735 | conf_begin_listen(struct TopConf *tc) | |
736 | { | |
637c4932 | 737 | rb_free(listener_address); |
212380e3 AC |
738 | listener_address = NULL; |
739 | return 0; | |
740 | } | |
741 | ||
742 | static int | |
743 | conf_end_listen(struct TopConf *tc) | |
744 | { | |
637c4932 | 745 | rb_free(listener_address); |
212380e3 AC |
746 | listener_address = NULL; |
747 | return 0; | |
748 | } | |
749 | ||
c6d72037 VY |
750 | |
751 | ||
212380e3 | 752 | static void |
c6d72037 | 753 | conf_set_listen_port_both(void *data, int ssl) |
212380e3 AC |
754 | { |
755 | conf_parm_t *args = data; | |
756 | for (; args; args = args->next) | |
757 | { | |
758 | if((args->type & CF_MTYPE) != CF_INT) | |
759 | { | |
760 | conf_report_error | |
761 | ("listener::port argument is not an integer " "-- ignoring."); | |
762 | continue; | |
763 | } | |
764 | if(listener_address == NULL) | |
765 | { | |
c6d72037 | 766 | add_listener(args->v.number, listener_address, AF_INET, ssl); |
ccda6e3f | 767 | #ifdef RB_IPV6 |
c6d72037 | 768 | add_listener(args->v.number, listener_address, AF_INET6, ssl); |
212380e3 AC |
769 | #endif |
770 | } | |
771 | else | |
772 | { | |
773 | int family; | |
ccda6e3f | 774 | #ifdef RB_IPV6 |
212380e3 AC |
775 | if(strchr(listener_address, ':') != NULL) |
776 | family = AF_INET6; | |
777 | else | |
778 | #endif | |
779 | family = AF_INET; | |
780 | ||
c6d72037 | 781 | add_listener(args->v.number, listener_address, family, ssl); |
212380e3 AC |
782 | |
783 | } | |
784 | ||
785 | } | |
786 | } | |
787 | ||
8bd5767b JT |
788 | static void |
789 | conf_set_listen_port(void *data) | |
790 | { | |
791 | conf_set_listen_port_both(data, 0); | |
792 | } | |
793 | ||
794 | static void | |
795 | conf_set_listen_sslport(void *data) | |
796 | { | |
797 | conf_set_listen_port_both(data, 1); | |
c6d72037 VY |
798 | } |
799 | ||
212380e3 AC |
800 | static void |
801 | conf_set_listen_address(void *data) | |
802 | { | |
637c4932 | 803 | rb_free(listener_address); |
47a03750 | 804 | listener_address = rb_strdup(data); |
212380e3 AC |
805 | } |
806 | ||
807 | static int | |
808 | conf_begin_auth(struct TopConf *tc) | |
809 | { | |
330fc5c1 | 810 | rb_dlink_node *ptr; |
637c4932 | 811 | rb_dlink_node *next_ptr; |
212380e3 AC |
812 | |
813 | if(yy_aconf) | |
814 | free_conf(yy_aconf); | |
815 | ||
637c4932 | 816 | RB_DLINK_FOREACH_SAFE(ptr, next_ptr, yy_aconf_list.head) |
212380e3 AC |
817 | { |
818 | free_conf(ptr->data); | |
330fc5c1 | 819 | rb_dlinkDestroy(ptr, &yy_aconf_list); |
212380e3 AC |
820 | } |
821 | ||
822 | yy_aconf = make_conf(); | |
823 | yy_aconf->status = CONF_CLIENT; | |
824 | ||
825 | return 0; | |
826 | } | |
827 | ||
828 | static int | |
829 | conf_end_auth(struct TopConf *tc) | |
830 | { | |
831 | struct ConfItem *yy_tmp; | |
330fc5c1 | 832 | rb_dlink_node *ptr; |
637c4932 | 833 | rb_dlink_node *next_ptr; |
212380e3 AC |
834 | |
835 | if(EmptyString(yy_aconf->name)) | |
47a03750 | 836 | yy_aconf->name = rb_strdup("NOMATCH"); |
212380e3 AC |
837 | |
838 | /* didnt even get one ->host? */ | |
839 | if(EmptyString(yy_aconf->host)) | |
840 | { | |
841 | conf_report_error("Ignoring auth block -- missing user@host"); | |
842 | return 0; | |
843 | } | |
844 | ||
845 | /* so the stacking works in order.. */ | |
846 | collapse(yy_aconf->user); | |
847 | collapse(yy_aconf->host); | |
848 | conf_add_class_to_conf(yy_aconf); | |
849 | add_conf_by_address(yy_aconf->host, CONF_CLIENT, yy_aconf->user, yy_aconf); | |
850 | ||
637c4932 | 851 | RB_DLINK_FOREACH_SAFE(ptr, next_ptr, yy_aconf_list.head) |
212380e3 AC |
852 | { |
853 | yy_tmp = ptr->data; | |
854 | ||
855 | if(yy_aconf->passwd) | |
47a03750 | 856 | yy_tmp->passwd = rb_strdup(yy_aconf->passwd); |
212380e3 AC |
857 | |
858 | /* this will always exist.. */ | |
47a03750 | 859 | yy_tmp->name = rb_strdup(yy_aconf->name); |
212380e3 AC |
860 | |
861 | if(yy_aconf->className) | |
47a03750 | 862 | yy_tmp->className = rb_strdup(yy_aconf->className); |
212380e3 AC |
863 | |
864 | yy_tmp->flags = yy_aconf->flags; | |
865 | yy_tmp->port = yy_aconf->port; | |
866 | ||
867 | collapse(yy_tmp->user); | |
868 | collapse(yy_tmp->host); | |
869 | ||
870 | conf_add_class_to_conf(yy_tmp); | |
871 | ||
872 | add_conf_by_address(yy_tmp->host, CONF_CLIENT, yy_tmp->user, yy_tmp); | |
330fc5c1 | 873 | rb_dlinkDestroy(ptr, &yy_aconf_list); |
212380e3 AC |
874 | } |
875 | ||
876 | yy_aconf = NULL; | |
877 | return 0; | |
878 | } | |
879 | ||
880 | static void | |
881 | conf_set_auth_user(void *data) | |
882 | { | |
883 | struct ConfItem *yy_tmp; | |
884 | char *p; | |
885 | ||
886 | /* The first user= line doesn't allocate a new conf */ | |
887 | if(!EmptyString(yy_aconf->host)) | |
888 | { | |
889 | yy_tmp = make_conf(); | |
890 | yy_tmp->status = CONF_CLIENT; | |
891 | } | |
892 | else | |
893 | yy_tmp = yy_aconf; | |
894 | ||
895 | if((p = strchr(data, '@'))) | |
896 | { | |
897 | *p++ = '\0'; | |
898 | ||
47a03750 VY |
899 | yy_tmp->user = rb_strdup(data); |
900 | yy_tmp->host = rb_strdup(p); | |
212380e3 AC |
901 | } |
902 | else | |
903 | { | |
47a03750 VY |
904 | yy_tmp->user = rb_strdup("*"); |
905 | yy_tmp->host = rb_strdup(data); | |
212380e3 AC |
906 | } |
907 | ||
908 | if(yy_aconf != yy_tmp) | |
330fc5c1 | 909 | rb_dlinkAddAlloc(yy_tmp, &yy_aconf_list); |
212380e3 AC |
910 | } |
911 | ||
912 | static void | |
913 | conf_set_auth_passwd(void *data) | |
914 | { | |
915 | if(yy_aconf->passwd) | |
916 | memset(yy_aconf->passwd, 0, strlen(yy_aconf->passwd)); | |
637c4932 | 917 | rb_free(yy_aconf->passwd); |
47a03750 | 918 | yy_aconf->passwd = rb_strdup(data); |
212380e3 AC |
919 | } |
920 | ||
921 | static void | |
922 | conf_set_auth_spoof(void *data) | |
923 | { | |
924 | char *p; | |
925 | char *user = NULL; | |
926 | char *host = NULL; | |
927 | ||
928 | host = data; | |
929 | ||
930 | /* user@host spoof */ | |
931 | if((p = strchr(host, '@')) != NULL) | |
932 | { | |
933 | *p = '\0'; | |
934 | user = data; | |
935 | host = p+1; | |
936 | ||
937 | if(EmptyString(user)) | |
938 | { | |
939 | conf_report_error("Warning -- spoof ident empty."); | |
940 | return; | |
941 | } | |
942 | ||
943 | if(strlen(user) > USERLEN) | |
944 | { | |
945 | conf_report_error("Warning -- spoof ident length invalid."); | |
946 | return; | |
947 | } | |
948 | ||
949 | if(!valid_username(user)) | |
950 | { | |
951 | conf_report_error("Warning -- invalid spoof (ident)."); | |
952 | return; | |
953 | } | |
954 | ||
955 | /* this must be restored! */ | |
956 | *p = '@'; | |
957 | } | |
958 | ||
959 | if(EmptyString(host)) | |
960 | { | |
961 | conf_report_error("Warning -- spoof host empty."); | |
962 | return; | |
963 | } | |
964 | ||
965 | if(strlen(host) > HOSTLEN) | |
966 | { | |
967 | conf_report_error("Warning -- spoof host length invalid."); | |
968 | return; | |
969 | } | |
970 | ||
971 | if(!valid_hostname(host)) | |
972 | { | |
973 | conf_report_error("Warning -- invalid spoof (host)."); | |
974 | return; | |
975 | } | |
976 | ||
637c4932 | 977 | rb_free(yy_aconf->name); |
47a03750 | 978 | yy_aconf->name = rb_strdup(data); |
212380e3 AC |
979 | yy_aconf->flags |= CONF_FLAGS_SPOOF_IP; |
980 | } | |
981 | ||
982 | static void | |
983 | conf_set_auth_flags(void *data) | |
984 | { | |
985 | conf_parm_t *args = data; | |
986 | ||
987 | set_modes_from_table((int *) &yy_aconf->flags, "flag", auth_table, args); | |
988 | } | |
989 | ||
990 | static void | |
991 | conf_set_auth_redir_serv(void *data) | |
992 | { | |
993 | yy_aconf->flags |= CONF_FLAGS_REDIR; | |
637c4932 | 994 | rb_free(yy_aconf->name); |
47a03750 | 995 | yy_aconf->name = rb_strdup(data); |
212380e3 AC |
996 | } |
997 | ||
998 | static void | |
999 | conf_set_auth_redir_port(void *data) | |
1000 | { | |
1001 | int port = *(unsigned int *) data; | |
1002 | ||
1003 | yy_aconf->flags |= CONF_FLAGS_REDIR; | |
1004 | yy_aconf->port = port; | |
1005 | } | |
1006 | ||
1007 | static void | |
1008 | conf_set_auth_class(void *data) | |
1009 | { | |
637c4932 | 1010 | rb_free(yy_aconf->className); |
47a03750 | 1011 | yy_aconf->className = rb_strdup(data); |
212380e3 AC |
1012 | } |
1013 | ||
1014 | /* ok, shared_oper handles the stacking, shared_flags handles adding | |
1015 | * things.. so all we need to do when we start and end a shared block, is | |
1016 | * clean up anything thats been left over. | |
1017 | */ | |
1018 | static int | |
1019 | conf_cleanup_shared(struct TopConf *tc) | |
1020 | { | |
637c4932 | 1021 | rb_dlink_node *ptr, *next_ptr; |
212380e3 | 1022 | |
637c4932 | 1023 | RB_DLINK_FOREACH_SAFE(ptr, next_ptr, yy_shared_list.head) |
212380e3 AC |
1024 | { |
1025 | free_remote_conf(ptr->data); | |
330fc5c1 | 1026 | rb_dlinkDestroy(ptr, &yy_shared_list); |
212380e3 AC |
1027 | } |
1028 | ||
1029 | if(yy_shared != NULL) | |
1030 | { | |
1031 | free_remote_conf(yy_shared); | |
1032 | yy_shared = NULL; | |
1033 | } | |
1034 | ||
1035 | return 0; | |
1036 | } | |
1037 | ||
1038 | static void | |
1039 | conf_set_shared_oper(void *data) | |
1040 | { | |
1041 | conf_parm_t *args = data; | |
1042 | const char *username; | |
1043 | char *p; | |
1044 | ||
1045 | if(yy_shared != NULL) | |
1046 | free_remote_conf(yy_shared); | |
1047 | ||
1048 | yy_shared = make_remote_conf(); | |
1049 | ||
1050 | if(args->next != NULL) | |
1051 | { | |
1052 | if((args->type & CF_MTYPE) != CF_QSTRING) | |
1053 | { | |
1054 | conf_report_error("Ignoring shared::oper -- server is not a qstring"); | |
1055 | return; | |
1056 | } | |
1057 | ||
47a03750 | 1058 | yy_shared->server = rb_strdup(args->v.string); |
212380e3 AC |
1059 | args = args->next; |
1060 | } | |
1061 | else | |
47a03750 | 1062 | yy_shared->server = rb_strdup("*"); |
212380e3 AC |
1063 | |
1064 | if((args->type & CF_MTYPE) != CF_QSTRING) | |
1065 | { | |
1066 | conf_report_error("Ignoring shared::oper -- oper is not a qstring"); | |
1067 | return; | |
1068 | } | |
1069 | ||
1070 | if((p = strchr(args->v.string, '@')) == NULL) | |
1071 | { | |
1072 | conf_report_error("Ignoring shard::oper -- oper is not a user@host"); | |
1073 | return; | |
1074 | } | |
1075 | ||
1076 | username = args->v.string; | |
1077 | *p++ = '\0'; | |
1078 | ||
1079 | if(EmptyString(p)) | |
47a03750 | 1080 | yy_shared->host = rb_strdup("*"); |
212380e3 | 1081 | else |
47a03750 | 1082 | yy_shared->host = rb_strdup(p); |
212380e3 AC |
1083 | |
1084 | if(EmptyString(username)) | |
47a03750 | 1085 | yy_shared->username = rb_strdup("*"); |
212380e3 | 1086 | else |
47a03750 | 1087 | yy_shared->username = rb_strdup(username); |
212380e3 | 1088 | |
330fc5c1 | 1089 | rb_dlinkAddAlloc(yy_shared, &yy_shared_list); |
212380e3 AC |
1090 | yy_shared = NULL; |
1091 | } | |
1092 | ||
1093 | static void | |
1094 | conf_set_shared_flags(void *data) | |
1095 | { | |
1096 | conf_parm_t *args = data; | |
1097 | int flags = 0; | |
637c4932 | 1098 | rb_dlink_node *ptr, *next_ptr; |
212380e3 AC |
1099 | |
1100 | if(yy_shared != NULL) | |
1101 | free_remote_conf(yy_shared); | |
1102 | ||
1103 | set_modes_from_table(&flags, "flag", shared_table, args); | |
1104 | ||
637c4932 | 1105 | RB_DLINK_FOREACH_SAFE(ptr, next_ptr, yy_shared_list.head) |
212380e3 AC |
1106 | { |
1107 | yy_shared = ptr->data; | |
1108 | ||
1109 | yy_shared->flags = flags; | |
330fc5c1 AC |
1110 | rb_dlinkDestroy(ptr, &yy_shared_list); |
1111 | rb_dlinkAddTail(yy_shared, &yy_shared->node, &shared_conf_list); | |
212380e3 AC |
1112 | } |
1113 | ||
1114 | yy_shared = NULL; | |
1115 | } | |
1116 | ||
1117 | static int | |
1118 | conf_begin_connect(struct TopConf *tc) | |
1119 | { | |
1120 | if(yy_server) | |
1121 | free_server_conf(yy_server); | |
1122 | ||
1123 | yy_server = make_server_conf(); | |
1124 | yy_server->port = PORTNUM; | |
5aa453a4 | 1125 | yy_server->flags |= SERVER_TB; |
212380e3 AC |
1126 | |
1127 | if(conf_cur_block_name != NULL) | |
47a03750 | 1128 | yy_server->name = rb_strdup(conf_cur_block_name); |
212380e3 AC |
1129 | |
1130 | return 0; | |
1131 | } | |
1132 | ||
1133 | static int | |
1134 | conf_end_connect(struct TopConf *tc) | |
1135 | { | |
1136 | if(EmptyString(yy_server->name)) | |
1137 | { | |
1138 | conf_report_error("Ignoring connect block -- missing name."); | |
1139 | return 0; | |
1140 | } | |
1141 | ||
1142 | if(ServerInfo.name != NULL && !irccmp(ServerInfo.name, yy_server->name)) | |
1143 | { | |
1144 | conf_report_error("Ignoring connect block for %s -- name is equal to my own name.", | |
1145 | yy_server->name); | |
1146 | return 0; | |
1147 | } | |
1148 | ||
1149 | if(EmptyString(yy_server->passwd) || EmptyString(yy_server->spasswd)) | |
1150 | { | |
1151 | conf_report_error("Ignoring connect block for %s -- missing password.", | |
1152 | yy_server->name); | |
1153 | return 0; | |
1154 | } | |
1155 | ||
1156 | if(EmptyString(yy_server->host)) | |
1157 | { | |
1158 | conf_report_error("Ignoring connect block for %s -- missing host.", | |
1159 | yy_server->name); | |
1160 | return 0; | |
1161 | } | |
1162 | ||
1163 | #ifndef HAVE_LIBZ | |
1164 | if(ServerConfCompressed(yy_server)) | |
1165 | { | |
1166 | conf_report_error("Ignoring connect::flags::compressed -- zlib not available."); | |
1167 | yy_server->flags &= ~SERVER_COMPRESSED; | |
1168 | } | |
1169 | #endif | |
8bd5767b JT |
1170 | if(ServerConfCompressed(yy_server) && ServerConfSSL(yy_server)) |
1171 | { | |
1172 | conf_report_error("Ignoring compressed for connect block %s -- " | |
1173 | "ssl and compressed are mutually exclusive (OpenSSL does its own compression)", | |
1174 | yy_server->name); | |
1175 | yy_server->flags &= ~SERVER_COMPRESSED; | |
c6d72037 | 1176 | } |
212380e3 AC |
1177 | |
1178 | add_server_conf(yy_server); | |
330fc5c1 | 1179 | rb_dlinkAdd(yy_server, &yy_server->node, &server_conf_list); |
212380e3 AC |
1180 | |
1181 | yy_server = NULL; | |
1182 | return 0; | |
1183 | } | |
1184 | ||
1185 | static void | |
1186 | conf_set_connect_host(void *data) | |
1187 | { | |
637c4932 | 1188 | rb_free(yy_server->host); |
47a03750 | 1189 | yy_server->host = rb_strdup(data); |
212380e3 AC |
1190 | if (strchr(yy_server->host, ':')) |
1191 | yy_server->aftype = AF_INET6; | |
1192 | } | |
1193 | ||
1194 | static void | |
1195 | conf_set_connect_vhost(void *data) | |
1196 | { | |
caa4d9d2 | 1197 | if(rb_inet_pton_sock(data, (struct sockaddr *)&yy_server->my_ipnum) <= 0) |
212380e3 AC |
1198 | { |
1199 | conf_report_error("Invalid netmask for server vhost (%s)", | |
1200 | (char *) data); | |
1201 | return; | |
1202 | } | |
1203 | ||
1204 | yy_server->flags |= SERVER_VHOSTED; | |
1205 | } | |
1206 | ||
1207 | static void | |
1208 | conf_set_connect_send_password(void *data) | |
1209 | { | |
1210 | if(yy_server->spasswd) | |
1211 | { | |
1212 | memset(yy_server->spasswd, 0, strlen(yy_server->spasswd)); | |
637c4932 | 1213 | rb_free(yy_server->spasswd); |
212380e3 AC |
1214 | } |
1215 | ||
47a03750 | 1216 | yy_server->spasswd = rb_strdup(data); |
212380e3 AC |
1217 | } |
1218 | ||
1219 | static void | |
1220 | conf_set_connect_accept_password(void *data) | |
1221 | { | |
1222 | if(yy_server->passwd) | |
1223 | { | |
1224 | memset(yy_server->passwd, 0, strlen(yy_server->passwd)); | |
637c4932 | 1225 | rb_free(yy_server->passwd); |
212380e3 | 1226 | } |
47a03750 | 1227 | yy_server->passwd = rb_strdup(data); |
212380e3 AC |
1228 | } |
1229 | ||
1230 | static void | |
1231 | conf_set_connect_port(void *data) | |
1232 | { | |
1233 | int port = *(unsigned int *) data; | |
1234 | ||
1235 | if(port < 1) | |
1236 | port = PORTNUM; | |
1237 | ||
1238 | yy_server->port = port; | |
1239 | } | |
1240 | ||
1241 | static void | |
1242 | conf_set_connect_aftype(void *data) | |
1243 | { | |
1244 | char *aft = data; | |
1245 | ||
1246 | if(strcasecmp(aft, "ipv4") == 0) | |
1247 | yy_server->aftype = AF_INET; | |
ccda6e3f | 1248 | #ifdef RB_IPV6 |
212380e3 AC |
1249 | else if(strcasecmp(aft, "ipv6") == 0) |
1250 | yy_server->aftype = AF_INET6; | |
1251 | #endif | |
1252 | else | |
1253 | conf_report_error("connect::aftype '%s' is unknown.", aft); | |
1254 | } | |
1255 | ||
1256 | static void | |
1257 | conf_set_connect_flags(void *data) | |
1258 | { | |
1259 | conf_parm_t *args = data; | |
1260 | ||
1261 | /* note, we allow them to set compressed, then remove it later if | |
1262 | * they do and LIBZ isnt available | |
1263 | */ | |
1264 | set_modes_from_table(&yy_server->flags, "flag", connect_table, args); | |
1265 | } | |
1266 | ||
1267 | static void | |
1268 | conf_set_connect_hub_mask(void *data) | |
1269 | { | |
1270 | struct remote_conf *yy_hub; | |
1271 | ||
1272 | if(EmptyString(yy_server->name)) | |
1273 | return; | |
1274 | ||
1275 | yy_hub = make_remote_conf(); | |
1276 | yy_hub->flags = CONF_HUB; | |
1277 | ||
47a03750 VY |
1278 | yy_hub->host = rb_strdup(data); |
1279 | yy_hub->server = rb_strdup(yy_server->name); | |
330fc5c1 | 1280 | rb_dlinkAdd(yy_hub, &yy_hub->node, &hubleaf_conf_list); |
212380e3 AC |
1281 | } |
1282 | ||
1283 | static void | |
1284 | conf_set_connect_leaf_mask(void *data) | |
1285 | { | |
1286 | struct remote_conf *yy_leaf; | |
1287 | ||
1288 | if(EmptyString(yy_server->name)) | |
1289 | return; | |
1290 | ||
1291 | yy_leaf = make_remote_conf(); | |
1292 | yy_leaf->flags = CONF_LEAF; | |
1293 | ||
47a03750 VY |
1294 | yy_leaf->host = rb_strdup(data); |
1295 | yy_leaf->server = rb_strdup(yy_server->name); | |
330fc5c1 | 1296 | rb_dlinkAdd(yy_leaf, &yy_leaf->node, &hubleaf_conf_list); |
212380e3 AC |
1297 | } |
1298 | ||
1299 | static void | |
1300 | conf_set_connect_class(void *data) | |
1301 | { | |
637c4932 | 1302 | rb_free(yy_server->class_name); |
47a03750 | 1303 | yy_server->class_name = rb_strdup(data); |
212380e3 AC |
1304 | } |
1305 | ||
1306 | static void | |
1307 | conf_set_exempt_ip(void *data) | |
1308 | { | |
1309 | struct ConfItem *yy_tmp; | |
1310 | ||
1311 | if(parse_netmask(data, NULL, NULL) == HM_HOST) | |
1312 | { | |
1313 | conf_report_error("Ignoring exempt -- invalid exempt::ip."); | |
1314 | return; | |
1315 | } | |
1316 | ||
1317 | yy_tmp = make_conf(); | |
47a03750 VY |
1318 | yy_tmp->passwd = rb_strdup("*"); |
1319 | yy_tmp->host = rb_strdup(data); | |
212380e3 AC |
1320 | yy_tmp->status = CONF_EXEMPTDLINE; |
1321 | add_conf_by_address(yy_tmp->host, CONF_EXEMPTDLINE, NULL, yy_tmp); | |
1322 | } | |
1323 | ||
1324 | static int | |
1325 | conf_cleanup_cluster(struct TopConf *tc) | |
1326 | { | |
637c4932 | 1327 | rb_dlink_node *ptr, *next_ptr; |
212380e3 | 1328 | |
637c4932 | 1329 | RB_DLINK_FOREACH_SAFE(ptr, next_ptr, yy_cluster_list.head) |
212380e3 AC |
1330 | { |
1331 | free_remote_conf(ptr->data); | |
330fc5c1 | 1332 | rb_dlinkDestroy(ptr, &yy_cluster_list); |
212380e3 AC |
1333 | } |
1334 | ||
1335 | if(yy_shared != NULL) | |
1336 | { | |
1337 | free_remote_conf(yy_shared); | |
1338 | yy_shared = NULL; | |
1339 | } | |
1340 | ||
1341 | return 0; | |
1342 | } | |
1343 | ||
1344 | static void | |
1345 | conf_set_cluster_name(void *data) | |
1346 | { | |
1347 | if(yy_shared != NULL) | |
1348 | free_remote_conf(yy_shared); | |
1349 | ||
1350 | yy_shared = make_remote_conf(); | |
47a03750 | 1351 | yy_shared->server = rb_strdup(data); |
330fc5c1 | 1352 | rb_dlinkAddAlloc(yy_shared, &yy_cluster_list); |
212380e3 AC |
1353 | |
1354 | yy_shared = NULL; | |
1355 | } | |
1356 | ||
1357 | static void | |
1358 | conf_set_cluster_flags(void *data) | |
1359 | { | |
1360 | conf_parm_t *args = data; | |
1361 | int flags = 0; | |
637c4932 | 1362 | rb_dlink_node *ptr, *next_ptr; |
212380e3 AC |
1363 | |
1364 | if(yy_shared != NULL) | |
1365 | free_remote_conf(yy_shared); | |
1366 | ||
1367 | set_modes_from_table(&flags, "flag", cluster_table, args); | |
1368 | ||
637c4932 | 1369 | RB_DLINK_FOREACH_SAFE(ptr, next_ptr, yy_cluster_list.head) |
212380e3 AC |
1370 | { |
1371 | yy_shared = ptr->data; | |
1372 | yy_shared->flags = flags; | |
330fc5c1 AC |
1373 | rb_dlinkAddTail(yy_shared, &yy_shared->node, &cluster_conf_list); |
1374 | rb_dlinkDestroy(ptr, &yy_cluster_list); | |
212380e3 AC |
1375 | } |
1376 | ||
1377 | yy_shared = NULL; | |
1378 | } | |
1379 | ||
1380 | static void | |
1381 | conf_set_general_havent_read_conf(void *data) | |
1382 | { | |
1383 | if(*(unsigned int *) data) | |
1384 | { | |
1385 | conf_report_error("You haven't read your config file properly."); | |
1386 | conf_report_error | |
1387 | ("There is a line in the example conf that will kill your server if not removed."); | |
1388 | conf_report_error | |
1389 | ("Consider actually reading/editing the conf file, and removing this line."); | |
1390 | if (!testing_conf) | |
1391 | exit(0); | |
1392 | } | |
1393 | } | |
1394 | ||
1395 | static void | |
1396 | conf_set_general_hide_error_messages(void *data) | |
1397 | { | |
1398 | char *val = data; | |
1399 | ||
1400 | if(strcasecmp(val, "yes") == 0) | |
1401 | ConfigFileEntry.hide_error_messages = 2; | |
1402 | else if(strcasecmp(val, "opers") == 0) | |
1403 | ConfigFileEntry.hide_error_messages = 1; | |
1404 | else if(strcasecmp(val, "no") == 0) | |
1405 | ConfigFileEntry.hide_error_messages = 0; | |
1406 | else | |
1407 | conf_report_error("Invalid setting '%s' for general::hide_error_messages.", val); | |
1408 | } | |
1409 | ||
1410 | static void | |
1411 | conf_set_general_kline_delay(void *data) | |
1412 | { | |
1413 | ConfigFileEntry.kline_delay = *(unsigned int *) data; | |
1414 | ||
1415 | /* THIS MUST BE HERE to stop us being unable to check klines */ | |
1416 | kline_queued = 0; | |
1417 | } | |
1418 | ||
1419 | static void | |
1420 | conf_set_general_stats_k_oper_only(void *data) | |
1421 | { | |
1422 | char *val = data; | |
1423 | ||
1424 | if(strcasecmp(val, "yes") == 0) | |
1425 | ConfigFileEntry.stats_k_oper_only = 2; | |
1426 | else if(strcasecmp(val, "masked") == 0) | |
1427 | ConfigFileEntry.stats_k_oper_only = 1; | |
1428 | else if(strcasecmp(val, "no") == 0) | |
1429 | ConfigFileEntry.stats_k_oper_only = 0; | |
1430 | else | |
1431 | conf_report_error("Invalid setting '%s' for general::stats_k_oper_only.", val); | |
1432 | } | |
1433 | ||
1434 | static void | |
1435 | conf_set_general_stats_i_oper_only(void *data) | |
1436 | { | |
1437 | char *val = data; | |
1438 | ||
1439 | if(strcasecmp(val, "yes") == 0) | |
1440 | ConfigFileEntry.stats_i_oper_only = 2; | |
1441 | else if(strcasecmp(val, "masked") == 0) | |
1442 | ConfigFileEntry.stats_i_oper_only = 1; | |
1443 | else if(strcasecmp(val, "no") == 0) | |
1444 | ConfigFileEntry.stats_i_oper_only = 0; | |
1445 | else | |
1446 | conf_report_error("Invalid setting '%s' for general::stats_i_oper_only.", val); | |
1447 | } | |
1448 | ||
1449 | static void | |
1450 | conf_set_general_compression_level(void *data) | |
1451 | { | |
1452 | #ifdef HAVE_LIBZ | |
1453 | ConfigFileEntry.compression_level = *(unsigned int *) data; | |
1454 | ||
1455 | if((ConfigFileEntry.compression_level < 1) || (ConfigFileEntry.compression_level > 9)) | |
1456 | { | |
1457 | conf_report_error | |
1458 | ("Invalid general::compression_level %d -- using default.", | |
1459 | ConfigFileEntry.compression_level); | |
1460 | ConfigFileEntry.compression_level = 0; | |
1461 | } | |
1462 | #else | |
1463 | conf_report_error("Ignoring general::compression_level -- zlib not available."); | |
1464 | #endif | |
1465 | } | |
1466 | ||
1467 | static void | |
1468 | conf_set_general_default_umodes(void *data) | |
1469 | { | |
1470 | char *pm; | |
1471 | int what = MODE_ADD, flag; | |
1472 | ||
1473 | ConfigFileEntry.default_umodes = 0; | |
1474 | for (pm = (char *) data; *pm; pm++) | |
1475 | { | |
1476 | switch (*pm) | |
1477 | { | |
1478 | case '+': | |
1479 | what = MODE_ADD; | |
1480 | break; | |
1481 | case '-': | |
1482 | what = MODE_DEL; | |
1483 | break; | |
1484 | ||
1485 | /* don't allow +o */ | |
1486 | case 'o': | |
1487 | case 'S': | |
1488 | case ' ': | |
1489 | break; | |
1490 | ||
1491 | default: | |
1492 | if ((flag = user_modes[(unsigned char) *pm])) | |
1493 | { | |
1494 | /* Proper value has probably not yet been set | |
1495 | * so don't check oper_only_umodes -- jilles */ | |
1496 | if (what == MODE_ADD) | |
1497 | ConfigFileEntry.default_umodes |= flag; | |
1498 | else | |
1499 | ConfigFileEntry.default_umodes &= ~flag; | |
1500 | } | |
1501 | break; | |
1502 | } | |
1503 | } | |
1504 | } | |
1505 | ||
1506 | static void | |
1507 | conf_set_general_oper_umodes(void *data) | |
1508 | { | |
1509 | set_modes_from_table(&ConfigFileEntry.oper_umodes, "umode", umode_table, data); | |
1510 | } | |
1511 | ||
1512 | static void | |
1513 | conf_set_general_oper_only_umodes(void *data) | |
1514 | { | |
1515 | set_modes_from_table(&ConfigFileEntry.oper_only_umodes, "umode", umode_table, data); | |
1516 | } | |
1517 | ||
1518 | static void | |
1519 | conf_set_general_oper_snomask(void *data) | |
1520 | { | |
1521 | char *pm; | |
1522 | int what = MODE_ADD, flag; | |
1523 | ||
1524 | ConfigFileEntry.oper_snomask = 0; | |
1525 | for (pm = (char *) data; *pm; pm++) | |
1526 | { | |
1527 | switch (*pm) | |
1528 | { | |
1529 | case '+': | |
1530 | what = MODE_ADD; | |
1531 | break; | |
1532 | case '-': | |
1533 | what = MODE_DEL; | |
1534 | break; | |
1535 | ||
1536 | default: | |
1537 | if ((flag = snomask_modes[(unsigned char) *pm])) | |
1538 | { | |
1539 | if (what == MODE_ADD) | |
1540 | ConfigFileEntry.oper_snomask |= flag; | |
1541 | else | |
1542 | ConfigFileEntry.oper_snomask &= ~flag; | |
1543 | } | |
1544 | break; | |
1545 | } | |
1546 | } | |
1547 | } | |
1548 | ||
1549 | static void | |
1550 | conf_set_serverhide_links_delay(void *data) | |
1551 | { | |
1552 | int val = *(unsigned int *) data; | |
1553 | ||
212380e3 AC |
1554 | ConfigServerHide.links_delay = val; |
1555 | } | |
1556 | ||
1557 | static int | |
1558 | conf_begin_service(struct TopConf *tc) | |
1559 | { | |
1560 | struct Client *target_p; | |
330fc5c1 | 1561 | rb_dlink_node *ptr; |
212380e3 | 1562 | |
5cefa1d6 | 1563 | RB_DLINK_FOREACH(ptr, global_serv_list.head) |
212380e3 AC |
1564 | { |
1565 | target_p = ptr->data; | |
1566 | ||
1567 | target_p->flags &= ~FLAGS_SERVICE; | |
1568 | } | |
1569 | ||
1570 | return 0; | |
1571 | } | |
1572 | ||
1573 | static void | |
1574 | conf_set_service_name(void *data) | |
1575 | { | |
1576 | struct Client *target_p; | |
1577 | const char *s; | |
1578 | char *tmp; | |
1579 | int dots = 0; | |
1580 | ||
1581 | for(s = data; *s != '\0'; s++) | |
1582 | { | |
1583 | if(!IsServChar(*s)) | |
1584 | { | |
1585 | conf_report_error("Ignoring service::name " | |
1586 | "-- bogus servername."); | |
1587 | return; | |
1588 | } | |
1589 | else if(*s == '.') | |
1590 | dots++; | |
1591 | } | |
1592 | ||
1593 | if(!dots) | |
1594 | { | |
1595 | conf_report_error("Ignoring service::name -- must contain '.'"); | |
1596 | return; | |
1597 | } | |
1598 | ||
47a03750 | 1599 | tmp = rb_strdup(data); |
330fc5c1 | 1600 | rb_dlinkAddAlloc(tmp, &service_list); |
212380e3 AC |
1601 | |
1602 | if((target_p = find_server(NULL, tmp))) | |
1603 | target_p->flags |= FLAGS_SERVICE; | |
1604 | } | |
1605 | ||
212380e3 AC |
1606 | static int |
1607 | conf_begin_alias(struct TopConf *tc) | |
1608 | { | |
eddc2ab6 | 1609 | yy_alias = rb_malloc(sizeof(struct alias_entry)); |
212380e3 AC |
1610 | |
1611 | if (conf_cur_block_name != NULL) | |
47a03750 | 1612 | yy_alias->name = rb_strdup(conf_cur_block_name); |
212380e3 AC |
1613 | |
1614 | yy_alias->flags = 0; | |
1615 | yy_alias->hits = 0; | |
1616 | ||
1617 | return 0; | |
1618 | } | |
1619 | ||
1620 | static int | |
1621 | conf_end_alias(struct TopConf *tc) | |
1622 | { | |
212380e3 AC |
1623 | if (yy_alias == NULL) |
1624 | return -1; | |
1625 | ||
1626 | if (yy_alias->name == NULL) | |
1627 | { | |
1628 | conf_report_error("Ignoring alias -- must have a name."); | |
1629 | ||
637c4932 | 1630 | rb_free(yy_alias); |
212380e3 AC |
1631 | |
1632 | return -1; | |
1633 | } | |
1634 | ||
1635 | if (yy_alias->target == NULL) | |
1636 | { | |
1637 | conf_report_error("Ignoring alias -- must have a target."); | |
1638 | ||
637c4932 | 1639 | rb_free(yy_alias); |
212380e3 AC |
1640 | |
1641 | return -1; | |
1642 | } | |
1643 | ||
8ac75529 | 1644 | if (!alias_dict) |
90187f21 | 1645 | alias_dict = irc_dictionary_create(strcasecmp); |
212380e3 | 1646 | |
8ac75529 | 1647 | irc_dictionary_add(alias_dict, yy_alias->name, yy_alias); |
212380e3 AC |
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 | ||
47a03750 | 1658 | yy_alias->name = rb_strdup(data); |
212380e3 AC |
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 | ||
47a03750 | 1667 | yy_alias->target = rb_strdup(data); |
212380e3 AC |
1668 | } |
1669 | ||
1670 | static void | |
1671 | conf_set_blacklist_host(void *data) | |
1672 | { | |
47a03750 | 1673 | yy_blacklist_host = rb_strdup(data); |
212380e3 AC |
1674 | } |
1675 | ||
1676 | static void | |
1677 | conf_set_blacklist_reason(void *data) | |
1678 | { | |
47a03750 | 1679 | yy_blacklist_reason = rb_strdup(data); |
212380e3 AC |
1680 | |
1681 | if (yy_blacklist_host && yy_blacklist_reason) | |
1682 | { | |
1683 | new_blacklist(yy_blacklist_host, yy_blacklist_reason); | |
637c4932 VY |
1684 | rb_free(yy_blacklist_host); |
1685 | rb_free(yy_blacklist_reason); | |
212380e3 AC |
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); | |
afdc068c | 1701 | rb_vsnprintf(msg, IRCD_BUFSIZE, fmt, ap); |
212380e3 AC |
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) | |
47a03750 | 1724 | conf_cur_block_name = rb_strdup(name); |
212380e3 AC |
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 | ||
637c4932 | 1741 | rb_free(conf_cur_block_name); |
212380e3 AC |
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 | ||
2e819b6b | 1757 | if(len && strlen(input) > (unsigned int)len) |
212380e3 AC |
1758 | input[len] = '\0'; |
1759 | ||
637c4932 | 1760 | rb_free(*loc); |
47a03750 | 1761 | *loc = rb_strdup(input); |
212380e3 AC |
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) | |
47a03750 | 1803 | cp->v.string = rb_strdup("yes"); |
212380e3 | 1804 | else |
47a03750 | 1805 | cp->v.string = rb_strdup("no"); |
212380e3 AC |
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 | ||
eddc2ab6 | 1873 | cf = rb_malloc(sizeof(struct ConfEntry)); |
212380e3 | 1874 | |
d7f753cd | 1875 | cf->cf_name = name; |
212380e3 AC |
1876 | cf->cf_type = type; |
1877 | cf->cf_func = func; | |
1878 | cf->cf_arg = NULL; | |
1879 | ||
330fc5c1 | 1880 | rb_dlinkAddAlloc(cf, &tc->tc_items); |
212380e3 AC |
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; | |
330fc5c1 | 1890 | rb_dlink_node *ptr; |
212380e3 AC |
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 | ||
330fc5c1 | 1898 | if((ptr = rb_dlinkFind(cf, &tc->tc_items)) == NULL) |
212380e3 AC |
1899 | return -1; |
1900 | ||
330fc5c1 | 1901 | rb_dlinkDestroy(ptr, &tc->tc_items); |
637c4932 | 1902 | rb_free(cf); |
212380e3 AC |
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 }, | |
212380e3 AC |
1913 | |
1914 | { "network_name", CF_QSTRING, conf_set_serverinfo_network_name, 0, NULL }, | |
1915 | { "name", CF_QSTRING, conf_set_serverinfo_name, 0, NULL }, | |
1916 | { "sid", CF_QSTRING, conf_set_serverinfo_sid, 0, NULL }, | |
1917 | { "vhost", CF_QSTRING, conf_set_serverinfo_vhost, 0, NULL }, | |
1918 | { "vhost6", CF_QSTRING, conf_set_serverinfo_vhost6, 0, NULL }, | |
1919 | ||
8bd5767b JT |
1920 | { "ssl_private_key", CF_QSTRING, NULL, 0, &ServerInfo.ssl_private_key }, |
1921 | { "ssl_ca_cert", CF_QSTRING, NULL, 0, &ServerInfo.ssl_ca_cert }, | |
1922 | { "ssl_cert", CF_QSTRING, NULL, 0, &ServerInfo.ssl_cert }, | |
1923 | { "ssl_dh_params", CF_QSTRING, NULL, 0, &ServerInfo.ssl_dh_params }, | |
c6d72037 VY |
1924 | { "ssld_count", CF_INT, NULL, 0, &ServerInfo.ssld_count }, |
1925 | ||
101db4c4 | 1926 | { "default_max_clients",CF_INT, NULL, 0, &ServerInfo.default_max_clients }, |
c2d96fcb | 1927 | |
212380e3 AC |
1928 | { "\0", 0, NULL, 0, NULL } |
1929 | }; | |
1930 | ||
1931 | static struct ConfEntry conf_admin_table[] = | |
1932 | { | |
1933 | { "name", CF_QSTRING, NULL, 200, &AdminInfo.name }, | |
1934 | { "description",CF_QSTRING, NULL, 200, &AdminInfo.description }, | |
1935 | { "email", CF_QSTRING, NULL, 200, &AdminInfo.email }, | |
1936 | { "\0", 0, NULL, 0, NULL } | |
1937 | }; | |
1938 | ||
1939 | static struct ConfEntry conf_log_table[] = | |
1940 | { | |
1941 | { "fname_userlog", CF_QSTRING, NULL, MAXPATHLEN, &ConfigFileEntry.fname_userlog }, | |
1942 | { "fname_fuserlog", CF_QSTRING, NULL, MAXPATHLEN, &ConfigFileEntry.fname_fuserlog }, | |
1943 | { "fname_operlog", CF_QSTRING, NULL, MAXPATHLEN, &ConfigFileEntry.fname_operlog }, | |
1944 | { "fname_foperlog", CF_QSTRING, NULL, MAXPATHLEN, &ConfigFileEntry.fname_foperlog }, | |
1945 | { "fname_serverlog", CF_QSTRING, NULL, MAXPATHLEN, &ConfigFileEntry.fname_serverlog }, | |
1946 | { "fname_killlog", CF_QSTRING, NULL, MAXPATHLEN, &ConfigFileEntry.fname_killlog }, | |
212380e3 AC |
1947 | { "fname_klinelog", CF_QSTRING, NULL, MAXPATHLEN, &ConfigFileEntry.fname_klinelog }, |
1948 | { "fname_operspylog", CF_QSTRING, NULL, MAXPATHLEN, &ConfigFileEntry.fname_operspylog }, | |
1949 | { "fname_ioerrorlog", CF_QSTRING, NULL, MAXPATHLEN, &ConfigFileEntry.fname_ioerrorlog }, | |
1950 | { "\0", 0, NULL, 0, NULL } | |
1951 | }; | |
1952 | ||
1953 | static struct ConfEntry conf_operator_table[] = | |
1954 | { | |
1955 | { "rsa_public_key_file", CF_QSTRING, conf_set_oper_rsa_public_key_file, 0, NULL }, | |
1956 | { "flags", CF_STRING | CF_FLIST, conf_set_oper_flags, 0, NULL }, | |
1957 | { "umodes", CF_STRING | CF_FLIST, conf_set_oper_umodes, 0, NULL }, | |
1958 | { "snomask", CF_QSTRING, conf_set_oper_snomask, 0, NULL }, | |
1959 | { "user", CF_QSTRING, conf_set_oper_user, 0, NULL }, | |
1960 | { "password", CF_QSTRING, conf_set_oper_password, 0, NULL }, | |
1961 | { "\0", 0, NULL, 0, NULL } | |
1962 | }; | |
1963 | ||
1964 | static struct ConfEntry conf_class_table[] = | |
1965 | { | |
1966 | { "ping_time", CF_TIME, conf_set_class_ping_time, 0, NULL }, | |
1967 | { "cidr_bitlen", CF_INT, conf_set_class_cidr_bitlen, 0, NULL }, | |
1968 | { "number_per_cidr", CF_INT, conf_set_class_number_per_cidr, 0, NULL }, | |
1969 | { "number_per_ip", CF_INT, conf_set_class_number_per_ip, 0, NULL }, | |
1970 | { "number_per_ip_global", CF_INT,conf_set_class_number_per_ip_global, 0, NULL }, | |
1971 | { "number_per_ident", CF_INT, conf_set_class_number_per_ident, 0, NULL }, | |
1972 | { "connectfreq", CF_TIME, conf_set_class_connectfreq, 0, NULL }, | |
1973 | { "max_number", CF_INT, conf_set_class_max_number, 0, NULL }, | |
1974 | { "sendq", CF_TIME, conf_set_class_sendq, 0, NULL }, | |
1975 | { "\0", 0, NULL, 0, NULL } | |
1976 | }; | |
1977 | ||
1978 | static struct ConfEntry conf_auth_table[] = | |
1979 | { | |
1980 | { "user", CF_QSTRING, conf_set_auth_user, 0, NULL }, | |
1981 | { "password", CF_QSTRING, conf_set_auth_passwd, 0, NULL }, | |
1982 | { "class", CF_QSTRING, conf_set_auth_class, 0, NULL }, | |
1983 | { "spoof", CF_QSTRING, conf_set_auth_spoof, 0, NULL }, | |
1984 | { "redirserv", CF_QSTRING, conf_set_auth_redir_serv, 0, NULL }, | |
1985 | { "redirport", CF_INT, conf_set_auth_redir_port, 0, NULL }, | |
1986 | { "flags", CF_STRING | CF_FLIST, conf_set_auth_flags, 0, NULL }, | |
1987 | { "\0", 0, NULL, 0, NULL } | |
1988 | }; | |
1989 | ||
1990 | static struct ConfEntry conf_connect_table[] = | |
1991 | { | |
1992 | { "send_password", CF_QSTRING, conf_set_connect_send_password, 0, NULL }, | |
1993 | { "accept_password", CF_QSTRING, conf_set_connect_accept_password, 0, NULL }, | |
1994 | { "flags", CF_STRING | CF_FLIST, conf_set_connect_flags, 0, NULL }, | |
1995 | { "host", CF_QSTRING, conf_set_connect_host, 0, NULL }, | |
1996 | { "vhost", CF_QSTRING, conf_set_connect_vhost, 0, NULL }, | |
1997 | { "port", CF_INT, conf_set_connect_port, 0, NULL }, | |
1998 | { "aftype", CF_STRING, conf_set_connect_aftype, 0, NULL }, | |
1999 | { "hub_mask", CF_QSTRING, conf_set_connect_hub_mask, 0, NULL }, | |
2000 | { "leaf_mask", CF_QSTRING, conf_set_connect_leaf_mask, 0, NULL }, | |
2001 | { "class", CF_QSTRING, conf_set_connect_class, 0, NULL }, | |
2002 | { "\0", 0, NULL, 0, NULL } | |
2003 | }; | |
2004 | ||
2005 | static struct ConfEntry conf_general_table[] = | |
2006 | { | |
2007 | { "oper_only_umodes", CF_STRING | CF_FLIST, conf_set_general_oper_only_umodes, 0, NULL }, | |
2008 | { "oper_umodes", CF_STRING | CF_FLIST, conf_set_general_oper_umodes, 0, NULL }, | |
2009 | { "oper_snomask", CF_QSTRING, conf_set_general_oper_snomask, 0, NULL }, | |
2010 | { "compression_level", CF_INT, conf_set_general_compression_level, 0, NULL }, | |
2011 | { "havent_read_conf", CF_YESNO, conf_set_general_havent_read_conf, 0, NULL }, | |
2012 | { "hide_error_messages",CF_STRING, conf_set_general_hide_error_messages,0, NULL }, | |
2013 | { "kline_delay", CF_TIME, conf_set_general_kline_delay, 0, NULL }, | |
2014 | { "stats_k_oper_only", CF_STRING, conf_set_general_stats_k_oper_only, 0, NULL }, | |
2015 | { "stats_i_oper_only", CF_STRING, conf_set_general_stats_i_oper_only, 0, NULL }, | |
2016 | { "default_umodes", CF_QSTRING, conf_set_general_default_umodes, 0, NULL }, | |
2017 | ||
2018 | { "default_operstring", CF_QSTRING, NULL, REALLEN, &ConfigFileEntry.default_operstring }, | |
2019 | { "default_adminstring",CF_QSTRING, NULL, REALLEN, &ConfigFileEntry.default_adminstring }, | |
2020 | { "servicestring", CF_QSTRING, NULL, REALLEN, &ConfigFileEntry.servicestring }, | |
2021 | { "egdpool_path", CF_QSTRING, NULL, MAXPATHLEN, &ConfigFileEntry.egdpool_path }, | |
2022 | { "kline_reason", CF_QSTRING, NULL, REALLEN, &ConfigFileEntry.kline_reason }, | |
2023 | { "identify_service", CF_QSTRING, NULL, REALLEN, &ConfigFileEntry.identifyservice }, | |
2024 | { "identify_command", CF_QSTRING, NULL, REALLEN, &ConfigFileEntry.identifycommand }, | |
2025 | { "servlink_path", CF_QSTRING, NULL, MAXPATHLEN, &ConfigFileEntry.servlink_path }, | |
2026 | ||
2027 | { "anti_spam_exit_message_time", CF_TIME, NULL, 0, &ConfigFileEntry.anti_spam_exit_message_time }, | |
2028 | { "disable_fake_channels", CF_YESNO, NULL, 0, &ConfigFileEntry.disable_fake_channels }, | |
2029 | { "min_nonwildcard_simple", CF_INT, NULL, 0, &ConfigFileEntry.min_nonwildcard_simple }, | |
2030 | { "non_redundant_klines", CF_YESNO, NULL, 0, &ConfigFileEntry.non_redundant_klines }, | |
2031 | { "tkline_expire_notices", CF_YESNO, NULL, 0, &ConfigFileEntry.tkline_expire_notices }, | |
2032 | ||
2033 | { "anti_nick_flood", CF_YESNO, NULL, 0, &ConfigFileEntry.anti_nick_flood }, | |
2034 | { "burst_away", CF_YESNO, NULL, 0, &ConfigFileEntry.burst_away }, | |
2035 | { "caller_id_wait", CF_TIME, NULL, 0, &ConfigFileEntry.caller_id_wait }, | |
2036 | { "client_exit", CF_YESNO, NULL, 0, &ConfigFileEntry.client_exit }, | |
2037 | { "client_flood", CF_INT, NULL, 0, &ConfigFileEntry.client_flood }, | |
2038 | { "collision_fnc", CF_YESNO, NULL, 0, &ConfigFileEntry.collision_fnc }, | |
2039 | { "connect_timeout", CF_TIME, NULL, 0, &ConfigFileEntry.connect_timeout }, | |
2040 | { "default_floodcount", CF_INT, NULL, 0, &ConfigFileEntry.default_floodcount }, | |
2041 | { "disable_auth", CF_YESNO, NULL, 0, &ConfigFileEntry.disable_auth }, | |
212380e3 AC |
2042 | { "dots_in_ident", CF_INT, NULL, 0, &ConfigFileEntry.dots_in_ident }, |
2043 | { "failed_oper_notice", CF_YESNO, NULL, 0, &ConfigFileEntry.failed_oper_notice }, | |
212380e3 | 2044 | { "global_snotices", CF_YESNO, NULL, 0, &ConfigFileEntry.global_snotices }, |
212380e3 AC |
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 }, | |
54015b5f | 2054 | { "max_unknown_ip", CF_INT, NULL, 0, &ConfigFileEntry.max_unknown_ip }, |
212380e3 AC |
2055 | { "min_nonwildcard", CF_INT, NULL, 0, &ConfigFileEntry.min_nonwildcard }, |
2056 | { "nick_delay", CF_TIME, NULL, 0, &ConfigFileEntry.nick_delay }, | |
2057 | { "no_oper_flood", CF_YESNO, NULL, 0, &ConfigFileEntry.no_oper_flood }, | |
2058 | { "operspy_admin_only", CF_YESNO, NULL, 0, &ConfigFileEntry.operspy_admin_only }, | |
2059 | { "operspy_dont_care_user_info", CF_YESNO, NULL, 0, &ConfigFileEntry.operspy_dont_care_user_info }, | |
2060 | { "pace_wait", CF_TIME, NULL, 0, &ConfigFileEntry.pace_wait }, | |
2061 | { "pace_wait_simple", CF_TIME, NULL, 0, &ConfigFileEntry.pace_wait_simple }, | |
2062 | { "ping_cookie", CF_YESNO, NULL, 0, &ConfigFileEntry.ping_cookie }, | |
2063 | { "reject_after_count", CF_INT, NULL, 0, &ConfigFileEntry.reject_after_count }, | |
2064 | { "reject_ban_time", CF_TIME, NULL, 0, &ConfigFileEntry.reject_ban_time }, | |
2065 | { "reject_duration", CF_TIME, NULL, 0, &ConfigFileEntry.reject_duration }, | |
2066 | { "short_motd", CF_YESNO, NULL, 0, &ConfigFileEntry.short_motd }, | |
2067 | { "stats_c_oper_only", CF_YESNO, NULL, 0, &ConfigFileEntry.stats_c_oper_only }, | |
2068 | { "stats_e_disabled", CF_YESNO, NULL, 0, &ConfigFileEntry.stats_e_disabled }, | |
2069 | { "stats_h_oper_only", CF_YESNO, NULL, 0, &ConfigFileEntry.stats_h_oper_only }, | |
2070 | { "stats_o_oper_only", CF_YESNO, NULL, 0, &ConfigFileEntry.stats_o_oper_only }, | |
2071 | { "stats_P_oper_only", CF_YESNO, NULL, 0, &ConfigFileEntry.stats_P_oper_only }, | |
2072 | { "stats_y_oper_only", CF_YESNO, NULL, 0, &ConfigFileEntry.stats_y_oper_only }, | |
2073 | { "target_change", CF_YESNO, NULL, 0, &ConfigFileEntry.target_change }, | |
2074 | { "ts_max_delta", CF_TIME, NULL, 0, &ConfigFileEntry.ts_max_delta }, | |
2075 | { "use_egd", CF_YESNO, NULL, 0, &ConfigFileEntry.use_egd }, | |
2076 | { "ts_warn_delta", CF_TIME, NULL, 0, &ConfigFileEntry.ts_warn_delta }, | |
2077 | { "use_whois_actually", CF_YESNO, NULL, 0, &ConfigFileEntry.use_whois_actually }, | |
2078 | { "warn_no_nline", CF_YESNO, NULL, 0, &ConfigFileEntry.warn_no_nline }, | |
2079 | { "\0", 0, NULL, 0, NULL } | |
2080 | }; | |
2081 | ||
2082 | static struct ConfEntry conf_channel_table[] = | |
2083 | { | |
2084 | { "default_split_user_count", CF_INT, NULL, 0, &ConfigChannel.default_split_user_count }, | |
2085 | { "default_split_server_count", CF_INT, NULL, 0, &ConfigChannel.default_split_server_count }, | |
2086 | { "burst_topicwho", CF_YESNO, NULL, 0, &ConfigChannel.burst_topicwho }, | |
212380e3 AC |
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); | |
c6d72037 | 2127 | add_conf_item("listen", "sslport", CF_INT | CF_FLIST, conf_set_listen_sslport); |
212380e3 AC |
2128 | add_conf_item("listen", "ip", CF_QSTRING, conf_set_listen_address); |
2129 | add_conf_item("listen", "host", CF_QSTRING, conf_set_listen_address); | |
2130 | ||
2131 | add_top_conf("auth", conf_begin_auth, conf_end_auth, conf_auth_table); | |
2132 | ||
2133 | add_top_conf("shared", conf_cleanup_shared, conf_cleanup_shared, NULL); | |
2134 | add_conf_item("shared", "oper", CF_QSTRING|CF_FLIST, conf_set_shared_oper); | |
2135 | add_conf_item("shared", "flags", CF_STRING | CF_FLIST, conf_set_shared_flags); | |
2136 | ||
2137 | add_top_conf("connect", conf_begin_connect, conf_end_connect, conf_connect_table); | |
2138 | ||
2139 | add_top_conf("exempt", NULL, NULL, NULL); | |
2140 | add_conf_item("exempt", "ip", CF_QSTRING, conf_set_exempt_ip); | |
2141 | ||
2142 | add_top_conf("cluster", conf_cleanup_cluster, conf_cleanup_cluster, NULL); | |
2143 | add_conf_item("cluster", "name", CF_QSTRING, conf_set_cluster_name); | |
2144 | add_conf_item("cluster", "flags", CF_STRING | CF_FLIST, conf_set_cluster_flags); | |
2145 | ||
2146 | add_top_conf("general", NULL, NULL, conf_general_table); | |
2147 | add_top_conf("channel", NULL, NULL, conf_channel_table); | |
2148 | add_top_conf("serverhide", NULL, NULL, conf_serverhide_table); | |
2149 | ||
2150 | add_top_conf("service", conf_begin_service, NULL, NULL); | |
2151 | add_conf_item("service", "name", CF_QSTRING, conf_set_service_name); | |
2152 | ||
2153 | add_top_conf("alias", conf_begin_alias, conf_end_alias, NULL); | |
2154 | add_conf_item("alias", "name", CF_QSTRING, conf_set_alias_name); | |
2155 | add_conf_item("alias", "target", CF_QSTRING, conf_set_alias_target); | |
2156 | ||
2157 | add_top_conf("blacklist", NULL, NULL, NULL); | |
2158 | add_conf_item("blacklist", "host", CF_QSTRING, conf_set_blacklist_host); | |
2159 | add_conf_item("blacklist", "reject_reason", CF_QSTRING, conf_set_blacklist_reason); | |
2160 | } |