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