diff options
-rw-r--r-- | kike.c | 22 |
1 files changed, 16 insertions, 6 deletions
@@ -316,6 +316,7 @@ struct client char *realname; ///< IRC realname (e-mail) char *hostname; ///< Hostname shown to the network + char *address; ///< Full address including port unsigned mode; ///< User's mode char *away_message; ///< Away message @@ -351,6 +352,7 @@ client_free (struct client *self) free (self->realname); free (self->hostname); + free (self->address); free (self->away_message); flood_detector_free (&self->antiflood); } @@ -775,6 +777,10 @@ client_kill (struct client *c, const char *reason) if (c->ssl) (void) SSL_shutdown (c->ssl); xclose (c->socket_fd); + + print_debug ("closed connection to %s (%s)", + c->address, reason ? reason : "Reason omitted"); + c->socket_fd = -1; client_free (c); LIST_UNLINK (ctx->clients, c); @@ -2541,16 +2547,19 @@ start: static bool client_initialize_ssl (struct client *c) { - // SSL support not enabled + const char *error_info = NULL; if (!c->ctx->ssl_ctx) - return false; + { + error_info = "SSL support disabled"; + goto error_ssl_1; + } c->ssl = SSL_new (c->ctx->ssl_ctx); if (!c->ssl) goto error_ssl_1; - if (!SSL_set_fd (c->ssl, c->socket_fd)) goto error_ssl_2; + SSL_set_accept_state (c->ssl); return true; @@ -2560,8 +2569,9 @@ error_ssl_2: error_ssl_1: // XXX: these error strings are really nasty; also there could be // multiple errors on the OpenSSL stack. - print_debug ("%s: %s: %s", "could not initialize SSL", - c->hostname, ERR_error_string (ERR_get_error (), NULL)); + if (!error_info) + error_info = ERR_error_string (ERR_get_error (), NULL); + print_debug ("could not initialize SSL for %s: %s", c->address, error_info); return false; } @@ -2664,13 +2674,13 @@ on_irc_client_available (const struct pollfd *pfd, void *user_data) char *address = format_host_port_pair (host, port); print_debug ("accepted connection from %s", address); - free (address); struct client *c = xmalloc (sizeof *c); client_init (c); c->ctx = ctx; c->socket_fd = fd; c->hostname = xstrdup (host); + c->address = address; c->last_active = time (NULL); LIST_PREPEND (ctx->clients, c); ctx->n_clients++; |