#include "client.h"
#include "common.h"
#include "hash.h"
-#include "irc_string.h"
+#include "match.h"
#include "ircd_signal.h"
-#include "sprintf_irc.h"
#include "msg.h" /* msgtab */
#include "hostmask.h"
#include "numeric.h"
#include "patchlevel.h"
#include "serno.h"
#include "sslproc.h"
+#include "chmode.h"
/* /quote set variables */
struct SetOptions GlobalSetOptions;
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 global_client_list;
+/* unknown/client pointer lists */
rb_dlink_list unknown_list; /* unknown clients ON this server only */
+rb_dlink_list lclient_list; /* local clients only ON this server */
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 */
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;
GlobalSetOptions.ident_timeout = IDENT_TIMEOUT;
- strlcpy(GlobalSetOptions.operstring,
+ rb_strlcpy(GlobalSetOptions.operstring,
ConfigFileEntry.default_operstring,
sizeof(GlobalSetOptions.operstring));
- strlcpy(GlobalSetOptions.adminstring,
+ rb_strlcpy(GlobalSetOptions.adminstring,
ConfigFileEntry.default_adminstring,
sizeof(GlobalSetOptions.adminstring));
struct ev_entry *check_splitmode_ev = NULL;
+static int
+seed_with_urandom(void)
+{
+ unsigned int seed;
+ int fd;
+
+ fd = open("/dev/urandom", O_RDONLY);
+ if(fd >= 0)
+ {
+ if(read(fd, &seed, sizeof(seed)) == sizeof(seed))
+ {
+ close(fd);
+ srand(seed);
+ return 1;
+ }
+ }
+ return 0;
+}
+
+static void
+seed_with_clock(void)
+{
+ const struct timeval *tv;
+ rb_set_time();
+ tv = rb_current_time_tv();
+ srand(tv->tv_sec ^ (tv->tv_usec | (getpid() << 20)));
+}
+
+static void
+seed_random(void *unused)
+{
+ unsigned int seed;
+ if(rb_get_random(&seed, sizeof(seed)) == -1)
+ {
+ if(!seed_with_urandom())
+ seed_with_clock();
+ return;
+ }
+ srand(seed);
+}
+
/*
* main
*
return -1;
}
+ rb_set_time();
+
/*
* Setup corefile size immediately after boot -kre
*/
setup_corefile();
- /* 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));
memset(&meLocalUser, 0, sizeof(meLocalUser));
me.localClient = &meLocalUser;
if(printVersion)
{
- printf("ircd: version %s\n", ircd_version);
+ printf("ircd: version %s(%s)\n", ircd_version, serno);
exit(EXIT_SUCCESS);
}
setup_signals();
-#ifdef __CYGWIN__
- server_state_foreground = 1;
-#endif
-
if (testing_conf)
server_state_foreground = 1;
init_host_hash();
clear_hash_parse();
init_client();
- initUser();
init_hook();
init_channels();
initclass();
ierror("no server name specified in serverinfo block.");
return -1;
}
- strlcpy(me.name, ServerInfo.name, sizeof(me.name));
+ rb_strlcpy(me.name, ServerInfo.name, sizeof(me.name));
if(ServerInfo.sid[0] == '\0')
{
ierror("no server description specified in serverinfo block.");
return -3;
}
- strlcpy(me.info, ServerInfo.description, sizeof(me.info));
+ rb_strlcpy(me.info, ServerInfo.description, sizeof(me.info));
if(ServerInfo.ssl_cert != NULL && ServerInfo.ssl_private_key != NULL)
{
rb_dlinkAddAlloc(&me, &global_serv_list);
construct_umodebuf();
+ construct_noparam_modes();
check_class();
write_pidfile(pidFileName);
* nick collisions. what a stupid idea. set an event for the IO loop --fl
*/
rb_event_addish("try_connections", try_connections, NULL, STARTUP_CONNECTIONS_TIME);
- rb_event_addonce("try_connections_startup", try_connections, NULL, 0);
-
- /* Setup the timeout check. I'll shift it later :) -- adrian */
- rb_event_addish("rb_checktimeouts", rb_checktimeouts, NULL, 1);
-
- rb_event_add("check_rehash", check_rehash, NULL, 1);
+ rb_event_addonce("try_connections_startup", try_connections, NULL, 2);
+ rb_event_add("check_rehash", check_rehash, NULL, 3);
+ rb_event_addish("reseed_srand", seed_random, NULL, 300); /* reseed every 10 minutes */
if(splitmode)
- check_splitmode_ev = rb_event_add("check_splitmode", check_splitmode, NULL, 2);
+ check_splitmode_ev = rb_event_add("check_splitmode", check_splitmode, NULL, 5);
print_startup(getpid());