]> jfr.im git - irc/rqf/shadowircd.git/blame - src/ircd.c
mode api: Remove most modes from the chmode_table, and have them initialized in modes...
[irc/rqf/shadowircd.git] / src / ircd.c
CommitLineData
212380e3 1/*
b1d6fa8c 2 * charybdis: A slightly useful ircd.
212380e3 3 * ircd.c: Starts up and runs the ircd.
4 *
5 * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
6 * Copyright (C) 1996-2002 Hybrid Development Team
b1d6fa8c
VY
7 * Copyright (C) 2002-2008 ircd-ratbox development team
8 * Copyright (C) 2005-2008 charybdis development team
212380e3 9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 * USA
24 *
b1d6fa8c 25 * $Id$
212380e3 26 */
27
7bab07d4 28#include "ratbox_lib.h"
212380e3 29#include "stdinc.h"
30#include "setup.h"
31#include "config.h"
212380e3 32#include "ircd.h"
33#include "channel.h"
34#include "class.h"
35#include "client.h"
36#include "common.h"
212380e3 37#include "hash.h"
13ae2f4b 38#include "match.h"
212380e3 39#include "ircd_signal.h"
212380e3 40#include "msg.h" /* msgtab */
41#include "hostmask.h"
42#include "numeric.h"
43#include "parse.h"
44#include "res.h"
45#include "restart.h"
46#include "s_auth.h"
212380e3 47#include "s_conf.h"
d3455e2c 48#include "logger.h"
212380e3 49#include "s_serv.h" /* try_connections */
50#include "s_user.h"
51#include "s_stats.h"
52#include "scache.h"
53#include "send.h"
54#include "supported.h"
55#include "whowas.h"
56#include "modules.h"
212380e3 57#include "hook.h"
58#include "ircd_getopt.h"
212380e3 59#include "newconf.h"
212380e3 60#include "reject.h"
61#include "s_conf.h"
62#include "s_newconf.h"
63#include "cache.h"
64#include "monitor.h"
212380e3 65#include "patchlevel.h"
66#include "serno.h"
8db00894 67#include "sslproc.h"
75818939 68#include "chmode.h"
001f5f67 69#include "privilege.h"
58af12a2 70#include "bandbi.h"
212380e3 71
b717a466 72/* /quote set variables */
7bab07d4 73struct SetOptions GlobalSetOptions;
b717a466
JT
74
75/* configuration set from ircd.conf */
76struct config_file_entry ConfigFileEntry;
77/* server info set from ircd.conf */
78struct server_info ServerInfo;
79/* admin info set from ircd.conf */
f0dd4837
VY
80struct admin_info AdminInfo;
81
b717a466 82struct Counter Count;
83251205
VY
83struct ServerStatistics ServerStats;
84
f0dd4837 85int maxconnections;
b717a466 86struct Client me; /* That's me */
f0dd4837
VY
87struct LocalUser meLocalUser; /* That's also part of me */
88
fd4535aa 89rb_dlink_list global_client_list;
b717a466 90
fd4535aa 91/* unknown/client pointer lists */
b717a466 92rb_dlink_list unknown_list; /* unknown clients ON this server only */
fd4535aa 93rb_dlink_list lclient_list; /* local clients only ON this server */
b717a466
JT
94rb_dlink_list serv_list; /* local servers to this server ONLY */
95rb_dlink_list global_serv_list; /* global servers on the network */
96rb_dlink_list local_oper_list; /* our opers, duplicated in lclient_list */
944de091
VY
97rb_dlink_list oper_list; /* network opers */
98
b717a466 99const char *logFileName = LPATH;
944de091
VY
100const char *pidFileName = PPATH;
101
f0dd4837 102char **myargv;
b717a466
JT
103int dorehash = 0;
104int dorehashbans = 0;
105int doremotd = 0;
106int kline_queued = 0;
107int server_state_foreground = 0;
108int opers_see_all_users = 0;
109int ssl_ok = 0;
110int zlib_ok = 1;
111
112int testing_conf = 0;
b5a93db8 113time_t startup_time;
b717a466 114
b5a93db8 115int default_server_capabs = CAP_MASK;
b717a466 116
b5a93db8
VY
117int splitmode;
118int splitchecking;
119int split_users;
120int split_servers;
121int eob_count;
8db00894 122
6972e25a
VY
123void
124ircd_shutdown(const char *reason)
125{
126 struct Client *target_p;
127 rb_dlink_node *ptr;
128
129 RB_DLINK_FOREACH(ptr, lclient_list.head)
130 {
131 target_p = ptr->data;
132
133 sendto_one(target_p, ":%s NOTICE %s :Server Terminating. %s",
134 me.name, target_p->name, reason);
135 }
136
137 RB_DLINK_FOREACH(ptr, serv_list.head)
138 {
139 target_p = ptr->data;
140
141 sendto_one(target_p, ":%s ERROR :Terminated by %s",
142 me.name, reason);
143 }
144
145 ilog(L_MAIN, "Server Terminating. %s", reason);
359dada2 146 close_logfiles();
6972e25a
VY
147
148 unlink(pidFileName);
149 exit(0);
150}
151
212380e3 152/*
153 * print_startup - print startup information
154 */
155static void
156print_startup(int pid)
157{
158 inotice("now running in %s mode from %s as pid %d ...",
159 !server_state_foreground ? "background" : "foreground",
160 ConfigFileEntry.dpath, pid);
161
162 /* let the parent process know the initialization was successful
163 * -- jilles */
164 if (!server_state_foreground)
165 write(0, ".", 1);
166 fclose(stdin);
167 fclose(stdout);
168 fclose(stderr);
169 open("/dev/null", O_RDWR);
170 dup2(0, 1);
171 dup2(0, 2);
172}
173
212380e3 174/*
175 * init_sys
176 *
177 * inputs - boot_daemon flag
178 * output - none
179 * side effects - if boot_daemon flag is not set, don't daemonize
180 */
181static void
182init_sys(void)
183{
b717a466
JT
184#if defined(RLIMIT_NOFILE) && defined(HAVE_SYS_RESOURCE_H)
185 struct rlimit limit;
186
187 if(!getrlimit(RLIMIT_NOFILE, &limit))
188 {
189 maxconnections = limit.rlim_cur;
190 if(maxconnections <= MAX_BUFFER)
191 {
192 fprintf(stderr, "ERROR: Shell FD limits are too low.\n");
9b37ad07 193 fprintf(stderr, "ERROR: charybdis reserves %d FDs, shell limits must be above this\n", MAX_BUFFER);
b717a466
JT
194 exit(EXIT_FAILURE);
195 }
196 return;
197 }
198#endif /* RLIMIT_FD_MAX */
3fe90825 199 maxconnections = MAXCONNECTIONS;
212380e3 200}
201
202static int
203make_daemon(void)
204{
205 int pid;
206 int pip[2];
207 char c;
208
209 if (pipe(pip) < 0)
210 {
211 perror("pipe");
212 exit(EXIT_FAILURE);
213 }
214 dup2(pip[1], 0);
215 close(pip[1]);
216 if((pid = fork()) < 0)
217 {
218 perror("fork");
219 exit(EXIT_FAILURE);
220 }
221 else if(pid > 0)
222 {
223 close(0);
224 /* Wait for initialization to finish, successfully or
225 * unsuccessfully. Until this point the child may still
226 * write to stdout/stderr.
227 * -- jilles */
228 if (read(pip[0], &c, 1) > 0)
229 exit(EXIT_SUCCESS);
230 else
231 exit(EXIT_FAILURE);
232 }
233
234 close(pip[0]);
235 setsid();
236/* fclose(stdin);
237 fclose(stdout);
238 fclose(stderr); */
239
240 return 0;
241}
242
243static int printVersion = 0;
244
245struct lgetopt myopts[] = {
212380e3 246 {"configfile", &ConfigFileEntry.configfile,
247 STRING, "File to use for ircd.conf"},
212380e3 248 {"logfile", &logFileName,
249 STRING, "File to use for ircd.log"},
250 {"pidfile", &pidFileName,
251 STRING, "File to use for process ID"},
252 {"foreground", &server_state_foreground,
253 YESNO, "Run in foreground (don't detach)"},
254 {"version", &printVersion,
255 YESNO, "Print version and exit"},
256 {"conftest", &testing_conf,
257 YESNO, "Test the configuration files and exit"},
258 {"help", NULL, USAGE, "Print this text"},
259 {NULL, NULL, STRING, NULL},
260};
261
212380e3 262static void
263check_rehash(void *unused)
264{
265 /*
266 * Check to see whether we have to rehash the configuration ..
267 */
268 if(dorehash)
269 {
270 rehash(1);
271 dorehash = 0;
272 }
273
274 if(dorehashbans)
275 {
276 rehash_bans(1);
277 dorehashbans = 0;
278 }
279
280 if(doremotd)
281 {
282 sendto_realops_snomask(SNO_GENERAL, L_ALL,
283 "Got signal SIGUSR1, reloading ircd motd file");
a822ef29 284 cache_user_motd();
212380e3 285 doremotd = 0;
286 }
287}
288
212380e3 289/*
290 * initalialize_global_set_options
291 *
292 * inputs - none
293 * output - none
294 * side effects - This sets all global set options needed
295 */
296static void
297initialize_global_set_options(void)
298{
299 memset(&GlobalSetOptions, 0, sizeof(GlobalSetOptions));
300 /* memset( &ConfigFileEntry, 0, sizeof(ConfigFileEntry)); */
301
b717a466
JT
302 GlobalSetOptions.maxclients = ServerInfo.default_max_clients;
303
304 if(GlobalSetOptions.maxclients > (maxconnections - MAX_BUFFER) || (GlobalSetOptions.maxclients <= 0))
3fe90825
VY
305 GlobalSetOptions.maxclients = maxconnections - MAX_BUFFER;
306
212380e3 307 GlobalSetOptions.autoconn = 1;
308
309 GlobalSetOptions.spam_time = MIN_JOIN_LEAVE_TIME;
310 GlobalSetOptions.spam_num = MAX_JOIN_LEAVE_COUNT;
311
312 if(ConfigFileEntry.default_floodcount)
313 GlobalSetOptions.floodcount = ConfigFileEntry.default_floodcount;
314 else
315 GlobalSetOptions.floodcount = 10;
316
317 split_servers = ConfigChannel.default_split_server_count;
318 split_users = ConfigChannel.default_split_user_count;
319
320 if(split_users && split_servers
321 && (ConfigChannel.no_create_on_split || ConfigChannel.no_join_on_split))
322 {
323 splitmode = 1;
324 splitchecking = 1;
325 }
326
14340828
JH
327 if(ConfigFileEntry.default_ident_timeout)
328 GlobalSetOptions.ident_timeout = ConfigFileEntry.default_ident_timeout;
e50ed244
JH
329 else
330 GlobalSetOptions.ident_timeout = IDENT_TIMEOUT;
212380e3 331
67537fef
G
332 if(ConfigFileEntry.default_operhost)
333 rb_strlcpy(GlobalSetOptions.operhost,
334 ConfigFileEntry.default_operhost,
335 sizeof(GlobalSetOptions.operhost));
336 else
337 rb_strlcpy(GlobalSetOptions.operhost, "", sizeof(GlobalSetOptions.operhost));
338
907468c4 339 rb_strlcpy(GlobalSetOptions.operstring,
212380e3 340 ConfigFileEntry.default_operstring,
341 sizeof(GlobalSetOptions.operstring));
907468c4 342 rb_strlcpy(GlobalSetOptions.adminstring,
212380e3 343 ConfigFileEntry.default_adminstring,
344 sizeof(GlobalSetOptions.adminstring));
345
346 /* memset( &ConfigChannel, 0, sizeof(ConfigChannel)); */
347
348 /* End of global set options */
349
350}
351
352/*
353 * initialize_server_capabs
354 *
355 * inputs - none
356 * output - none
357 */
358static void
359initialize_server_capabs(void)
360{
361 default_server_capabs &= ~CAP_ZIP;
362}
363
364
365/*
366 * write_pidfile
367 *
368 * inputs - filename+path of pid file
369 * output - none
370 * side effects - write the pid of the ircd to filename
371 */
372static void
373write_pidfile(const char *filename)
374{
375 FILE *fb;
376 char buff[32];
377 if((fb = fopen(filename, "w")))
378 {
379 unsigned int pid = (unsigned int) getpid();
380
38e6acdd 381 rb_snprintf(buff, sizeof(buff), "%u\n", pid);
212380e3 382 if((fputs(buff, fb) == -1))
383 {
384 ilog(L_MAIN, "Error writing %u to pid file %s (%s)",
385 pid, filename, strerror(errno));
386 }
387 fclose(fb);
388 return;
389 }
390 else
391 {
392 ilog(L_MAIN, "Error opening pid file %s", filename);
393 }
394}
395
396/*
397 * check_pidfile
398 *
399 * inputs - filename+path of pid file
400 * output - none
401 * side effects - reads pid from pidfile and checks if ircd is in process
402 * list. if it is, gracefully exits
403 * -kre
404 */
405static void
406check_pidfile(const char *filename)
407{
408 FILE *fb;
409 char buff[32];
410 pid_t pidfromfile;
411
412 /* Don't do logging here, since we don't have log() initialised */
413 if((fb = fopen(filename, "r")))
414 {
415 if(fgets(buff, 20, fb) != NULL)
416 {
417 pidfromfile = atoi(buff);
418 if(!kill(pidfromfile, 0))
419 {
420 printf("ircd: daemon is already running\n");
421 exit(-1);
422 }
423 }
424 fclose(fb);
425 }
426}
427
428/*
429 * setup_corefile
430 *
431 * inputs - nothing
432 * output - nothing
433 * side effects - setups corefile to system limits.
434 * -kre
435 */
436static void
437setup_corefile(void)
438{
439#ifdef HAVE_SYS_RESOURCE_H
440 struct rlimit rlim; /* resource limits */
441
442 /* Set corefilesize to maximum */
443 if(!getrlimit(RLIMIT_CORE, &rlim))
444 {
445 rlim.rlim_cur = rlim.rlim_max;
446 setrlimit(RLIMIT_CORE, &rlim);
447 }
448#endif
449}
450
b1d6fa8c
VY
451static void
452ircd_log_cb(const char *str)
453{
94c10015 454 ilog(L_MAIN, "libratbox reports: %s", str);
b1d6fa8c
VY
455}
456
457static void
458ircd_restart_cb(const char *str)
459{
2d9a60fe 460 inotice("libratbox has called the restart callback: %s", str);
b1d6fa8c
VY
461 restart(str);
462}
463
464/*
465 * Why EXIT_FAILURE here?
466 * Because if ircd_die_cb() is called it's because of a fatal
467 * error inside libcharybdis, and we don't know how to handle the
468 * exception, so it is logical to return a FAILURE exit code here.
469 * --nenolod
470 */
471static void
472ircd_die_cb(const char *str)
473{
474 if(str != NULL)
475 {
476 /* Try to get the message out to currently logged in operators. */
94c10015
VY
477 sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "libratbox has called the die callback..aborting: %s", str);
478 inotice("libratbox has called the die callback..aborting: %s", str);
b1d6fa8c 479 }
94c10015 480 else
2d9a60fe 481 inotice("libratbox has called the die callback..aborting");
b1d6fa8c
VY
482
483 unlink(pidFileName);
484 exit(EXIT_FAILURE);
485}
486
ccfe0e97
WP
487struct ev_entry *check_splitmode_ev = NULL;
488
8dd8b3e2
VY
489static int
490seed_with_urandom(void)
491{
492 unsigned int seed;
493 int fd;
494
495 fd = open("/dev/urandom", O_RDONLY);
496 if(fd >= 0)
497 {
498 if(read(fd, &seed, sizeof(seed)) == sizeof(seed))
499 {
500 close(fd);
501 srand(seed);
502 return 1;
503 }
504 }
505 return 0;
506}
507
508static void
509seed_with_clock(void)
510{
511 const struct timeval *tv;
512 rb_set_time();
513 tv = rb_current_time_tv();
514 srand(tv->tv_sec ^ (tv->tv_usec | (getpid() << 20)));
515}
516
517static void
518seed_random(void *unused)
519{
520 unsigned int seed;
521 if(rb_get_random(&seed, sizeof(seed)) == -1)
522 {
523 if(!seed_with_urandom())
524 seed_with_clock();
525 return;
526 }
527 srand(seed);
528}
529
212380e3 530/*
531 * main
532 *
533 * Initializes the IRCd.
534 *
535 * Inputs - number of commandline args, args themselves
536 * Outputs - none
537 * Side Effects - this is where the ircd gets going right now
538 */
539int
540main(int argc, char *argv[])
541{
542 int fd;
543
544 /* Check to see if the user is running us as root, which is a nono */
545 if(geteuid() == 0)
546 {
547 fprintf(stderr, "Don't run ircd as root!!!\n");
548 return -1;
549 }
550
9a7b24a6
VY
551 init_sys();
552
f43b492b
JT
553 ConfigFileEntry.dpath = DPATH;
554 ConfigFileEntry.configfile = CPATH; /* Server configuration file */
f43b492b
JT
555 ConfigFileEntry.connect_timeout = 30; /* Default to 30 */
556
557 umask(077); /* better safe than sorry --SRB */
9a7b24a6
VY
558
559 myargv = argv;
560 parseargs(&argc, &argv, myopts);
561
562 if(chdir(ConfigFileEntry.dpath))
563 {
564 fprintf(stderr, "Unable to chdir to %s: %s\n", ConfigFileEntry.dpath, strerror(errno));
565 exit(EXIT_FAILURE);
566 }
567
fd4535aa
VY
568 rb_set_time();
569
212380e3 570 /*
571 * Setup corefile size immediately after boot -kre
572 */
573 setup_corefile();
574
212380e3 575 memset(&me, 0, sizeof(me));
576 memset(&meLocalUser, 0, sizeof(meLocalUser));
577 me.localClient = &meLocalUser;
578
579 /* Make sure all lists are zeroed */
580 memset(&unknown_list, 0, sizeof(unknown_list));
581 memset(&lclient_list, 0, sizeof(lclient_list));
582 memset(&serv_list, 0, sizeof(serv_list));
583 memset(&global_serv_list, 0, sizeof(global_serv_list));
584 memset(&local_oper_list, 0, sizeof(local_oper_list));
585 memset(&oper_list, 0, sizeof(oper_list));
586
af81d5a0 587 rb_dlinkAddTail(&me, &me.node, &global_client_list);
212380e3 588
7bab07d4
VY
589 memset(&Count, 0, sizeof(Count));
590 memset(&ServerInfo, 0, sizeof(ServerInfo));
591 memset(&AdminInfo, 0, sizeof(AdminInfo));
592 memset(&ServerStats, 0, sizeof(struct ServerStatistics));
212380e3 593
594 /* Initialise the channel capability usage counts... */
595 init_chcap_usage_counts();
596
212380e3 597 if(printVersion)
598 {
7f980188 599 printf("ircd: version %s(%s)\n", ircd_version, serno);
b0ef251c 600 printf("ircd: %s\n", rb_lib_version());
212380e3 601 exit(EXIT_SUCCESS);
602 }
603
9a7b24a6 604
212380e3 605
606 setup_signals();
607
212380e3 608 if (testing_conf)
609 server_state_foreground = 1;
610
611 /* Make sure fd 0, 1 and 2 are in use -- jilles */
612 do
613 {
614 fd = open("/dev/null", O_RDWR);
615 } while (fd < 2 && fd != -1);
616 if (fd > 2)
617 close(fd);
618 else if (fd == -1)
619 exit(1);
620
621 /* Check if there is pidfile and daemon already running */
622 if(!testing_conf)
623 {
624 check_pidfile(pidFileName);
625
626 if(!server_state_foreground)
627 make_daemon();
628 inotice("starting %s ...", ircd_version);
7b52cd51 629 inotice("%s", rb_lib_version());
212380e3 630 }
631
632 /* Init the event subsystem */
15f1b609 633 rb_lib_init(ircd_log_cb, ircd_restart_cb, ircd_die_cb, !server_state_foreground, maxconnections, DNODE_HEAP_SIZE, FD_HEAP_SIZE);
348684d2 634 rb_linebuf_init(LINEBUF_HEAP_SIZE);
212380e3 635
2b454b76
VY
636 if(ConfigFileEntry.use_egd && (ConfigFileEntry.egdpool_path != NULL))
637 {
638 rb_init_prng(ConfigFileEntry.egdpool_path, RB_PRNG_EGD);
639 } else
640 rb_init_prng(NULL, RB_PRNG_DEFAULT);
641
2a64312f
VY
642 seed_random(NULL);
643
1fe75e33 644 init_module_modes();
212380e3 645 init_main_logfile();
212380e3 646 newconf_init();
647 init_s_conf();
648 init_s_newconf();
649 init_hash();
650 clear_scache_hash_table(); /* server cache name table */
651 init_host_hash();
652 clear_hash_parse();
653 init_client();
212380e3 654 init_hook();
655 init_channels();
656 initclass();
657 initwhowas();
212380e3 658 init_reject();
659 init_cache();
660 init_monitor();
661 init_isupport();
a9f16d80 662
6795400d 663 construct_cflags_strings();
a9f16d80 664
212380e3 665 load_all_modules(1);
666#ifndef STATIC_MODULES
667 load_core_modules(1);
668#endif
669 init_auth(); /* Initialise the auth code */
670 init_resolver(); /* Needs to be setup before the io loop */
001f5f67 671 privilegeset_set_new("default", "", 0);
212380e3 672
673 if (testing_conf)
674 fprintf(stderr, "\nBeginning config test\n");
675 read_conf_files(YES); /* cold start init conf files */
212380e3 676#ifndef STATIC_MODULES
677
678 mod_add_path(MODULE_DIR);
679 mod_add_path(MODULE_DIR "/autoload");
680#endif
681
58af12a2 682 init_bandb();
8db00894
VY
683 init_ssld();
684
9f025822
WP
685 rehash_bans(0);
686
212380e3 687 initialize_server_capabs(); /* Set up default_server_capabs */
688 initialize_global_set_options();
689
690 if(ServerInfo.name == NULL)
691 {
692 ierror("no server name specified in serverinfo block.");
693 return -1;
694 }
907468c4 695 rb_strlcpy(me.name, ServerInfo.name, sizeof(me.name));
212380e3 696
697 if(ServerInfo.sid[0] == '\0')
698 {
699 ierror("no server sid specified in serverinfo block.");
700 return -2;
701 }
702 strcpy(me.id, ServerInfo.sid);
703 init_uid();
704
705 /* serverinfo{} description must exist. If not, error out. */
706 if(ServerInfo.description == NULL)
707 {
708 ierror("no server description specified in serverinfo block.");
709 return -3;
710 }
907468c4 711 rb_strlcpy(me.info, ServerInfo.description, sizeof(me.info));
212380e3 712
b717a466
JT
713 if(ServerInfo.ssl_cert != NULL && ServerInfo.ssl_private_key != NULL)
714 {
715 /* just do the rb_setup_ssl_server to validate the config */
716 if(!rb_setup_ssl_server(ServerInfo.ssl_cert, ServerInfo.ssl_private_key, ServerInfo.ssl_dh_params))
717 {
718 ilog(L_MAIN, "WARNING: Unable to setup SSL.");
719 ssl_ok = 0;
720 }
721 else
722 ssl_ok = 1;
8db00894
VY
723 }
724
212380e3 725 if (testing_conf)
726 {
727 fprintf(stderr, "\nConfig testing complete.\n");
728 fflush(stderr);
729 return 0; /* Why? We want the launcher to exit out. */
730 }
731
732 me.from = &me;
733 me.servptr = &me;
734 SetMe(&me);
735 make_server(&me);
9f6bbe3c 736 startup_time = rb_current_time();
212380e3 737 add_to_client_hash(me.name, &me);
738 add_to_id_hash(me.id, &me);
994544c2 739 me.serv->nameinfo = scache_connect(me.name, me.info, 0);
212380e3 740
af81d5a0 741 rb_dlinkAddAlloc(&me, &global_serv_list);
212380e3 742
743 construct_umodebuf();
744
745 check_class();
746 write_pidfile(pidFileName);
747 load_help();
748 open_logfiles();
749
750 ilog(L_MAIN, "Server Ready");
751
212380e3 752 /* We want try_connections to be called as soon as possible now! -- adrian */
753 /* No, 'cause after a restart it would cause all sorts of nick collides */
754 /* um. by waiting even longer, that just means we have even *more*
755 * nick collisions. what a stupid idea. set an event for the IO loop --fl
756 */
9e29fe51 757 rb_event_addish("try_connections", try_connections, NULL, STARTUP_CONNECTIONS_TIME);
42706093
VY
758 rb_event_addonce("try_connections_startup", try_connections, NULL, 2);
759 rb_event_add("check_rehash", check_rehash, NULL, 3);
8dd8b3e2 760 rb_event_addish("reseed_srand", seed_random, NULL, 300); /* reseed every 10 minutes */
212380e3 761
212380e3 762 if(splitmode)
42706093 763 check_splitmode_ev = rb_event_add("check_splitmode", check_splitmode, NULL, 5);
212380e3 764
212380e3 765 print_startup(getpid());
766
9b2fe0ba 767 rb_lib_loop(0);
212380e3 768
769 return 0;
770}