ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/ircd.c
(Generate patch)

Comparing:
ircd-hybrid-7.3/src/ircd.c (file contents), Revision 1149 by michael, Sun Jul 31 20:04:17 2011 UTC vs.
ircd-hybrid/trunk/src/ircd.c (file contents), Revision 4105 by michael, Mon Jun 30 15:39:47 2014 UTC

# Line 1 | Line 1
1   /*
2 < *  ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 < *  ircd.c: Starts up and runs the ircd.
2 > *  ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3   *
4 < *  Copyright (C) 2002 by the past and present ircd coders, and others.
4 > *  Copyright (c) 1997-2014 ircd-hybrid development team
5   *
6   *  This program is free software; you can redistribute it and/or modify
7   *  it under the terms of the GNU General Public License as published by
# Line 18 | Line 17
17   *  along with this program; if not, write to the Free Software
18   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
19   *  USA
20 < *
21 < *  $Id$
20 > */
21 >
22 > /*! \file ircd.c
23 > * \brief Starts up and runs the ircd.
24 > * \version $Id$
25   */
26  
27   #include "stdinc.h"
28 < #include "s_user.h"
28 > #include "user.h"
29   #include "list.h"
30   #include "ircd.h"
31   #include "channel.h"
30 #include "channel_mode.h"
32   #include "client.h"
32 #include "common.h"
33   #include "event.h"
34   #include "fdlist.h"
35   #include "hash.h"
36   #include "irc_string.h"
37   #include "ircd_signal.h"
38 < #include "s_gline.h"
38 > #include "gline.h"
39   #include "motd.h"
40 < #include "ircd_handler.h"
41 < #include "msg.h"         /* msgtab */
40 > #include "conf.h"
41   #include "hostmask.h"
43 #include "numeric.h"
44 #include "packet.h"
42   #include "parse.h"
43 < #include "irc_res.h"
43 > #include "res.h"
44   #include "restart.h"
45   #include "rng_mt.h"
46 < #include "s_auth.h"
46 > #include "auth.h"
47   #include "s_bsd.h"
48 < #include "s_conf.h"
49 < #include "s_log.h"
53 < #include "s_misc.h"
54 < #include "s_serv.h"      /* try_connections */
48 > #include "log.h"
49 > #include "server.h"      /* try_connections */
50   #include "send.h"
51   #include "whowas.h"
52   #include "modules.h"
53   #include "memory.h"
54 < #include "hook.h"
54 > #include "mempool.h"
55   #include "ircd_getopt.h"
61 #include "balloc.h"
62 #include "motd.h"
63 #include "supported.h"
56   #include "watch.h"
57 + #include "conf_db.h"
58 + #include "conf_class.h"
59  
60 < /* Try and find the correct name to use with getrlimit() for setting the max.
61 < * number of files allowed to be open by this process.
62 < */
60 >
61 > #ifdef HAVE_LIBGEOIP
62 > GeoIP *geoip_ctx;
63 > #endif
64  
65   /* /quote set variables */
66   struct SetOptions GlobalSetOptions;
67 <
68 < /* configuration set from ircd.conf */
74 < struct config_file_entry ConfigFileEntry;
75 < /* server info set from ircd.conf */
76 < struct server_info ServerInfo;
77 < /* admin info set from ircd.conf */
78 < struct admin_info AdminInfo = { NULL, NULL, NULL };
79 < struct Counter Count = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
80 < struct ServerState_t server_state = { 0 };
81 < struct logging_entry ConfigLoggingEntry = { 1, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0} };
67 > struct Counter Count;
68 > struct ServerState_t server_state;
69   struct ServerStatistics ServerStats;
70   struct timeval SystemTime;
71   struct Client me;             /* That's me */
# Line 88 | Line 75 | const char *logFileName = LPATH;
75   const char *pidFileName = PPATH;
76  
77   char **myargv;
91 char ircd_platform[PLATFORMLEN];
78  
79   int dorehash = 0;
80   int doremotd = 0;
# Line 96 | Line 82 | int doremotd = 0;
82   /* Set to zero because it should be initialized later using
83   * initialize_server_capabs
84   */
85 < int default_server_capabs = 0;
100 <
101 < #ifdef HAVE_LIBCRYPTO
102 < int bio_spare_fd = -1;
103 < #endif
104 <
85 > unsigned int default_server_capabs;
86   unsigned int splitmode;
87   unsigned int splitchecking;
88   unsigned int split_users;
89   unsigned int split_servers;
90  
91 < /* Do klines the same way hybrid-6 did them, i.e. at the
92 < * top of the next io_loop instead of in the same loop as
93 < * the klines are being applied.
94 < *
95 < * This should fix strange CPU starvation as very indirectly reported.
96 < * (Why do you people not email bug reports? WHY? WHY?)
97 < *
98 < * - Dianora
99 < */
91 > static struct event event_cleanup_glines =
92 > {
93 >  .name = "cleanup_glines",
94 >  .handler = cleanup_glines,
95 >  .when = CLEANUP_GLINES_TIME
96 > };
97 >
98 > static struct event event_cleanup_tklines =
99 > {
100 >  .name = "cleanup_tklines",
101 >  .handler = cleanup_tklines,
102 >  .when = CLEANUP_TKLINES_TIME
103 > };
104  
105 < int rehashed_klines = 0;
105 > static struct event event_try_connections =
106 > {
107 >  .name = "try_connections",
108 >  .handler = try_connections,
109 >  .when = STARTUP_CONNECTIONS_TIME
110 > };
111  
112 + static struct event event_comm_checktimeouts =
113 + {
114 +  .name = "comm_checktimeouts",
115 +  .handler = comm_checktimeouts,
116 +  .when = 1
117 + };
118 +
119 + static struct event event_save_all_databases =
120 + {
121 +  .name = "save_all_databases",
122 +  .handler = save_all_databases,
123 +  .when = DATABASE_UPDATE_TIMEOUT
124 + };
125 +
126 + struct event event_write_links_file =
127 + {
128 +  .name = "write_links_file",
129 +  .handler = write_links_file,
130 + };
131 +
132 + struct event event_check_splitmode =
133 + {
134 +  .name = "check_splitmode",
135 +  .handler = check_splitmode,
136 +  .when = 60
137 + };
138  
139   /*
140   * print_startup - print startup information
# Line 126 | Line 142 | int rehashed_klines = 0;
142   static void
143   print_startup(int pid)
144   {
145 <  printf("ircd: version %s\n", ircd_version);
145 >  printf("ircd: version %s(%s)\n", ircd_version, serno);
146    printf("ircd: pid %d\n", pid);
147    printf("ircd: running in %s mode from %s\n", !server_state.foreground ? "background"
148           : "foreground", ConfigFileEntry.dpath);
# Line 153 | Line 169 | make_daemon(void)
169  
170   static int printVersion = 0;
171  
172 < struct lgetopt myopts[] = {
173 <  {"dlinefile",  &ConfigFileEntry.dlinefile,
174 <   STRING, "File to use for dline.conf"},
159 <  {"configfile", &ConfigFileEntry.configfile,
172 > static struct lgetopt myopts[] =
173 > {
174 >  {"configfile", &ConfigFileEntry.configfile,
175     STRING, "File to use for ircd.conf"},
176 <  {"klinefile",  &ConfigFileEntry.klinefile,
177 <   STRING, "File to use for kline.conf"},
178 <  {"xlinefile",  &ConfigFileEntry.xlinefile,
179 <   STRING, "File to use for xline.conf"},
180 <  {"logfile",    &logFileName,
176 >  {"glinefile",  &ConfigFileEntry.glinefile,
177 >   STRING, "File to use for gline database"},
178 >  {"klinefile",  &ConfigFileEntry.klinefile,
179 >   STRING, "File to use for kline database"},
180 >  {"dlinefile",  &ConfigFileEntry.dlinefile,
181 >   STRING, "File to use for dline database"},
182 >  {"xlinefile",  &ConfigFileEntry.xlinefile,
183 >   STRING, "File to use for xline database"},
184 >  {"resvfile",  &ConfigFileEntry.resvfile,
185 >   STRING, "File to use for resv database"},
186 >  {"logfile",    &logFileName,
187     STRING, "File to use for ircd.log"},
188    {"pidfile",    &pidFileName,
189     STRING, "File to use for process ID"},
190 <  {"foreground", &server_state.foreground,
190 >  {"foreground", &server_state.foreground,
191     YESNO, "Run in foreground (don't detach)"},
192 <  {"version",    &printVersion,
192 >  {"version",    &printVersion,
193     YESNO, "Print version and exit"},
194    {"help", NULL, USAGE, "Print this text"},
195    {NULL, NULL, STRING, NULL},
# Line 177 | Line 198 | struct lgetopt myopts[] = {
198   void
199   set_time(void)
200   {
201 <  static char to_send[200];
181 <  struct timeval newtime;
182 <  newtime.tv_sec  = 0;
183 <  newtime.tv_usec = 0;
201 >  struct timeval newtime = { .tv_sec = 0, .tv_usec = 0 };
202  
203    if (gettimeofday(&newtime, NULL) == -1)
204    {
205 <    ilog(L_ERROR, "Clock Failure (%s), TS can be corrupted",
205 >    ilog(LOG_TYPE_IRCD, "Clock Failure (%s), TS can be corrupted",
206           strerror(errno));
207 <    sendto_realops_flags(UMODE_ALL, L_ALL,
207 >    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
208                           "Clock Failure (%s), TS can be corrupted",
209                           strerror(errno));
210 <    restart("Clock Failure");
210 >    server_die("Clock Failure", 1);
211    }
212  
213    if (newtime.tv_sec < CurrentTime)
214    {
215 <    snprintf(to_send, sizeof(to_send),
216 <             "System clock is running backwards - (%lu < %lu)",
217 <             (unsigned long)newtime.tv_sec, (unsigned long)CurrentTime);
218 <    report_error(L_ALL, to_send, me.name, 0);
215 >    ilog(LOG_TYPE_IRCD, "System clock is running backwards - (%lu < %lu)",
216 >         (unsigned long)newtime.tv_sec, (unsigned long)CurrentTime);
217 >    sendto_realops_flags(UMODE_DEBUG, L_ALL, SEND_NOTICE,
218 >                         "System clock is running backwards - (%lu < %lu)",
219 >                         (unsigned long)newtime.tv_sec,
220 >                         (unsigned long)CurrentTime);
221      set_back_events(CurrentTime - newtime.tv_sec);
222    }
223  
# Line 208 | Line 228 | set_time(void)
228   static void
229   io_loop(void)
230   {
231 <  while (1 == 1)
231 >  while (1)
232    {
213    /*
214     * Maybe we want a flags word?
215     * ie. if (REHASHED_KLINES(global_flags))
216     * SET_REHASHED_KLINES(global_flags)
217     * CLEAR_REHASHED_KLINES(global_flags)
218     *
219     * - Dianora
220     */
221    if (rehashed_klines)
222    {
223      check_conf_klines();
224      rehashed_klines = 0;
225    }
226
233      if (listing_client_list.head)
234      {
235        dlink_node *ptr = NULL, *ptr_next = NULL;
236        DLINK_FOREACH_SAFE(ptr, ptr_next, listing_client_list.head)
237 <      {
232 <        struct Client *client_p = ptr->data;
233 <        assert(client_p->localClient->list_task);
234 <        safe_list_channels(client_p, client_p->localClient->list_task, 0);
235 <      }
237 >        safe_list_channels(ptr->data, 0);
238      }
239  
240 <    /* Run pending events, then get the number of seconds to the next
241 <     * event
240 <     */
241 <    while (eventNextTime() <= CurrentTime)
242 <      eventRun();
240 >    /* Run pending events */
241 >    event_run();
242  
243      comm_select();
244      exit_aborted_clients();
245      free_exited_clients();
247    send_queued_all();
246  
247      /* Check to see whether we have to rehash the configuration .. */
248      if (dorehash)
# Line 252 | Line 250 | io_loop(void)
250        rehash(1);
251        dorehash = 0;
252      }
253 +
254      if (doremotd)
255      {
256 <      read_message_file(&ConfigFileEntry.motd);
257 <      sendto_realops_flags(UMODE_ALL, L_ALL,
258 <                           "Got signal SIGUSR1, reloading ircd motd file");
256 >      motd_recache();
257 >      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
258 >                           "Got signal SIGUSR1, reloading motd file(s)");
259        doremotd = 0;
260      }
261    }
# Line 266 | Line 265 | io_loop(void)
265   *
266   * inputs       - none
267   * output       - none
268 < * side effects - This sets all global set options needed
268 > * side effects - This sets all global set options needed
269   */
270   static void
271   initialize_global_set_options(void)
# Line 297 | Line 296 | initialize_global_set_options(void)
296    }
297  
298    GlobalSetOptions.ident_timeout = IDENT_TIMEOUT;
300  GlobalSetOptions.idletime = ConfigFileEntry.idletime;
299    /* End of global set options */
300   }
301  
304 /* initialize_message_files()
305 *
306 * inputs       - none
307 * output       - none
308 * side effects - Set up all message files needed, motd etc.
309 */
310 static void
311 initialize_message_files(void)
312 {
313  init_message_file(USER_MOTD, MPATH, &ConfigFileEntry.motd);
314  init_message_file(OPER_MOTD, OPATH, &ConfigFileEntry.opermotd);
315  init_message_file(USER_LINKS, LIPATH, &ConfigFileEntry.linksfile);
316
317  read_message_file(&ConfigFileEntry.motd);
318  read_message_file(&ConfigFileEntry.opermotd);
319  read_message_file(&ConfigFileEntry.linksfile);
320
321  init_isupport();
322 }
323
302   /* initialize_server_capabs()
303   *
304   * inputs       - none
# Line 332 | Line 310 | initialize_server_capabs(void)
310    add_capability("QS", CAP_QS, 1);
311    add_capability("EOB", CAP_EOB, 1);
312    add_capability("TS6", CAP_TS6, 0);
335  add_capability("ZIP", CAP_ZIP, 0);
313    add_capability("CLUSTER", CAP_CLUSTER, 1);
314 < #ifdef HALFOPS
314 >  add_capability("SVS", CAP_SVS, 1);
315 >  add_capability("CHW", CAP_CHW, 1);
316    add_capability("HOPS", CAP_HOPS, 1);
339 #endif
317   }
318  
319   /* write_pidfile()
# Line 348 | Line 325 | initialize_server_capabs(void)
325   static void
326   write_pidfile(const char *filename)
327   {
328 <  FBFILE *fb;
328 >  FILE *fb;
329  
330 <  if ((fb = fbopen(filename, "w")))
330 >  if ((fb = fopen(filename, "w")))
331    {
332 <    char buff[32];
332 >    char buff[IRCD_BUFSIZE];
333      unsigned int pid = (unsigned int)getpid();
357    size_t nbytes = snprintf(buff, sizeof(buff), "%u\n", pid);
334  
335 <    if ((fbputs(buff, fb, nbytes) == -1))
336 <      ilog(L_ERROR, "Error writing %u to pid file %s (%s)",
335 >    snprintf(buff, sizeof(buff), "%u\n", pid);
336 >
337 >    if ((fputs(buff, fb) == -1))
338 >      ilog(LOG_TYPE_IRCD, "Error writing %u to pid file %s (%s)",
339             pid, filename, strerror(errno));
340  
341 <    fbclose(fb);
364 <    return;
341 >    fclose(fb);
342    }
343    else
344    {
345 <    ilog(L_ERROR, "Error opening pid file %s", filename);
345 >    ilog(LOG_TYPE_IRCD, "Error opening pid file %s", filename);
346    }
347   }
348  
# Line 380 | Line 357 | write_pidfile(const char *filename)
357   static void
358   check_pidfile(const char *filename)
359   {
360 <  FBFILE *fb;
361 <  char buff[32];
360 >  FILE *fb;
361 >  char buff[IRCD_BUFSIZE];
362    pid_t pidfromfile;
363  
364    /* Don't do logging here, since we don't have log() initialised */
365 <  if ((fb = fbopen(filename, "r")))
365 >  if ((fb = fopen(filename, "r")))
366    {
367 <    if (fbgets(buff, 20, fb) == NULL)
367 >    if (fgets(buff, 20, fb) == NULL)
368      {
369        /* log(L_ERROR, "Error reading from pid file %s (%s)", filename,
370         * strerror(errno));
# Line 405 | Line 382 | check_pidfile(const char *filename)
382        }
383      }
384  
385 <    fbclose(fb);
385 >    fclose(fb);
386    }
387    else if (errno != ENOENT)
388    {
# Line 435 | Line 412 | setup_corefile(void)
412   #endif
413   }
414  
415 + #ifdef HAVE_LIBCRYPTO
416 + static int
417 + always_accept_verify_cb(int preverify_ok, X509_STORE_CTX *x509_ctx)
418 + {
419 +  return 1;
420 + }
421 + #endif
422 +
423   /* init_ssl()
424   *
425   * inputs       - nothing
# Line 442 | Line 427 | setup_corefile(void)
427   * side effects - setups SSL context.
428   */
429   static void
430 < init_ssl(void)
430 > ssl_init(void)
431   {
432   #ifdef HAVE_LIBCRYPTO
433 +  const unsigned char session_id[] = "ircd-hybrid";
434 +
435    SSL_load_error_strings();
436    SSLeay_add_ssl_algorithms();
437  
# Line 452 | Line 439 | init_ssl(void)
439    {
440      const char *s;
441  
442 <    fprintf(stderr, "ERROR: Could not initialize the SSL context -- %s\n",
442 >    fprintf(stderr, "ERROR: Could not initialize the SSL Server context -- %s\n",
443              s = ERR_lib_error_string(ERR_get_error()));
444 <    ilog(L_CRIT, "ERROR: Could not initialize the SSL context -- %s\n", s);
444 >    ilog(LOG_TYPE_IRCD, "ERROR: Could not initialize the SSL Server context -- %s\n", s);
445    }
446  
447 <  SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_NO_SSLv2);
448 <  SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_TLS_ROLLBACK_BUG|SSL_OP_ALL);
449 <  SSL_CTX_set_verify(ServerInfo.server_ctx, SSL_VERIFY_NONE, NULL);
447 >  SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_TLSv1);
448 >  SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_TLS_ROLLBACK_BUG);
449 >  SSL_CTX_set_verify(ServerInfo.server_ctx, SSL_VERIFY_PEER|SSL_VERIFY_CLIENT_ONCE,
450 >                     always_accept_verify_cb);
451 >  SSL_CTX_set_session_id_context(ServerInfo.server_ctx, session_id, sizeof(session_id) - 1);
452  
453 <  bio_spare_fd = save_spare_fd("SSL private key validation");
454 < #endif /* HAVE_LIBCRYPTO */
455 < }
453 > #if OPENSSL_VERSION_NUMBER >= 0x1000005FL && !defined(OPENSSL_NO_ECDH)
454 >  {
455 >    EC_KEY *key = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);
456  
457 < /* init_callbacks()
458 < *
459 < * inputs       - nothing
460 < * output       - nothing
461 < * side effects - setups standard hook points
462 < */
463 < static void
464 < init_callbacks(void)
465 < {
466 <  iorecv_cb = register_callback("iorecv", iorecv_default);
467 <  iosend_cb = register_callback("iosend", iosend_default);
468 <  iorecvctrl_cb = register_callback("iorecvctrl", NULL);
469 <  iosendctrl_cb = register_callback("iosendctrl", NULL);
457 >    if (key)
458 >    {
459 >      SSL_CTX_set_tmp_ecdh(ServerInfo.server_ctx, key);
460 >      EC_KEY_free(key);
461 >    }
462 >  }
463 >
464 >  SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_SINGLE_ECDH_USE);
465 > #endif
466 >
467 >  if ((ServerInfo.client_ctx = SSL_CTX_new(SSLv23_client_method())) == NULL)
468 >  {
469 >    const char *s;
470 >
471 >    fprintf(stderr, "ERROR: Could not initialize the SSL Client context -- %s\n",
472 >            s = ERR_lib_error_string(ERR_get_error()));
473 >    ilog(LOG_TYPE_IRCD, "ERROR: Could not initialize the SSL Client context -- %s\n", s);
474 >  }
475 >
476 >  SSL_CTX_set_options(ServerInfo.client_ctx, SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_TLSv1);
477 >  SSL_CTX_set_options(ServerInfo.client_ctx, SSL_OP_TLS_ROLLBACK_BUG);
478 >  SSL_CTX_set_verify(ServerInfo.client_ctx, SSL_VERIFY_PEER|SSL_VERIFY_CLIENT_ONCE,
479 >                     always_accept_verify_cb);
480 > #endif /* HAVE_LIBCRYPTO */
481   }
482  
483   int
484   main(int argc, char *argv[])
485   {
486 <  /* Check to see if the user is running
487 <   * us as root, which is a nono
488 <   */
486 >  /* Check to see if the user is running us as root, which is a nono */
487    if (geteuid() == 0)
488    {
489 <    fprintf(stderr, "Don't run ircd as root!!!\n");
489 >    fprintf(stderr, "ERROR: This server won't run as root/superuser\n");
490      return -1;
491    }
492  
# Line 502 | Line 500 | main(int argc, char *argv[])
500    init_genrand(SystemTime.tv_sec ^ (SystemTime.tv_usec | (getpid() << 20)));
501  
502    me.localClient = &meLocalUser;
503 <  dlinkAdd(&me, &me.node, &global_client_list); /* Pointer to beginning
503 >  dlinkAdd(&me, &me.node, &global_client_list);  /* Pointer to beginning
504                                                     of Client list */
505 <  /* Initialise the channel capability usage counts... */
508 <  init_chcap_usage_counts();
509 <
505 >  ConfigLoggingEntry.use_logging = 1;
506    ConfigFileEntry.dpath      = DPATH;
507 <  ConfigFileEntry.configfile = CPATH;  /* Server configuration file */
508 <  ConfigFileEntry.klinefile  = KPATH;  /* Server kline file         */
509 <  ConfigFileEntry.xlinefile  = XPATH;  /* Server xline file         */
510 <  ConfigFileEntry.rxlinefile = RXPATH; /* Server regex xline file   */
511 <  ConfigFileEntry.rklinefile = RKPATH; /* Server regex kline file   */
512 <  ConfigFileEntry.dlinefile  = DLPATH; /* dline file                */
513 <  ConfigFileEntry.glinefile  = GPATH;  /* gline log file            */
514 <  ConfigFileEntry.cresvfile  = CRESVPATH; /* channel resv file      */
515 <  ConfigFileEntry.nresvfile  = NRESVPATH; /* nick resv file         */
507 >  ConfigFileEntry.spath      = SPATH;
508 >  ConfigFileEntry.mpath      = MPATH;
509 >  ConfigFileEntry.configfile = CPATH;    /* Server configuration file */
510 >  ConfigFileEntry.klinefile  = KPATH;    /* Server kline file         */
511 >  ConfigFileEntry.glinefile  = GPATH;    /* Server gline file         */
512 >  ConfigFileEntry.xlinefile  = XPATH;    /* Server xline file         */
513 >  ConfigFileEntry.dlinefile  = DLPATH;   /* dline file                */
514 >  ConfigFileEntry.resvfile   = RESVPATH; /* resv file                 */
515 >
516    myargv = argv;
517    umask(077);                /* better safe than sorry --SRB */
518  
# Line 524 | Line 520 | main(int argc, char *argv[])
520  
521    if (printVersion)
522    {
523 <    printf("ircd: version %s\n", ircd_version);
523 >    printf("ircd: version %s(%s)\n", ircd_version, serno);
524      exit(EXIT_SUCCESS);
525    }
526  
# Line 534 | Line 530 | main(int argc, char *argv[])
530      exit(EXIT_FAILURE);
531    }
532  
533 <  init_ssl();
533 >  ssl_init();
534  
535    if (!server_state.foreground)
536    {
# Line 546 | Line 542 | main(int argc, char *argv[])
542  
543    setup_signals();
544  
549  get_ircd_platform(ircd_platform);
550
551  /* Init the event subsystem */
552  eventInit();
545    /* We need this to initialise the fd array before anything else */
546    fdlist_init();
547 <  init_log(logFileName);
547 >  log_set_file(LOG_TYPE_IRCD, 0, logFileName);
548    check_can_use_v6();
549 <  init_comm();         /* This needs to be setup early ! -- adrian */
549 >  init_netio();         /* This needs to be setup early ! -- adrian */
550 >
551    /* Check if there is pidfile and daemon already running */
552    check_pidfile(pidFileName);
553  
554 <  initBlockHeap();
554 >  mp_pool_init();
555    init_dlink_nodes();
556 <  init_callbacks();
564 <  initialize_message_files();
556 >  init_isupport();
557    dbuf_init();
558 <  init_hash();
558 >  hash_init();
559    init_ip_hash_table();      /* client host ip hash table */
560    init_host_hash();          /* Host-hashtable. */
561 <  clear_tree_parse();
562 <  init_client();
563 <  init_class();
572 <  init_whowas();
561 >  client_init();
562 >  class_init();
563 >  whowas_init();
564    watch_init();
565 <  init_auth();          /* Initialise the auth code */
565 >  auth_init();          /* Initialise the auth code */
566    init_resolver();      /* Needs to be setup before the io loop */
567 +  modules_init();
568    read_conf_files(1);   /* cold start init conf files */
569    init_uid();
570    initialize_server_capabs();   /* Set up default_server_capabs */
571    initialize_global_set_options();
572 <  init_channels();
572 >  channel_init();
573 >  read_links_file();
574 >  motd_init();
575 > #ifdef HAVE_LIBGEOIP
576 >  geoip_ctx = GeoIP_new(GEOIP_MEMORY_CACHE);
577 > #endif
578  
579    if (EmptyString(ServerInfo.sid))
580    {
581 <    ilog(L_CRIT, "ERROR: No server id specified in serverinfo block.");
581 >    ilog(LOG_TYPE_IRCD, "ERROR: No server id specified in serverinfo block.");
582      exit(EXIT_FAILURE);
583    }
584  
# Line 589 | Line 586 | main(int argc, char *argv[])
586  
587    if (EmptyString(ServerInfo.name))
588    {
589 <    ilog(L_CRIT, "ERROR: No server name specified in serverinfo block.");
589 >    ilog(LOG_TYPE_IRCD, "ERROR: No server name specified in serverinfo block.");
590      exit(EXIT_FAILURE);
591    }
592  
# Line 598 | Line 595 | main(int argc, char *argv[])
595    /* serverinfo{} description must exist.  If not, error out.*/
596    if (EmptyString(ServerInfo.description))
597    {
598 <    ilog(L_CRIT, "ERROR: No server description specified in serverinfo block.");
598 >    ilog(LOG_TYPE_IRCD, "ERROR: No server description specified in serverinfo block.");
599      exit(EXIT_FAILURE);
600    }
601  
602    strlcpy(me.info, ServerInfo.description, sizeof(me.info));
603  
604 <  me.from     = &me;
605 <  me.servptr  = &me;
606 <  me.lasttime = me.since = me.firsttime = CurrentTime;
604 >  me.from                   = &me;
605 >  me.servptr                = &me;
606 >  me.localClient->lasttime  = CurrentTime;
607 >  me.localClient->since     = CurrentTime;
608 >  me.localClient->firsttime = CurrentTime;
609  
610    SetMe(&me);
611    make_server(&me);
612  
613    hash_add_id(&me);
614    hash_add_client(&me);
615 <  
615 >
616    /* add ourselves to global_serv_list */
617    dlinkAdd(&me, make_dlink_node(), &global_serv_list);
618  
619 +  load_kline_database();
620 +  load_dline_database();
621 +  load_gline_database();
622 +  load_xline_database();
623 +  load_resv_database();
624 +
625    if (chdir(MODPATH))
626    {
627 <    ilog(L_CRIT, "Could not load core modules. Terminating!");
627 >    ilog(LOG_TYPE_IRCD, "Could not load core modules. Terminating!");
628      exit(EXIT_FAILURE);
629    }
630  
# Line 642 | Line 647 | main(int argc, char *argv[])
647  
648    write_pidfile(pidFileName);
649  
650 <  ilog(L_NOTICE, "Server Ready");
650 >  ilog(LOG_TYPE_IRCD, "Server Ready");
651  
652 <  eventAddIsh("cleanup_glines", cleanup_glines, NULL, CLEANUP_GLINES_TIME);
653 <  eventAddIsh("cleanup_tklines", cleanup_tklines, NULL, CLEANUP_TKLINES_TIME);
652 >  event_addish(&event_cleanup_glines, NULL);
653 >  event_addish(&event_cleanup_tklines, NULL);
654  
655    /* We want try_connections to be called as soon as possible now! -- adrian */
656    /* No, 'cause after a restart it would cause all sorts of nick collides */
657 <  eventAddIsh("try_connections", try_connections, NULL, STARTUP_CONNECTIONS_TIME);
653 <
654 <  eventAddIsh("collect_zipstats", collect_zipstats, NULL, ZIPSTATS_TIME);
657 >  event_addish(&event_try_connections, NULL);
658  
659    /* Setup the timeout check. I'll shift it later :)  -- adrian */
660 <  eventAddIsh("comm_checktimeouts", comm_checktimeouts, NULL, 1);
660 >  event_addish(&event_comm_checktimeouts, NULL);
661 >
662 >  event_addish(&event_save_all_databases, NULL);
663  
664    if (ConfigServerHide.links_delay > 0)
665 <    eventAddIsh("write_links_file", write_links_file, NULL, ConfigServerHide.links_delay);
665 >  {
666 >    event_write_links_file.when = ConfigServerHide.links_delay;
667 >    event_addish(&event_write_links_file, NULL);
668 >  }
669    else
670      ConfigServerHide.links_disabled = 1;
671  
672    if (splitmode)
673 <    eventAddIsh("check_splitmode", check_splitmode, NULL, 60);
673 >    event_addish(&event_check_splitmode, NULL);
674  
675    io_loop();
676    return 0;

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)