]> www.infradead.org Git - users/dwmw2/openconnect.git/commitdiff
Fix logging of rekey / trojan invocation delay
authorWade Cline <wade.cline@intel.com>
Wed, 28 Feb 2024 03:19:00 +0000 (19:19 -0800)
committerDaniel Lenski <dlenski@gmail.com>
Wed, 28 Feb 2024 05:40:30 +0000 (21:40 -0800)
Closes #677

The rekey / trojan invocation is supposed to happen in the future.
Therefore subtract current time from expected time of rekey / invocation,
not the reverse.

These delays have been shown incorrectly ever since the SIGUSR1 handler was
added in b156b581e894b03e7169827b9e293ca2f13e1366.

Originally submitted at
https://lists.infradead.org/pipermail/openconnect-devel/2024-February/005400.html

Signed-off-by: Cline, Wade <wade.cline@intel.com>
Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
Signed-off-by: Daniel Lenski <dlenski@gmail.com>
main.c

diff --git a/main.c b/main.c
index 7ce432bc5c5803312ce2b52dd0104befa06e3293..00d98f0e1925c21fc015ef017676560cef84542d 100644 (file)
--- a/main.c
+++ b/main.c
@@ -1614,14 +1614,14 @@ static void print_connection_stats(void *_vpninfo, const struct oc_stats *stats)
                     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"),
-                            (long)(time(NULL) - vpninfo->ssl_times.last_rekey + vpninfo->ssl_times.rekey));
+                            (long)(vpninfo->ssl_times.last_rekey + vpninfo->ssl_times.rekey - time(NULL)));
        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",
-                            (long)(time(NULL) - vpninfo->ssl_times.last_rekey + vpninfo->ssl_times.rekey));
+                            (long)(vpninfo->ssl_times.last_rekey + vpninfo->ssl_times.rekey - time(NULL)));
        if (vpninfo->trojan_interval && vpninfo->last_trojan)
                vpn_progress(vpninfo, PRG_INFO, _("Next Trojan invocation in %ld seconds\n"),
-                            (long)(time(NULL) - vpninfo->last_trojan + vpninfo->trojan_interval));
+                            (long)(vpninfo->last_trojan + vpninfo->trojan_interval - time(NULL)));
 
        /* XX: restore loglevel */
        openconnect_set_loglevel(vpninfo, saved_loglevel);