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