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

Comparing:
ircd-hybrid/trunk/src/ircd.c (file contents), Revision 3321 by michael, Tue Apr 15 16:02:56 2014 UTC vs.
ircd-hybrid/branches/8.2.x/src/ircd.c (file contents), Revision 4208 by michael, Sat Jul 12 18:13:06 2014 UTC

# Line 25 | Line 25
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"
# Line 40 | Line 40
40   #include "conf.h"
41   #include "hostmask.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 "log.h"
49 < #include "s_serv.h"      /* try_connections */
49 > #include "server.h"      /* try_connections */
50   #include "send.h"
51   #include "whowas.h"
52   #include "modules.h"
53   #include "memory.h"
54   #include "mempool.h"
55   #include "ircd_getopt.h"
56 #include "supported.h"
56   #include "watch.h"
57   #include "conf_db.h"
58   #include "conf_class.h"
# Line 63 | Line 62
62   GeoIP *geoip_ctx;
63   #endif
64  
66 /* /quote set variables */
67 struct SetOptions GlobalSetOptions;
68 struct Counter Count;
69 struct ServerState_t server_state;
65   struct ServerStatistics ServerStats;
66   struct timeval SystemTime;
67   struct Client me;             /* That's me */
# Line 83 | Line 78 | int doremotd = 0;
78   /* Set to zero because it should be initialized later using
79   * initialize_server_capabs
80   */
81 < int default_server_capabs = 0;
81 > unsigned int default_server_capabs;
82   unsigned int splitmode;
83   unsigned int splitchecking;
84   unsigned int split_users;
85   unsigned int split_servers;
86  
87 < /* Do klines the same way hybrid-6 did them, i.e. at the
88 < * top of the next io_loop instead of in the same loop as
89 < * the klines are being applied.
90 < *
91 < * This should fix strange CPU starvation as very indirectly reported.
92 < * (Why do you people not email bug reports? WHY? WHY?)
93 < *
94 < * - Dianora
95 < */
87 > static struct event event_cleanup_glines =
88 > {
89 >  .name = "cleanup_glines",
90 >  .handler = cleanup_glines,
91 >  .when = CLEANUP_GLINES_TIME
92 > };
93 >
94 > static struct event event_cleanup_tklines =
95 > {
96 >  .name = "cleanup_tklines",
97 >  .handler = cleanup_tklines,
98 >  .when = CLEANUP_TKLINES_TIME
99 > };
100 >
101 > static struct event event_try_connections =
102 > {
103 >  .name = "try_connections",
104 >  .handler = try_connections,
105 >  .when = STARTUP_CONNECTIONS_TIME
106 > };
107  
108 < int rehashed_klines = 0;
108 > static struct event event_comm_checktimeouts =
109 > {
110 >  .name = "comm_checktimeouts",
111 >  .handler = comm_checktimeouts,
112 >  .when = 1
113 > };
114 >
115 > static struct event event_save_all_databases =
116 > {
117 >  .name = "save_all_databases",
118 >  .handler = save_all_databases,
119 >  .when = DATABASE_UPDATE_TIMEOUT
120 > };
121 >
122 > struct event event_write_links_file =
123 > {
124 >  .name = "write_links_file",
125 >  .handler = write_links_file,
126 > };
127  
128  
129   /*
# Line 196 | Line 220 | io_loop(void)
220   {
221    while (1)
222    {
199    /*
200     * Maybe we want a flags word?
201     * ie. if (REHASHED_KLINES(global_flags))
202     * SET_REHASHED_KLINES(global_flags)
203     * CLEAR_REHASHED_KLINES(global_flags)
204     *
205     * - Dianora
206     */
207    if (rehashed_klines)
208    {
209      check_conf_klines();
210      rehashed_klines = 0;
211    }
212
223      if (listing_client_list.head)
224      {
225        dlink_node *ptr = NULL, *ptr_next = NULL;
# Line 217 | Line 227 | io_loop(void)
227          safe_list_channels(ptr->data, 0);
228      }
229  
230 <    /* Run pending events, then get the number of seconds to the next
231 <     * event
222 <     */
223 <    while (eventNextTime() <= CurrentTime)
224 <      eventRun();
230 >    /* Run pending events */
231 >    event_run();
232  
233      comm_select();
234      exit_aborted_clients();
# Line 253 | Line 260 | io_loop(void)
260   static void
261   initialize_global_set_options(void)
262   {
256  memset(&GlobalSetOptions, 0, sizeof(GlobalSetOptions));
257
263    GlobalSetOptions.autoconn  = 1;
264    GlobalSetOptions.spam_time = MIN_JOIN_LEAVE_TIME;
265    GlobalSetOptions.spam_num  = MAX_JOIN_LEAVE_COUNT;
# Line 279 | Line 284 | initialize_global_set_options(void)
284    }
285  
286    GlobalSetOptions.ident_timeout = IDENT_TIMEOUT;
282  /* End of global set options */
287   }
288  
289   /* initialize_server_capabs()
# Line 296 | Line 300 | initialize_server_capabs(void)
300    add_capability("CLUSTER", CAP_CLUSTER, 1);
301    add_capability("SVS", CAP_SVS, 1);
302    add_capability("CHW", CAP_CHW, 1);
299 #ifdef HALFOPS
303    add_capability("HOPS", CAP_HOPS, 1);
301 #endif
304   }
305  
306   /* write_pidfile()
# Line 422 | Line 424 | ssl_init(void)
424  
425    if ((ServerInfo.server_ctx = SSL_CTX_new(SSLv23_server_method())) == NULL)
426    {
427 <    const char *s;
427 >    const char *s = ERR_lib_error_string(ERR_get_error());
428  
429 <    fprintf(stderr, "ERROR: Could not initialize the SSL Server context -- %s\n",
428 <            s = ERR_lib_error_string(ERR_get_error()));
429 >    fprintf(stderr, "ERROR: Could not initialize the SSL Server context -- %s\n", s);
430      ilog(LOG_TYPE_IRCD, "ERROR: Could not initialize the SSL Server context -- %s\n", s);
431    }
432  
433 <  SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_TLSv1);
434 <  SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_TLS_ROLLBACK_BUG|SSL_OP_ALL);
433 >  SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3);
434 >  SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_SINGLE_DH_USE);
435    SSL_CTX_set_verify(ServerInfo.server_ctx, SSL_VERIFY_PEER|SSL_VERIFY_CLIENT_ONCE,
436                       always_accept_verify_cb);
437    SSL_CTX_set_session_id_context(ServerInfo.server_ctx, session_id, sizeof(session_id) - 1);
438  
439 + #if OPENSSL_VERSION_NUMBER >= 0x1000005FL && !defined(OPENSSL_NO_ECDH)
440 +  {
441 +    EC_KEY *key = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);
442 +
443 +    if (key)
444 +    {
445 +      SSL_CTX_set_tmp_ecdh(ServerInfo.server_ctx, key);
446 +      EC_KEY_free(key);
447 +    }
448 +  }
449 +
450 +  SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_SINGLE_ECDH_USE);
451 + #endif
452 +
453    if ((ServerInfo.client_ctx = SSL_CTX_new(SSLv23_client_method())) == NULL)
454    {
455 <    const char *s;
455 >    const char *s = ERR_lib_error_string(ERR_get_error());
456  
457 <    fprintf(stderr, "ERROR: Could not initialize the SSL Client context -- %s\n",
443 <            s = ERR_lib_error_string(ERR_get_error()));
457 >    fprintf(stderr, "ERROR: Could not initialize the SSL Client context -- %s\n", s);
458      ilog(LOG_TYPE_IRCD, "ERROR: Could not initialize the SSL Client context -- %s\n", s);
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_TLS_ROLLBACK_BUG|SSL_OP_ALL);
461 >  SSL_CTX_set_options(ServerInfo.client_ctx, SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3);
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,
464                       always_accept_verify_cb);
465   #endif /* HAVE_LIBCRYPTO */
# Line 457 | Line 471 | main(int argc, char *argv[])
471    /* Check to see if the user is running us as root, which is a nono */
472    if (geteuid() == 0)
473    {
474 <    fprintf(stderr, "Don't run ircd as root!!!\n");
474 >    fprintf(stderr, "ERROR: This server won't run as root/superuser\n");
475      return -1;
476    }
477  
# Line 473 | Line 487 | main(int argc, char *argv[])
487    me.localClient = &meLocalUser;
488    dlinkAdd(&me, &me.node, &global_client_list);  /* Pointer to beginning
489                                                     of Client list */
490 +  ConfigLoggingEntry.use_logging = 1;
491    ConfigFileEntry.dpath      = DPATH;
492    ConfigFileEntry.spath      = SPATH;
493    ConfigFileEntry.mpath      = MPATH;
# Line 512 | Line 527 | main(int argc, char *argv[])
527  
528    setup_signals();
529  
515  /* Init the event subsystem */
516  eventInit();
517
530    /* We need this to initialise the fd array before anything else */
531    fdlist_init();
532    log_set_file(LOG_TYPE_IRCD, 0, logFileName);
# Line 586 | Line 598 | main(int argc, char *argv[])
598    hash_add_id(&me);
599    hash_add_client(&me);
600  
601 <  /* add ourselves to global_serv_list */
590 <  dlinkAdd(&me, make_dlink_node(), &global_serv_list);
601 >  dlinkAdd(&me, make_dlink_node(), &global_server_list);
602  
603    load_kline_database();
604    load_dline_database();
# Line 622 | Line 633 | main(int argc, char *argv[])
633  
634    ilog(LOG_TYPE_IRCD, "Server Ready");
635  
636 <  eventAddIsh("cleanup_glines", cleanup_glines, NULL, CLEANUP_GLINES_TIME);
637 <  eventAddIsh("cleanup_tklines", cleanup_tklines, NULL, CLEANUP_TKLINES_TIME);
636 >  event_addish(&event_cleanup_glines, NULL);
637 >  event_addish(&event_cleanup_tklines, NULL);
638  
639    /* We want try_connections to be called as soon as possible now! -- adrian */
640    /* No, 'cause after a restart it would cause all sorts of nick collides */
641 <  eventAddIsh("try_connections", try_connections, NULL, STARTUP_CONNECTIONS_TIME);
641 >  event_addish(&event_try_connections, NULL);
642  
643    /* Setup the timeout check. I'll shift it later :)  -- adrian */
644 <  eventAddIsh("comm_checktimeouts", comm_checktimeouts, NULL, 1);
644 >  event_addish(&event_comm_checktimeouts, NULL);
645  
646 <  eventAddIsh("save_all_databases", save_all_databases, NULL, DATABASE_UPDATE_TIMEOUT);
646 >  event_addish(&event_save_all_databases, NULL);
647  
648    if (ConfigServerHide.links_delay > 0)
649 <    eventAddIsh("write_links_file", write_links_file, NULL, ConfigServerHide.links_delay);
649 >  {
650 >    event_write_links_file.when = ConfigServerHide.links_delay;
651 >    event_addish(&event_write_links_file, NULL);
652 >  }
653    else
654      ConfigServerHide.links_disabled = 1;
655  
656    if (splitmode)
657 <    eventAddIsh("check_splitmode", check_splitmode, NULL, 60);
657 >    event_addish(&splitmode_event, NULL);
658  
659    io_loop();
660    return 0;

Diff Legend

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