Browse Source

Option to disable attaching to persistent connections

Three options are provided to control scanning of persistent
(pre-satrted) connections in config-auto folder, and how they
are attached to.

Auto: Scan and list persistent connections and attach to their
      management i/f automatically at startup, and periodically
      retry on failure to attach.
Manual: Scan and list as above, but do not attach automatically.
      User can attach to such connections by manually clicking
      connect.
Never: Do not scan config-auto folder.

Default is "Auto"

Change of this setting in the settings menu will take full effect
only if none of the connections are in connecting/connected/detached
state so that the connection list can be updated. Otherwise
restart the GUI.

TODO: Copying the settings dialog changes to all languages

Signed-off-by: Selva Nair <selva.nair@gmail.com>
pull/519/head
Selva Nair 2 years ago
parent
commit
0e76e4b544
  1. 12
      localization.c
  2. 2
      openvpn-gui-res.h
  3. 6
      openvpn.c
  4. 8
      openvpn_config.c
  5. 1
      options.h
  6. 1
      registry.c
  7. 6
      res/openvpn-gui-res-en.rc

12
localization.c

@ -514,6 +514,12 @@ GeneralSettingsDlgProc(HWND hwndDlg, UINT msg, UNUSED WPARAM wParam, LPARAM lPar
CheckRadioButton (hwndDlg, ID_RB_BALLOON0, ID_RB_BALLOON2, ID_RB_BALLOON2);
if (o.show_script_window)
Button_SetCheck(GetDlgItem(hwndDlg, ID_CHK_SHOW_SCRIPT_WIN), BST_CHECKED);
if (o.enable_persistent == 0) /* Never */
CheckRadioButton (hwndDlg, ID_RB_BALLOON3, ID_RB_BALLOON5, ID_RB_BALLOON5);
else if (o.enable_persistent == 1) /* Enabled, but no auto-attach */
CheckRadioButton (hwndDlg, ID_RB_BALLOON3, ID_RB_BALLOON5, ID_RB_BALLOON4);
else if (o.enable_persistent == 2) /* Enabled and auto-attach */
CheckRadioButton (hwndDlg, ID_RB_BALLOON3, ID_RB_BALLOON5, ID_RB_BALLOON3);
break;
@ -541,6 +547,12 @@ GeneralSettingsDlgProc(HWND hwndDlg, UINT msg, UNUSED WPARAM wParam, LPARAM lPar
o.show_balloon = 2;
else
o.show_balloon = 1;
if (IsDlgButtonChecked(hwndDlg, ID_RB_BALLOON3))
o.enable_persistent = 2;
else if (IsDlgButtonChecked(hwndDlg, ID_RB_BALLOON4))
o.enable_persistent = 1;
else
o.enable_persistent = 0;
o.show_script_window =
(Button_GetCheck(GetDlgItem(hwndDlg, ID_CHK_SHOW_SCRIPT_WIN)) == BST_CHECKED);

2
openvpn-gui-res.h

@ -113,6 +113,8 @@
#define ID_CHK_ALWAYS_USE_ISERVICE 243
#define ID_RB_BALLOON3 244
#define ID_RB_BALLOON4 245
#define ID_RB_BALLOON5 246
#define ID_TXT_PERSISTENT 247
/* Proxy Auth Dialog */
#define ID_DLG_PROXY_AUTH 250

6
openvpn.c

@ -125,7 +125,8 @@ OnReady(connection_t *c, UNUSED char *msg)
/* ask for the current state, especially useful when the daemon was prestarted */
ManagementCommand(c, "state", OnStateChange, regular);
if (c->flags & FLAG_DAEMON_PERSISTENT) /* find the current state */
if (c->flags & FLAG_DAEMON_PERSISTENT
&& o.enable_persistent == 2)
{
c->auto_connect = true;
}
@ -2106,7 +2107,8 @@ ThreadOpenVPNStatus(void *p)
wait_event = c->hProcess;
}
if (o.silent_connection == 0 && (c->flags & FLAG_DAEMON_PERSISTENT) == 0)
/* For persistent connections, popup the status win only if we're in manual mode */
if (o.silent_connection == 0 && ((c->flags & FLAG_DAEMON_PERSISTENT) == 0 || o.enable_persistent == 1))
ShowWindow(c->hwndStatus, SW_SHOW);
/* Load echo msg histroy from registry */

8
openvpn_config.c

@ -115,7 +115,10 @@ AddConfigFileToList(int config, const TCHAR *filename, const TCHAR *config_dir)
c->flags |= FLAG_DAEMON_PERSISTENT;
_sntprintf_0(c->log_path, _T("%ls\\%ls.log"), o.global_log_dir, c->config_name);
/* set to auto-connect -- this attempts to attach to them on startup */
c->auto_connect = true;
if (o.enable_persistent == 2)
{
c->auto_connect = true;
}
}
/* Check if connection should be autostarted */
@ -443,7 +446,8 @@ BuildFileList()
BuildFileList0 (o.global_config_dir, recurse_depth, root1, flags);
}
if (o.service_state == service_connected)
if (o.service_state == service_connected
&& o.enable_persistent)
{
root1 = NewConfigGroup(L"Persistent Profiles", root0, flags);
if (!IsSamePath(o.config_auto_dir, o.config_dir))

1
options.h

@ -218,6 +218,7 @@ typedef struct {
DWORD mgmt_port_offset; /* management interface port = this offset + index of connection profile */
DWORD ovpn_engine; /* 0 - openvpn2, 1 - openvpn3 */
DWORD enable_persistent; /* 0 - disabled, 1 - enabled, 2 - enabled & auto attach */
#ifdef DEBUG
FILE *debug_fp;
#endif

1
registry.c

@ -65,6 +65,7 @@ struct regkey_int {
{L"popup_mute_interval", &o.popup_mute_interval, 24},
{L"disable_popup_messages", &o.disable_popup_messages, 0},
{L"management_port_offset", &o.mgmt_port_offset, 25340},
{L"enable_peristent_connections", &o.enable_persistent, 2},
{L"ovpn_engine", &o.ovpn_engine, OPENVPN_ENGINE_OVPN2}
};

6
res/openvpn-gui-res-en.rc

@ -173,7 +173,7 @@ BEGIN
GROUPBOX "Startup", 202, 6, 47, 235, 30
AUTOCHECKBOX "Launch on User &Logon", ID_CHK_STARTUP, 17, 59, 100, 12
GROUPBOX "Preferences", ID_GROUPBOX3, 6, 82, 235, 105
GROUPBOX "Preferences", ID_GROUPBOX3, 6, 82, 235, 135
AUTOCHECKBOX "A&ppend to log", ID_CHK_LOG_APPEND, 17, 95, 60, 10
AUTOCHECKBOX "Show script &window", ID_CHK_SHOW_SCRIPT_WIN, 17, 110, 200, 10
AUTOCHECKBOX "S&ilent connection", ID_CHK_SILENT, 17, 125, 200, 10
@ -182,6 +182,10 @@ BEGIN
AUTORADIOBUTTON "On &connect", ID_RB_BALLOON1, 28, 170, 50, 10, WS_GROUP | WS_TABSTOP
AUTORADIOBUTTON "On connect/&reconnect", ID_RB_BALLOON2, 86, 170, 90, 10
AUTORADIOBUTTON "&Never", ID_RB_BALLOON0, 181, 170, 40, 10
LTEXT "Persistent Connections", ID_TXT_PERSISTENT, 17, 185, 100, 10
AUTORADIOBUTTON "A&uto", ID_RB_BALLOON3, 28, 200, 50, 10, WS_GROUP | WS_TABSTOP
AUTORADIOBUTTON "&Manual", ID_RB_BALLOON4, 86, 200, 90, 10
AUTORADIOBUTTON "&Disable", ID_RB_BALLOON5, 181, 200, 40, 10
END
/* Advanced Dialog */

Loading…
Cancel
Save