29 |
|
#include "channel.h" |
30 |
|
#include "channel_mode.h" |
31 |
|
#include "client.h" |
32 |
– |
#include "common.h" |
32 |
|
#include "event.h" |
33 |
|
#include "fdlist.h" |
34 |
|
#include "hash.h" |
35 |
|
#include "irc_string.h" |
37 |
– |
#include "sprintf_irc.h" |
36 |
|
#include "ircd_signal.h" |
37 |
|
#include "s_gline.h" |
38 |
|
#include "motd.h" |
41 |
– |
#include "ircd_handler.h" |
42 |
– |
#include "msg.h" /* msgtab */ |
39 |
|
#include "hostmask.h" |
40 |
|
#include "numeric.h" |
41 |
|
#include "packet.h" |
60 |
|
#include "supported.h" |
61 |
|
#include "watch.h" |
62 |
|
|
67 |
– |
/* Try and find the correct name to use with getrlimit() for setting the max. |
68 |
– |
* number of files allowed to be open by this process. |
69 |
– |
*/ |
63 |
|
|
64 |
|
/* /quote set variables */ |
65 |
|
struct SetOptions GlobalSetOptions; |
70 |
|
struct server_info ServerInfo; |
71 |
|
/* admin info set from ircd.conf */ |
72 |
|
struct admin_info AdminInfo = { NULL, NULL, NULL }; |
73 |
< |
struct Counter Count = { 0, 0, 0, 0, 0, 0, 0, 0 }; |
73 |
> |
struct Counter Count = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; |
74 |
|
struct ServerState_t server_state = { 0 }; |
75 |
< |
struct logging_entry ConfigLoggingEntry = { 1, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0} }; |
75 |
> |
struct logging_entry ConfigLoggingEntry = { 1 }; |
76 |
|
struct ServerStatistics ServerStats; |
77 |
|
struct timeval SystemTime; |
78 |
|
struct Client me; /* That's me */ |
178 |
|
|
179 |
|
if (gettimeofday(&newtime, NULL) == -1) |
180 |
|
{ |
181 |
< |
ilog(L_ERROR, "Clock Failure (%s), TS can be corrupted", |
181 |
> |
ilog(LOG_TYPE_IRCD, "Clock Failure (%s), TS can be corrupted", |
182 |
|
strerror(errno)); |
183 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, |
184 |
|
"Clock Failure (%s), TS can be corrupted", |
188 |
|
|
189 |
|
if (newtime.tv_sec < CurrentTime) |
190 |
|
{ |
191 |
< |
ircsprintf(to_send, "System clock is running backwards - (%lu < %lu)", |
192 |
< |
(unsigned long)newtime.tv_sec, (unsigned long)CurrentTime); |
191 |
> |
snprintf(to_send, sizeof(to_send), |
192 |
> |
"System clock is running backwards - (%lu < %lu)", |
193 |
> |
(unsigned long)newtime.tv_sec, (unsigned long)CurrentTime); |
194 |
|
report_error(L_ALL, to_send, me.name, 0); |
195 |
|
set_back_events(CurrentTime - newtime.tv_sec); |
196 |
|
} |
291 |
|
} |
292 |
|
|
293 |
|
GlobalSetOptions.ident_timeout = IDENT_TIMEOUT; |
300 |
– |
GlobalSetOptions.idletime = ConfigFileEntry.idletime; |
294 |
|
/* End of global set options */ |
295 |
|
} |
296 |
|
|
327 |
|
add_capability("TS6", CAP_TS6, 0); |
328 |
|
add_capability("ZIP", CAP_ZIP, 0); |
329 |
|
add_capability("CLUSTER", CAP_CLUSTER, 1); |
330 |
+ |
add_capability("SVS", CAP_SVS, 1); |
331 |
|
#ifdef HALFOPS |
332 |
|
add_capability("HOPS", CAP_HOPS, 1); |
333 |
|
#endif |
348 |
|
{ |
349 |
|
char buff[32]; |
350 |
|
unsigned int pid = (unsigned int)getpid(); |
351 |
< |
size_t nbytes = ircsprintf(buff, "%u\n", pid); |
351 |
> |
size_t nbytes = snprintf(buff, sizeof(buff), "%u\n", pid); |
352 |
|
|
353 |
|
if ((fbputs(buff, fb, nbytes) == -1)) |
354 |
< |
ilog(L_ERROR, "Error writing %u to pid file %s (%s)", |
354 |
> |
ilog(LOG_TYPE_IRCD, "Error writing %u to pid file %s (%s)", |
355 |
|
pid, filename, strerror(errno)); |
356 |
|
|
357 |
|
fbclose(fb); |
359 |
|
} |
360 |
|
else |
361 |
|
{ |
362 |
< |
ilog(L_ERROR, "Error opening pid file %s", filename); |
362 |
> |
ilog(LOG_TYPE_IRCD, "Error opening pid file %s", filename); |
363 |
|
} |
364 |
|
} |
365 |
|
|
448 |
|
|
449 |
|
fprintf(stderr, "ERROR: Could not initialize the SSL context -- %s\n", |
450 |
|
s = ERR_lib_error_string(ERR_get_error())); |
451 |
< |
ilog(L_CRIT, "ERROR: Could not initialize the SSL context -- %s\n", s); |
451 |
> |
ilog(LOG_TYPE_IRCD, "ERROR: Could not initialize the SSL context -- %s\n", s); |
452 |
|
} |
453 |
|
|
454 |
|
SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_NO_SSLv2); |
495 |
|
/* It ain't random, but it ought to be a little harder to guess */ |
496 |
|
init_genrand(SystemTime.tv_sec ^ (SystemTime.tv_usec | (getpid() << 20))); |
497 |
|
|
504 |
– |
memset(&me, 0, sizeof(me)); |
505 |
– |
memset(&meLocalUser, 0, sizeof(meLocalUser)); |
498 |
|
me.localClient = &meLocalUser; |
499 |
|
dlinkAdd(&me, &me.node, &global_client_list); /* Pointer to beginning |
500 |
|
of Client list */ |
509 |
– |
|
510 |
– |
memset(&ServerInfo, 0, sizeof(ServerInfo)); |
511 |
– |
memset(&ServerStats, 0, sizeof(ServerStats)); |
512 |
– |
|
501 |
|
/* Initialise the channel capability usage counts... */ |
502 |
|
init_chcap_usage_counts(); |
503 |
|
|
546 |
|
eventInit(); |
547 |
|
/* We need this to initialise the fd array before anything else */ |
548 |
|
fdlist_init(); |
549 |
< |
init_log(logFileName); |
549 |
> |
log_add_file(LOG_TYPE_IRCD, 0, logFileName); |
550 |
|
check_can_use_v6(); |
551 |
|
init_comm(); /* This needs to be setup early ! -- adrian */ |
552 |
|
/* Check if there is pidfile and daemon already running */ |
575 |
|
|
576 |
|
if (EmptyString(ServerInfo.sid)) |
577 |
|
{ |
578 |
< |
ilog(L_CRIT, "ERROR: No server id specified in serverinfo block."); |
578 |
> |
ilog(LOG_TYPE_IRCD, "ERROR: No server id specified in serverinfo block."); |
579 |
|
exit(EXIT_FAILURE); |
580 |
|
} |
581 |
|
|
583 |
|
|
584 |
|
if (EmptyString(ServerInfo.name)) |
585 |
|
{ |
586 |
< |
ilog(L_CRIT, "ERROR: No server name specified in serverinfo block."); |
586 |
> |
ilog(LOG_TYPE_IRCD, "ERROR: No server name specified in serverinfo block."); |
587 |
|
exit(EXIT_FAILURE); |
588 |
|
} |
589 |
|
|
592 |
|
/* serverinfo{} description must exist. If not, error out.*/ |
593 |
|
if (EmptyString(ServerInfo.description)) |
594 |
|
{ |
595 |
< |
ilog(L_CRIT, "ERROR: No server description specified in serverinfo block."); |
595 |
> |
ilog(LOG_TYPE_IRCD, "ERROR: No server description specified in serverinfo block."); |
596 |
|
exit(EXIT_FAILURE); |
597 |
|
} |
598 |
|
|
599 |
|
strlcpy(me.info, ServerInfo.description, sizeof(me.info)); |
600 |
|
|
601 |
< |
me.from = &me; |
602 |
< |
me.servptr = &me; |
601 |
> |
me.from = &me; |
602 |
> |
me.servptr = &me; |
603 |
> |
me.localClient->lasttime = CurrentTime; |
604 |
> |
me.localClient->since = CurrentTime; |
605 |
> |
me.localClient->firsttime = CurrentTime; |
606 |
|
|
607 |
|
SetMe(&me); |
608 |
|
make_server(&me); |
609 |
|
|
619 |
– |
me.lasttime = me.since = me.firsttime = CurrentTime; |
620 |
– |
|
610 |
|
hash_add_id(&me); |
611 |
|
hash_add_client(&me); |
612 |
|
|
615 |
|
|
616 |
|
if (chdir(MODPATH)) |
617 |
|
{ |
618 |
< |
ilog(L_CRIT, "Could not load core modules. Terminating!"); |
618 |
> |
ilog(LOG_TYPE_IRCD, "Could not load core modules. Terminating!"); |
619 |
|
exit(EXIT_FAILURE); |
620 |
|
} |
621 |
|
|
638 |
|
|
639 |
|
write_pidfile(pidFileName); |
640 |
|
|
641 |
< |
ilog(L_NOTICE, "Server Ready"); |
641 |
> |
ilog(LOG_TYPE_IRCD, "Server Ready"); |
642 |
|
|
643 |
|
eventAddIsh("cleanup_glines", cleanup_glines, NULL, CLEANUP_GLINES_TIME); |
644 |
|
eventAddIsh("cleanup_tklines", cleanup_tklines, NULL, CLEANUP_TKLINES_TIME); |