From 17b45cdd406d3d4218ba08a0835da839a6d79465 Mon Sep 17 00:00:00 2001 From: Wade Cline Date: Tue, 27 Feb 2024 19:19:00 -0800 Subject: [PATCH] Fix logging of rekey / trojan invocation delay 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 Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com> Signed-off-by: Daniel Lenski --- main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index 7ce432bc..00d98f0e 100644 --- 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); -- 2.50.1