From c37467ebe490fdaa2863284e0df1e649182f3d2a Mon Sep 17 00:00:00 2001 From: Selva Nair Date: Thu, 8 Jun 2017 10:54:41 -0400 Subject: [PATCH] Distinguish between auth and key password failures Signed-off-by: Selva Nair --- openvpn.c | 7 ++++++- options.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/openvpn.c b/openvpn.c index d3592e7..f8127b5 100644 --- a/openvpn.c +++ b/openvpn.c @@ -220,6 +220,7 @@ OnStateChange(connection_t *c, char *data) /* Save time when we got connected. */ c->connected_since = atoi(data); c->failed_psw_attempts = 0; + c->failed_auth_attempts = 0; c->state = connected; SetMenuStatus(c, connected); @@ -235,7 +236,9 @@ OnStateChange(connection_t *c, char *data) { if (!c->dynamic_cr) { - if (strcmp(message, "auth-failure") == 0 || strcmp(message, "private-key-password-failure") == 0) + if (strcmp(message, "auth-failure") == 0) + c->failed_auth_attempts++; + else if (strcmp(message, "private-key-password-failure") == 0) c->failed_psw_attempts++; if (strcmp(message, "auth-failure") == 0 && (c->flags & FLAG_SAVE_AUTH_PASS)) @@ -848,6 +851,7 @@ OnStop(connection_t *c, UNUSED char *msg) case connected: /* OpenVPN process ended unexpectedly */ c->failed_psw_attempts = 0; + c->failed_auth_attempts = 0; c->state = disconnected; CheckAndSetTrayIcon(); SetDlgItemText(c->hwndStatus, ID_TXT_STATUS, LoadLocalizedString(IDS_NFO_STATE_DISCONNECTED)); @@ -909,6 +913,7 @@ OnStop(connection_t *c, UNUSED char *msg) // } /* Shutdown was initiated by us */ c->failed_psw_attempts = 0; + c->failed_auth_attempts = 0; c->state = disconnected; CheckAndSetTrayIcon(); SendMessage(c->hwndStatus, WM_CLOSE, 0, 0); diff --git a/options.h b/options.h index fa30008..6fc9672 100644 --- a/options.h +++ b/options.h @@ -102,6 +102,7 @@ struct connection { BOOL auto_connect; /* AutoConnect at startup id TRUE */ conn_state_t state; /* State the connection currently is in */ int failed_psw_attempts; /* # of failed attempts entering password(s) */ + int failed_auth_attempts; /* # of failed user-auth attempts */ time_t connected_since; /* Time when the connection was established */ proxy_t proxy_type; /* Set during querying proxy credentials */