From bffb1981d0d6b8d88c2db6964dd0a3c40893001c Mon Sep 17 00:00:00 2001 From: Daniel Lenski Date: Tue, 7 Apr 2020 23:25:17 -0700 Subject: [PATCH] trigger periodic TNCC even if we have no packets to receive from oNCP, and don't use server's interval if zero Signed-off-by: Daniel Lenski --- auth-juniper.c | 2 +- oncp.c | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/auth-juniper.c b/auth-juniper.c index bafbae58..7ca1361a 100644 --- a/auth-juniper.c +++ b/auth-juniper.c @@ -498,7 +498,7 @@ static int tncc_preauth(struct openconnect_info *vpninfo) goto respfail; if (len > 0) { int interval = atoi(recvbuf); - if (interval != vpninfo->trojan_interval) { + if (interval != 0) { vpninfo->trojan_interval = interval; vpn_progress(vpninfo, PRG_DEBUG, _("Got reauth interval from TNCC: %d seconds\n"), diff --git a/oncp.c b/oncp.c index 72b5ed77..243143da 100644 --- a/oncp.c +++ b/oncp.c @@ -899,6 +899,12 @@ int oncp_mainloop(struct openconnect_info *vpninfo, int *timeout, int readable) int ret; int work_done = 0; + /* Periodic TNCC */ + if (trojan_check_deadline(vpninfo, timeout)) { + oncp_send_tncc_command(vpninfo, 0); + return 1; + } + if (vpninfo->ssl_fd == -1) goto do_reconnect; @@ -915,11 +921,6 @@ int oncp_mainloop(struct openconnect_info *vpninfo, int *timeout, int readable) handle that */ int receive_mtu = MAX(16384, vpninfo->ip_info.mtu); - if (trojan_check_deadline(vpninfo, timeout)) { - /* Periodic TNCC */ - oncp_send_tncc_command(vpninfo, 0); - } - len = receive_mtu + vpninfo->pkt_trailer; if (!vpninfo->cstp_pkt) { vpninfo->cstp_pkt = malloc(sizeof(struct pkt) + len); -- 2.50.1