kike: better debug messages
I had a wonderful "I'm a fucking idiot" moment when I tried connecting over SSL/TLS with no certificate at the server. By the way, ZyklonB crashes with FreeBSD 10's Valgrind and gdb seemingly loses track of execution while in getaddrinfo().
This commit is contained in:
parent
19ff2715b5
commit
37e1895fd0
22
kike.c
22
kike.c
|
@ -316,6 +316,7 @@ struct client
|
||||||
char *realname; ///< IRC realname (e-mail)
|
char *realname; ///< IRC realname (e-mail)
|
||||||
|
|
||||||
char *hostname; ///< Hostname shown to the network
|
char *hostname; ///< Hostname shown to the network
|
||||||
|
char *address; ///< Full address including port
|
||||||
|
|
||||||
unsigned mode; ///< User's mode
|
unsigned mode; ///< User's mode
|
||||||
char *away_message; ///< Away message
|
char *away_message; ///< Away message
|
||||||
|
@ -351,6 +352,7 @@ client_free (struct client *self)
|
||||||
free (self->realname);
|
free (self->realname);
|
||||||
|
|
||||||
free (self->hostname);
|
free (self->hostname);
|
||||||
|
free (self->address);
|
||||||
free (self->away_message);
|
free (self->away_message);
|
||||||
flood_detector_free (&self->antiflood);
|
flood_detector_free (&self->antiflood);
|
||||||
}
|
}
|
||||||
|
@ -775,6 +777,10 @@ client_kill (struct client *c, const char *reason)
|
||||||
if (c->ssl)
|
if (c->ssl)
|
||||||
(void) SSL_shutdown (c->ssl);
|
(void) SSL_shutdown (c->ssl);
|
||||||
xclose (c->socket_fd);
|
xclose (c->socket_fd);
|
||||||
|
|
||||||
|
print_debug ("closed connection to %s (%s)",
|
||||||
|
c->address, reason ? reason : "Reason omitted");
|
||||||
|
|
||||||
c->socket_fd = -1;
|
c->socket_fd = -1;
|
||||||
client_free (c);
|
client_free (c);
|
||||||
LIST_UNLINK (ctx->clients, c);
|
LIST_UNLINK (ctx->clients, c);
|
||||||
|
@ -2541,16 +2547,19 @@ start:
|
||||||
static bool
|
static bool
|
||||||
client_initialize_ssl (struct client *c)
|
client_initialize_ssl (struct client *c)
|
||||||
{
|
{
|
||||||
// SSL support not enabled
|
const char *error_info = NULL;
|
||||||
if (!c->ctx->ssl_ctx)
|
if (!c->ctx->ssl_ctx)
|
||||||
return false;
|
{
|
||||||
|
error_info = "SSL support disabled";
|
||||||
|
goto error_ssl_1;
|
||||||
|
}
|
||||||
|
|
||||||
c->ssl = SSL_new (c->ctx->ssl_ctx);
|
c->ssl = SSL_new (c->ctx->ssl_ctx);
|
||||||
if (!c->ssl)
|
if (!c->ssl)
|
||||||
goto error_ssl_1;
|
goto error_ssl_1;
|
||||||
|
|
||||||
if (!SSL_set_fd (c->ssl, c->socket_fd))
|
if (!SSL_set_fd (c->ssl, c->socket_fd))
|
||||||
goto error_ssl_2;
|
goto error_ssl_2;
|
||||||
|
|
||||||
SSL_set_accept_state (c->ssl);
|
SSL_set_accept_state (c->ssl);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
@ -2560,8 +2569,9 @@ error_ssl_2:
|
||||||
error_ssl_1:
|
error_ssl_1:
|
||||||
// XXX: these error strings are really nasty; also there could be
|
// XXX: these error strings are really nasty; also there could be
|
||||||
// multiple errors on the OpenSSL stack.
|
// multiple errors on the OpenSSL stack.
|
||||||
print_debug ("%s: %s: %s", "could not initialize SSL",
|
if (!error_info)
|
||||||
c->hostname, ERR_error_string (ERR_get_error (), NULL));
|
error_info = ERR_error_string (ERR_get_error (), NULL);
|
||||||
|
print_debug ("could not initialize SSL for %s: %s", c->address, error_info);
|
||||||
return false;
|
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);
|
char *address = format_host_port_pair (host, port);
|
||||||
print_debug ("accepted connection from %s", address);
|
print_debug ("accepted connection from %s", address);
|
||||||
free (address);
|
|
||||||
|
|
||||||
struct client *c = xmalloc (sizeof *c);
|
struct client *c = xmalloc (sizeof *c);
|
||||||
client_init (c);
|
client_init (c);
|
||||||
c->ctx = ctx;
|
c->ctx = ctx;
|
||||||
c->socket_fd = fd;
|
c->socket_fd = fd;
|
||||||
c->hostname = xstrdup (host);
|
c->hostname = xstrdup (host);
|
||||||
|
c->address = address;
|
||||||
c->last_active = time (NULL);
|
c->last_active = time (NULL);
|
||||||
LIST_PREPEND (ctx->clients, c);
|
LIST_PREPEND (ctx->clients, c);
|
||||||
ctx->n_clients++;
|
ctx->n_clients++;
|
||||||
|
|
Loading…
Reference in New Issue