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 4161 by michael, Thu Jul 3 18:25:53 2014 UTC vs.
Revision 4730 by michael, Sat Oct 11 19:16:48 2014 UTC

# Line 15 | Line 15
15   *
16   *  You should have received a copy of the GNU General Public License
17   *  along with this program; if not, write to the Free Software
18 < *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
18 > *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19   *  USA
20   */
21  
# Line 56 | Line 56
56   #include "watch.h"
57   #include "conf_db.h"
58   #include "conf_class.h"
59 + #include "ipcache.h"
60  
61  
62   #ifdef HAVE_LIBGEOIP
63   GeoIP *geoip_ctx;
64   #endif
65  
65 struct ServerStatistics ServerStats;
66   struct timeval SystemTime;
67   struct Client me;             /* That's me */
68 < struct LocalUser meLocalUser; /* That's also part of me */
68 > struct Connection meConnection; /* That's also part of me */
69  
70   const char *logFileName = LPATH;
71   const char *pidFileName = PPATH;
# Line 135 | Line 135 | print_startup(int pid)
135    printf("ircd: version %s(%s)\n", ircd_version, serno);
136    printf("ircd: pid %d\n", pid);
137    printf("ircd: running in %s mode from %s\n", !server_state.foreground ? "background"
138 <         : "foreground", ConfigFileEntry.dpath);
138 >         : "foreground", ConfigGeneral.dpath);
139   }
140  
141   static void
# Line 161 | Line 161 | static int printVersion = 0;
161  
162   static struct lgetopt myopts[] =
163   {
164 <  {"configfile", &ConfigFileEntry.configfile,
164 >  {"configfile", &ConfigGeneral.configfile,
165     STRING, "File to use for ircd.conf"},
166 <  {"glinefile",  &ConfigFileEntry.glinefile,
166 >  {"glinefile",  &ConfigGeneral.glinefile,
167     STRING, "File to use for gline database"},
168 <  {"klinefile",  &ConfigFileEntry.klinefile,
168 >  {"klinefile",  &ConfigGeneral.klinefile,
169     STRING, "File to use for kline database"},
170 <  {"dlinefile",  &ConfigFileEntry.dlinefile,
170 >  {"dlinefile",  &ConfigGeneral.dlinefile,
171     STRING, "File to use for dline database"},
172 <  {"xlinefile",  &ConfigFileEntry.xlinefile,
172 >  {"xlinefile",  &ConfigGeneral.xlinefile,
173     STRING, "File to use for xline database"},
174 <  {"resvfile",  &ConfigFileEntry.resvfile,
174 >  {"resvfile",  &ConfigGeneral.resvfile,
175     STRING, "File to use for resv database"},
176    {"logfile",    &logFileName,
177     STRING, "File to use for ircd.log"},
# Line 260 | Line 260 | io_loop(void)
260   static void
261   initialize_global_set_options(void)
262   {
263  memset(&GlobalSetOptions, 0, sizeof(GlobalSetOptions));
264
263    GlobalSetOptions.autoconn  = 1;
264    GlobalSetOptions.spam_time = MIN_JOIN_LEAVE_TIME;
265    GlobalSetOptions.spam_num  = MAX_JOIN_LEAVE_COUNT;
266  
267 <  if (ConfigFileEntry.default_floodcount)
268 <    GlobalSetOptions.floodcount = ConfigFileEntry.default_floodcount;
267 >  if (ConfigGeneral.default_floodcount)
268 >    GlobalSetOptions.floodcount = ConfigGeneral.default_floodcount;
269    else
270      GlobalSetOptions.floodcount = 10;
271  
# Line 286 | Line 284 | initialize_global_set_options(void)
284    }
285  
286    GlobalSetOptions.ident_timeout = IDENT_TIMEOUT;
289  /* End of global set options */
287   }
288  
289   /* initialize_server_capabs()
# Line 420 | Line 417 | static void
417   ssl_init(void)
418   {
419   #ifdef HAVE_LIBCRYPTO
423  const unsigned char session_id[] = "ircd-hybrid";
424
420    SSL_load_error_strings();
421    SSLeay_add_ssl_algorithms();
422  
423 <  if ((ServerInfo.server_ctx = SSL_CTX_new(SSLv23_server_method())) == NULL)
423 >  if ((ConfigServerInfo.server_ctx = SSL_CTX_new(SSLv23_server_method())) == NULL)
424    {
425      const char *s = ERR_lib_error_string(ERR_get_error());
426  
427      fprintf(stderr, "ERROR: Could not initialize the SSL Server context -- %s\n", s);
428      ilog(LOG_TYPE_IRCD, "ERROR: Could not initialize the SSL Server context -- %s\n", s);
429 +    exit(EXIT_FAILURE);
430    }
431  
432 <  SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_TLSv1);
433 <  SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_SINGLE_DH_USE);
434 <  SSL_CTX_set_verify(ServerInfo.server_ctx, SSL_VERIFY_PEER|SSL_VERIFY_CLIENT_ONCE,
432 >  SSL_CTX_set_options(ConfigServerInfo.server_ctx, SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_TICKET);
433 >  SSL_CTX_set_options(ConfigServerInfo.server_ctx, SSL_OP_SINGLE_DH_USE|SSL_OP_CIPHER_SERVER_PREFERENCE);
434 >  SSL_CTX_set_verify(ConfigServerInfo.server_ctx, SSL_VERIFY_PEER|SSL_VERIFY_CLIENT_ONCE,
435                       always_accept_verify_cb);
436 <  SSL_CTX_set_session_id_context(ServerInfo.server_ctx, session_id, sizeof(session_id) - 1);
436 >  SSL_CTX_set_session_cache_mode(ConfigServerInfo.server_ctx, SSL_SESS_CACHE_OFF);
437  
438   #if OPENSSL_VERSION_NUMBER >= 0x1000005FL && !defined(OPENSSL_NO_ECDH)
439    {
# Line 445 | Line 441 | ssl_init(void)
441  
442      if (key)
443      {
444 <      SSL_CTX_set_tmp_ecdh(ServerInfo.server_ctx, key);
444 >      SSL_CTX_set_tmp_ecdh(ConfigServerInfo.server_ctx, key);
445        EC_KEY_free(key);
446      }
447    }
448  
449 <  SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_SINGLE_ECDH_USE);
449 >  SSL_CTX_set_options(ConfigServerInfo.server_ctx, SSL_OP_SINGLE_ECDH_USE);
450   #endif
451  
452 <  if ((ServerInfo.client_ctx = SSL_CTX_new(SSLv23_client_method())) == NULL)
452 >  if ((ConfigServerInfo.client_ctx = SSL_CTX_new(SSLv23_client_method())) == NULL)
453    {
454      const char *s = ERR_lib_error_string(ERR_get_error());
455  
456      fprintf(stderr, "ERROR: Could not initialize the SSL Client context -- %s\n", s);
457      ilog(LOG_TYPE_IRCD, "ERROR: Could not initialize the SSL Client context -- %s\n", s);
458 +    exit(EXIT_FAILURE);
459    }
460  
461 <  SSL_CTX_set_options(ServerInfo.client_ctx, SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_TLSv1);
462 <  SSL_CTX_set_options(ServerInfo.client_ctx, SSL_OP_SINGLE_DH_USE);
463 <  SSL_CTX_set_verify(ServerInfo.client_ctx, SSL_VERIFY_PEER|SSL_VERIFY_CLIENT_ONCE,
461 >  SSL_CTX_set_options(ConfigServerInfo.client_ctx, SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_TICKET);
462 >  SSL_CTX_set_options(ConfigServerInfo.client_ctx, SSL_OP_SINGLE_DH_USE);
463 >  SSL_CTX_set_verify(ConfigServerInfo.client_ctx, SSL_VERIFY_PEER|SSL_VERIFY_CLIENT_ONCE,
464                       always_accept_verify_cb);
465 +  SSL_CTX_set_session_cache_mode(ConfigServerInfo.client_ctx, SSL_SESS_CACHE_OFF);
466   #endif /* HAVE_LIBCRYPTO */
467   }
468  
# Line 487 | Line 485 | main(int argc, char *argv[])
485    /* It ain't random, but it ought to be a little harder to guess */
486    init_genrand(SystemTime.tv_sec ^ (SystemTime.tv_usec | (getpid() << 20)));
487  
488 <  me.localClient = &meLocalUser;
488 >  me.connection = &meConnection;
489    dlinkAdd(&me, &me.node, &global_client_list);  /* Pointer to beginning
490                                                     of Client list */
491 <  ConfigLoggingEntry.use_logging = 1;
492 <  ConfigFileEntry.dpath      = DPATH;
493 <  ConfigFileEntry.spath      = SPATH;
494 <  ConfigFileEntry.mpath      = MPATH;
495 <  ConfigFileEntry.configfile = CPATH;    /* Server configuration file */
496 <  ConfigFileEntry.klinefile  = KPATH;    /* Server kline file         */
497 <  ConfigFileEntry.glinefile  = GPATH;    /* Server gline file         */
498 <  ConfigFileEntry.xlinefile  = XPATH;    /* Server xline file         */
499 <  ConfigFileEntry.dlinefile  = DLPATH;   /* dline file                */
500 <  ConfigFileEntry.resvfile   = RESVPATH; /* resv file                 */
491 >  ConfigLog.use_logging = 1;
492 >  ConfigGeneral.dpath      = DPATH;
493 >  ConfigGeneral.spath      = SPATH;
494 >  ConfigGeneral.mpath      = MPATH;
495 >  ConfigGeneral.configfile = CPATH;    /* Server configuration file */
496 >  ConfigGeneral.klinefile  = KPATH;    /* Server kline file         */
497 >  ConfigGeneral.glinefile  = GPATH;    /* Server gline file         */
498 >  ConfigGeneral.xlinefile  = XPATH;    /* Server xline file         */
499 >  ConfigGeneral.dlinefile  = DLPATH;   /* dline file                */
500 >  ConfigGeneral.resvfile   = RESVPATH; /* resv file                 */
501  
502    myargv = argv;
503    umask(077);                /* better safe than sorry --SRB */
# Line 512 | Line 510 | main(int argc, char *argv[])
510      exit(EXIT_SUCCESS);
511    }
512  
513 <  if (chdir(ConfigFileEntry.dpath))
513 >  if (chdir(ConfigGeneral.dpath))
514    {
515      perror("chdir");
516      exit(EXIT_FAILURE);
# Line 533 | Line 531 | main(int argc, char *argv[])
531    /* We need this to initialise the fd array before anything else */
532    fdlist_init();
533    log_set_file(LOG_TYPE_IRCD, 0, logFileName);
534 <  check_can_use_v6();
534 >
535    init_netio();         /* This needs to be setup early ! -- adrian */
536  
537    /* Check if there is pidfile and daemon already running */
# Line 544 | Line 542 | main(int argc, char *argv[])
542    init_isupport();
543    dbuf_init();
544    hash_init();
545 <  init_ip_hash_table();      /* client host ip hash table */
545 >  ipcache_init();
546    init_host_hash();          /* Host-hashtable. */
547    client_init();
548    class_init();
# Line 564 | Line 562 | main(int argc, char *argv[])
562    geoip_ctx = GeoIP_new(GEOIP_MEMORY_CACHE);
563   #endif
564  
565 <  if (EmptyString(ServerInfo.sid))
565 >  if (EmptyString(ConfigServerInfo.sid))
566    {
567      ilog(LOG_TYPE_IRCD, "ERROR: No server id specified in serverinfo block.");
568      exit(EXIT_FAILURE);
569    }
570  
571 <  strlcpy(me.id, ServerInfo.sid, sizeof(me.id));
571 >  strlcpy(me.id, ConfigServerInfo.sid, sizeof(me.id));
572  
573 <  if (EmptyString(ServerInfo.name))
573 >  if (EmptyString(ConfigServerInfo.name))
574    {
575      ilog(LOG_TYPE_IRCD, "ERROR: No server name specified in serverinfo block.");
576      exit(EXIT_FAILURE);
577    }
578  
579 <  strlcpy(me.name, ServerInfo.name, sizeof(me.name));
579 >  strlcpy(me.name, ConfigServerInfo.name, sizeof(me.name));
580  
581    /* serverinfo{} description must exist.  If not, error out.*/
582 <  if (EmptyString(ServerInfo.description))
582 >  if (EmptyString(ConfigServerInfo.description))
583    {
584      ilog(LOG_TYPE_IRCD, "ERROR: No server description specified in serverinfo block.");
585      exit(EXIT_FAILURE);
586    }
587  
588 <  strlcpy(me.info, ServerInfo.description, sizeof(me.info));
588 >  strlcpy(me.info, ConfigServerInfo.description, sizeof(me.info));
589  
590    me.from                   = &me;
591    me.servptr                = &me;
592 <  me.localClient->lasttime  = CurrentTime;
593 <  me.localClient->since     = CurrentTime;
594 <  me.localClient->firsttime = CurrentTime;
592 >  me.connection->lasttime  = CurrentTime;
593 >  me.connection->since     = CurrentTime;
594 >  me.connection->firsttime = CurrentTime;
595  
596    SetMe(&me);
597    make_server(&me);
# Line 601 | Line 599 | main(int argc, char *argv[])
599    hash_add_id(&me);
600    hash_add_client(&me);
601  
602 <  /* add ourselves to global_serv_list */
605 <  dlinkAdd(&me, make_dlink_node(), &global_serv_list);
602 >  dlinkAdd(&me, make_dlink_node(), &global_server_list);
603  
604    load_kline_database();
605    load_dline_database();
# Line 621 | Line 618 | main(int argc, char *argv[])
618    load_core_modules(1);
619  
620    /* Go back to DPATH after checking to see if we can chdir to MODPATH */
621 <  if (chdir(ConfigFileEntry.dpath))
621 >  if (chdir(ConfigGeneral.dpath))
622    {
623      perror("chdir");
624      exit(EXIT_FAILURE);
# Line 645 | Line 642 | main(int argc, char *argv[])
642    event_addish(&event_try_connections, NULL);
643  
644    /* Setup the timeout check. I'll shift it later :)  -- adrian */
645 <  event_addish(&event_comm_checktimeouts, NULL);
645 >  event_add(&event_comm_checktimeouts, NULL);
646  
647    event_addish(&event_save_all_databases, NULL);
648  

Diff Legend

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