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/trunk/src/ircd.c (file contents):
Revision 2330 by michael, Sun Jun 23 13:29:56 2013 UTC vs.
Revision 3065 by michael, Thu Feb 27 19:03:46 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"
# Line 65 | Line 67
67   #ifdef HAVE_LIBGEOIP
68   GeoIP *geoip_ctx;
69   #endif
70 +
71   /* /quote set variables */
72   struct SetOptions GlobalSetOptions;
73 <
74 < /* configuration set from ircd.conf */
72 < struct config_file_entry ConfigFileEntry;
73 < /* server info set from ircd.conf */
74 < struct server_info ServerInfo;
75 < /* admin info set from ircd.conf */
76 < struct admin_info AdminInfo = { NULL, NULL, NULL };
77 < struct Counter Count = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
78 < struct ServerState_t server_state = { 0 };
79 < struct logging_entry ConfigLoggingEntry = { .use_logging = 1 };
73 > struct Counter Count;
74 > struct ServerState_t server_state;
75   struct ServerStatistics ServerStats;
76   struct timeval SystemTime;
77   struct Client me;             /* That's me */
# Line 118 | Line 113 | int rehashed_klines = 0;
113   static void
114   print_startup(int pid)
115   {
116 <  printf("ircd: version %s\n", ircd_version);
116 >  printf("ircd: version %s(%s)\n", ircd_version, serno);
117    printf("ircd: pid %d\n", pid);
118    printf("ircd: running in %s mode from %s\n", !server_state.foreground ? "background"
119           : "foreground", ConfigFileEntry.dpath);
# Line 146 | Line 141 | make_daemon(void)
141   static int printVersion = 0;
142  
143   static struct lgetopt myopts[] = {
144 <  {"configfile", &ConfigFileEntry.configfile,
144 >  {"configfile", &ConfigFileEntry.configfile,
145     STRING, "File to use for ircd.conf"},
146    {"glinefile",  &ConfigFileEntry.glinefile,
147     STRING, "File to use for gline database"},
148 <  {"klinefile",  &ConfigFileEntry.klinefile,
148 >  {"klinefile",  &ConfigFileEntry.klinefile,
149     STRING, "File to use for kline database"},
150    {"dlinefile",  &ConfigFileEntry.dlinefile,
151     STRING, "File to use for dline database"},
152 <  {"xlinefile",  &ConfigFileEntry.xlinefile,
152 >  {"xlinefile",  &ConfigFileEntry.xlinefile,
153     STRING, "File to use for xline database"},
154    {"resvfile",  &ConfigFileEntry.resvfile,
155     STRING, "File to use for resv database"},
156 <  {"logfile",    &logFileName,
156 >  {"logfile",    &logFileName,
157     STRING, "File to use for ircd.log"},
158    {"pidfile",    &pidFileName,
159     STRING, "File to use for process ID"},
160 <  {"foreground", &server_state.foreground,
160 >  {"foreground", &server_state.foreground,
161     YESNO, "Run in foreground (don't detach)"},
162 <  {"version",    &printVersion,
162 >  {"version",    &printVersion,
163     YESNO, "Print version and exit"},
164    {"help", NULL, USAGE, "Print this text"},
165    {NULL, NULL, STRING, NULL},
# Line 173 | Line 168 | static struct lgetopt myopts[] = {
168   void
169   set_time(void)
170   {
171 <  static char to_send[200];
177 <  struct timeval newtime;
178 <  newtime.tv_sec  = 0;
179 <  newtime.tv_usec = 0;
171 >  struct timeval newtime = { .tv_sec = 0, .tv_usec = 0 };
172  
173    if (gettimeofday(&newtime, NULL) == -1)
174    {
# Line 190 | Line 182 | set_time(void)
182  
183    if (newtime.tv_sec < CurrentTime)
184    {
185 <    snprintf(to_send, sizeof(to_send),
186 <             "System clock is running backwards - (%lu < %lu)",
187 <             (unsigned long)newtime.tv_sec, (unsigned long)CurrentTime);
188 <    report_error(L_ALL, to_send, me.name, 0);
185 >    ilog(LOG_TYPE_IRCD, "System clock is running backwards - (%lu < %lu)",
186 >         (unsigned long)newtime.tv_sec, (unsigned long)CurrentTime);
187 >    sendto_realops_flags(UMODE_DEBUG, L_ALL, SEND_NOTICE,
188 >                         "System clock is running backwards - (%lu < %lu)",
189 >                         (unsigned long)newtime.tv_sec,
190 >                         (unsigned long)CurrentTime);
191      set_back_events(CurrentTime - newtime.tv_sec);
192    }
193  
# Line 208 | Line 202 | io_loop(void)
202    {
203      /*
204       * Maybe we want a flags word?
205 <     * ie. if (REHASHED_KLINES(global_flags))
205 >     * ie. if (REHASHED_KLINES(global_flags))
206       * SET_REHASHED_KLINES(global_flags)
207       * CLEAR_REHASHED_KLINES(global_flags)
208       *
# Line 240 | Line 234 | io_loop(void)
234      comm_select();
235      exit_aborted_clients();
236      free_exited_clients();
243    send_queued_all();
237  
238      /* Check to see whether we have to rehash the configuration .. */
239      if (dorehash)
# Line 252 | Line 245 | io_loop(void)
245      {
246        motd_recache();
247        sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
248 <                           "Got signal SIGUSR1, reloading motd files");
248 >                           "Got signal SIGUSR1, reloading motd file(s)");
249        doremotd = 0;
250      }
251    }
# Line 262 | Line 255 | io_loop(void)
255   *
256   * inputs       - none
257   * output       - none
258 < * side effects - This sets all global set options needed
258 > * side effects - This sets all global set options needed
259   */
260   static void
261   initialize_global_set_options(void)
# Line 308 | Line 301 | initialize_server_capabs(void)
301    add_capability("EOB", CAP_EOB, 1);
302    add_capability("TS6", CAP_TS6, 0);
303    add_capability("CLUSTER", CAP_CLUSTER, 1);
311 //  add_capability("FAKEHOST", CAP_FAKEHOST, 1);
304    add_capability("SVS", CAP_SVS, 1);
305   #ifdef HALFOPS
306    add_capability("HOPS", CAP_HOPS, 1);
# Line 328 | Line 320 | write_pidfile(const char *filename)
320  
321    if ((fb = fopen(filename, "w")))
322    {
323 <    char buff[32];
323 >    char buff[IRCD_BUFSIZE];
324      unsigned int pid = (unsigned int)getpid();
325  
326      snprintf(buff, sizeof(buff), "%u\n", pid);
# Line 357 | Line 349 | static void
349   check_pidfile(const char *filename)
350   {
351    FILE *fb;
352 <  char buff[32];
352 >  char buff[IRCD_BUFSIZE];
353    pid_t pidfromfile;
354  
355    /* Don't do logging here, since we don't have log() initialised */
# Line 429 | Line 421 | static void
421   ssl_init(void)
422   {
423   #ifdef HAVE_LIBCRYPTO
424 +  const unsigned char session_id[] = "ircd-hybrid";
425 +
426    SSL_load_error_strings();
427    SSLeay_add_ssl_algorithms();
428  
# Line 445 | Line 439 | ssl_init(void)
439    SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_TLS_ROLLBACK_BUG|SSL_OP_ALL);
440    SSL_CTX_set_verify(ServerInfo.server_ctx, SSL_VERIFY_PEER|SSL_VERIFY_CLIENT_ONCE,
441                       always_accept_verify_cb);
442 +  SSL_CTX_set_session_id_context(ServerInfo.server_ctx, session_id, sizeof(session_id) - 1);
443  
444    if ((ServerInfo.client_ctx = SSL_CTX_new(SSLv23_client_method())) == NULL)
445    {
# Line 502 | Line 497 | main(int argc, char *argv[])
497  
498    if (printVersion)
499    {
500 <    printf("ircd: version %s\n", ircd_version);
500 >    printf("ircd: version %s(%s)\n", ircd_version, serno);
501      exit(EXIT_SUCCESS);
502    }
503  
# Line 531 | Line 526 | main(int argc, char *argv[])
526    fdlist_init();
527    log_set_file(LOG_TYPE_IRCD, 0, logFileName);
528    check_can_use_v6();
529 <  init_comm();         /* This needs to be setup early ! -- adrian */
529 >  init_netio();         /* This needs to be setup early ! -- adrian */
530  
531    /* Check if there is pidfile and daemon already running */
532    check_pidfile(pidFileName);
# Line 597 | Line 592 | main(int argc, char *argv[])
592  
593    hash_add_id(&me);
594    hash_add_client(&me);
595 <  
595 >
596    /* add ourselves to global_serv_list */
597    dlinkAdd(&me, make_dlink_node(), &global_serv_list);
598  

Diff Legend

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