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 |
165 |
|
|
166 |
|
static int printVersion = 0; |
167 |
|
|
168 |
< |
static struct lgetopt myopts[] = { |
168 |
> |
static struct lgetopt myopts[] = |
169 |
> |
{ |
170 |
|
{"configfile", &ConfigFileEntry.configfile, |
171 |
|
STRING, "File to use for ircd.conf"}, |
172 |
|
{"glinefile", &ConfigFileEntry.glinefile, |
203 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
204 |
|
"Clock Failure (%s), TS can be corrupted", |
205 |
|
strerror(errno)); |
206 |
< |
restart("Clock Failure"); |
206 |
> |
server_die("Clock Failure", 1); |
207 |
|
} |
208 |
|
|
209 |
|
if (newtime.tv_sec < CurrentTime) |
224 |
|
static void |
225 |
|
io_loop(void) |
226 |
|
{ |
227 |
< |
while (1 == 1) |
227 |
> |
while (1) |
228 |
|
{ |
203 |
– |
/* |
204 |
– |
* Maybe we want a flags word? |
205 |
– |
* ie. if (REHASHED_KLINES(global_flags)) |
206 |
– |
* SET_REHASHED_KLINES(global_flags) |
207 |
– |
* CLEAR_REHASHED_KLINES(global_flags) |
208 |
– |
* |
209 |
– |
* - Dianora |
210 |
– |
*/ |
211 |
– |
if (rehashed_klines) |
212 |
– |
{ |
213 |
– |
check_conf_klines(); |
214 |
– |
rehashed_klines = 0; |
215 |
– |
} |
216 |
– |
|
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 |
< |
{ |
222 |
< |
struct Client *client_p = ptr->data; |
223 |
< |
assert(client_p->localClient->list_task); |
224 |
< |
safe_list_channels(client_p, client_p->localClient->list_task, 0); |
225 |
< |
} |
233 |
> |
safe_list_channels(ptr->data, 0); |
234 |
|
} |
235 |
|
|
236 |
< |
/* Run pending events, then get the number of seconds to the next |
237 |
< |
* event |
230 |
< |
*/ |
231 |
< |
while (eventNextTime() <= CurrentTime) |
232 |
< |
eventRun(); |
236 |
> |
/* Run pending events */ |
237 |
> |
event_run(); |
238 |
|
|
239 |
|
comm_select(); |
240 |
|
exit_aborted_clients(); |
246 |
|
rehash(1); |
247 |
|
dorehash = 0; |
248 |
|
} |
249 |
+ |
|
250 |
|
if (doremotd) |
251 |
|
{ |
252 |
|
motd_recache(); |
308 |
|
add_capability("TS6", CAP_TS6, 0); |
309 |
|
add_capability("CLUSTER", CAP_CLUSTER, 1); |
310 |
|
add_capability("SVS", CAP_SVS, 1); |
311 |
< |
#ifdef HALFOPS |
311 |
> |
add_capability("CHW", CAP_CHW, 1); |
312 |
|
add_capability("HOPS", CAP_HOPS, 1); |
307 |
– |
#endif |
313 |
|
} |
314 |
|
|
315 |
|
/* write_pidfile() |
441 |
|
} |
442 |
|
|
443 |
|
SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_TLSv1); |
444 |
< |
SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_TLS_ROLLBACK_BUG|SSL_OP_ALL); |
444 |
> |
SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_TLS_ROLLBACK_BUG); |
445 |
|
SSL_CTX_set_verify(ServerInfo.server_ctx, SSL_VERIFY_PEER|SSL_VERIFY_CLIENT_ONCE, |
446 |
|
always_accept_verify_cb); |
447 |
|
SSL_CTX_set_session_id_context(ServerInfo.server_ctx, session_id, sizeof(session_id) - 1); |
448 |
|
|
449 |
+ |
#if OPENSSL_VERSION_NUMBER >= 0x1000005FL && !defined(OPENSSL_NO_ECDH) |
450 |
+ |
{ |
451 |
+ |
EC_KEY *key = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1); |
452 |
+ |
|
453 |
+ |
if (key) |
454 |
+ |
{ |
455 |
+ |
SSL_CTX_set_tmp_ecdh(ServerInfo.server_ctx, key); |
456 |
+ |
EC_KEY_free(key); |
457 |
+ |
} |
458 |
+ |
} |
459 |
+ |
|
460 |
+ |
SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_SINGLE_ECDH_USE); |
461 |
+ |
#endif |
462 |
+ |
|
463 |
|
if ((ServerInfo.client_ctx = SSL_CTX_new(SSLv23_client_method())) == NULL) |
464 |
|
{ |
465 |
|
const char *s; |
470 |
|
} |
471 |
|
|
472 |
|
SSL_CTX_set_options(ServerInfo.client_ctx, SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_TLSv1); |
473 |
< |
SSL_CTX_set_options(ServerInfo.client_ctx, SSL_OP_TLS_ROLLBACK_BUG|SSL_OP_ALL); |
473 |
> |
SSL_CTX_set_options(ServerInfo.client_ctx, SSL_OP_TLS_ROLLBACK_BUG); |
474 |
|
SSL_CTX_set_verify(ServerInfo.client_ctx, SSL_VERIFY_PEER|SSL_VERIFY_CLIENT_ONCE, |
475 |
|
always_accept_verify_cb); |
476 |
|
#endif /* HAVE_LIBCRYPTO */ |
482 |
|
/* Check to see if the user is running us as root, which is a nono */ |
483 |
|
if (geteuid() == 0) |
484 |
|
{ |
485 |
< |
fprintf(stderr, "Don't run ircd as root!!!\n"); |
485 |
> |
fprintf(stderr, "ERROR: This server won't run as root/superuser\n"); |
486 |
|
return -1; |
487 |
|
} |
488 |
|
|
498 |
|
me.localClient = &meLocalUser; |
499 |
|
dlinkAdd(&me, &me.node, &global_client_list); /* Pointer to beginning |
500 |
|
of Client list */ |
501 |
< |
/* Initialise the channel capability usage counts... */ |
483 |
< |
init_chcap_usage_counts(); |
484 |
< |
|
501 |
> |
ConfigLoggingEntry.use_logging = 1; |
502 |
|
ConfigFileEntry.dpath = DPATH; |
503 |
+ |
ConfigFileEntry.spath = SPATH; |
504 |
+ |
ConfigFileEntry.mpath = MPATH; |
505 |
|
ConfigFileEntry.configfile = CPATH; /* Server configuration file */ |
506 |
|
ConfigFileEntry.klinefile = KPATH; /* Server kline file */ |
507 |
|
ConfigFileEntry.glinefile = GPATH; /* Server gline file */ |
538 |
|
|
539 |
|
setup_signals(); |
540 |
|
|
522 |
– |
/* Init the event subsystem */ |
523 |
– |
eventInit(); |
524 |
– |
|
541 |
|
/* We need this to initialise the fd array before anything else */ |
542 |
|
fdlist_init(); |
543 |
|
log_set_file(LOG_TYPE_IRCD, 0, logFileName); |
645 |
|
|
646 |
|
ilog(LOG_TYPE_IRCD, "Server Ready"); |
647 |
|
|
648 |
< |
eventAddIsh("cleanup_glines", cleanup_glines, NULL, CLEANUP_GLINES_TIME); |
649 |
< |
eventAddIsh("cleanup_tklines", cleanup_tklines, NULL, CLEANUP_TKLINES_TIME); |
648 |
> |
event_addish(&event_cleanup_glines, NULL); |
649 |
> |
event_addish(&event_cleanup_tklines, NULL); |
650 |
|
|
651 |
|
/* We want try_connections to be called as soon as possible now! -- adrian */ |
652 |
|
/* No, 'cause after a restart it would cause all sorts of nick collides */ |
653 |
< |
eventAddIsh("try_connections", try_connections, NULL, STARTUP_CONNECTIONS_TIME); |
653 |
> |
event_addish(&event_try_connections, NULL); |
654 |
|
|
655 |
|
/* Setup the timeout check. I'll shift it later :) -- adrian */ |
656 |
< |
eventAddIsh("comm_checktimeouts", comm_checktimeouts, NULL, 1); |
656 |
> |
event_addish(&event_comm_checktimeouts, NULL); |
657 |
|
|
658 |
< |
eventAddIsh("save_all_databases", save_all_databases, NULL, DATABASE_UPDATE_TIMEOUT); |
658 |
> |
event_addish(&event_save_all_databases, NULL); |
659 |
|
|
660 |
|
if (ConfigServerHide.links_delay > 0) |
661 |
< |
eventAddIsh("write_links_file", write_links_file, NULL, ConfigServerHide.links_delay); |
661 |
> |
{ |
662 |
> |
event_write_links_file.when = ConfigServerHide.links_delay; |
663 |
> |
event_addish(&event_write_links_file, NULL); |
664 |
> |
} |
665 |
|
else |
666 |
|
ConfigServerHide.links_disabled = 1; |
667 |
|
|
668 |
|
if (splitmode) |
669 |
< |
eventAddIsh("check_splitmode", check_splitmode, NULL, 60); |
669 |
> |
event_addish(&event_check_splitmode, NULL); |
670 |
|
|
671 |
|
io_loop(); |
672 |
|
return 0; |