| 32 |
|
#include "common.h" |
| 33 |
|
#include "hash.h" |
| 34 |
|
#include "ircd_signal.h" |
| 35 |
– |
#include "s_gline.h" |
| 35 |
|
#include "motd.h" |
| 36 |
|
#include "ircd_handler.h" |
| 37 |
|
#include "msg.h" /* msgtab */ |
| 41 |
|
#include "parse.h" |
| 42 |
|
#include "restart.h" |
| 43 |
|
#include "s_auth.h" |
| 45 |
– |
#include "s_conf.h" |
| 44 |
|
#include "parse_aline.h" |
| 45 |
|
#include "s_serv.h" |
| 46 |
|
#include "send.h" |
| 47 |
|
#include "whowas.h" |
| 48 |
|
#include "conf/modules.h" |
| 51 |
– |
#include "ircd_getopt.h" |
| 49 |
|
#include "motd.h" |
| 53 |
– |
#include "supported.h" |
| 50 |
|
#include "watch.h" |
| 51 |
+ |
#include "patchlevel.h" |
| 52 |
+ |
#include "serno.h" |
| 53 |
|
|
| 56 |
– |
/* Try and find the correct name to use with getrlimit() for setting the max. |
| 57 |
– |
* number of files allowed to be open by this process. |
| 58 |
– |
*/ |
| 54 |
|
|
| 55 |
|
/* /quote set variables */ |
| 56 |
|
struct SetOptions GlobalSetOptions; |
| 66 |
|
struct logging_entry ConfigLoggingEntry = { 1, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0} }; |
| 67 |
|
struct Client me; /* That's me */ |
| 68 |
|
struct LocalUser meLocalUser; /* That's also part of me */ |
| 74 |
– |
unsigned long connect_id = 0; /* unique connect ID */ |
| 69 |
|
|
| 76 |
– |
static unsigned long initialVMTop = 0; /* top of virtual memory at init */ |
| 70 |
|
const char *logFileName = LPATH; |
| 71 |
|
const char *pidFileName = PPATH; |
| 72 |
|
|
| 73 |
|
char **myargv; |
| 74 |
< |
char ircd_platform[PLATFORMLEN]; |
| 74 |
> |
const char *ircd_version = PATCHLEVEL; |
| 75 |
> |
const char *serno = SERIALNUM; |
| 76 |
> |
char ircd_platform[IRCD_BUFSIZE]; |
| 77 |
|
|
| 78 |
|
int dorehash = 0; |
| 79 |
|
int doremotd = 0; |
| 89 |
|
|
| 90 |
|
int splitmode; |
| 91 |
|
int splitchecking; |
| 97 |
– |
int split_users; |
| 98 |
– |
unsigned int split_servers; |
| 92 |
|
|
| 93 |
|
static dlink_node *fdlimit_hook; |
| 94 |
|
|
| 104 |
|
|
| 105 |
|
int rehashed_klines = 0; |
| 106 |
|
|
| 114 |
– |
/* |
| 115 |
– |
* get_vm_top - get the operating systems notion of the resident set size |
| 116 |
– |
*/ |
| 107 |
|
#ifndef _WIN32 |
| 118 |
– |
static unsigned long |
| 119 |
– |
get_vm_top(void) |
| 120 |
– |
{ |
| 121 |
– |
/* |
| 122 |
– |
* NOTE: sbrk is not part of the ANSI C library or the POSIX.1 standard |
| 123 |
– |
* however it seems that everyone defines it. Calling sbrk with a 0 |
| 124 |
– |
* argument will return a pointer to the top of the process virtual |
| 125 |
– |
* memory without changing the process size, so this call should be |
| 126 |
– |
* reasonably safe (sbrk returns the new value for the top of memory). |
| 127 |
– |
* This code relies on the notion that the address returned will be an |
| 128 |
– |
* offset from 0 (NULL), so the result of sbrk is cast to a size_t and |
| 129 |
– |
* returned. We really shouldn't be using it here but... |
| 130 |
– |
*/ |
| 131 |
– |
|
| 132 |
– |
void *vptr = sbrk(0); |
| 133 |
– |
return (unsigned long)vptr; |
| 134 |
– |
} |
| 135 |
– |
|
| 108 |
|
/* |
| 109 |
|
* print_startup - print startup information |
| 110 |
|
*/ |
| 137 |
|
} |
| 138 |
|
#endif |
| 139 |
|
|
| 168 |
– |
/* |
| 169 |
– |
* get_maxrss - get the operating systems notion of the resident set size |
| 170 |
– |
*/ |
| 171 |
– |
unsigned long |
| 172 |
– |
get_maxrss(void) |
| 173 |
– |
{ |
| 174 |
– |
#ifdef _WIN32 |
| 175 |
– |
return (0); /* FIXME */ |
| 176 |
– |
#else |
| 177 |
– |
return (get_vm_top() - initialVMTop); |
| 178 |
– |
#endif |
| 179 |
– |
} |
| 180 |
– |
|
| 140 |
|
static int printVersion = 0; |
| 141 |
|
|
| 142 |
< |
struct lgetopt myopts[] = { |
| 142 |
> |
static struct lgetopt myopts[] = { |
| 143 |
|
{"dlinefile", &ConfigFileEntry.dlinefile, |
| 144 |
|
STRING, "File to use for dline.conf"}, |
| 145 |
|
{"configfile", &ConfigFileEntry.configfile, |
| 243 |
|
GlobalSetOptions.joinfloodcount = 16; |
| 244 |
|
GlobalSetOptions.joinfloodtime = 8; |
| 245 |
|
|
| 246 |
< |
split_servers = ConfigChannel.default_split_server_count; |
| 247 |
< |
split_users = ConfigChannel.default_split_user_count; |
| 246 |
> |
GlobalSetOptions.split_servers = ConfigChannel.default_split_server_count; |
| 247 |
> |
GlobalSetOptions.split_users = ConfigChannel.default_split_user_count; |
| 248 |
|
|
| 249 |
< |
if (split_users && split_servers && (ConfigChannel.no_create_on_split || |
| 250 |
< |
ConfigChannel.no_join_on_split)) |
| 249 |
> |
if (GlobalSetOptions.split_users && |
| 250 |
> |
GlobalSetOptions.split_servers && (ConfigChannel.no_create_on_split || |
| 251 |
> |
ConfigChannel.no_join_on_split)) |
| 252 |
|
{ |
| 253 |
|
splitmode = 1; |
| 254 |
|
splitchecking = 1; |
| 279 |
|
init_isupport(); |
| 280 |
|
} |
| 281 |
|
|
| 322 |
– |
/* initialize_server_capabs() |
| 323 |
– |
* |
| 324 |
– |
* inputs - none |
| 325 |
– |
* output - none |
| 326 |
– |
*/ |
| 327 |
– |
static void |
| 328 |
– |
initialize_server_capabs(void) |
| 329 |
– |
{ |
| 330 |
– |
add_capability("QS", CAP_QS, 1); |
| 331 |
– |
add_capability("EOB", CAP_EOB, 1); |
| 332 |
– |
add_capability("HUB", CAP_HUB, 0); |
| 333 |
– |
add_capability("TS6", CAP_TS6, 0); |
| 334 |
– |
add_capability("ZIP", CAP_ZIP, 0); |
| 335 |
– |
add_capability("CLUSTER", CAP_CLUSTER, 1); |
| 336 |
– |
#ifdef HALFOPS |
| 337 |
– |
add_capability("HOPS", CAP_HOPS, 1); |
| 338 |
– |
#endif |
| 339 |
– |
} |
| 340 |
– |
|
| 282 |
|
/* write_pidfile() |
| 283 |
|
* |
| 284 |
|
* inputs - filename+path of pid file |
| 354 |
|
#endif |
| 355 |
|
} |
| 356 |
|
|
| 416 |
– |
/* setup_corefile() |
| 417 |
– |
* |
| 418 |
– |
* inputs - nothing |
| 419 |
– |
* output - nothing |
| 420 |
– |
* side effects - setups corefile to system limits. |
| 421 |
– |
* -kre |
| 422 |
– |
*/ |
| 423 |
– |
static void |
| 424 |
– |
setup_corefile(void) |
| 425 |
– |
{ |
| 426 |
– |
#ifdef HAVE_SYS_RESOURCE_H |
| 427 |
– |
struct rlimit rlim; /* resource limits */ |
| 428 |
– |
|
| 429 |
– |
/* Set corefilesize to maximum */ |
| 430 |
– |
if (!getrlimit(RLIMIT_CORE, &rlim)) |
| 431 |
– |
{ |
| 432 |
– |
rlim.rlim_cur = rlim.rlim_max; |
| 433 |
– |
setrlimit(RLIMIT_CORE, &rlim); |
| 434 |
– |
} |
| 435 |
– |
#endif |
| 436 |
– |
} |
| 437 |
– |
|
| 357 |
|
/* init_ssl() |
| 358 |
|
* |
| 359 |
|
* inputs - nothing |
| 361 |
|
* side effects - setups SSL context. |
| 362 |
|
*/ |
| 363 |
|
static void |
| 364 |
< |
init_ssl(void) |
| 364 |
> |
ssl_init(void) |
| 365 |
|
{ |
| 366 |
|
#ifdef HAVE_LIBCRYPTO |
| 367 |
|
SSL_library_init(); |
| 410 |
|
int old_fdlimit = hard_fdlimit; |
| 411 |
|
int fdmax = va_arg(args, int); |
| 412 |
|
|
| 413 |
< |
/* allow MAXCLIENTS_MIN clients even at the cost of MAX_BUFFER and |
| 414 |
< |
* some not really LEAKED_FDS */ |
| 415 |
< |
fdmax = IRCD_MAX(fdmax, LEAKED_FDS + MAX_BUFFER + MAXCLIENTS_MIN); |
| 413 |
> |
/* |
| 414 |
> |
* allow MAXCLIENTS_MIN clients even at the cost of MAX_BUFFER and |
| 415 |
> |
* some not really LEAKED_FDS |
| 416 |
> |
*/ |
| 417 |
> |
fdmax = LIBIO_MAX(fdmax, LEAKED_FDS + MAX_BUFFER + MAXCLIENTS_MIN); |
| 418 |
|
|
| 419 |
|
pass_callback(fdlimit_hook, fdmax); |
| 420 |
|
|
| 446 |
|
|
| 447 |
|
/* Setup corefile size immediately after boot -kre */ |
| 448 |
|
setup_corefile(); |
| 528 |
– |
|
| 529 |
– |
/* set initialVMTop before we allocate any memory */ |
| 530 |
– |
initialVMTop = get_vm_top(); |
| 449 |
|
#endif |
| 450 |
|
|
| 451 |
|
memset(&ServerInfo, 0, sizeof(ServerInfo)); |
| 478 |
|
exit(EXIT_FAILURE); |
| 479 |
|
} |
| 480 |
|
|
| 481 |
< |
init_ssl(); |
| 481 |
> |
ssl_init(); |
| 482 |
|
|
| 483 |
|
#ifndef _WIN32 |
| 484 |
|
if (!server_state.foreground) |
| 493 |
|
|
| 494 |
|
check_pidfile(pidFileName); |
| 495 |
|
setup_signals(); |
| 496 |
< |
get_ircd_platform(ircd_platform); |
| 496 |
> |
libio_get_platform(ircd_platform, sizeof(ircd_platform)); |
| 497 |
|
init_log(logFileName); |
| 498 |
|
ServerInfo.can_use_v6 = check_can_use_v6(); |
| 499 |
|
|
| 507 |
|
|
| 508 |
|
SetMe(&me); |
| 509 |
|
make_server(&me); |
| 510 |
+ |
|
| 511 |
|
dlinkAdd(&me, &me.node, &global_client_list); |
| 512 |
|
dlinkAdd(&me, make_dlink_node(), &global_serv_list); |
| 513 |
|
|
| 514 |
|
init_callbacks(); |
| 515 |
|
initialize_message_files(); |
| 516 |
< |
init_hash(); |
| 516 |
> |
hash_init(); |
| 517 |
|
init_ip_hash_table(); /* client host ip hash table */ |
| 599 |
– |
init_host_hash(); /* Host-hashtable. */ |
| 518 |
|
clear_tree_parse(); |
| 519 |
|
init_client(); |
| 520 |
|
init_class(); |
| 521 |
< |
init_whowas(); |
| 522 |
< |
init_auth(); /* Initialise the auth code */ |
| 523 |
< |
init_channels(); |
| 521 |
> |
whowas_init(); |
| 522 |
> |
watch_init(); |
| 523 |
> |
|
| 524 |
> |
init_auth(); |
| 525 |
> |
channel_init(); |
| 526 |
|
init_channel_modes(); |
| 527 |
< |
initialize_server_capabs(); /* Set up default_server_capabs */ |
| 527 |
> |
server_init(); |
| 528 |
|
|
| 529 |
|
read_conf_files(1); /* cold start init conf files */ |
| 610 |
– |
check_class(); |
| 611 |
– |
init_watch(); |
| 530 |
|
|
| 531 |
|
if (ServerInfo.name == NULL) |
| 532 |
|
{ |
| 575 |
|
|
| 576 |
|
ilog(L_NOTICE, "Server Ready"); |
| 577 |
|
|
| 660 |
– |
eventAddIsh("cleanup_glines", cleanup_glines, NULL, CLEANUP_GLINES_TIME); |
| 578 |
|
eventAddIsh("cleanup_tklines", cleanup_tklines, NULL, CLEANUP_TKLINES_TIME); |
| 579 |
|
|
| 580 |
|
/* We want try_connections to be called as soon as possible now! -- adrian */ |