25 |
|
*/ |
26 |
|
|
27 |
|
#include "stdinc.h" |
28 |
< |
#include "s_user.h" |
28 |
> |
#include "user.h" |
29 |
|
#include "list.h" |
30 |
|
#include "ircd.h" |
31 |
|
#include "channel.h" |
32 |
– |
#include "channel_mode.h" |
32 |
|
#include "client.h" |
33 |
|
#include "event.h" |
34 |
|
#include "fdlist.h" |
35 |
|
#include "hash.h" |
36 |
|
#include "irc_string.h" |
37 |
|
#include "ircd_signal.h" |
38 |
< |
#include "s_gline.h" |
38 |
> |
#include "gline.h" |
39 |
|
#include "motd.h" |
40 |
|
#include "conf.h" |
41 |
|
#include "hostmask.h" |
43 |
– |
#include "numeric.h" |
44 |
– |
#include "packet.h" |
42 |
|
#include "parse.h" |
43 |
< |
#include "irc_res.h" |
43 |
> |
#include "res.h" |
44 |
|
#include "restart.h" |
45 |
|
#include "rng_mt.h" |
46 |
< |
#include "s_auth.h" |
46 |
> |
#include "auth.h" |
47 |
|
#include "s_bsd.h" |
48 |
|
#include "log.h" |
49 |
< |
#include "s_misc.h" |
53 |
< |
#include "s_serv.h" /* try_connections */ |
49 |
> |
#include "server.h" /* try_connections */ |
50 |
|
#include "send.h" |
51 |
|
#include "whowas.h" |
52 |
|
#include "modules.h" |
53 |
|
#include "memory.h" |
54 |
|
#include "mempool.h" |
59 |
– |
#include "hook.h" |
55 |
|
#include "ircd_getopt.h" |
61 |
– |
#include "supported.h" |
56 |
|
#include "watch.h" |
57 |
|
#include "conf_db.h" |
58 |
|
#include "conf_class.h" |
62 |
|
GeoIP *geoip_ctx; |
63 |
|
#endif |
64 |
|
|
71 |
– |
/* /quote set variables */ |
72 |
– |
struct SetOptions GlobalSetOptions; |
73 |
– |
struct Counter Count; |
74 |
– |
struct ServerState_t server_state; |
65 |
|
struct ServerStatistics ServerStats; |
66 |
|
struct timeval SystemTime; |
67 |
|
struct Client me; /* That's me */ |
78 |
|
/* Set to zero because it should be initialized later using |
79 |
|
* initialize_server_capabs |
80 |
|
*/ |
81 |
< |
int default_server_capabs = 0; |
81 |
> |
unsigned int default_server_capabs; |
82 |
|
unsigned int splitmode; |
83 |
|
unsigned int splitchecking; |
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?) |
103 |
< |
* |
104 |
< |
* - Dianora |
105 |
< |
*/ |
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 |
+ |
struct event event_check_splitmode = |
129 |
+ |
{ |
130 |
+ |
.name = "check_splitmode", |
131 |
+ |
.handler = check_splitmode, |
132 |
+ |
.when = 60 |
133 |
+ |
}; |
134 |
|
|
135 |
|
/* |
136 |
|
* print_startup - print startup information |
226 |
|
{ |
227 |
|
while (1) |
228 |
|
{ |
204 |
– |
/* |
205 |
– |
* Maybe we want a flags word? |
206 |
– |
* ie. if (REHASHED_KLINES(global_flags)) |
207 |
– |
* SET_REHASHED_KLINES(global_flags) |
208 |
– |
* CLEAR_REHASHED_KLINES(global_flags) |
209 |
– |
* |
210 |
– |
* - Dianora |
211 |
– |
*/ |
212 |
– |
if (rehashed_klines) |
213 |
– |
{ |
214 |
– |
check_conf_klines(); |
215 |
– |
rehashed_klines = 0; |
216 |
– |
} |
217 |
– |
|
229 |
|
if (listing_client_list.head) |
230 |
|
{ |
231 |
|
dlink_node *ptr = NULL, *ptr_next = NULL; |
232 |
|
DLINK_FOREACH_SAFE(ptr, ptr_next, listing_client_list.head) |
233 |
< |
{ |
223 |
< |
struct Client *client_p = ptr->data; |
224 |
< |
assert(client_p->localClient->list_task); |
225 |
< |
safe_list_channels(client_p, client_p->localClient->list_task, 0); |
226 |
< |
} |
233 |
> |
safe_list_channels(ptr->data, 0); |
234 |
|
} |
235 |
|
|
236 |
< |
/* Run pending events, then get the number of seconds to the next |
237 |
< |
* event |
231 |
< |
*/ |
232 |
< |
while (eventNextTime() <= CurrentTime) |
233 |
< |
eventRun(); |
236 |
> |
/* Run pending events */ |
237 |
> |
event_run(); |
238 |
|
|
239 |
|
comm_select(); |
240 |
|
exit_aborted_clients(); |
309 |
|
add_capability("CLUSTER", CAP_CLUSTER, 1); |
310 |
|
add_capability("SVS", CAP_SVS, 1); |
311 |
|
add_capability("CHW", CAP_CHW, 1); |
308 |
– |
#ifdef HALFOPS |
312 |
|
add_capability("HOPS", CAP_HOPS, 1); |
310 |
– |
#endif |
313 |
|
} |
314 |
|
|
315 |
|
/* write_pidfile() |
433 |
|
|
434 |
|
if ((ServerInfo.server_ctx = SSL_CTX_new(SSLv23_server_method())) == NULL) |
435 |
|
{ |
436 |
< |
const char *s; |
436 |
> |
const char *s = ERR_lib_error_string(ERR_get_error()); |
437 |
|
|
438 |
< |
fprintf(stderr, "ERROR: Could not initialize the SSL Server context -- %s\n", |
437 |
< |
s = ERR_lib_error_string(ERR_get_error())); |
438 |
> |
fprintf(stderr, "ERROR: Could not initialize the SSL Server context -- %s\n", s); |
439 |
|
ilog(LOG_TYPE_IRCD, "ERROR: Could not initialize the SSL Server context -- %s\n", s); |
440 |
|
} |
441 |
|
|
442 |
|
SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_TLSv1); |
443 |
< |
SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_TLS_ROLLBACK_BUG|SSL_OP_ALL); |
443 |
> |
SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_TLS_ROLLBACK_BUG); |
444 |
|
SSL_CTX_set_verify(ServerInfo.server_ctx, SSL_VERIFY_PEER|SSL_VERIFY_CLIENT_ONCE, |
445 |
|
always_accept_verify_cb); |
446 |
|
SSL_CTX_set_session_id_context(ServerInfo.server_ctx, session_id, sizeof(session_id) - 1); |
447 |
|
|
448 |
+ |
#if OPENSSL_VERSION_NUMBER >= 0x1000005FL && !defined(OPENSSL_NO_ECDH) |
449 |
+ |
{ |
450 |
+ |
EC_KEY *key = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1); |
451 |
+ |
|
452 |
+ |
if (key) |
453 |
+ |
{ |
454 |
+ |
SSL_CTX_set_tmp_ecdh(ServerInfo.server_ctx, key); |
455 |
+ |
EC_KEY_free(key); |
456 |
+ |
} |
457 |
+ |
} |
458 |
+ |
|
459 |
+ |
SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_SINGLE_ECDH_USE); |
460 |
+ |
#endif |
461 |
+ |
|
462 |
|
if ((ServerInfo.client_ctx = SSL_CTX_new(SSLv23_client_method())) == NULL) |
463 |
|
{ |
464 |
< |
const char *s; |
464 |
> |
const char *s = ERR_lib_error_string(ERR_get_error()); |
465 |
|
|
466 |
< |
fprintf(stderr, "ERROR: Could not initialize the SSL Client context -- %s\n", |
452 |
< |
s = ERR_lib_error_string(ERR_get_error())); |
466 |
> |
fprintf(stderr, "ERROR: Could not initialize the SSL Client context -- %s\n", s); |
467 |
|
ilog(LOG_TYPE_IRCD, "ERROR: Could not initialize the SSL Client context -- %s\n", s); |
468 |
|
} |
469 |
|
|
470 |
|
SSL_CTX_set_options(ServerInfo.client_ctx, SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_TLSv1); |
471 |
< |
SSL_CTX_set_options(ServerInfo.client_ctx, SSL_OP_TLS_ROLLBACK_BUG|SSL_OP_ALL); |
471 |
> |
SSL_CTX_set_options(ServerInfo.client_ctx, SSL_OP_TLS_ROLLBACK_BUG); |
472 |
|
SSL_CTX_set_verify(ServerInfo.client_ctx, SSL_VERIFY_PEER|SSL_VERIFY_CLIENT_ONCE, |
473 |
|
always_accept_verify_cb); |
474 |
|
#endif /* HAVE_LIBCRYPTO */ |
480 |
|
/* Check to see if the user is running us as root, which is a nono */ |
481 |
|
if (geteuid() == 0) |
482 |
|
{ |
483 |
< |
fprintf(stderr, "Don't run ircd as root!!!\n"); |
483 |
> |
fprintf(stderr, "ERROR: This server won't run as root/superuser\n"); |
484 |
|
return -1; |
485 |
|
} |
486 |
|
|
496 |
|
me.localClient = &meLocalUser; |
497 |
|
dlinkAdd(&me, &me.node, &global_client_list); /* Pointer to beginning |
498 |
|
of Client list */ |
499 |
+ |
ConfigLoggingEntry.use_logging = 1; |
500 |
|
ConfigFileEntry.dpath = DPATH; |
501 |
|
ConfigFileEntry.spath = SPATH; |
502 |
|
ConfigFileEntry.mpath = MPATH; |
536 |
|
|
537 |
|
setup_signals(); |
538 |
|
|
524 |
– |
/* Init the event subsystem */ |
525 |
– |
eventInit(); |
526 |
– |
|
539 |
|
/* We need this to initialise the fd array before anything else */ |
540 |
|
fdlist_init(); |
541 |
|
log_set_file(LOG_TYPE_IRCD, 0, logFileName); |
643 |
|
|
644 |
|
ilog(LOG_TYPE_IRCD, "Server Ready"); |
645 |
|
|
646 |
< |
eventAddIsh("cleanup_glines", cleanup_glines, NULL, CLEANUP_GLINES_TIME); |
647 |
< |
eventAddIsh("cleanup_tklines", cleanup_tklines, NULL, CLEANUP_TKLINES_TIME); |
646 |
> |
event_addish(&event_cleanup_glines, NULL); |
647 |
> |
event_addish(&event_cleanup_tklines, NULL); |
648 |
|
|
649 |
|
/* We want try_connections to be called as soon as possible now! -- adrian */ |
650 |
|
/* No, 'cause after a restart it would cause all sorts of nick collides */ |
651 |
< |
eventAddIsh("try_connections", try_connections, NULL, STARTUP_CONNECTIONS_TIME); |
651 |
> |
event_addish(&event_try_connections, NULL); |
652 |
|
|
653 |
|
/* Setup the timeout check. I'll shift it later :) -- adrian */ |
654 |
< |
eventAddIsh("comm_checktimeouts", comm_checktimeouts, NULL, 1); |
654 |
> |
event_addish(&event_comm_checktimeouts, NULL); |
655 |
|
|
656 |
< |
eventAddIsh("save_all_databases", save_all_databases, NULL, DATABASE_UPDATE_TIMEOUT); |
656 |
> |
event_addish(&event_save_all_databases, NULL); |
657 |
|
|
658 |
|
if (ConfigServerHide.links_delay > 0) |
659 |
< |
eventAddIsh("write_links_file", write_links_file, NULL, ConfigServerHide.links_delay); |
659 |
> |
{ |
660 |
> |
event_write_links_file.when = ConfigServerHide.links_delay; |
661 |
> |
event_addish(&event_write_links_file, NULL); |
662 |
> |
} |
663 |
|
else |
664 |
|
ConfigServerHide.links_disabled = 1; |
665 |
|
|
666 |
|
if (splitmode) |
667 |
< |
eventAddIsh("check_splitmode", check_splitmode, NULL, 60); |
667 |
> |
event_addish(&event_check_splitmode, NULL); |
668 |
|
|
669 |
|
io_loop(); |
670 |
|
return 0; |