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