From: Daniel Lenski Date: Tue, 5 Jan 2021 17:17:30 +0000 (+0000) Subject: Merge branch 'stats_and_connection_info' into 'master' X-Git-Tag: v8.20~373 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=4df34b87de54fd875b9fb5aa1712cf1b592875b9;p=users%2Fdwmw2%2Fopenconnect.git Merge branch 'stats_and_connection_info' into 'master' add SIGUSR1 as trigger to print detailed connection information and stats See merge request openconnect/openconnect!154 --- 4df34b87de54fd875b9fb5aa1712cf1b592875b9 diff --cc main.c index 58a7fc0f,da4a26bf..f477a4c6 --- a/main.c +++ b/main.c @@@ -1418,13 -1424,44 +1424,47 @@@ static void print_connection_info(struc (ip_info->netmask6 && ip_info->addr) ? " + " : "", ip_info->netmask6 ? : "", ssl_compr ? " + " : "", ssl_compr ? : "", + ssl_state, vpninfo->proto->udp_protocol ? : "UDP", udp_compr ? " + " : "", udp_compr ? : "", dtls_state); + if (vpninfo->auth_expiration != 0) + vpn_progress(vpninfo, PRG_INFO, _("Session authentication will expire at %s"), + ctime(&vpninfo->auth_expiration)); } + static void print_connection_stats(void *_vpninfo, const struct oc_stats *stats) + { + struct openconnect_info *vpninfo = _vpninfo; + int saved_loglevel = vpninfo->verbose; + + /* XX: print even if loglevel would otherwise suppress */ + openconnect_set_loglevel(vpninfo, PRG_INFO); + + print_connection_info(vpninfo); + vpn_progress(vpninfo, PRG_INFO, + _("RX: %ld packets (%ld B); TX: %ld packets (%ld B)\n"), + stats->rx_pkts, stats->rx_bytes, stats->tx_pkts, stats->tx_bytes); + + if (vpninfo->ssl_fd != -1) + vpn_progress(vpninfo, PRG_INFO, _("SSL ciphersuite: %s\n"), openconnect_get_cstp_cipher(vpninfo)); + if (vpninfo->dtls_state == DTLS_CONNECTED) + vpn_progress(vpninfo, PRG_INFO, _("%s ciphersuite: %s\n"), + vpninfo->proto->udp_protocol ? : "UDP", openconnect_get_dtls_cipher(vpninfo)); + if (vpninfo->ssl_times.last_rekey && vpninfo->ssl_times.rekey) + vpn_progress(vpninfo, PRG_INFO, _("Next SSL rekey in %ld seconds\n"), + time(NULL) - vpninfo->ssl_times.last_rekey + vpninfo->ssl_times.rekey); + if (vpninfo->dtls_times.last_rekey && vpninfo->dtls_times.rekey) + vpn_progress(vpninfo, PRG_INFO, _("Next %s rekey in %ld seconds\n"), + vpninfo->proto->udp_protocol ? : "UDP", + time(NULL) - vpninfo->ssl_times.last_rekey + vpninfo->ssl_times.rekey); + if (vpninfo->trojan_interval && vpninfo->last_trojan) + vpn_progress(vpninfo, PRG_INFO, _("Next Trojan invocation in %ld seconds\n"), + time(NULL) - vpninfo->last_trojan + vpninfo->trojan_interval); + + /* XX: restore loglevel */ + openconnect_set_loglevel(vpninfo, saved_loglevel); + } + #ifndef _WIN32 static FILE *background_self(struct openconnect_info *vpninfo, char *pidfile) { FILE *fp = NULL;