]> jfr.im git - solanum.git/blame - src/ircd.c
ssl: allow cipher list to be overridden (closes #67)
[solanum.git] / src / ircd.c
CommitLineData
212380e3 1/*
6fce54ff 2 * charybdis: A slightly useful ircd.
212380e3
AC
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
6fce54ff 7 * Copyright (C) 2002-2008 ircd-ratbox development team
adef4da1 8 * Copyright (C) 2005-2013 charybdis development team
212380e3
AC
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 *
6fce54ff 25 * $Id$
212380e3
AC
26 */
27
2af8c7ff 28#include "ratbox_lib.h"
212380e3
AC
29#include "stdinc.h"
30#include "setup.h"
31#include "config.h"
212380e3
AC
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"
4562c604 38#include "match.h"
212380e3 39#include "ircd_signal.h"
212380e3
AC
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"
4016731b 48#include "logger.h"
212380e3
AC
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
AC
57#include "hook.h"
58#include "ircd_getopt.h"
212380e3 59#include "newconf.h"
212380e3
AC
60#include "reject.h"
61#include "s_conf.h"
62#include "s_newconf.h"
63#include "cache.h"
64#include "monitor.h"
212380e3
AC
65#include "patchlevel.h"
66#include "serno.h"
c6d72037 67#include "sslproc.h"
efccc22c 68#include "chmode.h"
39a68b53 69#include "privilege.h"
6eebc373 70#include "bandbi.h"
212380e3 71
8bd5767b 72/* /quote set variables */
2af8c7ff 73struct SetOptions GlobalSetOptions;
8bd5767b
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 */
1aad9782
VY
80struct admin_info AdminInfo;
81
8bd5767b 82struct Counter Count;
47adde3d
VY
83struct ServerStatistics ServerStats;
84
1aad9782 85int maxconnections;
8bd5767b 86struct Client me; /* That's me */
1aad9782
VY
87struct LocalUser meLocalUser; /* That's also part of me */
88
3d3d1a95 89rb_dlink_list global_client_list;
8bd5767b 90
3d3d1a95 91/* unknown/client pointer lists */
8bd5767b 92rb_dlink_list unknown_list; /* unknown clients ON this server only */
3d3d1a95 93rb_dlink_list lclient_list; /* local clients only ON this server */
8bd5767b
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 */
b5b84cad
VY
97rb_dlink_list oper_list; /* network opers */
98
8bd5767b 99const char *logFileName = LPATH;
b5b84cad
VY
100const char *pidFileName = PPATH;
101
1aad9782 102char **myargv;
8bd5767b
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;
cd27d99c 113time_t startup_time;
8bd5767b 114
346fba92 115int default_server_capabs;
8bd5767b 116
cd27d99c
VY
117int splitmode;
118int splitchecking;
119int split_users;
120int split_servers;
121int eob_count;
c6d72037 122
fd5af3d0
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);
ea82a3ca 146 close_logfiles();
fd5af3d0
VY
147
148 unlink(pidFileName);
149 exit(0);
150}
151
212380e3
AC
152/*
153 * print_startup - print startup information
154 */
155static void
156print_startup(int pid)
157{
b45b2dae
JT
158 int fd;
159
160 close(1);
161 fd = open("/dev/null", O_RDWR);
162 if (fd == -1) {
163 perror("open /dev/null");
164 exit(EXIT_FAILURE);
165 }
166 if (fd == 0)
167 fd = dup(fd);
168 if (fd != 1)
169 abort();
170
212380e3
AC
171 inotice("now running in %s mode from %s as pid %d ...",
172 !server_state_foreground ? "background" : "foreground",
173 ConfigFileEntry.dpath, pid);
174
175 /* let the parent process know the initialization was successful
176 * -- jilles */
177 if (!server_state_foreground)
178 write(0, ".", 1);
b45b2dae
JT
179 if (dup2(1, 0) == -1)
180 abort();
181 if (dup2(1, 2) == -1)
182 abort();
212380e3
AC
183}
184
212380e3
AC
185/*
186 * init_sys
187 *
188 * inputs - boot_daemon flag
189 * output - none
190 * side effects - if boot_daemon flag is not set, don't daemonize
191 */
192static void
193init_sys(void)
194{
8bd5767b
JT
195#if defined(RLIMIT_NOFILE) && defined(HAVE_SYS_RESOURCE_H)
196 struct rlimit limit;
197
198 if(!getrlimit(RLIMIT_NOFILE, &limit))
199 {
200 maxconnections = limit.rlim_cur;
201 if(maxconnections <= MAX_BUFFER)
202 {
203 fprintf(stderr, "ERROR: Shell FD limits are too low.\n");
ec86417c 204 fprintf(stderr, "ERROR: charybdis reserves %d FDs, shell limits must be above this\n", MAX_BUFFER);
8bd5767b
JT
205 exit(EXIT_FAILURE);
206 }
207 return;
208 }
209#endif /* RLIMIT_FD_MAX */
101db4c4 210 maxconnections = MAXCONNECTIONS;
212380e3
AC
211}
212
213static int
214make_daemon(void)
215{
216 int pid;
217 int pip[2];
218 char c;
219
220 if (pipe(pip) < 0)
221 {
222 perror("pipe");
223 exit(EXIT_FAILURE);
224 }
225 dup2(pip[1], 0);
226 close(pip[1]);
227 if((pid = fork()) < 0)
228 {
229 perror("fork");
230 exit(EXIT_FAILURE);
231 }
232 else if(pid > 0)
233 {
234 close(0);
235 /* Wait for initialization to finish, successfully or
236 * unsuccessfully. Until this point the child may still
237 * write to stdout/stderr.
238 * -- jilles */
239 if (read(pip[0], &c, 1) > 0)
240 exit(EXIT_SUCCESS);
241 else
242 exit(EXIT_FAILURE);
243 }
244
245 close(pip[0]);
246 setsid();
247/* fclose(stdin);
248 fclose(stdout);
249 fclose(stderr); */
250
251 return 0;
252}
253
254static int printVersion = 0;
255
256struct lgetopt myopts[] = {
212380e3
AC
257 {"configfile", &ConfigFileEntry.configfile,
258 STRING, "File to use for ircd.conf"},
212380e3
AC
259 {"logfile", &logFileName,
260 STRING, "File to use for ircd.log"},
261 {"pidfile", &pidFileName,
262 STRING, "File to use for process ID"},
263 {"foreground", &server_state_foreground,
264 YESNO, "Run in foreground (don't detach)"},
265 {"version", &printVersion,
266 YESNO, "Print version and exit"},
267 {"conftest", &testing_conf,
268 YESNO, "Test the configuration files and exit"},
269 {"help", NULL, USAGE, "Print this text"},
270 {NULL, NULL, STRING, NULL},
271};
272
212380e3
AC
273static void
274check_rehash(void *unused)
275{
276 /*
277 * Check to see whether we have to rehash the configuration ..
278 */
279 if(dorehash)
280 {
281 rehash(1);
282 dorehash = 0;
283 }
284
285 if(dorehashbans)
286 {
287 rehash_bans(1);
288 dorehashbans = 0;
289 }
290
291 if(doremotd)
292 {
293 sendto_realops_snomask(SNO_GENERAL, L_ALL,
294 "Got signal SIGUSR1, reloading ircd motd file");
041d54ff 295 cache_user_motd();
212380e3
AC
296 doremotd = 0;
297 }
298}
299
212380e3
AC
300/*
301 * initalialize_global_set_options
302 *
303 * inputs - none
304 * output - none
55abcbb2 305 * side effects - This sets all global set options needed
212380e3
AC
306 */
307static void
308initialize_global_set_options(void)
309{
310 memset(&GlobalSetOptions, 0, sizeof(GlobalSetOptions));
311 /* memset( &ConfigFileEntry, 0, sizeof(ConfigFileEntry)); */
312
8bd5767b
JT
313 GlobalSetOptions.maxclients = ServerInfo.default_max_clients;
314
315 if(GlobalSetOptions.maxclients > (maxconnections - MAX_BUFFER) || (GlobalSetOptions.maxclients <= 0))
101db4c4
VY
316 GlobalSetOptions.maxclients = maxconnections - MAX_BUFFER;
317
212380e3
AC
318 GlobalSetOptions.autoconn = 1;
319
320 GlobalSetOptions.spam_time = MIN_JOIN_LEAVE_TIME;
321 GlobalSetOptions.spam_num = MAX_JOIN_LEAVE_COUNT;
322
7f3382fe 323 GlobalSetOptions.floodcount = ConfigFileEntry.default_floodcount;
212380e3
AC
324
325 split_servers = ConfigChannel.default_split_server_count;
326 split_users = ConfigChannel.default_split_user_count;
327
328 if(split_users && split_servers
329 && (ConfigChannel.no_create_on_split || ConfigChannel.no_join_on_split))
330 {
331 splitmode = 1;
332 splitchecking = 1;
333 }
334
7f3382fe 335 GlobalSetOptions.ident_timeout = ConfigFileEntry.default_ident_timeout;
212380e3 336
f427c8b0 337 rb_strlcpy(GlobalSetOptions.operstring,
212380e3
AC
338 ConfigFileEntry.default_operstring,
339 sizeof(GlobalSetOptions.operstring));
f427c8b0 340 rb_strlcpy(GlobalSetOptions.adminstring,
212380e3
AC
341 ConfigFileEntry.default_adminstring,
342 sizeof(GlobalSetOptions.adminstring));
343
344 /* memset( &ConfigChannel, 0, sizeof(ConfigChannel)); */
345
346 /* End of global set options */
347
348}
349
350/*
351 * initialize_server_capabs
352 *
353 * inputs - none
354 * output - none
355 */
356static void
357initialize_server_capabs(void)
358{
359 default_server_capabs &= ~CAP_ZIP;
360}
361
362
363/*
364 * write_pidfile
365 *
366 * inputs - filename+path of pid file
367 * output - none
368 * side effects - write the pid of the ircd to filename
369 */
370static void
371write_pidfile(const char *filename)
372{
373 FILE *fb;
374 char buff[32];
375 if((fb = fopen(filename, "w")))
376 {
377 unsigned int pid = (unsigned int) getpid();
378
b2f0da88 379 rb_snprintf(buff, sizeof(buff), "%u\n", pid);
212380e3
AC
380 if((fputs(buff, fb) == -1))
381 {
382 ilog(L_MAIN, "Error writing %u to pid file %s (%s)",
383 pid, filename, strerror(errno));
384 }
385 fclose(fb);
386 return;
387 }
388 else
389 {
390 ilog(L_MAIN, "Error opening pid file %s", filename);
391 }
392}
393
394/*
395 * check_pidfile
396 *
397 * inputs - filename+path of pid file
398 * output - none
399 * side effects - reads pid from pidfile and checks if ircd is in process
400 * list. if it is, gracefully exits
401 * -kre
402 */
403static void
404check_pidfile(const char *filename)
405{
406 FILE *fb;
407 char buff[32];
408 pid_t pidfromfile;
409
410 /* Don't do logging here, since we don't have log() initialised */
411 if((fb = fopen(filename, "r")))
412 {
413 if(fgets(buff, 20, fb) != NULL)
414 {
415 pidfromfile = atoi(buff);
416 if(!kill(pidfromfile, 0))
417 {
418 printf("ircd: daemon is already running\n");
419 exit(-1);
420 }
421 }
422 fclose(fb);
423 }
424}
425
426/*
427 * setup_corefile
428 *
429 * inputs - nothing
430 * output - nothing
431 * side effects - setups corefile to system limits.
432 * -kre
433 */
434static void
435setup_corefile(void)
436{
437#ifdef HAVE_SYS_RESOURCE_H
438 struct rlimit rlim; /* resource limits */
439
440 /* Set corefilesize to maximum */
441 if(!getrlimit(RLIMIT_CORE, &rlim))
442 {
443 rlim.rlim_cur = rlim.rlim_max;
444 setrlimit(RLIMIT_CORE, &rlim);
445 }
446#endif
447}
448
6fce54ff
VY
449static void
450ircd_log_cb(const char *str)
451{
6643434b 452 ilog(L_MAIN, "libratbox reports: %s", str);
6fce54ff
VY
453}
454
455static void
456ircd_restart_cb(const char *str)
457{
b1daa815 458 inotice("libratbox has called the restart callback: %s", str);
6fce54ff
VY
459 restart(str);
460}
461
462/*
463 * Why EXIT_FAILURE here?
464 * Because if ircd_die_cb() is called it's because of a fatal
465 * error inside libcharybdis, and we don't know how to handle the
466 * exception, so it is logical to return a FAILURE exit code here.
467 * --nenolod
468 */
469static void
470ircd_die_cb(const char *str)
471{
472 if(str != NULL)
473 {
474 /* Try to get the message out to currently logged in operators. */
6643434b
VY
475 sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "libratbox has called the die callback..aborting: %s", str);
476 inotice("libratbox has called the die callback..aborting: %s", str);
6fce54ff 477 }
6643434b 478 else
b1daa815 479 inotice("libratbox has called the die callback..aborting");
6fce54ff
VY
480
481 unlink(pidFileName);
482 exit(EXIT_FAILURE);
483}
484
fa832850
AC
485struct ev_entry *check_splitmode_ev = NULL;
486
d80645d0
VY
487static int
488seed_with_urandom(void)
489{
490 unsigned int seed;
491 int fd;
492
493 fd = open("/dev/urandom", O_RDONLY);
494 if(fd >= 0)
495 {
496 if(read(fd, &seed, sizeof(seed)) == sizeof(seed))
497 {
498 close(fd);
499 srand(seed);
500 return 1;
501 }
5457b102 502 close(fd);
d80645d0
VY
503 }
504 return 0;
505}
506
507static void
508seed_with_clock(void)
509{
55abcbb2 510 const struct timeval *tv;
d80645d0
VY
511 rb_set_time();
512 tv = rb_current_time_tv();
513 srand(tv->tv_sec ^ (tv->tv_usec | (getpid() << 20)));
514}
515
516static void
517seed_random(void *unused)
518{
519 unsigned int seed;
520 if(rb_get_random(&seed, sizeof(seed)) == -1)
521 {
522 if(!seed_with_urandom())
523 seed_with_clock();
524 return;
525 }
526 srand(seed);
527}
528
212380e3
AC
529/*
530 * main
531 *
532 * Initializes the IRCd.
533 *
534 * Inputs - number of commandline args, args themselves
535 * Outputs - none
536 * Side Effects - this is where the ircd gets going right now
537 */
538int
539main(int argc, char *argv[])
540{
541 int fd;
542
543 /* Check to see if the user is running us as root, which is a nono */
544 if(geteuid() == 0)
545 {
546 fprintf(stderr, "Don't run ircd as root!!!\n");
547 return -1;
548 }
549
adc7be98
VY
550 init_sys();
551
befa24c8
JT
552 ConfigFileEntry.dpath = DPATH;
553 ConfigFileEntry.configfile = CPATH; /* Server configuration file */
befa24c8 554 ConfigFileEntry.connect_timeout = 30; /* Default to 30 */
346fba92 555
befa24c8 556 umask(077); /* better safe than sorry --SRB */
adc7be98
VY
557
558 myargv = argv;
559 parseargs(&argc, &argv, myopts);
560
561 if(chdir(ConfigFileEntry.dpath))
562 {
563 fprintf(stderr, "Unable to chdir to %s: %s\n", ConfigFileEntry.dpath, strerror(errno));
564 exit(EXIT_FAILURE);
565 }
566
3d3d1a95
VY
567 rb_set_time();
568
212380e3
AC
569 /*
570 * Setup corefile size immediately after boot -kre
571 */
572 setup_corefile();
573
212380e3
AC
574 memset(&me, 0, sizeof(me));
575 memset(&meLocalUser, 0, sizeof(meLocalUser));
576 me.localClient = &meLocalUser;
577
578 /* Make sure all lists are zeroed */
579 memset(&unknown_list, 0, sizeof(unknown_list));
580 memset(&lclient_list, 0, sizeof(lclient_list));
581 memset(&serv_list, 0, sizeof(serv_list));
582 memset(&global_serv_list, 0, sizeof(global_serv_list));
583 memset(&local_oper_list, 0, sizeof(local_oper_list));
584 memset(&oper_list, 0, sizeof(oper_list));
585
330fc5c1 586 rb_dlinkAddTail(&me, &me.node, &global_client_list);
212380e3 587
2af8c7ff
VY
588 memset(&Count, 0, sizeof(Count));
589 memset(&ServerInfo, 0, sizeof(ServerInfo));
590 memset(&AdminInfo, 0, sizeof(AdminInfo));
591 memset(&ServerStats, 0, sizeof(struct ServerStatistics));
212380e3 592
212380e3
AC
593 if(printVersion)
594 {
b3803848 595 printf("ircd: version %s(%s)\n", ircd_version, serno);
8bd1c8a1
AC
596#ifdef CUSTOM_BRANDING
597 printf("ircd: based on %s-%s\n", PACKAGE_NAME, PACKAGE_VERSION);
598#endif
d2b6b9f3 599 printf("ircd: %s\n", rb_lib_version());
212380e3
AC
600 exit(EXIT_SUCCESS);
601 }
602
212380e3
AC
603 setup_signals();
604
212380e3
AC
605 if (testing_conf)
606 server_state_foreground = 1;
607
608 /* Make sure fd 0, 1 and 2 are in use -- jilles */
609 do
610 {
611 fd = open("/dev/null", O_RDWR);
612 } while (fd < 2 && fd != -1);
613 if (fd > 2)
614 close(fd);
615 else if (fd == -1)
616 exit(1);
617
618 /* Check if there is pidfile and daemon already running */
619 if(!testing_conf)
620 {
621 check_pidfile(pidFileName);
622
623 if(!server_state_foreground)
624 make_daemon();
625 inotice("starting %s ...", ircd_version);
31c86ea8 626 inotice("%s", rb_lib_version());
212380e3
AC
627 }
628
629 /* Init the event subsystem */
0edb29fa 630 rb_lib_init(ircd_log_cb, ircd_restart_cb, ircd_die_cb, !server_state_foreground, maxconnections, DNODE_HEAP_SIZE, FD_HEAP_SIZE);
150f35f7 631 rb_linebuf_init(LINEBUF_HEAP_SIZE);
212380e3 632
e861902f 633 rb_init_prng(NULL, RB_PRNG_DEFAULT);
37cd159e 634
e1db84d8
VY
635 seed_random(NULL);
636
346fba92
AC
637 init_builtin_capabs();
638 default_server_capabs = CAP_MASK;
639
212380e3 640 init_main_logfile();
212380e3
AC
641 newconf_init();
642 init_s_conf();
643 init_s_newconf();
644 init_hash();
645 clear_scache_hash_table(); /* server cache name table */
646 init_host_hash();
647 clear_hash_parse();
648 init_client();
212380e3
AC
649 init_hook();
650 init_channels();
651 initclass();
652 initwhowas();
212380e3
AC
653 init_reject();
654 init_cache();
655 init_monitor();
030cdce7 656
19716b9f 657 construct_cflags_strings();
030cdce7 658
212380e3
AC
659 load_all_modules(1);
660#ifndef STATIC_MODULES
661 load_core_modules(1);
662#endif
663 init_auth(); /* Initialise the auth code */
664 init_resolver(); /* Needs to be setup before the io loop */
39a68b53 665 privilegeset_set_new("default", "", 0);
212380e3
AC
666
667 if (testing_conf)
668 fprintf(stderr, "\nBeginning config test\n");
669 read_conf_files(YES); /* cold start init conf files */
212380e3
AC
670#ifndef STATIC_MODULES
671
55abcbb2
KB
672 mod_add_path(MODULE_DIR);
673 mod_add_path(MODULE_DIR "/autoload");
212380e3
AC
674#endif
675
b583faf9
AC
676 init_isupport();
677
6eebc373 678 init_bandb();
c6d72037
VY
679 init_ssld();
680
80c9ac51
AC
681 rehash_bans(0);
682
212380e3
AC
683 initialize_server_capabs(); /* Set up default_server_capabs */
684 initialize_global_set_options();
685
686 if(ServerInfo.name == NULL)
687 {
688 ierror("no server name specified in serverinfo block.");
689 return -1;
690 }
f427c8b0 691 rb_strlcpy(me.name, ServerInfo.name, sizeof(me.name));
212380e3
AC
692
693 if(ServerInfo.sid[0] == '\0')
694 {
695 ierror("no server sid specified in serverinfo block.");
696 return -2;
697 }
698 strcpy(me.id, ServerInfo.sid);
699 init_uid();
700
701 /* serverinfo{} description must exist. If not, error out. */
702 if(ServerInfo.description == NULL)
703 {
704 ierror("no server description specified in serverinfo block.");
705 return -3;
706 }
f427c8b0 707 rb_strlcpy(me.info, ServerInfo.description, sizeof(me.info));
212380e3 708
8bd5767b
JT
709 if(ServerInfo.ssl_cert != NULL && ServerInfo.ssl_private_key != NULL)
710 {
711 /* just do the rb_setup_ssl_server to validate the config */
c1725bda 712 if(!rb_setup_ssl_server(ServerInfo.ssl_cert, ServerInfo.ssl_private_key, ServerInfo.ssl_dh_params, ServerInfo.ssl_cipher_list))
8bd5767b
JT
713 {
714 ilog(L_MAIN, "WARNING: Unable to setup SSL.");
715 ssl_ok = 0;
716 }
717 else
718 ssl_ok = 1;
c6d72037
VY
719 }
720
212380e3
AC
721 if (testing_conf)
722 {
723 fprintf(stderr, "\nConfig testing complete.\n");
724 fflush(stderr);
725 return 0; /* Why? We want the launcher to exit out. */
726 }
727
728 me.from = &me;
729 me.servptr = &me;
730 SetMe(&me);
731 make_server(&me);
e3354945 732 startup_time = rb_current_time();
212380e3
AC
733 add_to_client_hash(me.name, &me);
734 add_to_id_hash(me.id, &me);
994544c2 735 me.serv->nameinfo = scache_connect(me.name, me.info, 0);
212380e3 736
330fc5c1 737 rb_dlinkAddAlloc(&me, &global_serv_list);
212380e3
AC
738
739 construct_umodebuf();
740
741 check_class();
742 write_pidfile(pidFileName);
743 load_help();
744 open_logfiles();
745
746 ilog(L_MAIN, "Server Ready");
747
212380e3
AC
748 /* We want try_connections to be called as soon as possible now! -- adrian */
749 /* No, 'cause after a restart it would cause all sorts of nick collides */
750 /* um. by waiting even longer, that just means we have even *more*
751 * nick collisions. what a stupid idea. set an event for the IO loop --fl
752 */
12aea5fe 753 rb_event_addish("try_connections", try_connections, NULL, STARTUP_CONNECTIONS_TIME);
36645728
VY
754 rb_event_addonce("try_connections_startup", try_connections, NULL, 2);
755 rb_event_add("check_rehash", check_rehash, NULL, 3);
d80645d0 756 rb_event_addish("reseed_srand", seed_random, NULL, 300); /* reseed every 10 minutes */
212380e3 757
212380e3 758 if(splitmode)
36645728 759 check_splitmode_ev = rb_event_add("check_splitmode", check_splitmode, NULL, 5);
212380e3 760
212380e3
AC
761 print_startup(getpid());
762
39944e1f 763 rb_lib_loop(0);
212380e3
AC
764
765 return 0;
766}