From 51a19a8f7da3e0c2611487c484f8f741df429649 Mon Sep 17 00:00:00 2001 From: Frank Fesevur Date: Tue, 1 Dec 2020 11:53:28 +0100 Subject: [PATCH] Only change to reconnecting when already connected --- openvpn.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/openvpn.c b/openvpn.c index 6e8c14f..51a0faf 100644 --- a/openvpn.c +++ b/openvpn.c @@ -324,12 +324,19 @@ OnStateChange(connection_t *c, char *data) c->failed_psw_attempts++; } - c->state = reconnecting; - CheckAndSetTrayIcon(); + // We change the state to reconnecting only if there was a prior successful connection. + if (c->state == connected) + { + c->state = reconnecting; - SetDlgItemText(c->hwndStatus, ID_TXT_STATUS, LoadLocalizedString(IDS_NFO_STATE_RECONNECTING)); - SetDlgItemTextW(c->hwndStatus, ID_TXT_IP, L""); - SetStatusWinIcon(c->hwndStatus, ID_ICO_CONNECTING); + // Update the tray icon + CheckAndSetTrayIcon(); + + // And the texts in the status window + SetDlgItemText(c->hwndStatus, ID_TXT_STATUS, LoadLocalizedString(IDS_NFO_STATE_RECONNECTING)); + SetDlgItemTextW(c->hwndStatus, ID_TXT_IP, L""); + SetStatusWinIcon(c->hwndStatus, ID_ICO_CONNECTING); + } } }