X-Git-Url: https://jfr.im/git/irc/rqf/shadowircd.git/blobdiff_plain/57b7610916d2cee677e065bec5c39f80291e9f51..8a78afe43d8c11af9e1d50ef438f0f193dcd12b3:/src/ircd.c diff --git a/src/ircd.c b/src/ircd.c index 5e108e0..bf13e0d 100644 --- a/src/ircd.c +++ b/src/ircd.c @@ -65,18 +65,7 @@ #include "monitor.h" #include "patchlevel.h" #include "serno.h" - -/* - * Try and find the correct name to use with getrlimit() for setting the max. - * number of files allowed to be open by this process. - */ -int _charybdis_data_version = CHARYBDIS_DV; - -extern int ServerRunning; -extern struct LocalUser meLocalUser; -extern char **myargv; - -int maxconnections; +#include "sslproc.h" /* /quote set variables */ struct SetOptions GlobalSetOptions; @@ -86,11 +75,73 @@ struct config_file_entry ConfigFileEntry; /* server info set from ircd.conf */ struct server_info ServerInfo; /* admin info set from ircd.conf */ -struct admin_info AdminInfo; - +struct admin_info AdminInfo; + struct Counter Count; struct ServerStatistics ServerStats; +int maxconnections; +struct timeval SystemTime; +struct Client me; /* That's me */ +struct LocalUser meLocalUser; /* That's also part of me */ + +rb_dlink_list lclient_list = { NULL, NULL, 0 }; +rb_dlink_list global_client_list = { NULL, NULL, 0 }; +rb_dlink_list global_channel_list = { NULL, NULL, 0 }; + +rb_dlink_list unknown_list; /* unknown clients ON this server only */ +rb_dlink_list serv_list; /* local servers to this server ONLY */ +rb_dlink_list global_serv_list; /* global servers on the network */ +rb_dlink_list local_oper_list; /* our opers, duplicated in lclient_list */ +rb_dlink_list oper_list; /* network opers */ + +time_t startup_time; + +int default_server_capabs = CAP_MASK; + +int splitmode; +int splitchecking; +int split_users; +int split_servers; +int eob_count; + +unsigned long initialVMTop = 0; /* top of virtual memory at init */ +const char *logFileName = LPATH; +const char *pidFileName = PPATH; + +char **myargv; +int dorehash = 0; +int dorehashbans = 0; +int doremotd = 0; +int kline_queued = 0; +int server_state_foreground = 0; +int opers_see_all_users = 0; +int ssl_ok = 0; +int zlib_ok = 1; + +int testing_conf = 0; + +struct config_channel_entry ConfigChannel; +rb_bh *channel_heap; +rb_bh *ban_heap; +rb_bh *topic_heap; +rb_bh *member_heap; + +rb_bh *client_heap = NULL; +rb_bh *lclient_heap = NULL; +rb_bh *pclient_heap = NULL; + +char current_uid[IDLEN]; + +/* patricia */ +rb_bh *prefix_heap; +rb_bh *node_heap; +rb_bh *patricia_heap; + +rb_bh *linebuf_heap; + +rb_bh *dnode_heap; + /* * print_startup - print startup information */ @@ -135,9 +186,12 @@ ircd_restart_cb(const char *str) static void ircd_die_cb(const char *str) { - /* Try to get the message out to currently logged in operators. */ - sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "Server panic! %s", str); - inotice("server panic: %s", str); + if(str != NULL) + { + /* Try to get the message out to currently logged in operators. */ + sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "Server panic! %s", str); + inotice("server panic: %s", str); + } unlink(pidFileName); exit(EXIT_FAILURE); @@ -282,7 +336,7 @@ initialize_global_set_options(void) GlobalSetOptions.maxclients = ServerInfo.default_max_clients; - if(GlobalSetOptions.maxclients > (maxconnections - MAX_BUFFER)) + if(GlobalSetOptions.maxclients > (maxconnections - MAX_BUFFER) || (GlobalSetOptions.maxclients <= 0)) GlobalSetOptions.maxclients = maxconnections - MAX_BUFFER; GlobalSetOptions.autoconn = 1; @@ -447,7 +501,6 @@ main(int argc, char *argv[]) */ setup_corefile(); - ServerRunning = 0; /* It ain't random, but it ought to be a little harder to guess */ srand(SystemTime.tv_sec ^ (SystemTime.tv_usec | (getpid() << 20))); memset(&me, 0, sizeof(me)); @@ -565,6 +618,8 @@ main(int argc, char *argv[]) mod_add_path(MODULE_DIR "/autoload"); #endif + init_ssld(); + initialize_server_capabs(); /* Set up default_server_capabs */ initialize_global_set_options(); @@ -591,6 +646,18 @@ main(int argc, char *argv[]) } strlcpy(me.info, ServerInfo.description, sizeof(me.info)); + if(ServerInfo.ssl_cert != NULL && ServerInfo.ssl_private_key != NULL) + { + /* just do the rb_setup_ssl_server to validate the config */ + if(!rb_setup_ssl_server(ServerInfo.ssl_cert, ServerInfo.ssl_private_key, ServerInfo.ssl_dh_params)) + { + ilog(L_MAIN, "WARNING: Unable to setup SSL."); + ssl_ok = 0; + } + else + ssl_ok = 1; + } + if (testing_conf) { fprintf(stderr, "\nConfig testing complete.\n"); @@ -628,8 +695,6 @@ main(int argc, char *argv[]) rb_event_addish("try_connections", try_connections, NULL, STARTUP_CONNECTIONS_TIME); rb_event_addonce("try_connections_startup", try_connections, NULL, 0); - rb_event_addish("collect_zipstats", collect_zipstats, NULL, ZIPSTATS_TIME); - /* Setup the timeout check. I'll shift it later :) -- adrian */ rb_event_addish("rb_checktimeouts", rb_checktimeouts, NULL, 1); @@ -638,11 +703,9 @@ main(int argc, char *argv[]) if(splitmode) check_splitmode_ev = rb_event_add("check_splitmode", check_splitmode, NULL, 2); - ServerRunning = 1; - print_startup(getpid()); - rb_lib_loop(250); + rb_lib_loop(0); return 0; }