mirror of https://github.com/OpenVPN/openvpn-gui
Handle CONNECTED,ROUTE_ERROR state message
When connected, the daemon now reports the state as CONNECTED,ROUTE_ERROR on routing errors that would have been reported as CONNECTED,SUCCESS in the past. To not overly disrupt the current behaviour we treat CONNECTED,ROUTE_ERROR almost the same was as CONNECTED,SUCCESS except that an error is logged and the status window is popped up if not already open for all cases other that CONNECTED,SUCCESS. Further, the icons on the status window, is left at yellow and the status text is set to "Connected with routing errors" in case of ROUTE_ERROR. Tray and menu icons will change to green. Leaving them yellow is not persistent as we do not yet have a state variable in the GUI that distinguishes between "successfully connected" and "connected with route errors". TODO: re-work this CONNECTED state handling based on how critical ROUTE_ERROR is in real use. Signed-off-by: Selva Nair <selva.nair@gmail.com>pull/584/head
parent
b4e3e076b8
commit
28a568201c
|
@ -259,6 +259,8 @@
|
||||||
#define IDS_NFO_STATE_RETRYING 1262
|
#define IDS_NFO_STATE_RETRYING 1262
|
||||||
#define IDS_NFO_STATE_DISCONNECTING 1263
|
#define IDS_NFO_STATE_DISCONNECTING 1263
|
||||||
#define IDS_NFO_CONN_CANCELLED 1264
|
#define IDS_NFO_CONN_CANCELLED 1264
|
||||||
|
#define IDS_NFO_STATE_ROUTE_ERROR 1265
|
||||||
|
#define IDS_NFO_NOTIFY_ROUTE_ERROR 1266
|
||||||
|
|
||||||
/* Program Startup Related */
|
/* Program Startup Related */
|
||||||
#define IDS_ERR_OPEN_DEBUG_FILE 1301
|
#define IDS_ERR_OPEN_DEBUG_FILE 1301
|
||||||
|
|
35
openvpn.c
35
openvpn.c
|
@ -311,12 +311,33 @@ OnStateChange(connection_t *c, char *data)
|
||||||
|
|
||||||
strncpy_s(c->daemon_state, _countof(c->daemon_state), state, _TRUNCATE);
|
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)
|
if (strcmp(state, "CONNECTED") == 0)
|
||||||
{
|
{
|
||||||
|
bool success = !strcmp(message, "SUCCESS");
|
||||||
|
|
||||||
parse_assigned_ip(c, pos + 1);
|
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 */
|
/* concatenate ipv4 and ipv6 addresses into one string */
|
||||||
WCHAR ip_txt[256];
|
WCHAR ip_txt[256];
|
||||||
WCHAR ip[64];
|
WCHAR ip[64];
|
||||||
|
@ -336,7 +357,8 @@ OnStateChange(connection_t *c, char *data)
|
||||||
|| (c->state == reconnecting && o.show_balloon == 2))
|
|| (c->state == reconnecting && o.show_balloon == 2))
|
||||||
{
|
{
|
||||||
TCHAR msg[256];
|
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("")));
|
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));
|
SetDlgItemText(c->hwndStatus, ID_TXT_STATUS, LoadLocalizedString(IDS_NFO_STATE_CONNECTED));
|
||||||
SetDlgItemTextW(c->hwndStatus, ID_TXT_IP, ip_txt);
|
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);
|
SetStatusWinIcon(c->hwndStatus, ID_ICO_CONNECTED);
|
||||||
|
|
||||||
/* Hide Status Window */
|
/* Hide Status Window */
|
||||||
|
|
|
@ -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). \
|
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\
|
You will stay connected even if you exit OpenVPN GUI.\n\n\
|
||||||
Do you want to proceed and exit OpenVPN GUI?"
|
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 */
|
/* options – Resources */
|
||||||
IDS_NFO_USAGE "--help\t\t\t: Show this message.\n\
|
IDS_NFO_USAGE "--help\t\t\t: Show this message.\n\
|
||||||
|
|
Loading…
Reference in New Issue