mirror of https://github.com/OpenVPN/openvpn-gui
Make 'management port offset' and 'menu view' user-configurable
- Add an option in the advanced settings menu for the management port offset. Allows any value in the range 1 to 61000 which with upto ~4000 added as connection id keeps it in range. Default is the currently hard coded value of 25340. As Windows has no concept of privileged ports and the ephemeral range used varies from version to version, no attempt is made to avoid conflicts with ports in use. - Add an option to choose the config menu view from the advanced settings with three options: Auto: Automatically switch to the nested view when number of configs exceed a limit (currently 25) Flat: Force the flat view irrespective of the number of configs Nested: Force the nested view irrespective of the number of configs Issues: 370 and 387 Signed-off-by: Selva Nair <selva.nair@gmail.com>pull/401/head
parent
8e9c9392a7
commit
f098f2fee4
|
@ -119,6 +119,7 @@
|
||||||
#define ID_EDT_PRECONNECT_TIMEOUT 282
|
#define ID_EDT_PRECONNECT_TIMEOUT 282
|
||||||
#define ID_EDT_CONNECT_TIMEOUT 283
|
#define ID_EDT_CONNECT_TIMEOUT 283
|
||||||
#define ID_EDT_DISCONNECT_TIMEOUT 284
|
#define ID_EDT_DISCONNECT_TIMEOUT 284
|
||||||
|
#define ID_EDT_MGMT_PORT 285
|
||||||
|
|
||||||
/* Connections dialog */
|
/* Connections dialog */
|
||||||
#define ID_DLG_CONNECTIONS 290
|
#define ID_DLG_CONNECTIONS 290
|
||||||
|
|
|
@ -104,7 +104,7 @@ AddConfigFileToList(int config, const TCHAR *filename, const TCHAR *config_dir)
|
||||||
c->manage.sk = INVALID_SOCKET;
|
c->manage.sk = INVALID_SOCKET;
|
||||||
c->manage.skaddr.sin_family = AF_INET;
|
c->manage.skaddr.sin_family = AF_INET;
|
||||||
c->manage.skaddr.sin_addr.s_addr = inet_addr("127.0.0.1");
|
c->manage.skaddr.sin_addr.s_addr = inet_addr("127.0.0.1");
|
||||||
c->manage.skaddr.sin_port = htons(25340 + config);
|
c->manage.skaddr.sin_port = htons(o.mgmt_port_offset + config);
|
||||||
|
|
||||||
#ifndef DISABLE_CHANGE_PASSWORD
|
#ifndef DISABLE_CHANGE_PASSWORD
|
||||||
if (CheckKeyFileWriteAccess (c))
|
if (CheckKeyFileWriteAccess (c))
|
||||||
|
|
29
options.c
29
options.c
|
@ -561,6 +561,17 @@ CheckAdvancedDlgParams (HWND hdlg)
|
||||||
L"Option error", MB_OK);
|
L"Option error", MB_OK);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOL status;
|
||||||
|
int tmp = GetDlgItemInt (hdlg, ID_EDT_MGMT_PORT, &status, FALSE);
|
||||||
|
/* Restrict the port offset to sensible range -- port used is this + upto ~4000 as connection index */
|
||||||
|
if (!status || (tmp < 1 || tmp > 61000))
|
||||||
|
{
|
||||||
|
MessageBox (NULL, L"Specified port is not valid (must be n the range 1 to 61000)",
|
||||||
|
L"Option error", MB_OK);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -596,6 +607,9 @@ SaveAdvancedDlgParams (HWND hdlg)
|
||||||
tmp = GetDlgItemInt (hdlg, ID_EDT_DISCONNECT_TIMEOUT, &status, FALSE);
|
tmp = GetDlgItemInt (hdlg, ID_EDT_DISCONNECT_TIMEOUT, &status, FALSE);
|
||||||
if (status && tmp > 0) o.disconnectscript_timeout = tmp;
|
if (status && tmp > 0) o.disconnectscript_timeout = tmp;
|
||||||
|
|
||||||
|
tmp = GetDlgItemInt (hdlg, ID_EDT_MGMT_PORT, &status, FALSE);
|
||||||
|
if (status) o.mgmt_port_offset = tmp;
|
||||||
|
|
||||||
SaveRegistryKeys ();
|
SaveRegistryKeys ();
|
||||||
ExpandOptions ();
|
ExpandOptions ();
|
||||||
|
|
||||||
|
@ -611,6 +625,13 @@ LoadAdvancedDlgParams (HWND hdlg)
|
||||||
SetDlgItemInt (hdlg, ID_EDT_PRECONNECT_TIMEOUT, o.preconnectscript_timeout, FALSE);
|
SetDlgItemInt (hdlg, ID_EDT_PRECONNECT_TIMEOUT, o.preconnectscript_timeout, FALSE);
|
||||||
SetDlgItemInt (hdlg, ID_EDT_CONNECT_TIMEOUT, o.connectscript_timeout, FALSE);
|
SetDlgItemInt (hdlg, ID_EDT_CONNECT_TIMEOUT, o.connectscript_timeout, FALSE);
|
||||||
SetDlgItemInt (hdlg, ID_EDT_DISCONNECT_TIMEOUT, o.disconnectscript_timeout, FALSE);
|
SetDlgItemInt (hdlg, ID_EDT_DISCONNECT_TIMEOUT, o.disconnectscript_timeout, FALSE);
|
||||||
|
SetDlgItemInt (hdlg, ID_EDT_MGMT_PORT, o.mgmt_port_offset, FALSE);
|
||||||
|
if (o.config_menu_view == 0)
|
||||||
|
CheckRadioButton (hdlg, ID_RB_BALLOON0, ID_RB_BALLOON2, ID_RB_BALLOON0);
|
||||||
|
else if (o.config_menu_view == 1)
|
||||||
|
CheckRadioButton (hdlg, ID_RB_BALLOON0, ID_RB_BALLOON2, ID_RB_BALLOON1);
|
||||||
|
else if (o.config_menu_view == 2)
|
||||||
|
CheckRadioButton (hdlg, ID_RB_BALLOON0, ID_RB_BALLOON2, ID_RB_BALLOON2);
|
||||||
}
|
}
|
||||||
|
|
||||||
INT_PTR CALLBACK
|
INT_PTR CALLBACK
|
||||||
|
@ -623,6 +644,8 @@ AdvancedSettingsDlgProc (HWND hwndDlg, UINT msg, UNUSED WPARAM wParam, LPARAM lP
|
||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG:
|
||||||
/* Limit extension editbox to 4 chars. */
|
/* Limit extension editbox to 4 chars. */
|
||||||
SendMessage (GetDlgItem(hwndDlg, ID_EDT_CONFIG_EXT), EM_SETLIMITTEXT, 4, 0);
|
SendMessage (GetDlgItem(hwndDlg, ID_EDT_CONFIG_EXT), EM_SETLIMITTEXT, 4, 0);
|
||||||
|
/* Limit management port editbox to 5 chars */
|
||||||
|
SendMessage(GetDlgItem(hwndDlg, ID_EDT_MGMT_PORT), EM_SETLIMITTEXT, 5, 0);
|
||||||
/* Populate UI */
|
/* Populate UI */
|
||||||
LoadAdvancedDlgParams (hwndDlg);
|
LoadAdvancedDlgParams (hwndDlg);
|
||||||
break;
|
break;
|
||||||
|
@ -658,6 +681,12 @@ AdvancedSettingsDlgProc (HWND hwndDlg, UINT msg, UNUSED WPARAM wParam, LPARAM lP
|
||||||
SetWindowLongPtr (hwndDlg, DWLP_MSGRESULT, status? PSNRET_NOERROR:PSNRET_INVALID);
|
SetWindowLongPtr (hwndDlg, DWLP_MSGRESULT, status? PSNRET_NOERROR:PSNRET_INVALID);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
if (IsDlgButtonChecked(hwndDlg, ID_RB_BALLOON2))
|
||||||
|
o.config_menu_view = 2;
|
||||||
|
else if (IsDlgButtonChecked(hwndDlg, ID_RB_BALLOON1))
|
||||||
|
o.config_menu_view = 1;
|
||||||
|
else
|
||||||
|
o.config_menu_view = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -209,6 +209,7 @@ typedef struct {
|
||||||
DWORD config_menu_view; /* 0 for auto, 1 for original flat menu, 2 for hierarchical */
|
DWORD config_menu_view; /* 0 for auto, 1 for original flat menu, 2 for hierarchical */
|
||||||
DWORD disable_popup_messages; /* set nonzero to suppress all echo msg messages */
|
DWORD disable_popup_messages; /* set nonzero to suppress all echo msg messages */
|
||||||
DWORD popup_mute_interval; /* Interval in hours to suppress repeated echo messages */
|
DWORD popup_mute_interval; /* Interval in hours to suppress repeated echo messages */
|
||||||
|
DWORD mgmt_port_offset; /* management interface port = this offset + index of connection profile */
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
FILE *debug_fp;
|
FILE *debug_fp;
|
||||||
|
|
|
@ -65,6 +65,7 @@ struct regkey_int {
|
||||||
{L"config_menu_view", &o.config_menu_view, CONFIG_VIEW_AUTO},
|
{L"config_menu_view", &o.config_menu_view, CONFIG_VIEW_AUTO},
|
||||||
{L"popup_mute_interval", &o.popup_mute_interval, 24},
|
{L"popup_mute_interval", &o.popup_mute_interval, 24},
|
||||||
{L"disable_popup_messages", &o.disable_popup_messages, 0},
|
{L"disable_popup_messages", &o.disable_popup_messages, 0},
|
||||||
|
{L"management_port_offset", &o.mgmt_port_offset, 25340},
|
||||||
};
|
};
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -193,6 +194,10 @@ GetRegistryKeys ()
|
||||||
ShowLocalizedMsg(IDS_ERR_PRECONN_SCRIPT_TIMEOUT);
|
ShowLocalizedMsg(IDS_ERR_PRECONN_SCRIPT_TIMEOUT);
|
||||||
o.preconnectscript_timeout = 10;
|
o.preconnectscript_timeout = 10;
|
||||||
}
|
}
|
||||||
|
if (o.mgmt_port_offset < 1 || o.mgmt_port_offset > 61000)
|
||||||
|
{
|
||||||
|
o.mgmt_port_offset = 25340;
|
||||||
|
}
|
||||||
|
|
||||||
ExpandOptions ();
|
ExpandOptions ();
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -181,7 +181,7 @@ BEGIN
|
||||||
END
|
END
|
||||||
|
|
||||||
/* Advanced Dialog */
|
/* Advanced Dialog */
|
||||||
ID_DLG_ADVANCED DIALOGEX 6, 18, 252, 218
|
ID_DLG_ADVANCED DIALOGEX 6, 18, 252, 235
|
||||||
STYLE WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | DS_CENTER
|
STYLE WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | DS_CENTER
|
||||||
CAPTION "Advanced"
|
CAPTION "Advanced"
|
||||||
FONT 8, "Microsoft Sans Serif"
|
FONT 8, "Microsoft Sans Serif"
|
||||||
|
@ -199,13 +199,22 @@ BEGIN
|
||||||
EDITTEXT ID_EDT_LOG_DIR, 53, 72, 150, 12, ES_AUTOHSCROLL
|
EDITTEXT ID_EDT_LOG_DIR, 53, 72, 150, 12, ES_AUTOHSCROLL
|
||||||
PUSHBUTTON "…", ID_BTN_LOG_DIR, 208, 72, 25, 12
|
PUSHBUTTON "…", ID_BTN_LOG_DIR, 208, 72, 25, 12
|
||||||
|
|
||||||
GROUPBOX "Script Timeout", 201, 6, 97, 235, 60
|
GROUPBOX "Script Timeout", 203, 6, 97, 235, 60
|
||||||
LTEXT "&Preconnect script timeout:", ID_TXT_PRECONNECT_TIMEOUT, 17, 110, 100, 10
|
LTEXT "&Preconnect script timeout:", ID_TXT_PRECONNECT_TIMEOUT, 17, 110, 100, 10
|
||||||
EDITTEXT ID_EDT_PRECONNECT_TIMEOUT, 103, 108, 20, 12, ES_AUTOHSCROLL|ES_NUMBER
|
EDITTEXT ID_EDT_PRECONNECT_TIMEOUT, 103, 108, 20, 12, ES_AUTOHSCROLL|ES_NUMBER
|
||||||
LTEXT "&Connect script timeout:", ID_TXT_CONNECT_TIMEOUT, 17, 125, 90, 10
|
LTEXT "&Connect script timeout:", ID_TXT_CONNECT_TIMEOUT, 17, 125, 90, 10
|
||||||
EDITTEXT ID_EDT_CONNECT_TIMEOUT, 103, 123, 20, 12, ES_AUTOHSCROLL|ES_NUMBER
|
EDITTEXT ID_EDT_CONNECT_TIMEOUT, 103, 123, 20, 12, ES_AUTOHSCROLL|ES_NUMBER
|
||||||
LTEXT "&Disconnect script timeout:", ID_TXT_DISCONNECT_TIMEOUT, 17, 140, 90, 10
|
LTEXT "&Disconnect script timeout:", ID_TXT_DISCONNECT_TIMEOUT, 17, 140, 90, 10
|
||||||
EDITTEXT ID_EDT_DISCONNECT_TIMEOUT, 103, 138, 20, 12, ES_AUTOHSCROLL|ES_NUMBER
|
EDITTEXT ID_EDT_DISCONNECT_TIMEOUT, 103, 138, 20, 12, ES_AUTOHSCROLL|ES_NUMBER
|
||||||
|
|
||||||
|
GROUPBOX "Management interface", 204, 6, 163, 235, 30
|
||||||
|
LTEXT "Port offset:", 205, 17, 175, 75, 10
|
||||||
|
EDITTEXT ID_EDT_MGMT_PORT, 103, 173, 30, 12, ES_AUTOHSCROLL
|
||||||
|
|
||||||
|
GROUPBOX "Config menu view", 206, 6, 198, 235, 30
|
||||||
|
AUTORADIOBUTTON "&Auto", ID_RB_BALLOON0, 28, 210, 50, 10, WS_GROUP | WS_TABSTOP
|
||||||
|
AUTORADIOBUTTON "&Flat", ID_RB_BALLOON1, 88, 210, 50, 10
|
||||||
|
AUTORADIOBUTTON "&Nested", ID_RB_BALLOON2, 148, 210, 50, 10
|
||||||
END
|
END
|
||||||
|
|
||||||
/* About Dialog */
|
/* About Dialog */
|
||||||
|
|
|
@ -184,7 +184,7 @@ BEGIN
|
||||||
END
|
END
|
||||||
|
|
||||||
/* Advanced Dialog */
|
/* Advanced Dialog */
|
||||||
ID_DLG_ADVANCED DIALOGEX 6, 18, 252, 218
|
ID_DLG_ADVANCED DIALOGEX 6, 18, 252, 235
|
||||||
STYLE WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | DS_CENTER
|
STYLE WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | DS_CENTER
|
||||||
CAPTION "Advanced"
|
CAPTION "Advanced"
|
||||||
FONT 8, "Microsoft Sans Serif"
|
FONT 8, "Microsoft Sans Serif"
|
||||||
|
@ -202,13 +202,22 @@ BEGIN
|
||||||
EDITTEXT ID_EDT_LOG_DIR, 53, 72, 150, 12, ES_AUTOHSCROLL
|
EDITTEXT ID_EDT_LOG_DIR, 53, 72, 150, 12, ES_AUTOHSCROLL
|
||||||
PUSHBUTTON "…", ID_BTN_LOG_DIR, 208, 72, 25, 12
|
PUSHBUTTON "…", ID_BTN_LOG_DIR, 208, 72, 25, 12
|
||||||
|
|
||||||
GROUPBOX "Script Timeout", 201, 6, 97, 235, 60
|
GROUPBOX "Script Timeout", 203, 6, 97, 235, 60
|
||||||
LTEXT "&Preconnect script timeout:", ID_TXT_PRECONNECT_TIMEOUT, 17, 110, 100, 10
|
LTEXT "&Preconnect script timeout:", ID_TXT_PRECONNECT_TIMEOUT, 17, 110, 100, 10
|
||||||
EDITTEXT ID_EDT_PRECONNECT_TIMEOUT, 103, 108, 20, 12, ES_AUTOHSCROLL|ES_NUMBER
|
EDITTEXT ID_EDT_PRECONNECT_TIMEOUT, 103, 108, 20, 12, ES_AUTOHSCROLL|ES_NUMBER
|
||||||
LTEXT "&Connect script timeout:", ID_TXT_CONNECT_TIMEOUT, 17, 125, 90, 10
|
LTEXT "&Connect script timeout:", ID_TXT_CONNECT_TIMEOUT, 17, 125, 90, 10
|
||||||
EDITTEXT ID_EDT_CONNECT_TIMEOUT, 103, 123, 20, 12, ES_AUTOHSCROLL|ES_NUMBER
|
EDITTEXT ID_EDT_CONNECT_TIMEOUT, 103, 123, 20, 12, ES_AUTOHSCROLL|ES_NUMBER
|
||||||
LTEXT "&Disconnect script timeout:", ID_TXT_DISCONNECT_TIMEOUT, 17, 140, 90, 10
|
LTEXT "&Disconnect script timeout:", ID_TXT_DISCONNECT_TIMEOUT, 17, 140, 90, 10
|
||||||
EDITTEXT ID_EDT_DISCONNECT_TIMEOUT, 103, 138, 20, 12, ES_AUTOHSCROLL|ES_NUMBER
|
EDITTEXT ID_EDT_DISCONNECT_TIMEOUT, 103, 138, 20, 12, ES_AUTOHSCROLL|ES_NUMBER
|
||||||
|
|
||||||
|
GROUPBOX "Management interface", 204, 6, 163, 235, 30
|
||||||
|
LTEXT "Port offset:", 205, 17, 175, 75, 10
|
||||||
|
EDITTEXT ID_EDT_MGMT_PORT, 103, 173, 30, 12, ES_AUTOHSCROLL
|
||||||
|
|
||||||
|
GROUPBOX "Config menu view", 206, 6, 198, 235, 30
|
||||||
|
AUTORADIOBUTTON "&Auto", ID_RB_BALLOON0, 28, 210, 50, 10, WS_GROUP | WS_TABSTOP
|
||||||
|
AUTORADIOBUTTON "&Flat", ID_RB_BALLOON1, 88, 210, 50, 10
|
||||||
|
AUTORADIOBUTTON "&Nested", ID_RB_BALLOON2, 148, 210, 50, 10
|
||||||
END
|
END
|
||||||
|
|
||||||
/* About Dialog */
|
/* About Dialog */
|
||||||
|
|
Loading…
Reference in New Issue