]> www.infradead.org Git - users/dwmw2/openconnect.git/commitdiff
Merge branch 'stats_and_connection_info' into 'master'
authorDaniel Lenski <dlenski@gmail.com>
Tue, 5 Jan 2021 17:17:30 +0000 (17:17 +0000)
committerDaniel Lenski <dlenski@gmail.com>
Tue, 5 Jan 2021 17:17:30 +0000 (17:17 +0000)
add SIGUSR1 as trigger to print detailed connection information and stats

See merge request openconnect/openconnect!154

1  2 
library.c
main.c

diff --cc library.c
Simple merge
diff --cc main.c
index 58a7fc0f9806d5d4bf6b769a97be5458a59c7d3e,da4a26bf2ca2b8d2da95baba8034f17119cabf44..f477a4c6c4c9abfc49786db3a0edce54903d289d
--- 1/main.c
--- 2/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;