diff --git a/openvpn-gui-res.h b/openvpn-gui-res.h index 91302b0..fcc45dd 100644 --- a/openvpn-gui-res.h +++ b/openvpn-gui-res.h @@ -259,6 +259,8 @@ #define IDS_NFO_STATE_RETRYING 1262 #define IDS_NFO_STATE_DISCONNECTING 1263 #define IDS_NFO_CONN_CANCELLED 1264 +#define IDS_NFO_STATE_ROUTE_ERROR 1265 +#define IDS_NFO_NOTIFY_ROUTE_ERROR 1266 /* Program Startup Related */ #define IDS_ERR_OPEN_DEBUG_FILE 1301 diff --git a/openvpn.c b/openvpn.c index 41bd94e..bfe01eb 100644 --- a/openvpn.c +++ b/openvpn.c @@ -311,12 +311,33 @@ OnStateChange(connection_t *c, char *data) strncpy_s(c->daemon_state, _countof(c->daemon_state), state, _TRUNCATE); + /* Connected state message could be SUCCESS or ERROR, ROUTE_ERROR. + * We treat both SUCCESS and ROUTE_ERROR similarly to preserve the + * current behaviour but show the status window and do not change + * icons to green if not "SUCCESS". + */ if (strcmp(state, "CONNECTED") == 0) { + bool success = !strcmp(message, "SUCCESS"); + parse_assigned_ip(c, pos + 1); - } - if (strcmp(state, "CONNECTED") == 0 && strcmp(message, "SUCCESS") == 0) - { + + if (!success) /* connection completed with errors */ + { + SetForegroundWindow(c->hwndStatus); + ShowWindow(c->hwndStatus, SW_SHOW); + /* The daemon does not currently log this error. Add a line to the status window */ + if (!strcmp(message, "ROUTE_ERROR")) + { + WriteStatusLog(c, L"ERROR: ", L"Some routes were not successfully added. The connection may not function correctly", false); + } + else + { + WriteStatusLog(c, L"ERROR: ", L"Connection completed with critical errors.", false); + return; + } + } + /* concatenate ipv4 and ipv6 addresses into one string */ WCHAR ip_txt[256]; WCHAR ip[64]; @@ -336,7 +357,8 @@ OnStateChange(connection_t *c, char *data) || (c->state == reconnecting && o.show_balloon == 2)) { TCHAR msg[256]; - LoadLocalizedStringBuf(msg, _countof(msg), IDS_NFO_NOW_CONNECTED, c->config_name); + DWORD id = success ? IDS_NFO_NOW_CONNECTED : IDS_NFO_NOTIFY_ROUTE_ERROR; + LoadLocalizedStringBuf(msg, _countof(msg), id, c->config_name); ShowTrayBalloon(msg, (ip[0] ? ip_txt : _T(""))); } @@ -351,6 +373,13 @@ OnStateChange(connection_t *c, char *data) SetDlgItemText(c->hwndStatus, ID_TXT_STATUS, LoadLocalizedString(IDS_NFO_STATE_CONNECTED)); SetDlgItemTextW(c->hwndStatus, ID_TXT_IP, ip_txt); + + if (!success) + { + SetDlgItemText(c->hwndStatus, ID_TXT_STATUS, LoadLocalizedString(IDS_NFO_STATE_ROUTE_ERROR)); + return; + } + SetStatusWinIcon(c->hwndStatus, ID_ICO_CONNECTED); /* Hide Status Window */ diff --git a/res/openvpn-gui-res-en.rc b/res/openvpn-gui-res-en.rc index 9f3f7b6..42117ef 100644 --- a/res/openvpn-gui-res-en.rc +++ b/res/openvpn-gui-res-en.rc @@ -424,6 +424,8 @@ View log file (%ls) for more details." IDS_NFO_SERVICE_ACTIVE_EXIT "You are currently connected (the OpenVPN Service is running). \ You will stay connected even if you exit OpenVPN GUI.\n\n\ Do you want to proceed and exit OpenVPN GUI?" + IDS_NFO_STATE_ROUTE_ERROR "Current State: Connected with route errors" + IDS_NFO_NOTIFY_ROUTE_ERROR "%ls connected with route errors" /* options – Resources */ IDS_NFO_USAGE "--help\t\t\t: Show this message.\n\