Add statistics about OpenSSL events such as handshakes, closes and errors.

This commit is contained in:
Jan Vidar Krey 2019-06-18 15:59:22 +02:00
parent 022a9895ec
commit 0ae96b0da8
3 changed files with 39 additions and 3 deletions

View File

@ -1,6 +1,6 @@
/* /*
* uhub - A tiny ADC p2p connection hub * uhub - A tiny ADC p2p connection hub
* Copyright (C) 2007-2014, Jan Vidar Krey * Copyright (C) 2007-2019, Jan Vidar Krey
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -805,4 +805,22 @@ void net_stats_add_close()
stats.closed++; stats.closed++;
} }
void net_stats_tls_add_accept()
{
stats.tls_accept++;
}
void net_stats_tls_add_connect()
{
stats.tls_connect++;
}
void net_stats_tls_add_error()
{
stats.tls_error++;
}
void net_stats_tls_add_close()
{
stats.tls_close++;
}

View File

@ -1,6 +1,6 @@
/* /*
* uhub - A tiny ADC p2p connection hub * uhub - A tiny ADC p2p connection hub
* Copyright (C) 2007-2014, Jan Vidar Krey * Copyright (C) 2007-2019, Jan Vidar Krey
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -28,6 +28,10 @@ struct net_statistics
size_t accept; size_t accept;
size_t closed; size_t closed;
size_t errors; size_t errors;
size_t tls_accept;
size_t tls_connect;
size_t tls_error;
size_t tls_close;
}; };
struct net_socket_t; struct net_socket_t;
@ -247,9 +251,14 @@ extern void net_stats_report();
extern void net_stats_reset(); extern void net_stats_reset();
extern void net_stats_add_tx(size_t bytes); extern void net_stats_add_tx(size_t bytes);
extern void net_stats_add_rx(size_t bytes); extern void net_stats_add_rx(size_t bytes);
extern void net_stats_tls_add_accept();
extern void net_stats_tls_add_connect();
extern void net_stats_tls_add_error();
extern void net_stats_tls_add_close();
extern void net_stats_add_accept(); extern void net_stats_add_accept();
extern void net_stats_add_error(); extern void net_stats_add_error();
extern void net_stats_add_close(); extern void net_stats_add_close();
extern void net_stats_add_connect();
extern int net_stats_timeout(); extern int net_stats_timeout();
extern void net_stats_get(struct net_statistics** intermediate, struct net_statistics** total); extern void net_stats_get(struct net_statistics** intermediate, struct net_statistics** total);

View File

@ -1,6 +1,6 @@
/* /*
* uhub - A tiny ADC p2p connection hub * uhub - A tiny ADC p2p connection hub
* Copyright (C) 2007-2014, Jan Vidar Krey * Copyright (C) 2007-2019, Jan Vidar Krey
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -27,6 +27,10 @@
void net_stats_add_tx(size_t bytes); void net_stats_add_tx(size_t bytes);
void net_stats_add_rx(size_t bytes); void net_stats_add_rx(size_t bytes);
void net_stats_tls_add_accept();
void net_stats_tls_add_errors();
void net_stats_tls_add_accept();
struct net_ssl_openssl struct net_ssl_openssl
{ {
@ -329,13 +333,16 @@ static int handle_openssl_error(struct net_connection* con, int ret, int read)
case SSL_ERROR_SSL: case SSL_ERROR_SSL:
net_ssl_set_state(handle, tls_st_error); net_ssl_set_state(handle, tls_st_error);
net_stats_tls_add_error();
return -2; return -2;
case SSL_ERROR_SYSCALL: case SSL_ERROR_SYSCALL:
net_ssl_set_state(handle, tls_st_error); net_ssl_set_state(handle, tls_st_error);
net_stats_tls_add_error();
return -2; return -2;
} }
net_stats_tls_add_error();
return -2; return -2;
} }
@ -351,6 +358,7 @@ ssize_t net_con_ssl_accept(struct net_connection* con)
{ {
net_con_update(con, NET_EVENT_READ); net_con_update(con, NET_EVENT_READ);
net_ssl_set_state(handle, tls_st_connected); net_ssl_set_state(handle, tls_st_connected);
net_stats_tls_add_accept();
return ret; return ret;
} }
return handle_openssl_error(con, ret, tls_st_accepting); return handle_openssl_error(con, ret, tls_st_accepting);
@ -369,6 +377,7 @@ ssize_t net_con_ssl_connect(struct net_connection* con)
{ {
net_con_update(con, NET_EVENT_READ); net_con_update(con, NET_EVENT_READ);
net_ssl_set_state(handle, tls_st_connected); net_ssl_set_state(handle, tls_st_connected);
net_stats_tls_add_connect();
return ret; return ret;
} }