--- /tmp/jabberd-2.1.24.1/router/main.c 2008-04-27 02:57:33.000000000 -0700 +++ ./jabberd2/router/main.c 2009-09-30 16:38:49.000000000 -0700 @@ -66,7 +66,7 @@ static void _router_config_expand(router { char *str, *ip, *mask, *name, *target; config_elem_t elem; - int i; + int i, len; alias_t alias; r->id = config_get_one(r->config, "id", 0); @@ -101,6 +101,8 @@ static void _router_config_expand(router r->local_pemfile = config_get_one(r->config, "local.pemfile", 0); + r->local_private_key_password = config_get_one(r->config, "local.private_key_password", 0); + r->io_max_fds = j_atoi(config_get_one(r->config, "io.max_fds", 0), 1024); elem = config_get(r->config, "io.limits.bytes"); @@ -186,6 +188,23 @@ static void _router_config_expand(router r->aliases = alias; } + /* message logging to flat file */ + r->message_logging_enabled = j_atoi(config_get_one(r->config, "message_logging_enabled", 0), 1); + r->message_logging_dir = config_get_one(r->config, "message_logging_dir", 0); + r->message_logging_file = config_get_one(r->config, "message_logging_file", 0); + len = strlen(r->message_logging_dir) + strlen(r->message_logging_file); + if (len < (PATH_MAX-13)) { // room for a full path plus .xxxx.gz appended (necessary for log rolling) + r->message_logging_fullpath = (char *)malloc(len+2); + snprintf(r->message_logging_fullpath, len+2, "%s/%s", r->message_logging_dir, r->message_logging_file); + } else { + log_debug(ZONE, "ERROR: message logging directory and filename exceed file system limits, %d bytes.\n Disabling message logging.", len); + r->message_logging_fullpath = NULL; + r->message_logging_enabled = 0; + } + r->message_logging_roll_days = j_atoi(config_get_one(r->config, "message_logging_roll_days", 0), 30); + r->message_logging_roll_megs = j_atoi(config_get_one(r->config, "message_logging_roll_megs", 0), 500); + r->filter_muc_messages_from = config_get_one(r->config, "filter_muc_messages_from", 0); + r->check_interval = j_atoi(config_get_one(r->config, "check.interval", 0), 60); r->check_keepalive = j_atoi(config_get_one(r->config, "check.keepalive", 0), 0); } @@ -282,6 +301,7 @@ JABBER_MAIN("jabberd2router", "Jabber 2 rate_t rt; component_t comp; union xhashv xhv; + int close_wait_max; #ifdef POOL_DEBUG time_t pool_time = 0; @@ -394,11 +414,11 @@ JABBER_MAIN("jabberd2router", "Jabber 2 #ifdef HAVE_SSL if(r->local_pemfile != NULL) { - r->sx_ssl = sx_env_plugin(r->sx_env, sx_ssl_init, r->local_pemfile, NULL, NULL); + r->sx_ssl = sx_env_plugin(r->sx_env, sx_ssl_init, r->local_pemfile, NULL, NULL, r->local_private_key_password); if(r->sx_ssl == NULL) log_write(r->log, LOG_ERR, "failed to load SSL pemfile, SSL disabled"); } -#endif +#endif // HAVE_SSL /* get sasl online */ r->sx_sasl = sx_env_plugin(r->sx_env, sx_sasl_init, "jabberd-router", _router_sx_sasl_callback, (void *) r); @@ -447,6 +467,12 @@ JABBER_MAIN("jabberd2router", "Jabber 2 r->next_check = time(NULL) + r->check_interval; log_debug(ZONE, "next time check at %d", r->next_check); + + if (r->message_logging_enabled) + { + // Roll message logs if necessary + roll_message_log(r); + } } #ifdef POOL_DEBUG @@ -466,12 +492,16 @@ JABBER_MAIN("jabberd2router", "Jabber 2 * their destinations */ + close_wait_max = 30; /* time limit for component shutdown */ + /* close connections to components */ xhv.comp_val = ∁ if(xhash_iter_first(r->components)) do { xhash_iter_get(r->components, NULL, xhv.val); sx_close(comp->s); + if (1 > close_wait_max--) break; + sleep(1); } while(xhash_count(r->components) > 0); xhash_free(r->components); @@ -502,6 +532,10 @@ JABBER_MAIN("jabberd2router", "Jabber 2 /* unload acls */ aci_unload(r->aci); + /* free message logging variables */ + if (r->message_logging_fullpath != NULL) + free(r->message_logging_fullpath); + /* unload filter */ filter_unload(r);