| 53 |
|
#include "memory.h" |
| 54 |
|
#include "mempool.h" |
| 55 |
|
#include "ircd_getopt.h" |
| 56 |
– |
#include "supported.h" |
| 56 |
|
#include "watch.h" |
| 57 |
|
#include "conf_db.h" |
| 58 |
|
#include "conf_class.h" |
| 62 |
|
GeoIP *geoip_ctx; |
| 63 |
|
#endif |
| 64 |
|
|
| 66 |
– |
/* /quote set variables */ |
| 67 |
– |
struct SetOptions GlobalSetOptions; |
| 68 |
– |
struct Counter Count; |
| 69 |
– |
struct ServerState_t server_state; |
| 65 |
|
struct ServerStatistics ServerStats; |
| 66 |
|
struct timeval SystemTime; |
| 67 |
|
struct Client me; /* That's me */ |
| 84 |
|
unsigned int split_users; |
| 85 |
|
unsigned int split_servers; |
| 86 |
|
|
| 87 |
< |
/* Do klines the same way hybrid-6 did them, i.e. at the |
| 88 |
< |
* top of the next io_loop instead of in the same loop as |
| 89 |
< |
* the klines are being applied. |
| 90 |
< |
* |
| 91 |
< |
* This should fix strange CPU starvation as very indirectly reported. |
| 92 |
< |
* (Why do you people not email bug reports? WHY? WHY?) |
| 98 |
< |
* |
| 99 |
< |
* - Dianora |
| 100 |
< |
*/ |
| 87 |
> |
static struct event event_cleanup_glines = |
| 88 |
> |
{ |
| 89 |
> |
.name = "cleanup_glines", |
| 90 |
> |
.handler = cleanup_glines, |
| 91 |
> |
.when = CLEANUP_GLINES_TIME |
| 92 |
> |
}; |
| 93 |
|
|
| 94 |
< |
int rehashed_klines = 0; |
| 94 |
> |
static struct event event_cleanup_tklines = |
| 95 |
> |
{ |
| 96 |
> |
.name = "cleanup_tklines", |
| 97 |
> |
.handler = cleanup_tklines, |
| 98 |
> |
.when = CLEANUP_TKLINES_TIME |
| 99 |
> |
}; |
| 100 |
> |
|
| 101 |
> |
static struct event event_try_connections = |
| 102 |
> |
{ |
| 103 |
> |
.name = "try_connections", |
| 104 |
> |
.handler = try_connections, |
| 105 |
> |
.when = STARTUP_CONNECTIONS_TIME |
| 106 |
> |
}; |
| 107 |
> |
|
| 108 |
> |
static struct event event_comm_checktimeouts = |
| 109 |
> |
{ |
| 110 |
> |
.name = "comm_checktimeouts", |
| 111 |
> |
.handler = comm_checktimeouts, |
| 112 |
> |
.when = 1 |
| 113 |
> |
}; |
| 114 |
> |
|
| 115 |
> |
static struct event event_save_all_databases = |
| 116 |
> |
{ |
| 117 |
> |
.name = "save_all_databases", |
| 118 |
> |
.handler = save_all_databases, |
| 119 |
> |
.when = DATABASE_UPDATE_TIMEOUT |
| 120 |
> |
}; |
| 121 |
> |
|
| 122 |
> |
struct event event_write_links_file = |
| 123 |
> |
{ |
| 124 |
> |
.name = "write_links_file", |
| 125 |
> |
.handler = write_links_file, |
| 126 |
> |
}; |
| 127 |
|
|
| 128 |
|
|
| 129 |
|
/* |
| 220 |
|
{ |
| 221 |
|
while (1) |
| 222 |
|
{ |
| 199 |
– |
/* |
| 200 |
– |
* Maybe we want a flags word? |
| 201 |
– |
* ie. if (REHASHED_KLINES(global_flags)) |
| 202 |
– |
* SET_REHASHED_KLINES(global_flags) |
| 203 |
– |
* CLEAR_REHASHED_KLINES(global_flags) |
| 204 |
– |
* |
| 205 |
– |
* - Dianora |
| 206 |
– |
*/ |
| 207 |
– |
if (rehashed_klines) |
| 208 |
– |
{ |
| 209 |
– |
check_conf_klines(); |
| 210 |
– |
rehashed_klines = 0; |
| 211 |
– |
} |
| 212 |
– |
|
| 223 |
|
if (listing_client_list.head) |
| 224 |
|
{ |
| 225 |
|
dlink_node *ptr = NULL, *ptr_next = NULL; |
| 227 |
|
safe_list_channels(ptr->data, 0); |
| 228 |
|
} |
| 229 |
|
|
| 230 |
< |
/* Run pending events, then get the number of seconds to the next |
| 231 |
< |
* event |
| 222 |
< |
*/ |
| 223 |
< |
while (eventNextTime() <= CurrentTime) |
| 224 |
< |
eventRun(); |
| 230 |
> |
/* Run pending events */ |
| 231 |
> |
event_run(); |
| 232 |
|
|
| 233 |
|
comm_select(); |
| 234 |
|
exit_aborted_clients(); |
| 427 |
|
|
| 428 |
|
if ((ServerInfo.server_ctx = SSL_CTX_new(SSLv23_server_method())) == NULL) |
| 429 |
|
{ |
| 430 |
< |
const char *s; |
| 430 |
> |
const char *s = ERR_lib_error_string(ERR_get_error()); |
| 431 |
|
|
| 432 |
< |
fprintf(stderr, "ERROR: Could not initialize the SSL Server context -- %s\n", |
| 426 |
< |
s = ERR_lib_error_string(ERR_get_error())); |
| 432 |
> |
fprintf(stderr, "ERROR: Could not initialize the SSL Server context -- %s\n", s); |
| 433 |
|
ilog(LOG_TYPE_IRCD, "ERROR: Could not initialize the SSL Server context -- %s\n", s); |
| 434 |
|
} |
| 435 |
|
|
| 436 |
|
SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_TLSv1); |
| 437 |
< |
SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_TLS_ROLLBACK_BUG|SSL_OP_ALL); |
| 437 |
> |
SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_SINGLE_DH_USE); |
| 438 |
|
SSL_CTX_set_verify(ServerInfo.server_ctx, SSL_VERIFY_PEER|SSL_VERIFY_CLIENT_ONCE, |
| 439 |
|
always_accept_verify_cb); |
| 440 |
|
SSL_CTX_set_session_id_context(ServerInfo.server_ctx, session_id, sizeof(session_id) - 1); |
| 441 |
|
|
| 442 |
+ |
#if OPENSSL_VERSION_NUMBER >= 0x1000005FL && !defined(OPENSSL_NO_ECDH) |
| 443 |
+ |
{ |
| 444 |
+ |
EC_KEY *key = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1); |
| 445 |
+ |
|
| 446 |
+ |
if (key) |
| 447 |
+ |
{ |
| 448 |
+ |
SSL_CTX_set_tmp_ecdh(ServerInfo.server_ctx, key); |
| 449 |
+ |
EC_KEY_free(key); |
| 450 |
+ |
} |
| 451 |
+ |
} |
| 452 |
+ |
|
| 453 |
+ |
SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_SINGLE_ECDH_USE); |
| 454 |
+ |
#endif |
| 455 |
+ |
|
| 456 |
|
if ((ServerInfo.client_ctx = SSL_CTX_new(SSLv23_client_method())) == NULL) |
| 457 |
|
{ |
| 458 |
< |
const char *s; |
| 458 |
> |
const char *s = ERR_lib_error_string(ERR_get_error()); |
| 459 |
|
|
| 460 |
< |
fprintf(stderr, "ERROR: Could not initialize the SSL Client context -- %s\n", |
| 441 |
< |
s = ERR_lib_error_string(ERR_get_error())); |
| 460 |
> |
fprintf(stderr, "ERROR: Could not initialize the SSL Client context -- %s\n", s); |
| 461 |
|
ilog(LOG_TYPE_IRCD, "ERROR: Could not initialize the SSL Client context -- %s\n", s); |
| 462 |
|
} |
| 463 |
|
|
| 464 |
|
SSL_CTX_set_options(ServerInfo.client_ctx, SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_TLSv1); |
| 465 |
< |
SSL_CTX_set_options(ServerInfo.client_ctx, SSL_OP_TLS_ROLLBACK_BUG|SSL_OP_ALL); |
| 465 |
> |
SSL_CTX_set_options(ServerInfo.client_ctx, SSL_OP_SINGLE_DH_USE); |
| 466 |
|
SSL_CTX_set_verify(ServerInfo.client_ctx, SSL_VERIFY_PEER|SSL_VERIFY_CLIENT_ONCE, |
| 467 |
|
always_accept_verify_cb); |
| 468 |
|
#endif /* HAVE_LIBCRYPTO */ |
| 490 |
|
me.localClient = &meLocalUser; |
| 491 |
|
dlinkAdd(&me, &me.node, &global_client_list); /* Pointer to beginning |
| 492 |
|
of Client list */ |
| 493 |
+ |
ConfigLoggingEntry.use_logging = 1; |
| 494 |
|
ConfigFileEntry.dpath = DPATH; |
| 495 |
|
ConfigFileEntry.spath = SPATH; |
| 496 |
|
ConfigFileEntry.mpath = MPATH; |
| 530 |
|
|
| 531 |
|
setup_signals(); |
| 532 |
|
|
| 513 |
– |
/* Init the event subsystem */ |
| 514 |
– |
eventInit(); |
| 515 |
– |
|
| 533 |
|
/* We need this to initialise the fd array before anything else */ |
| 534 |
|
fdlist_init(); |
| 535 |
|
log_set_file(LOG_TYPE_IRCD, 0, logFileName); |
| 637 |
|
|
| 638 |
|
ilog(LOG_TYPE_IRCD, "Server Ready"); |
| 639 |
|
|
| 640 |
< |
eventAddIsh("cleanup_glines", cleanup_glines, NULL, CLEANUP_GLINES_TIME); |
| 641 |
< |
eventAddIsh("cleanup_tklines", cleanup_tklines, NULL, CLEANUP_TKLINES_TIME); |
| 640 |
> |
event_addish(&event_cleanup_glines, NULL); |
| 641 |
> |
event_addish(&event_cleanup_tklines, NULL); |
| 642 |
|
|
| 643 |
|
/* We want try_connections to be called as soon as possible now! -- adrian */ |
| 644 |
|
/* No, 'cause after a restart it would cause all sorts of nick collides */ |
| 645 |
< |
eventAddIsh("try_connections", try_connections, NULL, STARTUP_CONNECTIONS_TIME); |
| 645 |
> |
event_addish(&event_try_connections, NULL); |
| 646 |
|
|
| 647 |
|
/* Setup the timeout check. I'll shift it later :) -- adrian */ |
| 648 |
< |
eventAddIsh("comm_checktimeouts", comm_checktimeouts, NULL, 1); |
| 648 |
> |
event_addish(&event_comm_checktimeouts, NULL); |
| 649 |
|
|
| 650 |
< |
eventAddIsh("save_all_databases", save_all_databases, NULL, DATABASE_UPDATE_TIMEOUT); |
| 650 |
> |
event_addish(&event_save_all_databases, NULL); |
| 651 |
|
|
| 652 |
|
if (ConfigServerHide.links_delay > 0) |
| 653 |
< |
eventAddIsh("write_links_file", write_links_file, NULL, ConfigServerHide.links_delay); |
| 653 |
> |
{ |
| 654 |
> |
event_write_links_file.when = ConfigServerHide.links_delay; |
| 655 |
> |
event_addish(&event_write_links_file, NULL); |
| 656 |
> |
} |
| 657 |
|
else |
| 658 |
|
ConfigServerHide.links_disabled = 1; |
| 659 |
|
|
| 660 |
|
if (splitmode) |
| 661 |
< |
eventAddIsh("check_splitmode", check_splitmode, NULL, 60); |
| 661 |
> |
event_addish(&splitmode_event, NULL); |
| 662 |
|
|
| 663 |
|
io_loop(); |
| 664 |
|
return 0; |