| 53 |
|
#include "s_log.h" |
| 54 |
|
#include "s_misc.h" |
| 55 |
|
#include "s_serv.h" /* try_connections */ |
| 56 |
– |
#include "s_stats.h" |
| 56 |
|
#include "send.h" |
| 57 |
|
#include "whowas.h" |
| 58 |
|
#include "modules.h" |
| 62 |
|
#include "balloc.h" |
| 63 |
|
#include "motd.h" |
| 64 |
|
#include "supported.h" |
| 65 |
+ |
#include "watch.h" |
| 66 |
|
|
| 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. |
| 80 |
|
struct Counter Count = { 0, 0, 0, 0, 0, 0, 0, 0 }; |
| 81 |
|
struct ServerState_t server_state = { 0 }; |
| 82 |
|
struct logging_entry ConfigLoggingEntry = { 1, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0} }; |
| 83 |
+ |
struct ServerStatistics ServerStats; |
| 84 |
|
struct timeval SystemTime; |
| 85 |
|
struct Client me; /* That's me */ |
| 86 |
|
struct LocalUser meLocalUser; /* That's also part of me */ |
| 86 |
– |
unsigned long connect_id = 0; /* unique connect ID */ |
| 87 |
|
|
| 88 |
|
static unsigned long initialVMTop = 0; /* top of virtual memory at init */ |
| 89 |
|
const char *logFileName = LPATH; |
| 122 |
|
|
| 123 |
|
int rehashed_klines = 0; |
| 124 |
|
|
| 125 |
– |
/* |
| 126 |
– |
* get_vm_top - get the operating systems notion of the resident set size |
| 127 |
– |
*/ |
| 128 |
– |
#ifndef _WIN32 |
| 129 |
– |
static unsigned long |
| 130 |
– |
get_vm_top(void) |
| 131 |
– |
{ |
| 132 |
– |
/* |
| 133 |
– |
* NOTE: sbrk is not part of the ANSI C library or the POSIX.1 standard |
| 134 |
– |
* however it seems that everyone defines it. Calling sbrk with a 0 |
| 135 |
– |
* argument will return a pointer to the top of the process virtual |
| 136 |
– |
* memory without changing the process size, so this call should be |
| 137 |
– |
* reasonably safe (sbrk returns the new value for the top of memory). |
| 138 |
– |
* This code relies on the notion that the address returned will be an |
| 139 |
– |
* offset from 0 (NULL), so the result of sbrk is cast to a size_t and |
| 140 |
– |
* returned. We really shouldn't be using it here but... |
| 141 |
– |
*/ |
| 142 |
– |
|
| 143 |
– |
void *vptr = sbrk(0); |
| 144 |
– |
return((unsigned long)vptr); |
| 145 |
– |
} |
| 125 |
|
|
| 126 |
+ |
#ifndef _WIN32 |
| 127 |
|
/* |
| 128 |
|
* print_startup - print startup information |
| 129 |
|
*/ |
| 156 |
|
} |
| 157 |
|
#endif |
| 158 |
|
|
| 179 |
– |
/* |
| 180 |
– |
* get_maxrss - get the operating systems notion of the resident set size |
| 181 |
– |
*/ |
| 182 |
– |
unsigned long |
| 183 |
– |
get_maxrss(void) |
| 184 |
– |
{ |
| 185 |
– |
#ifdef _WIN32 |
| 186 |
– |
return (0); /* FIXME */ |
| 187 |
– |
#else |
| 188 |
– |
return (get_vm_top() - initialVMTop); |
| 189 |
– |
#endif |
| 190 |
– |
} |
| 191 |
– |
|
| 159 |
|
static int printVersion = 0; |
| 160 |
|
|
| 161 |
|
struct lgetopt myopts[] = { |
| 248 |
|
{ |
| 249 |
|
struct Client *client_p = ptr->data; |
| 250 |
|
assert(client_p->localClient->list_task); |
| 251 |
< |
safe_list_channels(client_p, client_p->localClient->list_task, 0, 0); |
| 251 |
> |
safe_list_channels(client_p, client_p->localClient->list_task, 0); |
| 252 |
|
} |
| 253 |
|
} |
| 254 |
|
|
| 347 |
|
initialize_server_capabs(void) |
| 348 |
|
{ |
| 349 |
|
add_capability("QS", CAP_QS, 1); |
| 383 |
– |
add_capability("LL", CAP_LL, 1); |
| 350 |
|
add_capability("EOB", CAP_EOB, 1); |
| 351 |
+ |
|
| 352 |
|
if (ServerInfo.sid != NULL) /* only enable TS6 if we have an SID */ |
| 353 |
|
add_capability("TS6", CAP_TS6, 0); |
| 354 |
+ |
|
| 355 |
|
add_capability("ZIP", CAP_ZIP, 0); |
| 356 |
|
add_capability("CLUSTER", CAP_CLUSTER, 1); |
| 357 |
|
#ifdef HALFOPS |
| 470 |
|
SSL_load_error_strings(); |
| 471 |
|
SSLeay_add_ssl_algorithms(); |
| 472 |
|
|
| 473 |
< |
ServerInfo.ctx = SSL_CTX_new(SSLv23_server_method()); |
| 506 |
< |
if (!ServerInfo.ctx) |
| 473 |
> |
if ((ServerInfo.server_ctx = SSL_CTX_new(SSLv23_server_method())) == NULL) |
| 474 |
|
{ |
| 475 |
|
const char *s; |
| 476 |
|
|
| 479 |
|
ilog(L_CRIT, "ERROR: Could not initialize the SSL context -- %s\n", s); |
| 480 |
|
} |
| 481 |
|
|
| 482 |
< |
SSL_CTX_set_options(ServerInfo.ctx, SSL_OP_NO_SSLv2); |
| 483 |
< |
SSL_CTX_set_options(ServerInfo.ctx, SSL_OP_TLS_ROLLBACK_BUG|SSL_OP_ALL); |
| 484 |
< |
SSL_CTX_set_verify(ServerInfo.ctx, SSL_VERIFY_NONE, NULL); |
| 482 |
> |
SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_NO_SSLv2); |
| 483 |
> |
SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_TLS_ROLLBACK_BUG|SSL_OP_ALL); |
| 484 |
> |
SSL_CTX_set_verify(ServerInfo.server_ctx, SSL_VERIFY_NONE, NULL); |
| 485 |
|
|
| 486 |
|
bio_spare_fd = save_spare_fd("SSL private key validation"); |
| 487 |
|
#endif /* HAVE_LIBCRYPTO */ |
| 496 |
|
static void |
| 497 |
|
init_callbacks(void) |
| 498 |
|
{ |
| 499 |
< |
iorecv_cb = register_callback("iorecv", NULL); |
| 500 |
< |
iosend_cb = register_callback("iosend", NULL); |
| 499 |
> |
iorecv_cb = register_callback("iorecv", iorecv_default); |
| 500 |
> |
iosend_cb = register_callback("iosend", iosend_default); |
| 501 |
|
iorecvctrl_cb = register_callback("iorecvctrl", NULL); |
| 502 |
|
iosendctrl_cb = register_callback("iosendctrl", NULL); |
| 503 |
|
} |
| 517 |
|
|
| 518 |
|
/* Setup corefile size immediately after boot -kre */ |
| 519 |
|
setup_corefile(); |
| 553 |
– |
|
| 554 |
– |
/* set initialVMTop before we allocate any memory */ |
| 555 |
– |
initialVMTop = get_vm_top(); |
| 520 |
|
#endif |
| 521 |
|
|
| 522 |
|
/* save server boot time right away, so getrusage works correctly */ |
| 531 |
|
of Client list */ |
| 532 |
|
|
| 533 |
|
memset(&ServerInfo, 0, sizeof(ServerInfo)); |
| 534 |
+ |
memset(&ServerStats, 0, sizeof(ServerStats)); |
| 535 |
|
|
| 536 |
|
/* Initialise the channel capability usage counts... */ |
| 537 |
|
init_chcap_usage_counts(); |
| 603 |
|
init_client(); |
| 604 |
|
init_class(); |
| 605 |
|
init_whowas(); |
| 606 |
< |
init_stats(); |
| 606 |
> |
watch_init(); |
| 607 |
|
read_conf_files(1); /* cold start init conf files */ |
| 643 |
– |
initServerMask(); |
| 608 |
|
me.id[0] = '\0'; |
| 609 |
|
init_uid(); |
| 610 |
|
init_auth(); /* Initialise the auth code */ |
| 620 |
|
ilog(L_CRIT, "No server name specified in serverinfo block."); |
| 621 |
|
exit(EXIT_FAILURE); |
| 622 |
|
} |
| 623 |
+ |
|
| 624 |
|
strlcpy(me.name, ServerInfo.name, sizeof(me.name)); |
| 625 |
|
|
| 626 |
|
/* serverinfo{} description must exist. If not, error out.*/ |
| 630 |
|
"ERROR: No server description specified in serverinfo block."); |
| 631 |
|
exit(EXIT_FAILURE); |
| 632 |
|
} |
| 633 |
+ |
|
| 634 |
|
strlcpy(me.info, ServerInfo.description, sizeof(me.info)); |
| 635 |
|
|
| 636 |
|
me.from = &me; |
| 693 |
|
eventAddIsh("check_splitmode", check_splitmode, NULL, 60); |
| 694 |
|
|
| 695 |
|
io_loop(); |
| 696 |
< |
return(0); |
| 696 |
> |
return 0; |
| 697 |
|
} |