]>
Commit | Line | Data |
---|---|---|
212380e3 | 1 | /* This code is in the public domain. |
212380e3 AC |
2 | */ |
3 | ||
4 | #include "stdinc.h" | |
5 | ||
6 | #ifdef HAVE_LIBCRYPTO | |
7 | #include <openssl/pem.h> | |
8 | #include <openssl/rsa.h> | |
9 | #endif | |
10 | ||
212380e3 | 11 | #include "newconf.h" |
212380e3 | 12 | #include "ircd_defs.h" |
4016731b | 13 | #include "logger.h" |
212380e3 AC |
14 | #include "s_conf.h" |
15 | #include "s_user.h" | |
16 | #include "s_newconf.h" | |
17 | #include "send.h" | |
18 | #include "setup.h" | |
19 | #include "modules.h" | |
20 | #include "listener.h" | |
21 | #include "hostmask.h" | |
22 | #include "s_serv.h" | |
212380e3 AC |
23 | #include "hash.h" |
24 | #include "cache.h" | |
25 | #include "ircd.h" | |
26 | #include "snomask.h" | |
c6d72037 | 27 | #include "sslproc.h" |
c53ca1e0 | 28 | #include "wsproc.h" |
f8606875 | 29 | #include "privilege.h" |
63eb8567 | 30 | #include "chmode.h" |
212380e3 AC |
31 | |
32 | #define CF_TYPE(x) ((x) & CF_MTYPE) | |
33 | ||
02270e96 | 34 | static int yy_defer_accept = 1; |
c53ca1e0 | 35 | static int yy_wsock = 0; |
02270e96 | 36 | |
212380e3 | 37 | struct TopConf *conf_cur_block; |
e12981c0 | 38 | static char *conf_cur_block_name = NULL; |
212380e3 | 39 | |
330fc5c1 | 40 | static rb_dlink_list conf_items; |
212380e3 AC |
41 | |
42 | static struct ConfItem *yy_aconf = NULL; | |
43 | ||
44 | static struct Class *yy_class = NULL; | |
45 | ||
46 | static struct remote_conf *yy_shared = NULL; | |
47 | static struct server_conf *yy_server = NULL; | |
48 | ||
330fc5c1 AC |
49 | static rb_dlink_list yy_aconf_list; |
50 | static rb_dlink_list yy_oper_list; | |
51 | static rb_dlink_list yy_shared_list; | |
52 | static rb_dlink_list yy_cluster_list; | |
212380e3 AC |
53 | static struct oper_conf *yy_oper = NULL; |
54 | ||
55 | static struct alias_entry *yy_alias = NULL; | |
56 | ||
57 | static char *yy_blacklist_host = NULL; | |
58 | static char *yy_blacklist_reason = NULL; | |
d3f6b808 | 59 | static uint8_t yy_blacklist_iptype = 0; |
50808796 | 60 | static rb_dlink_list yy_blacklist_filters = { NULL, NULL, 0 }; |
0a1e77c2 | 61 | |
8275e270 EM |
62 | static char *yy_opm_address_ipv4 = NULL; |
63 | static char *yy_opm_address_ipv6 = NULL; | |
64 | static uint16_t yy_opm_port_ipv4 = 0; | |
65 | static uint16_t yy_opm_port_ipv6 = 0; | |
51fa2ab8 | 66 | static rb_dlink_list yy_opm_scanner_list; |
8275e270 | 67 | |
f8606875 | 68 | static char *yy_privset_extends = NULL; |
212380e3 AC |
69 | |
70 | static const char * | |
71 | conf_strtype(int type) | |
72 | { | |
dceac3e4 | 73 | switch (CF_TYPE(type)) |
212380e3 AC |
74 | { |
75 | case CF_INT: | |
76 | return "integer value"; | |
77 | case CF_STRING: | |
78 | return "unquoted string"; | |
79 | case CF_YESNO: | |
80 | return "yes/no value"; | |
81 | case CF_QSTRING: | |
82 | return "quoted string"; | |
83 | case CF_TIME: | |
84 | return "time/size value"; | |
85 | default: | |
86 | return "unknown type"; | |
87 | } | |
88 | } | |
89 | ||
90 | int | |
023c36ae | 91 | add_top_conf(const char *name, int (*sfunc) (struct TopConf *), |
212380e3 AC |
92 | int (*efunc) (struct TopConf *), struct ConfEntry *items) |
93 | { | |
94 | struct TopConf *tc; | |
95 | ||
eddc2ab6 | 96 | tc = rb_malloc(sizeof(struct TopConf)); |
212380e3 | 97 | |
d7f753cd | 98 | tc->tc_name = name; |
212380e3 AC |
99 | tc->tc_sfunc = sfunc; |
100 | tc->tc_efunc = efunc; | |
101 | tc->tc_entries = items; | |
102 | ||
330fc5c1 | 103 | rb_dlinkAddAlloc(tc, &conf_items); |
212380e3 AC |
104 | return 0; |
105 | } | |
106 | ||
107 | struct TopConf * | |
108 | find_top_conf(const char *name) | |
109 | { | |
330fc5c1 | 110 | rb_dlink_node *d; |
212380e3 AC |
111 | struct TopConf *tc; |
112 | ||
5cefa1d6 | 113 | RB_DLINK_FOREACH(d, conf_items.head) |
212380e3 AC |
114 | { |
115 | tc = d->data; | |
116 | if(strcasecmp(tc->tc_name, name) == 0) | |
117 | return tc; | |
118 | } | |
119 | ||
120 | return NULL; | |
121 | } | |
122 | ||
123 | ||
124 | struct ConfEntry * | |
125 | find_conf_item(const struct TopConf *top, const char *name) | |
126 | { | |
127 | struct ConfEntry *cf; | |
330fc5c1 | 128 | rb_dlink_node *d; |
212380e3 AC |
129 | |
130 | if(top->tc_entries) | |
131 | { | |
132 | int i; | |
133 | ||
134 | for(i = 0; top->tc_entries[i].cf_type; i++) | |
135 | { | |
136 | cf = &top->tc_entries[i]; | |
137 | ||
138 | if(!strcasecmp(cf->cf_name, name)) | |
139 | return cf; | |
140 | } | |
141 | } | |
142 | ||
5cefa1d6 | 143 | RB_DLINK_FOREACH(d, top->tc_items.head) |
212380e3 AC |
144 | { |
145 | cf = d->data; | |
146 | if(strcasecmp(cf->cf_name, name) == 0) | |
147 | return cf; | |
148 | } | |
149 | ||
150 | return NULL; | |
151 | } | |
152 | ||
153 | int | |
154 | remove_top_conf(char *name) | |
155 | { | |
156 | struct TopConf *tc; | |
330fc5c1 | 157 | rb_dlink_node *ptr; |
212380e3 AC |
158 | |
159 | if((tc = find_top_conf(name)) == NULL) | |
160 | return -1; | |
161 | ||
330fc5c1 | 162 | if((ptr = rb_dlinkFind(tc, &conf_items)) == NULL) |
212380e3 AC |
163 | return -1; |
164 | ||
330fc5c1 | 165 | rb_dlinkDestroy(ptr, &conf_items); |
637c4932 | 166 | rb_free(tc); |
212380e3 AC |
167 | |
168 | return 0; | |
169 | } | |
170 | ||
171 | static void | |
172 | conf_set_serverinfo_name(void *data) | |
173 | { | |
174 | if(ServerInfo.name == NULL) | |
175 | { | |
176 | const char *s; | |
177 | int dots = 0; | |
178 | ||
179 | for(s = data; *s != '\0'; s++) | |
180 | { | |
181 | if(!IsServChar(*s)) | |
182 | { | |
183 | conf_report_error("Ignoring serverinfo::name " | |
184 | "-- bogus servername."); | |
185 | return; | |
186 | } | |
187 | else if(*s == '.') | |
188 | ++dots; | |
189 | } | |
190 | ||
191 | if(!dots) | |
192 | { | |
193 | conf_report_error("Ignoring serverinfo::name -- must contain '.'"); | |
194 | return; | |
195 | } | |
196 | ||
197 | s = data; | |
198 | ||
199 | if(IsDigit(*s)) | |
200 | { | |
201 | conf_report_error("Ignoring serverinfo::name -- cannot begin with digit."); | |
202 | return; | |
203 | } | |
204 | ||
205 | /* the ircd will exit() in main() if we dont set one */ | |
206 | if(strlen(s) <= HOSTLEN) | |
47a03750 | 207 | ServerInfo.name = rb_strdup((char *) data); |
212380e3 AC |
208 | } |
209 | } | |
210 | ||
211 | static void | |
212 | conf_set_serverinfo_sid(void *data) | |
213 | { | |
214 | char *sid = data; | |
215 | ||
216 | if(ServerInfo.sid[0] == '\0') | |
217 | { | |
218 | if(!IsDigit(sid[0]) || !IsIdChar(sid[1]) || | |
219 | !IsIdChar(sid[2]) || sid[3] != '\0') | |
220 | { | |
221 | conf_report_error("Ignoring serverinfo::sid " | |
222 | "-- bogus sid."); | |
223 | return; | |
224 | } | |
225 | ||
226 | strcpy(ServerInfo.sid, sid); | |
227 | } | |
228 | } | |
229 | ||
230 | static void | |
231 | conf_set_serverinfo_network_name(void *data) | |
232 | { | |
233 | char *p; | |
234 | ||
235 | if((p = strchr((char *) data, ' '))) | |
236 | *p = '\0'; | |
237 | ||
637c4932 | 238 | rb_free(ServerInfo.network_name); |
47a03750 | 239 | ServerInfo.network_name = rb_strdup((char *) data); |
212380e3 AC |
240 | } |
241 | ||
242 | static void | |
243 | conf_set_serverinfo_vhost(void *data) | |
244 | { | |
caa4d9d2 | 245 | if(rb_inet_pton(AF_INET, (char *) data, &ServerInfo.ip.sin_addr) <= 0) |
212380e3 | 246 | { |
532f83a7 | 247 | conf_report_error("Invalid IPv4 address for server vhost (%s)", (char *) data); |
212380e3 AC |
248 | return; |
249 | } | |
250 | ServerInfo.ip.sin_family = AF_INET; | |
251 | ServerInfo.specific_ipv4_vhost = 1; | |
252 | } | |
253 | ||
254 | static void | |
255 | conf_set_serverinfo_vhost6(void *data) | |
256 | { | |
ccda6e3f | 257 | #ifdef RB_IPV6 |
caa4d9d2 | 258 | if(rb_inet_pton(AF_INET6, (char *) data, &ServerInfo.ip6.sin6_addr) <= 0) |
212380e3 | 259 | { |
532f83a7 | 260 | conf_report_error("Invalid IPv6 address for server vhost (%s)", (char *) data); |
212380e3 AC |
261 | return; |
262 | } | |
263 | ||
264 | ServerInfo.specific_ipv6_vhost = 1; | |
265 | ServerInfo.ip6.sin6_family = AF_INET6; | |
266 | #else | |
267 | conf_report_error("Warning -- ignoring serverinfo::vhost6 -- IPv6 support not available."); | |
268 | #endif | |
269 | } | |
270 | ||
b583faf9 AC |
271 | static void |
272 | conf_set_serverinfo_nicklen(void *data) | |
273 | { | |
7b42eab6 | 274 | ConfigFileEntry.nicklen = (*(unsigned int *) data) + 1; |
b583faf9 AC |
275 | |
276 | if (ConfigFileEntry.nicklen > NICKLEN) | |
277 | { | |
278 | conf_report_error("Warning -- ignoring serverinfo::nicklen -- provided nicklen (%u) is greater than allowed nicklen (%u)", | |
ca8ff483 | 279 | ConfigFileEntry.nicklen - 1, NICKLEN - 1); |
b583faf9 AC |
280 | ConfigFileEntry.nicklen = NICKLEN; |
281 | } | |
ca8ff483 JT |
282 | else if (ConfigFileEntry.nicklen < 9 + 1) |
283 | { | |
284 | conf_report_error("Warning -- serverinfo::nicklen is too low (%u) -- forcing 9", | |
4f0d2b58 | 285 | ConfigFileEntry.nicklen - 1); |
ca8ff483 JT |
286 | ConfigFileEntry.nicklen = 9 + 1; |
287 | } | |
b583faf9 AC |
288 | } |
289 | ||
212380e3 AC |
290 | static void |
291 | conf_set_modules_module(void *data) | |
292 | { | |
212380e3 AC |
293 | char *m_bn; |
294 | ||
b7a689d1 | 295 | m_bn = rb_basename((char *) data); |
212380e3 | 296 | |
43f45e81 | 297 | if(findmodule_byname(m_bn) == -1) |
216d70e9 | 298 | load_one_module((char *) data, MAPI_ORIGIN_EXTENSION, 0); |
212380e3 | 299 | |
637c4932 | 300 | rb_free(m_bn); |
212380e3 AC |
301 | } |
302 | ||
303 | static void | |
304 | conf_set_modules_path(void *data) | |
305 | { | |
212380e3 | 306 | mod_add_path((char *) data); |
212380e3 AC |
307 | } |
308 | ||
309 | struct mode_table | |
310 | { | |
311 | const char *name; | |
312 | int mode; | |
313 | }; | |
314 | ||
315 | /* *INDENT-OFF* */ | |
316 | static struct mode_table umode_table[] = { | |
317 | {"callerid", UMODE_CALLERID }, | |
318 | {"deaf", UMODE_DEAF }, | |
319 | {"invisible", UMODE_INVISIBLE }, | |
320 | {"locops", UMODE_LOCOPS }, | |
321 | {"noforward", UMODE_NOFORWARD }, | |
322 | {"regonlymsg", UMODE_REGONLYMSG}, | |
323 | {"servnotice", UMODE_SERVNOTICE}, | |
324 | {"wallop", UMODE_WALLOP }, | |
325 | {"operwall", UMODE_OPERWALL }, | |
326 | {NULL, 0} | |
327 | }; | |
328 | ||
19c13ce5 | 329 | static struct mode_table oper_table[] = { |
212380e3 | 330 | {"encrypted", OPER_ENCRYPTED }, |
b1594414 | 331 | {"need_ssl", OPER_NEEDSSL }, |
212380e3 AC |
332 | {NULL, 0} |
333 | }; | |
334 | ||
335 | static struct mode_table auth_table[] = { | |
fbe8d087 EM |
336 | {"encrypted", CONF_FLAGS_ENCRYPTED }, |
337 | {"spoof_notice", CONF_FLAGS_SPOOF_NOTICE }, | |
338 | {"exceed_limit", CONF_FLAGS_NOLIMIT }, | |
339 | {"dnsbl_exempt", CONF_FLAGS_EXEMPTDNSBL }, | |
340 | {"proxy_exempt", CONF_FLAGS_EXEMPTPROXY }, | |
341 | {"kline_exempt", CONF_FLAGS_EXEMPTKLINE }, | |
342 | {"flood_exempt", CONF_FLAGS_EXEMPTFLOOD }, | |
343 | {"spambot_exempt", CONF_FLAGS_EXEMPTSPAMBOT }, | |
344 | {"shide_exempt", CONF_FLAGS_EXEMPTSHIDE }, | |
345 | {"jupe_exempt", CONF_FLAGS_EXEMPTJUPE }, | |
346 | {"resv_exempt", CONF_FLAGS_EXEMPTRESV }, | |
347 | {"no_tilde", CONF_FLAGS_NO_TILDE }, | |
348 | {"need_ident", CONF_FLAGS_NEED_IDENTD }, | |
349 | {"have_ident", CONF_FLAGS_NEED_IDENTD }, | |
350 | {"need_ssl", CONF_FLAGS_NEED_SSL }, | |
351 | {"need_sasl", CONF_FLAGS_NEED_SASL }, | |
352 | {"extend_chans", CONF_FLAGS_EXTEND_CHANS }, | |
212380e3 AC |
353 | {NULL, 0} |
354 | }; | |
355 | ||
356 | static struct mode_table connect_table[] = { | |
357 | { "autoconn", SERVER_AUTOCONN }, | |
358 | { "compressed", SERVER_COMPRESSED }, | |
359 | { "encrypted", SERVER_ENCRYPTED }, | |
360 | { "topicburst", SERVER_TB }, | |
c6d72037 | 361 | { "ssl", SERVER_SSL }, |
212380e3 AC |
362 | { NULL, 0 }, |
363 | }; | |
364 | ||
365 | static struct mode_table cluster_table[] = { | |
366 | { "kline", SHARED_PKLINE }, | |
367 | { "tkline", SHARED_TKLINE }, | |
368 | { "unkline", SHARED_UNKLINE }, | |
369 | { "locops", SHARED_LOCOPS }, | |
370 | { "xline", SHARED_PXLINE }, | |
371 | { "txline", SHARED_TXLINE }, | |
372 | { "unxline", SHARED_UNXLINE }, | |
373 | { "resv", SHARED_PRESV }, | |
374 | { "tresv", SHARED_TRESV }, | |
375 | { "unresv", SHARED_UNRESV }, | |
376 | { "all", CLUSTER_ALL }, | |
377 | {NULL, 0} | |
378 | }; | |
379 | ||
380 | static struct mode_table shared_table[] = | |
381 | { | |
382 | { "kline", SHARED_PKLINE|SHARED_TKLINE }, | |
383 | { "xline", SHARED_PXLINE|SHARED_TXLINE }, | |
384 | { "resv", SHARED_PRESV|SHARED_TRESV }, | |
f5cb68d5 VY |
385 | { "dline", SHARED_PDLINE|SHARED_TDLINE }, |
386 | { "tdline", SHARED_TDLINE }, | |
387 | { "pdline", SHARED_PDLINE }, | |
388 | { "undline", SHARED_UNDLINE }, | |
212380e3 AC |
389 | { "tkline", SHARED_TKLINE }, |
390 | { "unkline", SHARED_UNKLINE }, | |
391 | { "txline", SHARED_TXLINE }, | |
392 | { "unxline", SHARED_UNXLINE }, | |
393 | { "tresv", SHARED_TRESV }, | |
394 | { "unresv", SHARED_UNRESV }, | |
395 | { "locops", SHARED_LOCOPS }, | |
396 | { "rehash", SHARED_REHASH }, | |
fe749d37 | 397 | { "grant", SHARED_GRANT }, |
cc7ae51c | 398 | { "die", SHARED_DIE }, |
15feac53 | 399 | { "module", SHARED_MODULE }, |
212380e3 AC |
400 | { "all", SHARED_ALL }, |
401 | { "none", 0 }, | |
402 | {NULL, 0} | |
403 | }; | |
404 | /* *INDENT-ON* */ | |
405 | ||
406 | static int | |
407 | find_umode(struct mode_table *tab, const char *name) | |
408 | { | |
409 | int i; | |
410 | ||
411 | for (i = 0; tab[i].name; i++) | |
412 | { | |
413 | if(strcmp(tab[i].name, name) == 0) | |
414 | return tab[i].mode; | |
415 | } | |
416 | ||
417 | return -1; | |
418 | } | |
419 | ||
420 | static void | |
421 | set_modes_from_table(int *modes, const char *whatis, struct mode_table *tab, conf_parm_t * args) | |
422 | { | |
423 | for (; args; args = args->next) | |
424 | { | |
425 | const char *umode; | |
426 | int dir = 1; | |
427 | int mode; | |
428 | ||
dceac3e4 | 429 | if(CF_TYPE(args->type) != CF_STRING) |
212380e3 AC |
430 | { |
431 | conf_report_error("Warning -- %s is not a string; ignoring.", whatis); | |
432 | continue; | |
433 | } | |
434 | ||
435 | umode = args->v.string; | |
436 | ||
437 | if(*umode == '~') | |
438 | { | |
439 | dir = 0; | |
440 | umode++; | |
441 | } | |
442 | ||
443 | mode = find_umode(tab, umode); | |
444 | ||
445 | if(mode == -1) | |
446 | { | |
447 | conf_report_error("Warning -- unknown %s %s.", whatis, args->v.string); | |
448 | continue; | |
449 | } | |
450 | ||
451 | if(mode) | |
452 | { | |
453 | if(dir) | |
454 | *modes |= mode; | |
455 | else | |
456 | *modes &= ~mode; | |
457 | } | |
458 | else | |
459 | *modes = 0; | |
460 | } | |
461 | } | |
462 | ||
f8606875 AC |
463 | static void |
464 | conf_set_privset_extends(void *data) | |
465 | { | |
466 | yy_privset_extends = rb_strdup((char *) data); | |
467 | } | |
468 | ||
469 | static void | |
470 | conf_set_privset_privs(void *data) | |
471 | { | |
472 | char *privs = NULL; | |
473 | conf_parm_t *args = data; | |
474 | ||
475 | for (; args; args = args->next) | |
476 | { | |
477 | if (privs == NULL) | |
478 | privs = rb_strdup(args->v.string); | |
479 | else | |
480 | { | |
481 | char *privs_old = privs; | |
482 | ||
483 | privs = rb_malloc(strlen(privs_old) + 1 + strlen(args->v.string) + 1); | |
065f67db | 484 | strcpy(privs, privs_old); |
f8606875 AC |
485 | strcat(privs, " "); |
486 | strcat(privs, args->v.string); | |
487 | ||
488 | rb_free(privs_old); | |
489 | } | |
490 | } | |
491 | ||
492 | if (privs) | |
493 | { | |
494 | if (yy_privset_extends) | |
495 | { | |
496 | struct PrivilegeSet *set = privilegeset_get(yy_privset_extends); | |
497 | ||
498 | if (!set) | |
499 | { | |
49b0375d | 500 | conf_report_error("Warning -- unknown parent privilege set %s for %s; assuming defaults", yy_privset_extends, conf_cur_block_name); |
f8606875 | 501 | |
49b0375d | 502 | set = privilegeset_get("default"); |
f8606875 AC |
503 | } |
504 | ||
505 | privilegeset_extend(set, conf_cur_block_name != NULL ? conf_cur_block_name : "<unknown>", privs, 0); | |
506 | ||
507 | rb_free(yy_privset_extends); | |
508 | yy_privset_extends = NULL; | |
509 | } | |
510 | else | |
511 | privilegeset_set_new(conf_cur_block_name != NULL ? conf_cur_block_name : "<unknown>", privs, 0); | |
512 | ||
513 | rb_free(privs); | |
514 | } | |
515 | } | |
516 | ||
212380e3 AC |
517 | static int |
518 | conf_begin_oper(struct TopConf *tc) | |
519 | { | |
330fc5c1 | 520 | rb_dlink_node *ptr; |
637c4932 | 521 | rb_dlink_node *next_ptr; |
212380e3 AC |
522 | |
523 | if(yy_oper != NULL) | |
524 | { | |
525 | free_oper_conf(yy_oper); | |
526 | yy_oper = NULL; | |
527 | } | |
528 | ||
637c4932 | 529 | RB_DLINK_FOREACH_SAFE(ptr, next_ptr, yy_oper_list.head) |
212380e3 AC |
530 | { |
531 | free_oper_conf(ptr->data); | |
330fc5c1 | 532 | rb_dlinkDestroy(ptr, &yy_oper_list); |
212380e3 AC |
533 | } |
534 | ||
535 | yy_oper = make_oper_conf(); | |
10847f65 | 536 | yy_oper->flags |= OPER_ENCRYPTED; |
212380e3 AC |
537 | |
538 | return 0; | |
539 | } | |
540 | ||
541 | static int | |
542 | conf_end_oper(struct TopConf *tc) | |
543 | { | |
544 | struct oper_conf *yy_tmpoper; | |
330fc5c1 | 545 | rb_dlink_node *ptr; |
637c4932 | 546 | rb_dlink_node *next_ptr; |
212380e3 AC |
547 | |
548 | if(conf_cur_block_name != NULL) | |
549 | { | |
550 | if(strlen(conf_cur_block_name) > OPERNICKLEN) | |
551 | conf_cur_block_name[OPERNICKLEN] = '\0'; | |
552 | ||
47a03750 | 553 | yy_oper->name = rb_strdup(conf_cur_block_name); |
212380e3 AC |
554 | } |
555 | ||
556 | if(EmptyString(yy_oper->name)) | |
557 | { | |
558 | conf_report_error("Ignoring operator block -- missing name."); | |
559 | return 0; | |
560 | } | |
561 | ||
562 | #ifdef HAVE_LIBCRYPTO | |
563 | if(EmptyString(yy_oper->passwd) && EmptyString(yy_oper->rsa_pubkey_file)) | |
564 | #else | |
565 | if(EmptyString(yy_oper->passwd)) | |
566 | #endif | |
567 | { | |
568 | conf_report_error("Ignoring operator block for %s -- missing password", | |
569 | yy_oper->name); | |
570 | return 0; | |
571 | } | |
572 | ||
7d5acab7 JT |
573 | |
574 | if (!yy_oper->privset) | |
575 | yy_oper->privset = privilegeset_get("default"); | |
576 | ||
212380e3 AC |
577 | /* now, yy_oper_list contains a stack of oper_conf's with just user |
578 | * and host in, yy_oper contains the rest of the information which | |
579 | * we need to copy into each element in yy_oper_list | |
580 | */ | |
637c4932 | 581 | RB_DLINK_FOREACH_SAFE(ptr, next_ptr, yy_oper_list.head) |
212380e3 AC |
582 | { |
583 | yy_tmpoper = ptr->data; | |
584 | ||
47a03750 | 585 | yy_tmpoper->name = rb_strdup(yy_oper->name); |
212380e3 AC |
586 | |
587 | /* could be an rsa key instead.. */ | |
588 | if(!EmptyString(yy_oper->passwd)) | |
47a03750 | 589 | yy_tmpoper->passwd = rb_strdup(yy_oper->passwd); |
212380e3 AC |
590 | |
591 | yy_tmpoper->flags = yy_oper->flags; | |
592 | yy_tmpoper->umodes = yy_oper->umodes; | |
593 | yy_tmpoper->snomask = yy_oper->snomask; | |
22c3b270 | 594 | yy_tmpoper->privset = yy_oper->privset; |
212380e3 AC |
595 | |
596 | #ifdef HAVE_LIBCRYPTO | |
597 | if(yy_oper->rsa_pubkey_file) | |
598 | { | |
599 | BIO *file; | |
600 | ||
601 | if((file = BIO_new_file(yy_oper->rsa_pubkey_file, "r")) == NULL) | |
602 | { | |
603 | conf_report_error("Ignoring operator block for %s -- " | |
604 | "rsa_public_key_file cant be opened", | |
605 | yy_tmpoper->name); | |
606 | return 0; | |
607 | } | |
023c36ae | 608 | |
212380e3 AC |
609 | yy_tmpoper->rsa_pubkey = |
610 | (RSA *) PEM_read_bio_RSA_PUBKEY(file, NULL, 0, NULL); | |
611 | ||
c422d2a0 | 612 | (void)BIO_set_close(file, BIO_CLOSE); |
212380e3 AC |
613 | BIO_free(file); |
614 | ||
615 | if(yy_tmpoper->rsa_pubkey == NULL) | |
616 | { | |
617 | conf_report_error("Ignoring operator block for %s -- " | |
618 | "rsa_public_key_file key invalid; check syntax", | |
619 | yy_tmpoper->name); | |
620 | return 0; | |
621 | } | |
622 | } | |
63c7a68e EM |
623 | |
624 | if(!EmptyString(yy_oper->certfp)) | |
462ae9d7 | 625 | yy_tmpoper->certfp = rb_strdup(yy_oper->certfp); |
212380e3 AC |
626 | #endif |
627 | ||
628 | /* all is ok, put it on oper_conf_list */ | |
330fc5c1 | 629 | rb_dlinkMoveNode(ptr, &yy_oper_list, &oper_conf_list); |
212380e3 AC |
630 | } |
631 | ||
632 | free_oper_conf(yy_oper); | |
633 | yy_oper = NULL; | |
634 | ||
635 | return 0; | |
636 | } | |
637 | ||
638 | static void | |
639 | conf_set_oper_flags(void *data) | |
640 | { | |
641 | conf_parm_t *args = data; | |
642 | ||
19c13ce5 | 643 | set_modes_from_table(&yy_oper->flags, "flag", oper_table, args); |
212380e3 AC |
644 | } |
645 | ||
ff31db84 AC |
646 | static void |
647 | conf_set_oper_fingerprint(void *data) | |
648 | { | |
462ae9d7 JT |
649 | if (yy_oper->certfp) |
650 | rb_free(yy_oper->certfp); | |
ff31db84 AC |
651 | yy_oper->certfp = rb_strdup((char *) data); |
652 | } | |
653 | ||
22c3b270 AC |
654 | static void |
655 | conf_set_oper_privset(void *data) | |
656 | { | |
657 | yy_oper->privset = privilegeset_get((char *) data); | |
658 | } | |
659 | ||
212380e3 AC |
660 | static void |
661 | conf_set_oper_user(void *data) | |
662 | { | |
663 | struct oper_conf *yy_tmpoper; | |
664 | char *p; | |
665 | char *host = (char *) data; | |
666 | ||
667 | yy_tmpoper = make_oper_conf(); | |
668 | ||
669 | if((p = strchr(host, '@'))) | |
670 | { | |
671 | *p++ = '\0'; | |
672 | ||
47a03750 VY |
673 | yy_tmpoper->username = rb_strdup(host); |
674 | yy_tmpoper->host = rb_strdup(p); | |
212380e3 AC |
675 | } |
676 | else | |
677 | { | |
678 | ||
47a03750 VY |
679 | yy_tmpoper->username = rb_strdup("*"); |
680 | yy_tmpoper->host = rb_strdup(host); | |
212380e3 AC |
681 | } |
682 | ||
683 | if(EmptyString(yy_tmpoper->username) || EmptyString(yy_tmpoper->host)) | |
684 | { | |
685 | conf_report_error("Ignoring user -- missing username/host"); | |
686 | free_oper_conf(yy_tmpoper); | |
687 | return; | |
688 | } | |
689 | ||
330fc5c1 | 690 | rb_dlinkAddAlloc(yy_tmpoper, &yy_oper_list); |
212380e3 AC |
691 | } |
692 | ||
693 | static void | |
694 | conf_set_oper_password(void *data) | |
695 | { | |
696 | if(yy_oper->passwd) | |
697 | { | |
698 | memset(yy_oper->passwd, 0, strlen(yy_oper->passwd)); | |
637c4932 | 699 | rb_free(yy_oper->passwd); |
212380e3 AC |
700 | } |
701 | ||
47a03750 | 702 | yy_oper->passwd = rb_strdup((char *) data); |
212380e3 AC |
703 | } |
704 | ||
705 | static void | |
706 | conf_set_oper_rsa_public_key_file(void *data) | |
707 | { | |
708 | #ifdef HAVE_LIBCRYPTO | |
637c4932 | 709 | rb_free(yy_oper->rsa_pubkey_file); |
47a03750 | 710 | yy_oper->rsa_pubkey_file = rb_strdup((char *) data); |
212380e3 AC |
711 | #else |
712 | conf_report_error("Warning -- ignoring rsa_public_key_file (OpenSSL support not available"); | |
713 | #endif | |
714 | } | |
715 | ||
716 | static void | |
717 | conf_set_oper_umodes(void *data) | |
718 | { | |
719 | set_modes_from_table(&yy_oper->umodes, "umode", umode_table, data); | |
720 | } | |
721 | ||
722 | static void | |
723 | conf_set_oper_snomask(void *data) | |
724 | { | |
725 | yy_oper->snomask = parse_snobuf_to_mask(0, (const char *) data); | |
726 | } | |
727 | ||
728 | static int | |
729 | conf_begin_class(struct TopConf *tc) | |
730 | { | |
731 | if(yy_class) | |
732 | free_class(yy_class); | |
733 | ||
734 | yy_class = make_class(); | |
735 | return 0; | |
736 | } | |
737 | ||
738 | static int | |
739 | conf_end_class(struct TopConf *tc) | |
740 | { | |
741 | if(conf_cur_block_name != NULL) | |
47a03750 | 742 | yy_class->class_name = rb_strdup(conf_cur_block_name); |
212380e3 AC |
743 | |
744 | if(EmptyString(yy_class->class_name)) | |
745 | { | |
746 | conf_report_error("Ignoring connect block -- missing name."); | |
747 | return 0; | |
748 | } | |
749 | ||
750 | add_class(yy_class); | |
751 | yy_class = NULL; | |
752 | return 0; | |
753 | } | |
754 | ||
755 | static void | |
756 | conf_set_class_ping_time(void *data) | |
757 | { | |
758 | yy_class->ping_freq = *(unsigned int *) data; | |
759 | } | |
760 | ||
761 | static void | |
e33e589c | 762 | conf_set_class_cidr_ipv4_bitlen(void *data) |
212380e3 | 763 | { |
e33e589c JT |
764 | unsigned int maxsize = 32; |
765 | if(*(unsigned int *) data > maxsize) | |
766 | conf_report_error | |
767 | ("class::cidr_ipv4_bitlen argument exceeds maxsize (%d > %d) - ignoring.", | |
768 | *(unsigned int *) data, maxsize); | |
769 | else | |
770 | yy_class->cidr_ipv4_bitlen = *(unsigned int *) data; | |
771 | ||
772 | } | |
773 | ||
ccda6e3f | 774 | #ifdef RB_IPV6 |
e33e589c JT |
775 | static void |
776 | conf_set_class_cidr_ipv6_bitlen(void *data) | |
777 | { | |
212380e3 | 778 | unsigned int maxsize = 128; |
212380e3 AC |
779 | if(*(unsigned int *) data > maxsize) |
780 | conf_report_error | |
e33e589c | 781 | ("class::cidr_ipv6_bitlen argument exceeds maxsize (%d > %d) - ignoring.", |
212380e3 AC |
782 | *(unsigned int *) data, maxsize); |
783 | else | |
e33e589c | 784 | yy_class->cidr_ipv6_bitlen = *(unsigned int *) data; |
212380e3 AC |
785 | |
786 | } | |
e33e589c JT |
787 | #endif |
788 | ||
212380e3 AC |
789 | static void |
790 | conf_set_class_number_per_cidr(void *data) | |
791 | { | |
792 | yy_class->cidr_amount = *(unsigned int *) data; | |
793 | } | |
794 | ||
795 | static void | |
796 | conf_set_class_number_per_ip(void *data) | |
797 | { | |
798 | yy_class->max_local = *(unsigned int *) data; | |
799 | } | |
800 | ||
801 | ||
802 | static void | |
803 | conf_set_class_number_per_ip_global(void *data) | |
804 | { | |
805 | yy_class->max_global = *(unsigned int *) data; | |
806 | } | |
807 | ||
808 | static void | |
809 | conf_set_class_number_per_ident(void *data) | |
810 | { | |
811 | yy_class->max_ident = *(unsigned int *) data; | |
812 | } | |
813 | ||
814 | static void | |
815 | conf_set_class_connectfreq(void *data) | |
816 | { | |
817 | yy_class->con_freq = *(unsigned int *) data; | |
818 | } | |
819 | ||
820 | static void | |
821 | conf_set_class_max_number(void *data) | |
822 | { | |
823 | yy_class->max_total = *(unsigned int *) data; | |
824 | } | |
825 | ||
826 | static void | |
827 | conf_set_class_sendq(void *data) | |
828 | { | |
829 | yy_class->max_sendq = *(unsigned int *) data; | |
830 | } | |
831 | ||
832 | static char *listener_address; | |
833 | ||
834 | static int | |
835 | conf_begin_listen(struct TopConf *tc) | |
836 | { | |
637c4932 | 837 | rb_free(listener_address); |
212380e3 AC |
838 | listener_address = NULL; |
839 | return 0; | |
840 | } | |
841 | ||
842 | static int | |
843 | conf_end_listen(struct TopConf *tc) | |
844 | { | |
637c4932 | 845 | rb_free(listener_address); |
212380e3 AC |
846 | listener_address = NULL; |
847 | return 0; | |
848 | } | |
849 | ||
02270e96 AC |
850 | static void |
851 | conf_set_listen_defer_accept(void *data) | |
852 | { | |
853 | yy_defer_accept = *(unsigned int *) data; | |
854 | } | |
c6d72037 | 855 | |
c53ca1e0 AC |
856 | static void |
857 | conf_set_listen_wsock(void *data) | |
858 | { | |
859 | yy_wsock = *(unsigned int *) data; | |
860 | } | |
861 | ||
212380e3 | 862 | static void |
c6d72037 | 863 | conf_set_listen_port_both(void *data, int ssl) |
212380e3 AC |
864 | { |
865 | conf_parm_t *args = data; | |
866 | for (; args; args = args->next) | |
867 | { | |
dceac3e4 | 868 | if(CF_TYPE(args->type) != CF_INT) |
212380e3 AC |
869 | { |
870 | conf_report_error | |
871 | ("listener::port argument is not an integer " "-- ignoring."); | |
872 | continue; | |
873 | } | |
874 | if(listener_address == NULL) | |
875 | { | |
35f284c2 AC |
876 | if (!ssl) |
877 | { | |
d84acbce AC |
878 | conf_report_warning("listener 'ANY/%d': support for plaintext listeners may be removed in a future release per RFC 7194. " |
879 | "It is suggested that users be migrated to SSL/TLS connections.", args->v.number); | |
35f284c2 | 880 | } |
c53ca1e0 | 881 | add_listener(args->v.number, listener_address, AF_INET, ssl, ssl || yy_defer_accept, yy_wsock); |
ccda6e3f | 882 | #ifdef RB_IPV6 |
c53ca1e0 | 883 | add_listener(args->v.number, listener_address, AF_INET6, ssl, ssl || yy_defer_accept, yy_wsock); |
212380e3 AC |
884 | #endif |
885 | } | |
886 | else | |
887 | { | |
888 | int family; | |
ccda6e3f | 889 | #ifdef RB_IPV6 |
212380e3 AC |
890 | if(strchr(listener_address, ':') != NULL) |
891 | family = AF_INET6; | |
023c36ae | 892 | else |
212380e3 AC |
893 | #endif |
894 | family = AF_INET; | |
023c36ae | 895 | |
35f284c2 AC |
896 | if (!ssl) |
897 | { | |
d84acbce AC |
898 | conf_report_warning("listener '%s/%d': support for plaintext listeners may be removed in a future release per RFC 7194. " |
899 | "It is suggested that users be migrated to SSL/TLS connections.", listener_address, args->v.number); | |
35f284c2 | 900 | } |
023c36ae | 901 | |
c53ca1e0 | 902 | add_listener(args->v.number, listener_address, family, ssl, ssl || yy_defer_accept, yy_wsock); |
212380e3 | 903 | } |
212380e3 AC |
904 | } |
905 | } | |
906 | ||
8bd5767b JT |
907 | static void |
908 | conf_set_listen_port(void *data) | |
909 | { | |
910 | conf_set_listen_port_both(data, 0); | |
911 | } | |
912 | ||
913 | static void | |
914 | conf_set_listen_sslport(void *data) | |
915 | { | |
916 | conf_set_listen_port_both(data, 1); | |
c6d72037 VY |
917 | } |
918 | ||
212380e3 AC |
919 | static void |
920 | conf_set_listen_address(void *data) | |
921 | { | |
637c4932 | 922 | rb_free(listener_address); |
47a03750 | 923 | listener_address = rb_strdup(data); |
212380e3 AC |
924 | } |
925 | ||
926 | static int | |
927 | conf_begin_auth(struct TopConf *tc) | |
928 | { | |
330fc5c1 | 929 | rb_dlink_node *ptr; |
637c4932 | 930 | rb_dlink_node *next_ptr; |
212380e3 AC |
931 | |
932 | if(yy_aconf) | |
933 | free_conf(yy_aconf); | |
934 | ||
637c4932 | 935 | RB_DLINK_FOREACH_SAFE(ptr, next_ptr, yy_aconf_list.head) |
212380e3 AC |
936 | { |
937 | free_conf(ptr->data); | |
330fc5c1 | 938 | rb_dlinkDestroy(ptr, &yy_aconf_list); |
212380e3 AC |
939 | } |
940 | ||
941 | yy_aconf = make_conf(); | |
942 | yy_aconf->status = CONF_CLIENT; | |
943 | ||
944 | return 0; | |
945 | } | |
946 | ||
947 | static int | |
948 | conf_end_auth(struct TopConf *tc) | |
949 | { | |
3d1f32c0 | 950 | struct ConfItem *yy_tmp, *found_conf; |
330fc5c1 | 951 | rb_dlink_node *ptr; |
637c4932 | 952 | rb_dlink_node *next_ptr; |
212380e3 | 953 | |
27f616dd JT |
954 | if(EmptyString(yy_aconf->info.name)) |
955 | yy_aconf->info.name = rb_strdup("NOMATCH"); | |
212380e3 AC |
956 | |
957 | /* didnt even get one ->host? */ | |
958 | if(EmptyString(yy_aconf->host)) | |
959 | { | |
960 | conf_report_error("Ignoring auth block -- missing user@host"); | |
961 | return 0; | |
962 | } | |
963 | ||
964 | /* so the stacking works in order.. */ | |
965 | collapse(yy_aconf->user); | |
966 | collapse(yy_aconf->host); | |
967 | conf_add_class_to_conf(yy_aconf); | |
3d1f32c0 | 968 | if ((found_conf = find_exact_conf_by_address("*", CONF_CLIENT, "*")) && found_conf->spasswd == NULL) |
6e5e2b00 | 969 | conf_report_error("Ignoring redundant auth block (after *@*)"); |
3d1f32c0 | 970 | else if ((found_conf = find_exact_conf_by_address(yy_aconf->host, CONF_CLIENT, yy_aconf->user)) && |
5f2df251 | 971 | (!found_conf->spasswd || (yy_aconf->spasswd && |
3d1f32c0 | 972 | 0 == irccmp(found_conf->spasswd, yy_aconf->spasswd)))) |
6e5e2b00 JT |
973 | conf_report_error("Ignoring duplicate auth block for %s@%s", |
974 | yy_aconf->user, yy_aconf->host); | |
975 | else | |
976 | add_conf_by_address(yy_aconf->host, CONF_CLIENT, yy_aconf->user, yy_aconf->spasswd, yy_aconf); | |
212380e3 | 977 | |
637c4932 | 978 | RB_DLINK_FOREACH_SAFE(ptr, next_ptr, yy_aconf_list.head) |
212380e3 AC |
979 | { |
980 | yy_tmp = ptr->data; | |
981 | ||
982 | if(yy_aconf->passwd) | |
47a03750 | 983 | yy_tmp->passwd = rb_strdup(yy_aconf->passwd); |
212380e3 | 984 | |
40c1fd47 VY |
985 | if(yy_aconf->spasswd) |
986 | yy_tmp->spasswd = rb_strdup(yy_aconf->spasswd); | |
023c36ae | 987 | |
212380e3 | 988 | /* this will always exist.. */ |
27f616dd | 989 | yy_tmp->info.name = rb_strdup(yy_aconf->info.name); |
212380e3 AC |
990 | |
991 | if(yy_aconf->className) | |
47a03750 | 992 | yy_tmp->className = rb_strdup(yy_aconf->className); |
212380e3 AC |
993 | |
994 | yy_tmp->flags = yy_aconf->flags; | |
995 | yy_tmp->port = yy_aconf->port; | |
996 | ||
997 | collapse(yy_tmp->user); | |
998 | collapse(yy_tmp->host); | |
999 | ||
1000 | conf_add_class_to_conf(yy_tmp); | |
1001 | ||
0c2ea0c3 | 1002 | if ((found_conf = find_exact_conf_by_address("*", CONF_CLIENT, "*")) && found_conf->spasswd == NULL) |
6e5e2b00 | 1003 | conf_report_error("Ignoring redundant auth block (after *@*)"); |
0c2ea0c3 JT |
1004 | else if ((found_conf = find_exact_conf_by_address(yy_tmp->host, CONF_CLIENT, yy_tmp->user)) && |
1005 | (!found_conf->spasswd || (yy_tmp->spasswd && | |
1006 | 0 == irccmp(found_conf->spasswd, yy_tmp->spasswd)))) | |
6e5e2b00 JT |
1007 | conf_report_error("Ignoring duplicate auth block for %s@%s", |
1008 | yy_tmp->user, yy_tmp->host); | |
1009 | else | |
1010 | add_conf_by_address(yy_tmp->host, CONF_CLIENT, yy_tmp->user, yy_tmp->spasswd, yy_tmp); | |
330fc5c1 | 1011 | rb_dlinkDestroy(ptr, &yy_aconf_list); |
212380e3 AC |
1012 | } |
1013 | ||
1014 | yy_aconf = NULL; | |
1015 | return 0; | |
1016 | } | |
1017 | ||
1018 | static void | |
1019 | conf_set_auth_user(void *data) | |
1020 | { | |
1021 | struct ConfItem *yy_tmp; | |
1022 | char *p; | |
1023 | ||
1024 | /* The first user= line doesn't allocate a new conf */ | |
1025 | if(!EmptyString(yy_aconf->host)) | |
1026 | { | |
1027 | yy_tmp = make_conf(); | |
1028 | yy_tmp->status = CONF_CLIENT; | |
1029 | } | |
1030 | else | |
1031 | yy_tmp = yy_aconf; | |
1032 | ||
1033 | if((p = strchr(data, '@'))) | |
1034 | { | |
1035 | *p++ = '\0'; | |
1036 | ||
47a03750 VY |
1037 | yy_tmp->user = rb_strdup(data); |
1038 | yy_tmp->host = rb_strdup(p); | |
212380e3 AC |
1039 | } |
1040 | else | |
1041 | { | |
47a03750 VY |
1042 | yy_tmp->user = rb_strdup("*"); |
1043 | yy_tmp->host = rb_strdup(data); | |
212380e3 AC |
1044 | } |
1045 | ||
1046 | if(yy_aconf != yy_tmp) | |
330fc5c1 | 1047 | rb_dlinkAddAlloc(yy_tmp, &yy_aconf_list); |
212380e3 AC |
1048 | } |
1049 | ||
40c1fd47 VY |
1050 | static void |
1051 | conf_set_auth_auth_user(void *data) | |
1052 | { | |
1053 | if(yy_aconf->spasswd) | |
1054 | memset(yy_aconf->spasswd, 0, strlen(yy_aconf->spasswd)); | |
1055 | rb_free(yy_aconf->spasswd); | |
1056 | yy_aconf->spasswd = rb_strdup(data); | |
1057 | } | |
1058 | ||
212380e3 AC |
1059 | static void |
1060 | conf_set_auth_passwd(void *data) | |
1061 | { | |
1062 | if(yy_aconf->passwd) | |
1063 | memset(yy_aconf->passwd, 0, strlen(yy_aconf->passwd)); | |
637c4932 | 1064 | rb_free(yy_aconf->passwd); |
47a03750 | 1065 | yy_aconf->passwd = rb_strdup(data); |
212380e3 AC |
1066 | } |
1067 | ||
1068 | static void | |
1069 | conf_set_auth_spoof(void *data) | |
1070 | { | |
1071 | char *p; | |
1072 | char *user = NULL; | |
1073 | char *host = NULL; | |
1074 | ||
1075 | host = data; | |
1076 | ||
1077 | /* user@host spoof */ | |
1078 | if((p = strchr(host, '@')) != NULL) | |
1079 | { | |
1080 | *p = '\0'; | |
1081 | user = data; | |
1082 | host = p+1; | |
1083 | ||
1084 | if(EmptyString(user)) | |
1085 | { | |
1086 | conf_report_error("Warning -- spoof ident empty."); | |
1087 | return; | |
1088 | } | |
1089 | ||
1090 | if(strlen(user) > USERLEN) | |
1091 | { | |
1092 | conf_report_error("Warning -- spoof ident length invalid."); | |
1093 | return; | |
1094 | } | |
1095 | ||
1096 | if(!valid_username(user)) | |
1097 | { | |
1098 | conf_report_error("Warning -- invalid spoof (ident)."); | |
1099 | return; | |
1100 | } | |
1101 | ||
1102 | /* this must be restored! */ | |
1103 | *p = '@'; | |
1104 | } | |
1105 | ||
1106 | if(EmptyString(host)) | |
1107 | { | |
1108 | conf_report_error("Warning -- spoof host empty."); | |
1109 | return; | |
1110 | } | |
1111 | ||
1112 | if(strlen(host) > HOSTLEN) | |
1113 | { | |
1114 | conf_report_error("Warning -- spoof host length invalid."); | |
1115 | return; | |
1116 | } | |
1117 | ||
1118 | if(!valid_hostname(host)) | |
1119 | { | |
1120 | conf_report_error("Warning -- invalid spoof (host)."); | |
1121 | return; | |
1122 | } | |
1123 | ||
27f616dd JT |
1124 | rb_free(yy_aconf->info.name); |
1125 | yy_aconf->info.name = rb_strdup(data); | |
212380e3 AC |
1126 | yy_aconf->flags |= CONF_FLAGS_SPOOF_IP; |
1127 | } | |
1128 | ||
1129 | static void | |
1130 | conf_set_auth_flags(void *data) | |
1131 | { | |
1132 | conf_parm_t *args = data; | |
1133 | ||
1134 | set_modes_from_table((int *) &yy_aconf->flags, "flag", auth_table, args); | |
1135 | } | |
1136 | ||
1137 | static void | |
1138 | conf_set_auth_redir_serv(void *data) | |
1139 | { | |
1140 | yy_aconf->flags |= CONF_FLAGS_REDIR; | |
27f616dd JT |
1141 | rb_free(yy_aconf->info.name); |
1142 | yy_aconf->info.name = rb_strdup(data); | |
212380e3 AC |
1143 | } |
1144 | ||
1145 | static void | |
1146 | conf_set_auth_redir_port(void *data) | |
1147 | { | |
1148 | int port = *(unsigned int *) data; | |
1149 | ||
1150 | yy_aconf->flags |= CONF_FLAGS_REDIR; | |
1151 | yy_aconf->port = port; | |
1152 | } | |
1153 | ||
1154 | static void | |
1155 | conf_set_auth_class(void *data) | |
1156 | { | |
637c4932 | 1157 | rb_free(yy_aconf->className); |
47a03750 | 1158 | yy_aconf->className = rb_strdup(data); |
212380e3 AC |
1159 | } |
1160 | ||
1161 | /* ok, shared_oper handles the stacking, shared_flags handles adding | |
1162 | * things.. so all we need to do when we start and end a shared block, is | |
1163 | * clean up anything thats been left over. | |
1164 | */ | |
1165 | static int | |
1166 | conf_cleanup_shared(struct TopConf *tc) | |
1167 | { | |
637c4932 | 1168 | rb_dlink_node *ptr, *next_ptr; |
212380e3 | 1169 | |
637c4932 | 1170 | RB_DLINK_FOREACH_SAFE(ptr, next_ptr, yy_shared_list.head) |
212380e3 AC |
1171 | { |
1172 | free_remote_conf(ptr->data); | |
330fc5c1 | 1173 | rb_dlinkDestroy(ptr, &yy_shared_list); |
212380e3 AC |
1174 | } |
1175 | ||
1176 | if(yy_shared != NULL) | |
1177 | { | |
1178 | free_remote_conf(yy_shared); | |
1179 | yy_shared = NULL; | |
1180 | } | |
1181 | ||
1182 | return 0; | |
1183 | } | |
1184 | ||
1185 | static void | |
1186 | conf_set_shared_oper(void *data) | |
1187 | { | |
1188 | conf_parm_t *args = data; | |
1189 | const char *username; | |
1190 | char *p; | |
1191 | ||
1192 | if(yy_shared != NULL) | |
1193 | free_remote_conf(yy_shared); | |
1194 | ||
1195 | yy_shared = make_remote_conf(); | |
1196 | ||
1197 | if(args->next != NULL) | |
1198 | { | |
dceac3e4 | 1199 | if(CF_TYPE(args->type) != CF_QSTRING) |
212380e3 AC |
1200 | { |
1201 | conf_report_error("Ignoring shared::oper -- server is not a qstring"); | |
1202 | return; | |
1203 | } | |
1204 | ||
47a03750 | 1205 | yy_shared->server = rb_strdup(args->v.string); |
212380e3 AC |
1206 | args = args->next; |
1207 | } | |
1208 | else | |
47a03750 | 1209 | yy_shared->server = rb_strdup("*"); |
212380e3 | 1210 | |
dceac3e4 | 1211 | if(CF_TYPE(args->type) != CF_QSTRING) |
212380e3 AC |
1212 | { |
1213 | conf_report_error("Ignoring shared::oper -- oper is not a qstring"); | |
1214 | return; | |
1215 | } | |
1216 | ||
1217 | if((p = strchr(args->v.string, '@')) == NULL) | |
1218 | { | |
1219 | conf_report_error("Ignoring shard::oper -- oper is not a user@host"); | |
1220 | return; | |
1221 | } | |
1222 | ||
1223 | username = args->v.string; | |
1224 | *p++ = '\0'; | |
1225 | ||
1226 | if(EmptyString(p)) | |
47a03750 | 1227 | yy_shared->host = rb_strdup("*"); |
212380e3 | 1228 | else |
47a03750 | 1229 | yy_shared->host = rb_strdup(p); |
212380e3 AC |
1230 | |
1231 | if(EmptyString(username)) | |
47a03750 | 1232 | yy_shared->username = rb_strdup("*"); |
212380e3 | 1233 | else |
47a03750 | 1234 | yy_shared->username = rb_strdup(username); |
212380e3 | 1235 | |
330fc5c1 | 1236 | rb_dlinkAddAlloc(yy_shared, &yy_shared_list); |
212380e3 AC |
1237 | yy_shared = NULL; |
1238 | } | |
1239 | ||
1240 | static void | |
1241 | conf_set_shared_flags(void *data) | |
1242 | { | |
1243 | conf_parm_t *args = data; | |
1244 | int flags = 0; | |
637c4932 | 1245 | rb_dlink_node *ptr, *next_ptr; |
212380e3 AC |
1246 | |
1247 | if(yy_shared != NULL) | |
1248 | free_remote_conf(yy_shared); | |
1249 | ||
1250 | set_modes_from_table(&flags, "flag", shared_table, args); | |
1251 | ||
637c4932 | 1252 | RB_DLINK_FOREACH_SAFE(ptr, next_ptr, yy_shared_list.head) |
212380e3 AC |
1253 | { |
1254 | yy_shared = ptr->data; | |
1255 | ||
1256 | yy_shared->flags = flags; | |
330fc5c1 AC |
1257 | rb_dlinkDestroy(ptr, &yy_shared_list); |
1258 | rb_dlinkAddTail(yy_shared, &yy_shared->node, &shared_conf_list); | |
212380e3 AC |
1259 | } |
1260 | ||
1261 | yy_shared = NULL; | |
1262 | } | |
1263 | ||
1264 | static int | |
1265 | conf_begin_connect(struct TopConf *tc) | |
1266 | { | |
1267 | if(yy_server) | |
1268 | free_server_conf(yy_server); | |
1269 | ||
1270 | yy_server = make_server_conf(); | |
1271 | yy_server->port = PORTNUM; | |
5aa453a4 | 1272 | yy_server->flags |= SERVER_TB; |
212380e3 AC |
1273 | |
1274 | if(conf_cur_block_name != NULL) | |
47a03750 | 1275 | yy_server->name = rb_strdup(conf_cur_block_name); |
212380e3 AC |
1276 | |
1277 | return 0; | |
1278 | } | |
1279 | ||
1280 | static int | |
1281 | conf_end_connect(struct TopConf *tc) | |
1282 | { | |
1283 | if(EmptyString(yy_server->name)) | |
1284 | { | |
1285 | conf_report_error("Ignoring connect block -- missing name."); | |
1286 | return 0; | |
1287 | } | |
1288 | ||
1289 | if(ServerInfo.name != NULL && !irccmp(ServerInfo.name, yy_server->name)) | |
1290 | { | |
1291 | conf_report_error("Ignoring connect block for %s -- name is equal to my own name.", | |
1292 | yy_server->name); | |
1293 | return 0; | |
1294 | } | |
1295 | ||
ff0cc1e6 | 1296 | if((EmptyString(yy_server->passwd) || EmptyString(yy_server->spasswd)) && EmptyString(yy_server->certfp)) |
212380e3 | 1297 | { |
c8f26906 | 1298 | conf_report_error("Ignoring connect block for %s -- no fingerprint or password credentials provided.", |
212380e3 AC |
1299 | yy_server->name); |
1300 | return 0; | |
1301 | } | |
1302 | ||
1303 | if(EmptyString(yy_server->host)) | |
1304 | { | |
1305 | conf_report_error("Ignoring connect block for %s -- missing host.", | |
1306 | yy_server->name); | |
1307 | return 0; | |
1308 | } | |
1309 | ||
1310 | #ifndef HAVE_LIBZ | |
1311 | if(ServerConfCompressed(yy_server)) | |
1312 | { | |
1313 | conf_report_error("Ignoring connect::flags::compressed -- zlib not available."); | |
1314 | yy_server->flags &= ~SERVER_COMPRESSED; | |
1315 | } | |
1316 | #endif | |
1317 | ||
1318 | add_server_conf(yy_server); | |
330fc5c1 | 1319 | rb_dlinkAdd(yy_server, &yy_server->node, &server_conf_list); |
212380e3 AC |
1320 | |
1321 | yy_server = NULL; | |
1322 | return 0; | |
1323 | } | |
1324 | ||
1325 | static void | |
1326 | conf_set_connect_host(void *data) | |
1327 | { | |
637c4932 | 1328 | rb_free(yy_server->host); |
47a03750 | 1329 | yy_server->host = rb_strdup(data); |
212380e3 AC |
1330 | if (strchr(yy_server->host, ':')) |
1331 | yy_server->aftype = AF_INET6; | |
1332 | } | |
1333 | ||
1334 | static void | |
1335 | conf_set_connect_vhost(void *data) | |
1336 | { | |
caa4d9d2 | 1337 | if(rb_inet_pton_sock(data, (struct sockaddr *)&yy_server->my_ipnum) <= 0) |
212380e3 | 1338 | { |
532f83a7 | 1339 | conf_report_error("Invalid IP address for server connect vhost (%s)", |
212380e3 AC |
1340 | (char *) data); |
1341 | return; | |
1342 | } | |
1343 | ||
1344 | yy_server->flags |= SERVER_VHOSTED; | |
1345 | } | |
1346 | ||
1347 | static void | |
1348 | conf_set_connect_send_password(void *data) | |
1349 | { | |
1350 | if(yy_server->spasswd) | |
1351 | { | |
1352 | memset(yy_server->spasswd, 0, strlen(yy_server->spasswd)); | |
637c4932 | 1353 | rb_free(yy_server->spasswd); |
212380e3 AC |
1354 | } |
1355 | ||
47a03750 | 1356 | yy_server->spasswd = rb_strdup(data); |
212380e3 AC |
1357 | } |
1358 | ||
1359 | static void | |
1360 | conf_set_connect_accept_password(void *data) | |
1361 | { | |
1362 | if(yy_server->passwd) | |
1363 | { | |
1364 | memset(yy_server->passwd, 0, strlen(yy_server->passwd)); | |
637c4932 | 1365 | rb_free(yy_server->passwd); |
212380e3 | 1366 | } |
47a03750 | 1367 | yy_server->passwd = rb_strdup(data); |
212380e3 AC |
1368 | } |
1369 | ||
ff0cc1e6 AC |
1370 | static void |
1371 | conf_set_connect_fingerprint(void *data) | |
1372 | { | |
462ae9d7 JT |
1373 | if (yy_server->certfp) |
1374 | rb_free(yy_server->certfp); | |
ff0cc1e6 AC |
1375 | yy_server->certfp = rb_strdup((char *) data); |
1376 | ||
1377 | /* force SSL to be enabled if fingerprint is enabled. */ | |
1378 | yy_server->flags |= SERVER_SSL; | |
1379 | } | |
1380 | ||
212380e3 AC |
1381 | static void |
1382 | conf_set_connect_port(void *data) | |
1383 | { | |
1384 | int port = *(unsigned int *) data; | |
1385 | ||
1386 | if(port < 1) | |
1387 | port = PORTNUM; | |
1388 | ||
1389 | yy_server->port = port; | |
1390 | } | |
1391 | ||
1392 | static void | |
1393 | conf_set_connect_aftype(void *data) | |
1394 | { | |
1395 | char *aft = data; | |
1396 | ||
1397 | if(strcasecmp(aft, "ipv4") == 0) | |
1398 | yy_server->aftype = AF_INET; | |
ccda6e3f | 1399 | #ifdef RB_IPV6 |
212380e3 AC |
1400 | else if(strcasecmp(aft, "ipv6") == 0) |
1401 | yy_server->aftype = AF_INET6; | |
1402 | #endif | |
1403 | else | |
1404 | conf_report_error("connect::aftype '%s' is unknown.", aft); | |
1405 | } | |
1406 | ||
1407 | static void | |
1408 | conf_set_connect_flags(void *data) | |
1409 | { | |
1410 | conf_parm_t *args = data; | |
1411 | ||
1412 | /* note, we allow them to set compressed, then remove it later if | |
1413 | * they do and LIBZ isnt available | |
1414 | */ | |
1415 | set_modes_from_table(&yy_server->flags, "flag", connect_table, args); | |
1416 | } | |
1417 | ||
1418 | static void | |
1419 | conf_set_connect_hub_mask(void *data) | |
1420 | { | |
1421 | struct remote_conf *yy_hub; | |
1422 | ||
1423 | if(EmptyString(yy_server->name)) | |
1424 | return; | |
1425 | ||
1426 | yy_hub = make_remote_conf(); | |
1427 | yy_hub->flags = CONF_HUB; | |
1428 | ||
47a03750 VY |
1429 | yy_hub->host = rb_strdup(data); |
1430 | yy_hub->server = rb_strdup(yy_server->name); | |
330fc5c1 | 1431 | rb_dlinkAdd(yy_hub, &yy_hub->node, &hubleaf_conf_list); |
212380e3 AC |
1432 | } |
1433 | ||
1434 | static void | |
1435 | conf_set_connect_leaf_mask(void *data) | |
1436 | { | |
1437 | struct remote_conf *yy_leaf; | |
1438 | ||
1439 | if(EmptyString(yy_server->name)) | |
1440 | return; | |
1441 | ||
1442 | yy_leaf = make_remote_conf(); | |
1443 | yy_leaf->flags = CONF_LEAF; | |
1444 | ||
47a03750 VY |
1445 | yy_leaf->host = rb_strdup(data); |
1446 | yy_leaf->server = rb_strdup(yy_server->name); | |
330fc5c1 | 1447 | rb_dlinkAdd(yy_leaf, &yy_leaf->node, &hubleaf_conf_list); |
212380e3 AC |
1448 | } |
1449 | ||
1450 | static void | |
1451 | conf_set_connect_class(void *data) | |
1452 | { | |
637c4932 | 1453 | rb_free(yy_server->class_name); |
47a03750 | 1454 | yy_server->class_name = rb_strdup(data); |
212380e3 AC |
1455 | } |
1456 | ||
1457 | static void | |
1458 | conf_set_exempt_ip(void *data) | |
1459 | { | |
1460 | struct ConfItem *yy_tmp; | |
1461 | ||
1462 | if(parse_netmask(data, NULL, NULL) == HM_HOST) | |
1463 | { | |
1464 | conf_report_error("Ignoring exempt -- invalid exempt::ip."); | |
1465 | return; | |
1466 | } | |
1467 | ||
1468 | yy_tmp = make_conf(); | |
47a03750 VY |
1469 | yy_tmp->passwd = rb_strdup("*"); |
1470 | yy_tmp->host = rb_strdup(data); | |
212380e3 | 1471 | yy_tmp->status = CONF_EXEMPTDLINE; |
40c1fd47 | 1472 | add_conf_by_address(yy_tmp->host, CONF_EXEMPTDLINE, NULL, NULL, yy_tmp); |
212380e3 AC |
1473 | } |
1474 | ||
1475 | static int | |
1476 | conf_cleanup_cluster(struct TopConf *tc) | |
1477 | { | |
637c4932 | 1478 | rb_dlink_node *ptr, *next_ptr; |
212380e3 | 1479 | |
637c4932 | 1480 | RB_DLINK_FOREACH_SAFE(ptr, next_ptr, yy_cluster_list.head) |
212380e3 AC |
1481 | { |
1482 | free_remote_conf(ptr->data); | |
330fc5c1 | 1483 | rb_dlinkDestroy(ptr, &yy_cluster_list); |
212380e3 AC |
1484 | } |
1485 | ||
1486 | if(yy_shared != NULL) | |
1487 | { | |
1488 | free_remote_conf(yy_shared); | |
1489 | yy_shared = NULL; | |
1490 | } | |
1491 | ||
1492 | return 0; | |
1493 | } | |
1494 | ||
1495 | static void | |
1496 | conf_set_cluster_name(void *data) | |
1497 | { | |
1498 | if(yy_shared != NULL) | |
1499 | free_remote_conf(yy_shared); | |
1500 | ||
1501 | yy_shared = make_remote_conf(); | |
47a03750 | 1502 | yy_shared->server = rb_strdup(data); |
330fc5c1 | 1503 | rb_dlinkAddAlloc(yy_shared, &yy_cluster_list); |
212380e3 AC |
1504 | |
1505 | yy_shared = NULL; | |
1506 | } | |
1507 | ||
1508 | static void | |
1509 | conf_set_cluster_flags(void *data) | |
1510 | { | |
1511 | conf_parm_t *args = data; | |
1512 | int flags = 0; | |
637c4932 | 1513 | rb_dlink_node *ptr, *next_ptr; |
212380e3 AC |
1514 | |
1515 | if(yy_shared != NULL) | |
1516 | free_remote_conf(yy_shared); | |
1517 | ||
1518 | set_modes_from_table(&flags, "flag", cluster_table, args); | |
1519 | ||
637c4932 | 1520 | RB_DLINK_FOREACH_SAFE(ptr, next_ptr, yy_cluster_list.head) |
212380e3 AC |
1521 | { |
1522 | yy_shared = ptr->data; | |
1523 | yy_shared->flags = flags; | |
330fc5c1 AC |
1524 | rb_dlinkAddTail(yy_shared, &yy_shared->node, &cluster_conf_list); |
1525 | rb_dlinkDestroy(ptr, &yy_cluster_list); | |
212380e3 AC |
1526 | } |
1527 | ||
1528 | yy_shared = NULL; | |
1529 | } | |
1530 | ||
1531 | static void | |
1532 | conf_set_general_havent_read_conf(void *data) | |
1533 | { | |
1534 | if(*(unsigned int *) data) | |
1535 | { | |
1536 | conf_report_error("You haven't read your config file properly."); | |
1537 | conf_report_error | |
1538 | ("There is a line in the example conf that will kill your server if not removed."); | |
1539 | conf_report_error | |
1540 | ("Consider actually reading/editing the conf file, and removing this line."); | |
1541 | if (!testing_conf) | |
1542 | exit(0); | |
1543 | } | |
1544 | } | |
1545 | ||
1546 | static void | |
1547 | conf_set_general_hide_error_messages(void *data) | |
1548 | { | |
1549 | char *val = data; | |
1550 | ||
1551 | if(strcasecmp(val, "yes") == 0) | |
1552 | ConfigFileEntry.hide_error_messages = 2; | |
1553 | else if(strcasecmp(val, "opers") == 0) | |
1554 | ConfigFileEntry.hide_error_messages = 1; | |
1555 | else if(strcasecmp(val, "no") == 0) | |
1556 | ConfigFileEntry.hide_error_messages = 0; | |
1557 | else | |
1558 | conf_report_error("Invalid setting '%s' for general::hide_error_messages.", val); | |
1559 | } | |
1560 | ||
1561 | static void | |
1562 | conf_set_general_kline_delay(void *data) | |
1563 | { | |
1564 | ConfigFileEntry.kline_delay = *(unsigned int *) data; | |
1565 | ||
1566 | /* THIS MUST BE HERE to stop us being unable to check klines */ | |
f66f0baa | 1567 | kline_queued = false; |
212380e3 AC |
1568 | } |
1569 | ||
1570 | static void | |
1571 | conf_set_general_stats_k_oper_only(void *data) | |
1572 | { | |
1573 | char *val = data; | |
1574 | ||
1575 | if(strcasecmp(val, "yes") == 0) | |
1576 | ConfigFileEntry.stats_k_oper_only = 2; | |
1577 | else if(strcasecmp(val, "masked") == 0) | |
1578 | ConfigFileEntry.stats_k_oper_only = 1; | |
1579 | else if(strcasecmp(val, "no") == 0) | |
1580 | ConfigFileEntry.stats_k_oper_only = 0; | |
1581 | else | |
1582 | conf_report_error("Invalid setting '%s' for general::stats_k_oper_only.", val); | |
1583 | } | |
1584 | ||
1585 | static void | |
1586 | conf_set_general_stats_i_oper_only(void *data) | |
1587 | { | |
1588 | char *val = data; | |
1589 | ||
1590 | if(strcasecmp(val, "yes") == 0) | |
1591 | ConfigFileEntry.stats_i_oper_only = 2; | |
1592 | else if(strcasecmp(val, "masked") == 0) | |
1593 | ConfigFileEntry.stats_i_oper_only = 1; | |
1594 | else if(strcasecmp(val, "no") == 0) | |
1595 | ConfigFileEntry.stats_i_oper_only = 0; | |
1596 | else | |
1597 | conf_report_error("Invalid setting '%s' for general::stats_i_oper_only.", val); | |
1598 | } | |
1599 | ||
1600 | static void | |
1601 | conf_set_general_compression_level(void *data) | |
1602 | { | |
1603 | #ifdef HAVE_LIBZ | |
1604 | ConfigFileEntry.compression_level = *(unsigned int *) data; | |
1605 | ||
1606 | if((ConfigFileEntry.compression_level < 1) || (ConfigFileEntry.compression_level > 9)) | |
1607 | { | |
1608 | conf_report_error | |
1609 | ("Invalid general::compression_level %d -- using default.", | |
1610 | ConfigFileEntry.compression_level); | |
1611 | ConfigFileEntry.compression_level = 0; | |
1612 | } | |
1613 | #else | |
1614 | conf_report_error("Ignoring general::compression_level -- zlib not available."); | |
1615 | #endif | |
1616 | } | |
1617 | ||
1618 | static void | |
1619 | conf_set_general_default_umodes(void *data) | |
1620 | { | |
1621 | char *pm; | |
1622 | int what = MODE_ADD, flag; | |
1623 | ||
1624 | ConfigFileEntry.default_umodes = 0; | |
1625 | for (pm = (char *) data; *pm; pm++) | |
1626 | { | |
1627 | switch (*pm) | |
1628 | { | |
1629 | case '+': | |
1630 | what = MODE_ADD; | |
1631 | break; | |
1632 | case '-': | |
1633 | what = MODE_DEL; | |
1634 | break; | |
1635 | ||
1636 | /* don't allow +o */ | |
1637 | case 'o': | |
1638 | case 'S': | |
5fabe513 | 1639 | case 'Z': |
212380e3 AC |
1640 | case ' ': |
1641 | break; | |
1642 | ||
1643 | default: | |
1644 | if ((flag = user_modes[(unsigned char) *pm])) | |
1645 | { | |
1646 | /* Proper value has probably not yet been set | |
1647 | * so don't check oper_only_umodes -- jilles */ | |
1648 | if (what == MODE_ADD) | |
1649 | ConfigFileEntry.default_umodes |= flag; | |
1650 | else | |
1651 | ConfigFileEntry.default_umodes &= ~flag; | |
1652 | } | |
1653 | break; | |
1654 | } | |
023c36ae | 1655 | } |
212380e3 AC |
1656 | } |
1657 | ||
1658 | static void | |
1659 | conf_set_general_oper_umodes(void *data) | |
1660 | { | |
1661 | set_modes_from_table(&ConfigFileEntry.oper_umodes, "umode", umode_table, data); | |
1662 | } | |
1663 | ||
13d8f0ed AC |
1664 | static void |
1665 | conf_set_general_certfp_method(void *data) | |
1666 | { | |
1667 | char *method = data; | |
1668 | ||
1669 | if (!strcasecmp(method, "sha1")) | |
1670 | ConfigFileEntry.certfp_method = RB_SSL_CERTFP_METH_SHA1; | |
1671 | else if (!strcasecmp(method, "sha256")) | |
1672 | ConfigFileEntry.certfp_method = RB_SSL_CERTFP_METH_SHA256; | |
1673 | else if (!strcasecmp(method, "sha512")) | |
1674 | ConfigFileEntry.certfp_method = RB_SSL_CERTFP_METH_SHA512; | |
1675 | else | |
1676 | { | |
1677 | ConfigFileEntry.certfp_method = RB_SSL_CERTFP_METH_SHA1; | |
1678 | conf_report_error("Ignoring general::certfp_method -- bogus certfp method %s", method); | |
1679 | } | |
1680 | } | |
1681 | ||
212380e3 AC |
1682 | static void |
1683 | conf_set_general_oper_only_umodes(void *data) | |
1684 | { | |
1685 | set_modes_from_table(&ConfigFileEntry.oper_only_umodes, "umode", umode_table, data); | |
1686 | } | |
1687 | ||
1688 | static void | |
1689 | conf_set_general_oper_snomask(void *data) | |
1690 | { | |
1691 | char *pm; | |
1692 | int what = MODE_ADD, flag; | |
1693 | ||
1694 | ConfigFileEntry.oper_snomask = 0; | |
1695 | for (pm = (char *) data; *pm; pm++) | |
1696 | { | |
1697 | switch (*pm) | |
1698 | { | |
1699 | case '+': | |
1700 | what = MODE_ADD; | |
1701 | break; | |
1702 | case '-': | |
1703 | what = MODE_DEL; | |
1704 | break; | |
1705 | ||
1706 | default: | |
1707 | if ((flag = snomask_modes[(unsigned char) *pm])) | |
1708 | { | |
1709 | if (what == MODE_ADD) | |
1710 | ConfigFileEntry.oper_snomask |= flag; | |
1711 | else | |
1712 | ConfigFileEntry.oper_snomask &= ~flag; | |
1713 | } | |
1714 | break; | |
1715 | } | |
1716 | } | |
1717 | } | |
1718 | ||
1719 | static void | |
1720 | conf_set_serverhide_links_delay(void *data) | |
1721 | { | |
1722 | int val = *(unsigned int *) data; | |
1723 | ||
212380e3 AC |
1724 | ConfigServerHide.links_delay = val; |
1725 | } | |
1726 | ||
212380e3 AC |
1727 | static void |
1728 | conf_set_service_name(void *data) | |
1729 | { | |
212380e3 AC |
1730 | const char *s; |
1731 | char *tmp; | |
1732 | int dots = 0; | |
1733 | ||
1734 | for(s = data; *s != '\0'; s++) | |
1735 | { | |
1736 | if(!IsServChar(*s)) | |
1737 | { | |
1738 | conf_report_error("Ignoring service::name " | |
1739 | "-- bogus servername."); | |
1740 | return; | |
1741 | } | |
1742 | else if(*s == '.') | |
1743 | dots++; | |
1744 | } | |
1745 | ||
1746 | if(!dots) | |
1747 | { | |
1748 | conf_report_error("Ignoring service::name -- must contain '.'"); | |
1749 | return; | |
1750 | } | |
1751 | ||
47a03750 | 1752 | tmp = rb_strdup(data); |
330fc5c1 | 1753 | rb_dlinkAddAlloc(tmp, &service_list); |
212380e3 AC |
1754 | } |
1755 | ||
212380e3 AC |
1756 | static int |
1757 | conf_begin_alias(struct TopConf *tc) | |
1758 | { | |
eddc2ab6 | 1759 | yy_alias = rb_malloc(sizeof(struct alias_entry)); |
212380e3 AC |
1760 | |
1761 | if (conf_cur_block_name != NULL) | |
47a03750 | 1762 | yy_alias->name = rb_strdup(conf_cur_block_name); |
212380e3 AC |
1763 | |
1764 | yy_alias->flags = 0; | |
1765 | yy_alias->hits = 0; | |
1766 | ||
1767 | return 0; | |
1768 | } | |
1769 | ||
1770 | static int | |
1771 | conf_end_alias(struct TopConf *tc) | |
1772 | { | |
212380e3 AC |
1773 | if (yy_alias == NULL) |
1774 | return -1; | |
1775 | ||
1776 | if (yy_alias->name == NULL) | |
1777 | { | |
1778 | conf_report_error("Ignoring alias -- must have a name."); | |
1779 | ||
637c4932 | 1780 | rb_free(yy_alias); |
212380e3 AC |
1781 | |
1782 | return -1; | |
1783 | } | |
1784 | ||
1785 | if (yy_alias->target == NULL) | |
1786 | { | |
1787 | conf_report_error("Ignoring alias -- must have a target."); | |
1788 | ||
637c4932 | 1789 | rb_free(yy_alias); |
212380e3 AC |
1790 | |
1791 | return -1; | |
1792 | } | |
1793 | ||
a4bf26dd | 1794 | rb_dictionary_add(alias_dict, yy_alias->name, yy_alias); |
212380e3 AC |
1795 | |
1796 | return 0; | |
1797 | } | |
1798 | ||
1799 | static void | |
1800 | conf_set_alias_name(void *data) | |
1801 | { | |
1802 | if (data == NULL || yy_alias == NULL) /* this shouldn't ever happen */ | |
1803 | return; | |
1804 | ||
47a03750 | 1805 | yy_alias->name = rb_strdup(data); |
212380e3 AC |
1806 | } |
1807 | ||
1808 | static void | |
1809 | conf_set_alias_target(void *data) | |
1810 | { | |
1811 | if (data == NULL || yy_alias == NULL) /* this shouldn't ever happen */ | |
1812 | return; | |
1813 | ||
47a03750 | 1814 | yy_alias->target = rb_strdup(data); |
212380e3 AC |
1815 | } |
1816 | ||
63eb8567 AC |
1817 | static void |
1818 | conf_set_channel_autochanmodes(void *data) | |
1819 | { | |
1820 | char *pm; | |
1821 | int what = MODE_ADD; | |
1822 | ||
1823 | ConfigChannel.autochanmodes = 0; | |
1824 | for (pm = (char *) data; *pm; pm++) | |
1825 | { | |
1826 | switch (*pm) | |
1827 | { | |
1828 | case '+': | |
1829 | what = MODE_ADD; | |
1830 | break; | |
1831 | case '-': | |
1832 | what = MODE_DEL; | |
1833 | break; | |
1834 | ||
1835 | default: | |
1836 | if (chmode_table[(unsigned char) *pm].set_func == chm_simple) | |
1837 | { | |
1838 | if (what == MODE_ADD) | |
1839 | ConfigChannel.autochanmodes |= chmode_table[(unsigned char) *pm].mode_type; | |
1840 | else | |
1841 | ConfigChannel.autochanmodes &= ~chmode_table[(unsigned char) *pm].mode_type; | |
1842 | } | |
1843 | else | |
1844 | { | |
4952e40b | 1845 | conf_report_error("channel::autochanmodes -- Invalid channel mode %c", *pm); |
63eb8567 AC |
1846 | continue; |
1847 | } | |
1848 | break; | |
1849 | } | |
1850 | } | |
1851 | } | |
1852 | ||
3c93d380 EM |
1853 | /* XXX for below */ |
1854 | static void conf_set_blacklist_reason(void *data); | |
1855 | ||
d3f6b808 EM |
1856 | #define IPTYPE_IPV4 1 |
1857 | #define IPTYPE_IPV6 2 | |
1858 | ||
212380e3 AC |
1859 | static void |
1860 | conf_set_blacklist_host(void *data) | |
1861 | { | |
3c93d380 EM |
1862 | if (yy_blacklist_host) |
1863 | { | |
1864 | conf_report_error("blacklist::host %s overlaps existing host %s", | |
1865 | (char *)data, yy_blacklist_host); | |
1866 | ||
1867 | /* Cleanup */ | |
1868 | conf_set_blacklist_reason(NULL); | |
1869 | return; | |
1870 | } | |
1871 | ||
d3f6b808 | 1872 | yy_blacklist_iptype |= IPTYPE_IPV4; |
47a03750 | 1873 | yy_blacklist_host = rb_strdup(data); |
212380e3 AC |
1874 | } |
1875 | ||
0a1e77c2 EM |
1876 | static void |
1877 | conf_set_blacklist_type(void *data) | |
1878 | { | |
1879 | conf_parm_t *args = data; | |
1880 | ||
1881 | /* Don't assume we have either if we got here */ | |
d3f6b808 | 1882 | yy_blacklist_iptype = 0; |
0a1e77c2 EM |
1883 | |
1884 | for (; args; args = args->next) | |
1885 | { | |
1886 | if (!strcasecmp(args->v.string, "ipv4")) | |
d3f6b808 | 1887 | yy_blacklist_iptype |= IPTYPE_IPV4; |
0a1e77c2 | 1888 | else if (!strcasecmp(args->v.string, "ipv6")) |
d3f6b808 | 1889 | yy_blacklist_iptype |= IPTYPE_IPV6; |
0a1e77c2 EM |
1890 | else |
1891 | conf_report_error("blacklist::type has unknown address family %s", | |
1892 | args->v.string); | |
1893 | } | |
1894 | ||
1895 | /* If we have neither, just default to IPv4 */ | |
d3f6b808 | 1896 | if (!yy_blacklist_iptype) |
0a1e77c2 | 1897 | { |
3fe0efd5 | 1898 | conf_report_warning("blacklist::type has neither IPv4 nor IPv6 (defaulting to IPv4)"); |
d3f6b808 | 1899 | yy_blacklist_iptype = IPTYPE_IPV4; |
0a1e77c2 EM |
1900 | } |
1901 | } | |
1902 | ||
3c93d380 EM |
1903 | static void |
1904 | conf_set_blacklist_matches(void *data) | |
1905 | { | |
1906 | conf_parm_t *args = data; | |
d3f6b808 | 1907 | enum filter_t { FILTER_NONE, FILTER_ALL, FILTER_LAST }; |
3c93d380 EM |
1908 | |
1909 | for (; args; args = args->next) | |
1910 | { | |
3c93d380 EM |
1911 | char *str = args->v.string; |
1912 | char *p; | |
d3f6b808 | 1913 | enum filter_t type = FILTER_LAST; |
3c93d380 EM |
1914 | |
1915 | if (CF_TYPE(args->type) != CF_QSTRING) | |
1916 | { | |
1917 | conf_report_error("blacklist::matches -- must be quoted string"); | |
1918 | continue; | |
1919 | } | |
1920 | ||
1921 | if (str == NULL) | |
1922 | { | |
1923 | conf_report_error("blacklist::matches -- invalid entry"); | |
1924 | continue; | |
1925 | } | |
1926 | ||
1927 | if (strlen(str) > HOSTIPLEN) | |
1928 | { | |
1929 | conf_report_error("blacklist::matches has an entry too long: %s", | |
1930 | str); | |
1931 | continue; | |
1932 | } | |
1933 | ||
1934 | for (p = str; *p != '\0'; p++) | |
1935 | { | |
1936 | /* Check for validity */ | |
1937 | if (*p == '.') | |
d3f6b808 EM |
1938 | type = FILTER_ALL; |
1939 | else if (!isdigit((unsigned char)*p)) | |
3c93d380 EM |
1940 | { |
1941 | conf_report_error("blacklist::matches has invalid IP match entry %s", | |
1942 | str); | |
d3f6b808 | 1943 | type = FILTER_NONE; |
3c93d380 EM |
1944 | break; |
1945 | } | |
1946 | } | |
1947 | ||
d3f6b808 | 1948 | if (type == FILTER_ALL) |
3c93d380 EM |
1949 | { |
1950 | /* Basic IP sanity check */ | |
1951 | struct rb_sockaddr_storage tmp; | |
1952 | if (rb_inet_pton(AF_INET, str, &tmp) <= 0) | |
1953 | { | |
1954 | conf_report_error("blacklist::matches has invalid IP match entry %s", | |
1955 | str); | |
1956 | continue; | |
1957 | } | |
1958 | } | |
d3f6b808 | 1959 | else if (type == FILTER_LAST) |
3c93d380 EM |
1960 | { |
1961 | /* Verify it's the correct length */ | |
1962 | if (strlen(str) > 3) | |
1963 | { | |
1964 | conf_report_error("blacklist::matches has invalid octet match entry %s", | |
1965 | str); | |
1966 | continue; | |
1967 | } | |
1968 | } | |
1969 | else | |
1970 | { | |
1971 | continue; /* Invalid entry */ | |
1972 | } | |
1973 | ||
d3f6b808 | 1974 | rb_dlinkAddAlloc(rb_strdup(str), &yy_blacklist_filters); |
3c93d380 EM |
1975 | } |
1976 | } | |
1977 | ||
212380e3 AC |
1978 | static void |
1979 | conf_set_blacklist_reason(void *data) | |
1980 | { | |
3c93d380 | 1981 | rb_dlink_node *ptr, *nptr; |
212380e3 | 1982 | |
2196b182 | 1983 | if (yy_blacklist_host && data) |
212380e3 | 1984 | { |
2196b182 | 1985 | yy_blacklist_reason = rb_strdup(data); |
835d456c | 1986 | if (yy_blacklist_iptype & IPTYPE_IPV6) |
0a1e77c2 | 1987 | { |
a6a30cc7 | 1988 | /* Make sure things fit (magic number 64 = alnum count + dots) |
771dcfad EM |
1989 | * Example: 1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa |
1990 | */ | |
0a1e77c2 EM |
1991 | if ((64 + strlen(yy_blacklist_host)) > IRCD_RES_HOSTLEN) |
1992 | { | |
1993 | conf_report_error("blacklist::host %s results in IPv6 queries that are too long", | |
1994 | yy_blacklist_host); | |
1995 | goto cleanup_bl; | |
1996 | } | |
1997 | } | |
1998 | /* Avoid doing redundant check, IPv6 is bigger than IPv4 --Elizabeth */ | |
d3f6b808 | 1999 | if ((yy_blacklist_iptype & IPTYPE_IPV4) && !(yy_blacklist_iptype & IPTYPE_IPV6)) |
0a1e77c2 | 2000 | { |
a6a30cc7 EM |
2001 | /* Make sure things fit for worst case (magic number 16 = number of nums + dots) |
2002 | * Example: 127.127.127.127.in-addr.arpa | |
771dcfad | 2003 | */ |
0a1e77c2 EM |
2004 | if ((16 + strlen(yy_blacklist_host)) > IRCD_RES_HOSTLEN) |
2005 | { | |
2006 | conf_report_error("blacklist::host %s results in IPv4 queries that are too long", | |
2007 | yy_blacklist_host); | |
2008 | goto cleanup_bl; | |
2009 | } | |
2010 | } | |
2011 | ||
d3f6b808 | 2012 | add_blacklist(yy_blacklist_host, yy_blacklist_reason, yy_blacklist_iptype, &yy_blacklist_filters); |
3c93d380 | 2013 | } |
0a1e77c2 EM |
2014 | |
2015 | cleanup_bl: | |
d3f6b808 | 2016 | RB_DLINK_FOREACH_SAFE(ptr, nptr, yy_blacklist_filters.head) |
e232f35c | 2017 | { |
d3f6b808 EM |
2018 | rb_free(ptr->data); |
2019 | rb_dlinkDestroy(ptr, &yy_blacklist_filters); | |
212380e3 | 2020 | } |
3c93d380 | 2021 | |
d3f6b808 EM |
2022 | yy_blacklist_filters = (rb_dlink_list){ NULL, NULL, 0 }; |
2023 | ||
3c93d380 EM |
2024 | rb_free(yy_blacklist_host); |
2025 | rb_free(yy_blacklist_reason); | |
2026 | yy_blacklist_host = NULL; | |
2027 | yy_blacklist_reason = NULL; | |
d3f6b808 | 2028 | yy_blacklist_iptype = 0; |
212380e3 AC |
2029 | } |
2030 | ||
51fa2ab8 EM |
2031 | |
2032 | struct opm_scanner | |
2033 | { | |
2034 | const char *type; | |
2035 | uint16_t port; | |
2036 | ||
2037 | rb_dlink_node node; | |
2038 | }; | |
2039 | ||
8275e270 EM |
2040 | static int |
2041 | conf_begin_opm(struct TopConf *tc) | |
2042 | { | |
2043 | yy_opm_address_ipv4 = yy_opm_address_ipv6 = NULL; | |
2044 | yy_opm_port_ipv4 = yy_opm_port_ipv6 = 0; | |
2045 | return 0; | |
2046 | } | |
2047 | ||
2048 | static int | |
2049 | conf_end_opm(struct TopConf *tc) | |
2050 | { | |
51fa2ab8 EM |
2051 | rb_dlink_node *ptr, *nptr; |
2052 | bool fail = false; | |
2053 | ||
2054 | if(!rb_dlink_list_length(&yy_opm_scanner_list)) | |
2055 | { | |
2056 | conf_report_error("No opm scanners configured, disabling opm."); | |
2057 | fail = true; | |
2058 | goto end; | |
2059 | } | |
2060 | ||
8275e270 EM |
2061 | if(yy_opm_port_ipv4 > 0) |
2062 | { | |
2063 | if(yy_opm_address_ipv4 != NULL) | |
2064 | create_opm_listener(yy_opm_address_ipv4, yy_opm_port_ipv4); | |
2065 | else | |
2066 | { | |
2067 | char ip[HOSTIPLEN]; | |
2068 | if(!rb_inet_ntop_sock((struct sockaddr *)&ServerInfo.ip, ip, sizeof(ip))) | |
8275e270 | 2069 | conf_report_error("No opm::listen_ipv4 nor serverinfo::vhost directive; cannot listen on IPv4"); |
8275e270 | 2070 | else |
8275e270 | 2071 | create_opm_listener(ip, yy_opm_port_ipv4); |
8275e270 EM |
2072 | } |
2073 | } | |
2074 | ||
2075 | if(yy_opm_port_ipv6 > 0) | |
2076 | { | |
2077 | if(yy_opm_address_ipv6 != NULL) | |
2078 | create_opm_listener(yy_opm_address_ipv6, yy_opm_port_ipv6); | |
2079 | else | |
2080 | { | |
2081 | char ip[HOSTIPLEN]; | |
2082 | if(!rb_inet_ntop_sock((struct sockaddr *)&ServerInfo.ip6, ip, sizeof(ip))) | |
8275e270 | 2083 | conf_report_error("No opm::listen_ipv6 nor serverinfo::vhost directive; cannot listen on IPv6"); |
8275e270 | 2084 | else |
8275e270 | 2085 | create_opm_listener(ip, yy_opm_port_ipv6); |
8275e270 EM |
2086 | } |
2087 | } | |
2088 | ||
51fa2ab8 EM |
2089 | /* If there's no listeners... */ |
2090 | fail = (yy_opm_port_ipv4 == 0 || yy_opm_port_ipv6 == 0); | |
2091 | ||
2092 | end: | |
2093 | RB_DLINK_FOREACH_SAFE(ptr, nptr, yy_opm_scanner_list.head) | |
2094 | { | |
2095 | struct opm_scanner *scanner = ptr->data; | |
2096 | ||
2097 | if(!fail) | |
2098 | create_opm_proxy_scanner(scanner->type, scanner->port); | |
2099 | ||
2100 | rb_dlinkDelete(&scanner->node, &yy_opm_scanner_list); | |
2101 | rb_free(scanner); | |
2102 | } | |
2103 | ||
8275e270 EM |
2104 | rb_free(yy_opm_address_ipv4); |
2105 | rb_free(yy_opm_address_ipv6); | |
2106 | return 0; | |
2107 | } | |
2108 | ||
51fa2ab8 | 2109 | |
8275e270 | 2110 | static void |
51fa2ab8 | 2111 | conf_set_opm_listen_address_both(void *data, bool ipv6) |
8275e270 EM |
2112 | { |
2113 | struct rb_sockaddr_storage addr; | |
51fa2ab8 | 2114 | const char *confstr = (ipv6 ? "opm::listen_ipv6" : "opm::listen_ipv4"); |
8275e270 EM |
2115 | char *ip = data; |
2116 | ||
8275e270 EM |
2117 | if(!rb_inet_pton_sock(ip, (struct sockaddr *)&addr)) |
2118 | { | |
51fa2ab8 | 2119 | conf_report_error("%s is an invalid address: %s", confstr, ip); |
8275e270 EM |
2120 | return; |
2121 | } | |
2122 | ||
51fa2ab8 | 2123 | if(ipv6) |
8275e270 | 2124 | { |
51fa2ab8 EM |
2125 | #ifdef RB_IPV6 |
2126 | if(GET_SS_FAMILY(&addr) != AF_INET6) | |
2127 | { | |
2128 | conf_report_error("%s is of the wrong address type: %s", confstr, ip); | |
2129 | return; | |
2130 | } | |
2131 | ||
2132 | if(yy_opm_address_ipv6 != NULL) | |
2133 | { | |
2134 | conf_report_error("%s overwrites previous address %s", confstr, ip); | |
2135 | return; | |
2136 | } | |
2137 | ||
2138 | yy_opm_address_ipv6 = rb_strdup(ip); | |
2139 | #else | |
2140 | conf_report_error("%s requires IPv6 support in your ircd", confstr, ip); | |
8275e270 | 2141 | return; |
8275e270 | 2142 | #endif |
51fa2ab8 EM |
2143 | } |
2144 | else | |
8275e270 | 2145 | { |
51fa2ab8 EM |
2146 | if(GET_SS_FAMILY(&addr) != AF_INET) |
2147 | { | |
2148 | conf_report_error("%s is of the wrong address type: %s", confstr, ip); | |
2149 | return; | |
2150 | } | |
2151 | ||
2152 | if(yy_opm_address_ipv4 != NULL) | |
2153 | { | |
2154 | conf_report_error("%s overwrites previous address %s", confstr, ip); | |
2155 | return; | |
2156 | } | |
2157 | ||
2158 | yy_opm_address_ipv4 = rb_strdup(ip); | |
8275e270 | 2159 | } |
51fa2ab8 | 2160 | } |
8275e270 | 2161 | |
51fa2ab8 EM |
2162 | static void |
2163 | conf_set_opm_listen_address_ipv4(void *data) | |
2164 | { | |
2165 | conf_set_opm_listen_address_both(data, false); | |
8275e270 EM |
2166 | } |
2167 | ||
2168 | static void | |
2169 | conf_set_opm_listen_address_ipv6(void *data) | |
2170 | { | |
51fa2ab8 EM |
2171 | conf_set_opm_listen_address_both(data, true); |
2172 | } | |
8275e270 | 2173 | |
51fa2ab8 EM |
2174 | static void |
2175 | conf_set_opm_listen_port_both(void *data, bool ipv6) | |
2176 | { | |
2177 | int port = *((int *)data); | |
2178 | const char *confstr = (ipv6 ? "opm::port_ipv6" : "opm::port_ipv4"); | |
8275e270 | 2179 | |
51fa2ab8 EM |
2180 | #ifndef RB_IPV6 |
2181 | if(ipv6) | |
8275e270 | 2182 | { |
51fa2ab8 | 2183 | conf_report_error("%s requires IPv6 support in your ircd", confstr); |
8275e270 EM |
2184 | return; |
2185 | } | |
51fa2ab8 | 2186 | #endif |
8275e270 | 2187 | |
51fa2ab8 | 2188 | if(port > 65535 || port <= 0) |
8275e270 | 2189 | { |
51fa2ab8 | 2190 | conf_report_error("%s is out of range: %d", confstr, port); |
8275e270 EM |
2191 | return; |
2192 | } | |
2193 | ||
51fa2ab8 | 2194 | if(ipv6) |
8275e270 | 2195 | { |
51fa2ab8 EM |
2196 | if(yy_opm_port_ipv4) |
2197 | { | |
2198 | conf_report_error("%s overwrites existing port %hu", | |
2199 | confstr, yy_opm_port_ipv4); | |
2200 | return; | |
2201 | } | |
2202 | ||
2203 | yy_opm_port_ipv4 = port; | |
8275e270 | 2204 | } |
51fa2ab8 EM |
2205 | else |
2206 | { | |
2207 | if(yy_opm_port_ipv6) | |
2208 | { | |
2209 | conf_report_error("%s overwrites existing port %hu", | |
2210 | confstr, yy_opm_port_ipv6); | |
2211 | return; | |
2212 | } | |
8275e270 | 2213 | |
51fa2ab8 EM |
2214 | yy_opm_port_ipv6 = port; |
2215 | } | |
8275e270 EM |
2216 | } |
2217 | ||
2218 | static void | |
2219 | conf_set_opm_listen_port_ipv4(void *data) | |
2220 | { | |
51fa2ab8 | 2221 | conf_set_opm_listen_port_both(data, false); |
8275e270 EM |
2222 | } |
2223 | ||
2224 | static void | |
2225 | conf_set_opm_listen_port_ipv6(void *data) | |
2226 | { | |
51fa2ab8 | 2227 | conf_set_opm_listen_port_both(data, true); |
8275e270 EM |
2228 | } |
2229 | ||
2230 | static void | |
2231 | conf_set_opm_listen_port(void *data) | |
2232 | { | |
51fa2ab8 EM |
2233 | conf_set_opm_listen_port_both(data, true); |
2234 | conf_set_opm_listen_port_both(data, false); | |
2235 | } | |
8275e270 | 2236 | |
51fa2ab8 EM |
2237 | static void |
2238 | conf_set_opm_scan_ports_all(void *data, const char *node, const char *type) | |
2239 | { | |
2240 | conf_parm_t *args = data; | |
2241 | for (; args; args = args->next) | |
8275e270 | 2242 | { |
51fa2ab8 EM |
2243 | rb_dlink_node *ptr; |
2244 | bool dup = false; | |
8275e270 | 2245 | |
51fa2ab8 EM |
2246 | if(CF_TYPE(args->type) != CF_INT) |
2247 | { | |
2248 | conf_report_error("%s argument is not an integer -- ignoring.", node); | |
2249 | continue; | |
2250 | } | |
2251 | ||
2252 | if(args->v.number > 65535 || args->v.number <= 0) | |
2253 | { | |
2254 | conf_report_error("%s argument is not an integer between 1 and 65535 -- ignoring.", node); | |
2255 | continue; | |
2256 | } | |
8275e270 | 2257 | |
51fa2ab8 EM |
2258 | /* Check for duplicates */ |
2259 | RB_DLINK_FOREACH(ptr, yy_opm_scanner_list.head) | |
2260 | { | |
2261 | struct opm_scanner *scanner = ptr->data; | |
2262 | ||
2263 | if(scanner->port == args->v.number && strcmp(type, scanner->type) == 0) | |
2264 | { | |
2265 | conf_report_error("%s argument is duplicate", node); | |
2266 | dup = true; | |
2267 | break; | |
2268 | } | |
2269 | } | |
2270 | ||
2271 | if(!dup) | |
2272 | { | |
2273 | struct opm_scanner *scanner = rb_malloc(sizeof(struct opm_scanner)); | |
2274 | scanner->port = args->v.number; | |
2275 | scanner->type = type; | |
2276 | rb_dlinkAdd(scanner, &scanner->node, &yy_opm_scanner_list); | |
2277 | } | |
8275e270 | 2278 | } |
51fa2ab8 | 2279 | } |
8275e270 | 2280 | |
51fa2ab8 EM |
2281 | static void |
2282 | conf_set_opm_scan_ports_socks4(void *data) | |
2283 | { | |
2284 | conf_set_opm_scan_ports_all(data, "opm::socks4_ports", "socks4"); | |
2285 | } | |
8275e270 | 2286 | |
51fa2ab8 EM |
2287 | static void |
2288 | conf_set_opm_scan_ports_socks5(void *data) | |
2289 | { | |
2290 | conf_set_opm_scan_ports_all(data, "opm::socks5_ports", "socks5"); | |
8275e270 EM |
2291 | } |
2292 | ||
fabe8b94 EM |
2293 | static void |
2294 | conf_set_opm_scan_ports_httpconnect(void *data) | |
2295 | { | |
2296 | conf_set_opm_scan_ports_all(data, "opm::httpconnect_ports", "httpconnect"); | |
2297 | } | |
2298 | ||
212380e3 AC |
2299 | /* public functions */ |
2300 | ||
2301 | ||
2302 | void | |
2303 | conf_report_error(const char *fmt, ...) | |
2304 | { | |
2305 | va_list ap; | |
82236a2a | 2306 | char msg[BUFSIZE + 1] = { 0 }; |
212380e3 AC |
2307 | |
2308 | va_start(ap, fmt); | |
82236a2a | 2309 | vsnprintf(msg, BUFSIZE, fmt, ap); |
212380e3 AC |
2310 | va_end(ap); |
2311 | ||
2312 | if (testing_conf) | |
2313 | { | |
2314 | fprintf(stderr, "\"%s\", line %d: %s\n", current_file, lineno + 1, msg); | |
2315 | return; | |
2316 | } | |
2317 | ||
2318 | ierror("\"%s\", line %d: %s", current_file, lineno + 1, msg); | |
d84acbce AC |
2319 | sendto_realops_snomask(SNO_GENERAL, L_ALL, "error: \"%s\", line %d: %s", current_file, lineno + 1, msg); |
2320 | } | |
2321 | ||
2322 | void | |
2323 | conf_report_warning(const char *fmt, ...) | |
2324 | { | |
2325 | va_list ap; | |
82236a2a | 2326 | char msg[BUFSIZE + 1] = { 0 }; |
d84acbce AC |
2327 | |
2328 | va_start(ap, fmt); | |
82236a2a | 2329 | vsnprintf(msg, BUFSIZE, fmt, ap); |
d84acbce AC |
2330 | va_end(ap); |
2331 | ||
2332 | if (testing_conf) | |
2333 | { | |
2334 | fprintf(stderr, "\"%s\", line %d: %s\n", current_file, lineno + 1, msg); | |
2335 | return; | |
2336 | } | |
2337 | ||
2338 | iwarn("\"%s\", line %d: %s", current_file, lineno + 1, msg); | |
2339 | sendto_realops_snomask(SNO_GENERAL, L_ALL, "warning: \"%s\", line %d: %s", current_file, lineno + 1, msg); | |
212380e3 AC |
2340 | } |
2341 | ||
2342 | int | |
2343 | conf_start_block(char *block, char *name) | |
2344 | { | |
2345 | if((conf_cur_block = find_top_conf(block)) == NULL) | |
2346 | { | |
2347 | conf_report_error("Configuration block '%s' is not defined.", block); | |
2348 | return -1; | |
2349 | } | |
2350 | ||
2351 | if(name) | |
47a03750 | 2352 | conf_cur_block_name = rb_strdup(name); |
212380e3 AC |
2353 | else |
2354 | conf_cur_block_name = NULL; | |
2355 | ||
2356 | if(conf_cur_block->tc_sfunc) | |
2357 | if(conf_cur_block->tc_sfunc(conf_cur_block) < 0) | |
2358 | return -1; | |
2359 | ||
2360 | return 0; | |
2361 | } | |
2362 | ||
2363 | int | |
2364 | conf_end_block(struct TopConf *tc) | |
2365 | { | |
e12981c0 | 2366 | int ret = 0; |
212380e3 | 2367 | if(tc->tc_efunc) |
e12981c0 | 2368 | ret = tc->tc_efunc(tc); |
212380e3 | 2369 | |
637c4932 | 2370 | rb_free(conf_cur_block_name); |
e12981c0 KB |
2371 | conf_cur_block_name = NULL; |
2372 | return ret; | |
212380e3 AC |
2373 | } |
2374 | ||
2375 | static void | |
2376 | conf_set_generic_int(void *data, void *location) | |
2377 | { | |
2378 | *((int *) location) = *((unsigned int *) data); | |
2379 | } | |
2380 | ||
2381 | static void | |
2382 | conf_set_generic_string(void *data, int len, void *location) | |
2383 | { | |
2384 | char **loc = location; | |
2385 | char *input = data; | |
2386 | ||
2e819b6b | 2387 | if(len && strlen(input) > (unsigned int)len) |
212380e3 AC |
2388 | input[len] = '\0'; |
2389 | ||
637c4932 | 2390 | rb_free(*loc); |
47a03750 | 2391 | *loc = rb_strdup(input); |
212380e3 AC |
2392 | } |
2393 | ||
2394 | int | |
dceac3e4 | 2395 | conf_call_set(struct TopConf *tc, char *item, conf_parm_t * value) |
212380e3 AC |
2396 | { |
2397 | struct ConfEntry *cf; | |
2398 | conf_parm_t *cp; | |
2399 | ||
2400 | if(!tc) | |
2401 | return -1; | |
2402 | ||
2403 | if((cf = find_conf_item(tc, item)) == NULL) | |
2404 | { | |
2405 | conf_report_error | |
2406 | ("Non-existant configuration setting %s::%s.", tc->tc_name, (char *) item); | |
2407 | return -1; | |
2408 | } | |
2409 | ||
2410 | /* if it takes one thing, make sure they only passed one thing, | |
2411 | and handle as needed. */ | |
ed45dfe6 | 2412 | if((value->v.list->type & CF_FLIST) && !(cf->cf_type & CF_FLIST)) |
212380e3 AC |
2413 | { |
2414 | conf_report_error | |
2415 | ("Option %s::%s does not take a list of values.", tc->tc_name, item); | |
2416 | return -1; | |
2417 | } | |
2418 | ||
2419 | cp = value->v.list; | |
2420 | ||
2421 | ||
2422 | if(CF_TYPE(value->v.list->type) != CF_TYPE(cf->cf_type)) | |
2423 | { | |
023c36ae | 2424 | /* if it expects a string value, but we got a yesno, |
212380e3 AC |
2425 | * convert it back |
2426 | */ | |
2427 | if((CF_TYPE(value->v.list->type) == CF_YESNO) && | |
2428 | (CF_TYPE(cf->cf_type) == CF_STRING)) | |
2429 | { | |
2430 | value->v.list->type = CF_STRING; | |
2431 | ||
2432 | if(cp->v.number == 1) | |
47a03750 | 2433 | cp->v.string = rb_strdup("yes"); |
212380e3 | 2434 | else |
47a03750 | 2435 | cp->v.string = rb_strdup("no"); |
212380e3 AC |
2436 | } |
2437 | ||
2438 | /* maybe it's a CF_TIME and they passed CF_INT -- | |
2439 | should still be valid */ | |
2440 | else if(!((CF_TYPE(value->v.list->type) == CF_INT) && | |
2441 | (CF_TYPE(cf->cf_type) == CF_TIME))) | |
2442 | { | |
2443 | conf_report_error | |
2444 | ("Wrong type for %s::%s (expected %s, got %s)", | |
2445 | tc->tc_name, (char *) item, | |
2446 | conf_strtype(cf->cf_type), conf_strtype(value->v.list->type)); | |
2447 | return -1; | |
2448 | } | |
2449 | } | |
2450 | ||
2451 | if(cf->cf_type & CF_FLIST) | |
2452 | { | |
2453 | #if 0 | |
2454 | if(cf->cf_arg) | |
2455 | conf_set_generic_list(value->v.list, cf->cf_arg); | |
2456 | else | |
2457 | #endif | |
2458 | /* just pass it the extended argument list */ | |
2459 | cf->cf_func(value->v.list); | |
2460 | } | |
2461 | else | |
2462 | { | |
2463 | /* it's old-style, needs only one arg */ | |
2464 | switch (cf->cf_type) | |
2465 | { | |
2466 | case CF_INT: | |
2467 | case CF_TIME: | |
2468 | case CF_YESNO: | |
2469 | if(cf->cf_arg) | |
2470 | conf_set_generic_int(&cp->v.number, cf->cf_arg); | |
2471 | else | |
2472 | cf->cf_func(&cp->v.number); | |
2473 | break; | |
2474 | case CF_STRING: | |
2475 | case CF_QSTRING: | |
2476 | if(EmptyString(cp->v.string)) | |
2477 | conf_report_error("Ignoring %s::%s -- empty field", | |
2478 | tc->tc_name, item); | |
2479 | else if(cf->cf_arg) | |
2480 | conf_set_generic_string(cp->v.string, cf->cf_len, cf->cf_arg); | |
2481 | else | |
2482 | cf->cf_func(cp->v.string); | |
2483 | break; | |
2484 | } | |
2485 | } | |
2486 | ||
2487 | ||
2488 | return 0; | |
2489 | } | |
2490 | ||
2491 | int | |
2492 | add_conf_item(const char *topconf, const char *name, int type, void (*func) (void *)) | |
2493 | { | |
2494 | struct TopConf *tc; | |
2495 | struct ConfEntry *cf; | |
2496 | ||
2497 | if((tc = find_top_conf(topconf)) == NULL) | |
2498 | return -1; | |
2499 | ||
12edf3e3 | 2500 | if(find_conf_item(tc, name) != NULL) |
212380e3 AC |
2501 | return -1; |
2502 | ||
eddc2ab6 | 2503 | cf = rb_malloc(sizeof(struct ConfEntry)); |
212380e3 | 2504 | |
d7f753cd | 2505 | cf->cf_name = name; |
212380e3 AC |
2506 | cf->cf_type = type; |
2507 | cf->cf_func = func; | |
2508 | cf->cf_arg = NULL; | |
2509 | ||
330fc5c1 | 2510 | rb_dlinkAddAlloc(cf, &tc->tc_items); |
212380e3 AC |
2511 | |
2512 | return 0; | |
2513 | } | |
2514 | ||
2515 | int | |
2516 | remove_conf_item(const char *topconf, const char *name) | |
2517 | { | |
2518 | struct TopConf *tc; | |
2519 | struct ConfEntry *cf; | |
330fc5c1 | 2520 | rb_dlink_node *ptr; |
212380e3 AC |
2521 | |
2522 | if((tc = find_top_conf(topconf)) == NULL) | |
2523 | return -1; | |
2524 | ||
2525 | if((cf = find_conf_item(tc, name)) == NULL) | |
2526 | return -1; | |
2527 | ||
330fc5c1 | 2528 | if((ptr = rb_dlinkFind(cf, &tc->tc_items)) == NULL) |
212380e3 AC |
2529 | return -1; |
2530 | ||
330fc5c1 | 2531 | rb_dlinkDestroy(ptr, &tc->tc_items); |
637c4932 | 2532 | rb_free(cf); |
212380e3 AC |
2533 | |
2534 | return 0; | |
2535 | } | |
2536 | ||
2537 | /* *INDENT-OFF* */ | |
2538 | static struct ConfEntry conf_serverinfo_table[] = | |
2539 | { | |
2540 | { "description", CF_QSTRING, NULL, 0, &ServerInfo.description }, | |
212380e3 AC |
2541 | |
2542 | { "network_name", CF_QSTRING, conf_set_serverinfo_network_name, 0, NULL }, | |
2543 | { "name", CF_QSTRING, conf_set_serverinfo_name, 0, NULL }, | |
2544 | { "sid", CF_QSTRING, conf_set_serverinfo_sid, 0, NULL }, | |
2545 | { "vhost", CF_QSTRING, conf_set_serverinfo_vhost, 0, NULL }, | |
2546 | { "vhost6", CF_QSTRING, conf_set_serverinfo_vhost6, 0, NULL }, | |
2547 | ||
8bd5767b JT |
2548 | { "ssl_private_key", CF_QSTRING, NULL, 0, &ServerInfo.ssl_private_key }, |
2549 | { "ssl_ca_cert", CF_QSTRING, NULL, 0, &ServerInfo.ssl_ca_cert }, | |
023c36ae | 2550 | { "ssl_cert", CF_QSTRING, NULL, 0, &ServerInfo.ssl_cert }, |
8bd5767b | 2551 | { "ssl_dh_params", CF_QSTRING, NULL, 0, &ServerInfo.ssl_dh_params }, |
c1725bda | 2552 | { "ssl_cipher_list", CF_QSTRING, NULL, 0, &ServerInfo.ssl_cipher_list }, |
c6d72037 VY |
2553 | { "ssld_count", CF_INT, NULL, 0, &ServerInfo.ssld_count }, |
2554 | ||
101db4c4 | 2555 | { "default_max_clients",CF_INT, NULL, 0, &ServerInfo.default_max_clients }, |
c2d96fcb | 2556 | |
b583faf9 AC |
2557 | { "nicklen", CF_INT, conf_set_serverinfo_nicklen, 0, NULL }, |
2558 | ||
212380e3 AC |
2559 | { "\0", 0, NULL, 0, NULL } |
2560 | }; | |
2561 | ||
2562 | static struct ConfEntry conf_admin_table[] = | |
2563 | { | |
2564 | { "name", CF_QSTRING, NULL, 200, &AdminInfo.name }, | |
2565 | { "description",CF_QSTRING, NULL, 200, &AdminInfo.description }, | |
2566 | { "email", CF_QSTRING, NULL, 200, &AdminInfo.email }, | |
2567 | { "\0", 0, NULL, 0, NULL } | |
2568 | }; | |
2569 | ||
2570 | static struct ConfEntry conf_log_table[] = | |
2571 | { | |
d74fa5b5 JT |
2572 | { "fname_userlog", CF_QSTRING, NULL, PATH_MAX, &ConfigFileEntry.fname_userlog }, |
2573 | { "fname_fuserlog", CF_QSTRING, NULL, PATH_MAX, &ConfigFileEntry.fname_fuserlog }, | |
2574 | { "fname_operlog", CF_QSTRING, NULL, PATH_MAX, &ConfigFileEntry.fname_operlog }, | |
2575 | { "fname_foperlog", CF_QSTRING, NULL, PATH_MAX, &ConfigFileEntry.fname_foperlog }, | |
2576 | { "fname_serverlog", CF_QSTRING, NULL, PATH_MAX, &ConfigFileEntry.fname_serverlog }, | |
2577 | { "fname_killlog", CF_QSTRING, NULL, PATH_MAX, &ConfigFileEntry.fname_killlog }, | |
2578 | { "fname_klinelog", CF_QSTRING, NULL, PATH_MAX, &ConfigFileEntry.fname_klinelog }, | |
2579 | { "fname_operspylog", CF_QSTRING, NULL, PATH_MAX, &ConfigFileEntry.fname_operspylog }, | |
2580 | { "fname_ioerrorlog", CF_QSTRING, NULL, PATH_MAX, &ConfigFileEntry.fname_ioerrorlog }, | |
212380e3 AC |
2581 | { "\0", 0, NULL, 0, NULL } |
2582 | }; | |
2583 | ||
2584 | static struct ConfEntry conf_operator_table[] = | |
2585 | { | |
2586 | { "rsa_public_key_file", CF_QSTRING, conf_set_oper_rsa_public_key_file, 0, NULL }, | |
2587 | { "flags", CF_STRING | CF_FLIST, conf_set_oper_flags, 0, NULL }, | |
2588 | { "umodes", CF_STRING | CF_FLIST, conf_set_oper_umodes, 0, NULL }, | |
22c3b270 | 2589 | { "privset", CF_QSTRING, conf_set_oper_privset, 0, NULL }, |
212380e3 AC |
2590 | { "snomask", CF_QSTRING, conf_set_oper_snomask, 0, NULL }, |
2591 | { "user", CF_QSTRING, conf_set_oper_user, 0, NULL }, | |
2592 | { "password", CF_QSTRING, conf_set_oper_password, 0, NULL }, | |
ff31db84 | 2593 | { "fingerprint", CF_QSTRING, conf_set_oper_fingerprint, 0, NULL }, |
212380e3 AC |
2594 | { "\0", 0, NULL, 0, NULL } |
2595 | }; | |
2596 | ||
f8606875 AC |
2597 | static struct ConfEntry conf_privset_table[] = |
2598 | { | |
2599 | { "extends", CF_QSTRING, conf_set_privset_extends, 0, NULL }, | |
2600 | { "privs", CF_STRING | CF_FLIST, conf_set_privset_privs, 0, NULL }, | |
2601 | { "\0", 0, NULL, 0, NULL } | |
2602 | }; | |
2603 | ||
212380e3 AC |
2604 | static struct ConfEntry conf_class_table[] = |
2605 | { | |
2606 | { "ping_time", CF_TIME, conf_set_class_ping_time, 0, NULL }, | |
e33e589c JT |
2607 | { "cidr_ipv4_bitlen", CF_INT, conf_set_class_cidr_ipv4_bitlen, 0, NULL }, |
2608 | #ifdef RB_IPV6 | |
2609 | { "cidr_ipv6_bitlen", CF_INT, conf_set_class_cidr_ipv6_bitlen, 0, NULL }, | |
2610 | #endif | |
212380e3 AC |
2611 | { "number_per_cidr", CF_INT, conf_set_class_number_per_cidr, 0, NULL }, |
2612 | { "number_per_ip", CF_INT, conf_set_class_number_per_ip, 0, NULL }, | |
2613 | { "number_per_ip_global", CF_INT,conf_set_class_number_per_ip_global, 0, NULL }, | |
2614 | { "number_per_ident", CF_INT, conf_set_class_number_per_ident, 0, NULL }, | |
2615 | { "connectfreq", CF_TIME, conf_set_class_connectfreq, 0, NULL }, | |
2616 | { "max_number", CF_INT, conf_set_class_max_number, 0, NULL }, | |
2617 | { "sendq", CF_TIME, conf_set_class_sendq, 0, NULL }, | |
2618 | { "\0", 0, NULL, 0, NULL } | |
2619 | }; | |
2620 | ||
2621 | static struct ConfEntry conf_auth_table[] = | |
2622 | { | |
2623 | { "user", CF_QSTRING, conf_set_auth_user, 0, NULL }, | |
40c1fd47 | 2624 | { "auth_user", CF_QSTRING, conf_set_auth_auth_user, 0, NULL }, |
212380e3 AC |
2625 | { "password", CF_QSTRING, conf_set_auth_passwd, 0, NULL }, |
2626 | { "class", CF_QSTRING, conf_set_auth_class, 0, NULL }, | |
2627 | { "spoof", CF_QSTRING, conf_set_auth_spoof, 0, NULL }, | |
2628 | { "redirserv", CF_QSTRING, conf_set_auth_redir_serv, 0, NULL }, | |
2629 | { "redirport", CF_INT, conf_set_auth_redir_port, 0, NULL }, | |
2630 | { "flags", CF_STRING | CF_FLIST, conf_set_auth_flags, 0, NULL }, | |
2631 | { "\0", 0, NULL, 0, NULL } | |
2632 | }; | |
2633 | ||
2634 | static struct ConfEntry conf_connect_table[] = | |
2635 | { | |
2636 | { "send_password", CF_QSTRING, conf_set_connect_send_password, 0, NULL }, | |
2637 | { "accept_password", CF_QSTRING, conf_set_connect_accept_password, 0, NULL }, | |
ff0cc1e6 | 2638 | { "fingerprint", CF_QSTRING, conf_set_connect_fingerprint, 0, NULL }, |
212380e3 AC |
2639 | { "flags", CF_STRING | CF_FLIST, conf_set_connect_flags, 0, NULL }, |
2640 | { "host", CF_QSTRING, conf_set_connect_host, 0, NULL }, | |
2641 | { "vhost", CF_QSTRING, conf_set_connect_vhost, 0, NULL }, | |
2642 | { "port", CF_INT, conf_set_connect_port, 0, NULL }, | |
2643 | { "aftype", CF_STRING, conf_set_connect_aftype, 0, NULL }, | |
2644 | { "hub_mask", CF_QSTRING, conf_set_connect_hub_mask, 0, NULL }, | |
2645 | { "leaf_mask", CF_QSTRING, conf_set_connect_leaf_mask, 0, NULL }, | |
2646 | { "class", CF_QSTRING, conf_set_connect_class, 0, NULL }, | |
2647 | { "\0", 0, NULL, 0, NULL } | |
2648 | }; | |
2649 | ||
2650 | static struct ConfEntry conf_general_table[] = | |
2651 | { | |
2652 | { "oper_only_umodes", CF_STRING | CF_FLIST, conf_set_general_oper_only_umodes, 0, NULL }, | |
2653 | { "oper_umodes", CF_STRING | CF_FLIST, conf_set_general_oper_umodes, 0, NULL }, | |
2654 | { "oper_snomask", CF_QSTRING, conf_set_general_oper_snomask, 0, NULL }, | |
2655 | { "compression_level", CF_INT, conf_set_general_compression_level, 0, NULL }, | |
2656 | { "havent_read_conf", CF_YESNO, conf_set_general_havent_read_conf, 0, NULL }, | |
2657 | { "hide_error_messages",CF_STRING, conf_set_general_hide_error_messages,0, NULL }, | |
2658 | { "kline_delay", CF_TIME, conf_set_general_kline_delay, 0, NULL }, | |
2659 | { "stats_k_oper_only", CF_STRING, conf_set_general_stats_k_oper_only, 0, NULL }, | |
2660 | { "stats_i_oper_only", CF_STRING, conf_set_general_stats_i_oper_only, 0, NULL }, | |
2661 | { "default_umodes", CF_QSTRING, conf_set_general_default_umodes, 0, NULL }, | |
2662 | ||
2663 | { "default_operstring", CF_QSTRING, NULL, REALLEN, &ConfigFileEntry.default_operstring }, | |
2664 | { "default_adminstring",CF_QSTRING, NULL, REALLEN, &ConfigFileEntry.default_adminstring }, | |
2665 | { "servicestring", CF_QSTRING, NULL, REALLEN, &ConfigFileEntry.servicestring }, | |
212380e3 AC |
2666 | { "kline_reason", CF_QSTRING, NULL, REALLEN, &ConfigFileEntry.kline_reason }, |
2667 | { "identify_service", CF_QSTRING, NULL, REALLEN, &ConfigFileEntry.identifyservice }, | |
2668 | { "identify_command", CF_QSTRING, NULL, REALLEN, &ConfigFileEntry.identifycommand }, | |
7d33cce8 | 2669 | { "sasl_service", CF_QSTRING, NULL, REALLEN, &ConfigFileEntry.sasl_service }, |
212380e3 AC |
2670 | |
2671 | { "anti_spam_exit_message_time", CF_TIME, NULL, 0, &ConfigFileEntry.anti_spam_exit_message_time }, | |
2672 | { "disable_fake_channels", CF_YESNO, NULL, 0, &ConfigFileEntry.disable_fake_channels }, | |
2673 | { "min_nonwildcard_simple", CF_INT, NULL, 0, &ConfigFileEntry.min_nonwildcard_simple }, | |
2674 | { "non_redundant_klines", CF_YESNO, NULL, 0, &ConfigFileEntry.non_redundant_klines }, | |
2675 | { "tkline_expire_notices", CF_YESNO, NULL, 0, &ConfigFileEntry.tkline_expire_notices }, | |
2676 | ||
2677 | { "anti_nick_flood", CF_YESNO, NULL, 0, &ConfigFileEntry.anti_nick_flood }, | |
2678 | { "burst_away", CF_YESNO, NULL, 0, &ConfigFileEntry.burst_away }, | |
2679 | { "caller_id_wait", CF_TIME, NULL, 0, &ConfigFileEntry.caller_id_wait }, | |
2680 | { "client_exit", CF_YESNO, NULL, 0, &ConfigFileEntry.client_exit }, | |
212380e3 | 2681 | { "collision_fnc", CF_YESNO, NULL, 0, &ConfigFileEntry.collision_fnc }, |
330692a1 | 2682 | { "resv_fnc", CF_YESNO, NULL, 0, &ConfigFileEntry.resv_fnc }, |
212380e3 AC |
2683 | { "connect_timeout", CF_TIME, NULL, 0, &ConfigFileEntry.connect_timeout }, |
2684 | { "default_floodcount", CF_INT, NULL, 0, &ConfigFileEntry.default_floodcount }, | |
944b0584 | 2685 | { "default_ident_timeout", CF_INT, NULL, 0, &ConfigFileEntry.default_ident_timeout }, |
212380e3 | 2686 | { "disable_auth", CF_YESNO, NULL, 0, &ConfigFileEntry.disable_auth }, |
212380e3 AC |
2687 | { "dots_in_ident", CF_INT, NULL, 0, &ConfigFileEntry.dots_in_ident }, |
2688 | { "failed_oper_notice", CF_YESNO, NULL, 0, &ConfigFileEntry.failed_oper_notice }, | |
212380e3 | 2689 | { "global_snotices", CF_YESNO, NULL, 0, &ConfigFileEntry.global_snotices }, |
212380e3 AC |
2690 | { "hide_spoof_ips", CF_YESNO, NULL, 0, &ConfigFileEntry.hide_spoof_ips }, |
2691 | { "dline_with_reason", CF_YESNO, NULL, 0, &ConfigFileEntry.dline_with_reason }, | |
2692 | { "kline_with_reason", CF_YESNO, NULL, 0, &ConfigFileEntry.kline_with_reason }, | |
2693 | { "map_oper_only", CF_YESNO, NULL, 0, &ConfigFileEntry.map_oper_only }, | |
2694 | { "max_accept", CF_INT, NULL, 0, &ConfigFileEntry.max_accept }, | |
2695 | { "max_monitor", CF_INT, NULL, 0, &ConfigFileEntry.max_monitor }, | |
2696 | { "max_nick_time", CF_TIME, NULL, 0, &ConfigFileEntry.max_nick_time }, | |
2697 | { "max_nick_changes", CF_INT, NULL, 0, &ConfigFileEntry.max_nick_changes }, | |
2698 | { "max_targets", CF_INT, NULL, 0, &ConfigFileEntry.max_targets }, | |
2699 | { "min_nonwildcard", CF_INT, NULL, 0, &ConfigFileEntry.min_nonwildcard }, | |
2700 | { "nick_delay", CF_TIME, NULL, 0, &ConfigFileEntry.nick_delay }, | |
2701 | { "no_oper_flood", CF_YESNO, NULL, 0, &ConfigFileEntry.no_oper_flood }, | |
2702 | { "operspy_admin_only", CF_YESNO, NULL, 0, &ConfigFileEntry.operspy_admin_only }, | |
2703 | { "operspy_dont_care_user_info", CF_YESNO, NULL, 0, &ConfigFileEntry.operspy_dont_care_user_info }, | |
2704 | { "pace_wait", CF_TIME, NULL, 0, &ConfigFileEntry.pace_wait }, | |
2705 | { "pace_wait_simple", CF_TIME, NULL, 0, &ConfigFileEntry.pace_wait_simple }, | |
2706 | { "ping_cookie", CF_YESNO, NULL, 0, &ConfigFileEntry.ping_cookie }, | |
2707 | { "reject_after_count", CF_INT, NULL, 0, &ConfigFileEntry.reject_after_count }, | |
2708 | { "reject_ban_time", CF_TIME, NULL, 0, &ConfigFileEntry.reject_ban_time }, | |
2709 | { "reject_duration", CF_TIME, NULL, 0, &ConfigFileEntry.reject_duration }, | |
43946961 JT |
2710 | { "throttle_count", CF_INT, NULL, 0, &ConfigFileEntry.throttle_count }, |
2711 | { "throttle_duration", CF_TIME, NULL, 0, &ConfigFileEntry.throttle_duration }, | |
212380e3 AC |
2712 | { "short_motd", CF_YESNO, NULL, 0, &ConfigFileEntry.short_motd }, |
2713 | { "stats_c_oper_only", CF_YESNO, NULL, 0, &ConfigFileEntry.stats_c_oper_only }, | |
2714 | { "stats_e_disabled", CF_YESNO, NULL, 0, &ConfigFileEntry.stats_e_disabled }, | |
2715 | { "stats_h_oper_only", CF_YESNO, NULL, 0, &ConfigFileEntry.stats_h_oper_only }, | |
2716 | { "stats_o_oper_only", CF_YESNO, NULL, 0, &ConfigFileEntry.stats_o_oper_only }, | |
2717 | { "stats_P_oper_only", CF_YESNO, NULL, 0, &ConfigFileEntry.stats_P_oper_only }, | |
2718 | { "stats_y_oper_only", CF_YESNO, NULL, 0, &ConfigFileEntry.stats_y_oper_only }, | |
2719 | { "target_change", CF_YESNO, NULL, 0, &ConfigFileEntry.target_change }, | |
2720 | { "ts_max_delta", CF_TIME, NULL, 0, &ConfigFileEntry.ts_max_delta }, | |
212380e3 AC |
2721 | { "ts_warn_delta", CF_TIME, NULL, 0, &ConfigFileEntry.ts_warn_delta }, |
2722 | { "use_whois_actually", CF_YESNO, NULL, 0, &ConfigFileEntry.use_whois_actually }, | |
2723 | { "warn_no_nline", CF_YESNO, NULL, 0, &ConfigFileEntry.warn_no_nline }, | |
1702b694 | 2724 | { "use_propagated_bans",CF_YESNO, NULL, 0, &ConfigFileEntry.use_propagated_bans }, |
e6e54763 SB |
2725 | { "client_flood_max_lines", CF_INT, NULL, 0, &ConfigFileEntry.client_flood_max_lines }, |
2726 | { "client_flood_burst_rate", CF_INT, NULL, 0, &ConfigFileEntry.client_flood_burst_rate }, | |
2727 | { "client_flood_burst_max", CF_INT, NULL, 0, &ConfigFileEntry.client_flood_burst_max }, | |
2728 | { "client_flood_message_num", CF_INT, NULL, 0, &ConfigFileEntry.client_flood_message_num }, | |
2729 | { "client_flood_message_time", CF_INT, NULL, 0, &ConfigFileEntry.client_flood_message_time }, | |
e88a1f1b | 2730 | { "max_ratelimit_tokens", CF_INT, NULL, 0, &ConfigFileEntry.max_ratelimit_tokens }, |
d42e6915 | 2731 | { "away_interval", CF_INT, NULL, 0, &ConfigFileEntry.away_interval }, |
71c95533 | 2732 | { "hide_opers_in_whois", CF_YESNO, NULL, 0, &ConfigFileEntry.hide_opers_in_whois }, |
13d8f0ed | 2733 | { "certfp_method", CF_STRING, conf_set_general_certfp_method, 0, NULL }, |
212380e3 AC |
2734 | { "\0", 0, NULL, 0, NULL } |
2735 | }; | |
2736 | ||
2737 | static struct ConfEntry conf_channel_table[] = | |
2738 | { | |
2739 | { "default_split_user_count", CF_INT, NULL, 0, &ConfigChannel.default_split_user_count }, | |
2740 | { "default_split_server_count", CF_INT, NULL, 0, &ConfigChannel.default_split_server_count }, | |
2741 | { "burst_topicwho", CF_YESNO, NULL, 0, &ConfigChannel.burst_topicwho }, | |
212380e3 AC |
2742 | { "kick_on_split_riding", CF_YESNO, NULL, 0, &ConfigChannel.kick_on_split_riding }, |
2743 | { "knock_delay", CF_TIME, NULL, 0, &ConfigChannel.knock_delay }, | |
2744 | { "knock_delay_channel",CF_TIME, NULL, 0, &ConfigChannel.knock_delay_channel }, | |
2745 | { "max_bans", CF_INT, NULL, 0, &ConfigChannel.max_bans }, | |
2746 | { "max_bans_large", CF_INT, NULL, 0, &ConfigChannel.max_bans_large }, | |
2747 | { "max_chans_per_user", CF_INT, NULL, 0, &ConfigChannel.max_chans_per_user }, | |
a4721f5e | 2748 | { "max_chans_per_user_large", CF_INT, NULL, 0, &ConfigChannel.max_chans_per_user_large }, |
212380e3 AC |
2749 | { "no_create_on_split", CF_YESNO, NULL, 0, &ConfigChannel.no_create_on_split }, |
2750 | { "no_join_on_split", CF_YESNO, NULL, 0, &ConfigChannel.no_join_on_split }, | |
6865c0b0 | 2751 | { "only_ascii_channels", CF_YESNO, NULL, 0, &ConfigChannel.only_ascii_channels }, |
212380e3 AC |
2752 | { "use_except", CF_YESNO, NULL, 0, &ConfigChannel.use_except }, |
2753 | { "use_invex", CF_YESNO, NULL, 0, &ConfigChannel.use_invex }, | |
2da6f6eb | 2754 | { "use_forward", CF_YESNO, NULL, 0, &ConfigChannel.use_forward }, |
212380e3 | 2755 | { "use_knock", CF_YESNO, NULL, 0, &ConfigChannel.use_knock }, |
c2c25552 | 2756 | { "resv_forcepart", CF_YESNO, NULL, 0, &ConfigChannel.resv_forcepart }, |
717238d2 | 2757 | { "channel_target_change", CF_YESNO, NULL, 0, &ConfigChannel.channel_target_change }, |
341f971e | 2758 | { "disable_local_channels", CF_YESNO, NULL, 0, &ConfigChannel.disable_local_channels }, |
63eb8567 | 2759 | { "autochanmodes", CF_QSTRING, conf_set_channel_autochanmodes, 0, NULL }, |
d513218a | 2760 | { "displayed_usercount", CF_INT, NULL, 0, &ConfigChannel.displayed_usercount }, |
14482679 | 2761 | { "strip_topic_colors", CF_YESNO, NULL, 0, &ConfigChannel.strip_topic_colors }, |
212380e3 AC |
2762 | { "\0", 0, NULL, 0, NULL } |
2763 | }; | |
2764 | ||
2765 | static struct ConfEntry conf_serverhide_table[] = | |
2766 | { | |
2767 | { "disable_hidden", CF_YESNO, NULL, 0, &ConfigServerHide.disable_hidden }, | |
2768 | { "flatten_links", CF_YESNO, NULL, 0, &ConfigServerHide.flatten_links }, | |
2769 | { "hidden", CF_YESNO, NULL, 0, &ConfigServerHide.hidden }, | |
2770 | { "links_delay", CF_TIME, conf_set_serverhide_links_delay, 0, NULL }, | |
2771 | { "\0", 0, NULL, 0, NULL } | |
2772 | }; | |
2773 | /* *INDENT-ON* */ | |
2774 | ||
2775 | void | |
2776 | newconf_init() | |
2777 | { | |
2778 | add_top_conf("modules", NULL, NULL, NULL); | |
2779 | add_conf_item("modules", "path", CF_QSTRING, conf_set_modules_path); | |
2780 | add_conf_item("modules", "module", CF_QSTRING, conf_set_modules_module); | |
2781 | ||
2782 | add_top_conf("serverinfo", NULL, NULL, conf_serverinfo_table); | |
2783 | add_top_conf("admin", NULL, NULL, conf_admin_table); | |
2784 | add_top_conf("log", NULL, NULL, conf_log_table); | |
2785 | add_top_conf("operator", conf_begin_oper, conf_end_oper, conf_operator_table); | |
2786 | add_top_conf("class", conf_begin_class, conf_end_class, conf_class_table); | |
f8606875 | 2787 | add_top_conf("privset", NULL, NULL, conf_privset_table); |
212380e3 AC |
2788 | |
2789 | add_top_conf("listen", conf_begin_listen, conf_end_listen, NULL); | |
02270e96 | 2790 | add_conf_item("listen", "defer_accept", CF_YESNO, conf_set_listen_defer_accept); |
c53ca1e0 | 2791 | add_conf_item("listen", "wsock", CF_YESNO, conf_set_listen_wsock); |
212380e3 | 2792 | add_conf_item("listen", "port", CF_INT | CF_FLIST, conf_set_listen_port); |
c6d72037 | 2793 | add_conf_item("listen", "sslport", CF_INT | CF_FLIST, conf_set_listen_sslport); |
212380e3 AC |
2794 | add_conf_item("listen", "ip", CF_QSTRING, conf_set_listen_address); |
2795 | add_conf_item("listen", "host", CF_QSTRING, conf_set_listen_address); | |
2796 | ||
2797 | add_top_conf("auth", conf_begin_auth, conf_end_auth, conf_auth_table); | |
2798 | ||
2799 | add_top_conf("shared", conf_cleanup_shared, conf_cleanup_shared, NULL); | |
dceac3e4 | 2800 | add_conf_item("shared", "oper", CF_QSTRING | CF_FLIST, conf_set_shared_oper); |
212380e3 AC |
2801 | add_conf_item("shared", "flags", CF_STRING | CF_FLIST, conf_set_shared_flags); |
2802 | ||
2803 | add_top_conf("connect", conf_begin_connect, conf_end_connect, conf_connect_table); | |
2804 | ||
2805 | add_top_conf("exempt", NULL, NULL, NULL); | |
2806 | add_conf_item("exempt", "ip", CF_QSTRING, conf_set_exempt_ip); | |
2807 | ||
2808 | add_top_conf("cluster", conf_cleanup_cluster, conf_cleanup_cluster, NULL); | |
2809 | add_conf_item("cluster", "name", CF_QSTRING, conf_set_cluster_name); | |
2810 | add_conf_item("cluster", "flags", CF_STRING | CF_FLIST, conf_set_cluster_flags); | |
2811 | ||
2812 | add_top_conf("general", NULL, NULL, conf_general_table); | |
2813 | add_top_conf("channel", NULL, NULL, conf_channel_table); | |
2814 | add_top_conf("serverhide", NULL, NULL, conf_serverhide_table); | |
2815 | ||
c46a4ecd | 2816 | add_top_conf("service", NULL, NULL, NULL); |
212380e3 AC |
2817 | add_conf_item("service", "name", CF_QSTRING, conf_set_service_name); |
2818 | ||
2819 | add_top_conf("alias", conf_begin_alias, conf_end_alias, NULL); | |
2820 | add_conf_item("alias", "name", CF_QSTRING, conf_set_alias_name); | |
2821 | add_conf_item("alias", "target", CF_QSTRING, conf_set_alias_target); | |
2822 | ||
2823 | add_top_conf("blacklist", NULL, NULL, NULL); | |
2824 | add_conf_item("blacklist", "host", CF_QSTRING, conf_set_blacklist_host); | |
0a1e77c2 | 2825 | add_conf_item("blacklist", "type", CF_STRING | CF_FLIST, conf_set_blacklist_type); |
3c93d380 | 2826 | add_conf_item("blacklist", "matches", CF_QSTRING | CF_FLIST, conf_set_blacklist_matches); |
212380e3 | 2827 | add_conf_item("blacklist", "reject_reason", CF_QSTRING, conf_set_blacklist_reason); |
8275e270 EM |
2828 | |
2829 | add_top_conf("opm", conf_begin_opm, conf_end_opm, NULL); | |
2830 | add_conf_item("opm", "listen_ipv4", CF_QSTRING, conf_set_opm_listen_address_ipv4); | |
8275e270 | 2831 | add_conf_item("opm", "listen_ipv6", CF_QSTRING, conf_set_opm_listen_address_ipv6); |
51fa2ab8 | 2832 | add_conf_item("opm", "port_v4", CF_INT, conf_set_opm_listen_port_ipv4); |
8275e270 EM |
2833 | add_conf_item("opm", "port_v6", CF_INT, conf_set_opm_listen_port_ipv6); |
2834 | add_conf_item("opm", "listen_port", CF_INT, conf_set_opm_listen_port); | |
51fa2ab8 EM |
2835 | add_conf_item("opm", "socks4_ports", CF_INT | CF_FLIST, conf_set_opm_scan_ports_socks4); |
2836 | add_conf_item("opm", "socks5_ports", CF_INT | CF_FLIST, conf_set_opm_scan_ports_socks5); | |
fabe8b94 | 2837 | add_conf_item("opm", "httpconnect_ports", CF_INT | CF_FLIST, conf_set_opm_scan_ports_httpconnect); |
212380e3 | 2838 | } |