|
|
@ -44,7 +44,7 @@ GetRegistryKeys()
|
|
|
|
TCHAR openvpn_path[MAX_PATH];
|
|
|
|
TCHAR openvpn_path[MAX_PATH];
|
|
|
|
HKEY regkey;
|
|
|
|
HKEY regkey;
|
|
|
|
|
|
|
|
|
|
|
|
if (!GetWindowsDirectory(windows_dir, _tsizeof(windows_dir))) {
|
|
|
|
if (!GetWindowsDirectory(windows_dir, _countof(windows_dir))) {
|
|
|
|
/* can't get windows dir */
|
|
|
|
/* can't get windows dir */
|
|
|
|
ShowLocalizedMsg(IDS_ERR_GET_WINDOWS_DIR);
|
|
|
|
ShowLocalizedMsg(IDS_ERR_GET_WINDOWS_DIR);
|
|
|
|
return(false);
|
|
|
|
return(false);
|
|
|
@ -58,7 +58,7 @@ GetRegistryKeys()
|
|
|
|
ShowLocalizedMsg(IDS_ERR_OPEN_REGISTRY);
|
|
|
|
ShowLocalizedMsg(IDS_ERR_OPEN_REGISTRY);
|
|
|
|
return(false);
|
|
|
|
return(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!GetRegistryValue(regkey, _T(""), openvpn_path, _tsizeof(openvpn_path)))
|
|
|
|
if (!GetRegistryValue(regkey, _T(""), openvpn_path, _countof(openvpn_path)))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
/* error reading registry value */
|
|
|
|
/* error reading registry value */
|
|
|
|
ShowLocalizedMsg(IDS_ERR_READING_REGISTRY);
|
|
|
|
ShowLocalizedMsg(IDS_ERR_READING_REGISTRY);
|
|
|
@ -70,52 +70,52 @@ GetRegistryKeys()
|
|
|
|
|
|
|
|
|
|
|
|
_sntprintf_0(temp_path, _T("%sconfig"), openvpn_path);
|
|
|
|
_sntprintf_0(temp_path, _T("%sconfig"), openvpn_path);
|
|
|
|
if (!GetRegKey(_T("config_dir"), o.config_dir,
|
|
|
|
if (!GetRegKey(_T("config_dir"), o.config_dir,
|
|
|
|
temp_path, _tsizeof(o.config_dir))) return(false);
|
|
|
|
temp_path, _countof(o.config_dir))) return(false);
|
|
|
|
|
|
|
|
|
|
|
|
if (!GetRegKey(_T("config_ext"), o.ext_string, _T("ovpn"), _tsizeof(o.ext_string))) return(false);
|
|
|
|
if (!GetRegKey(_T("config_ext"), o.ext_string, _T("ovpn"), _countof(o.ext_string))) return(false);
|
|
|
|
|
|
|
|
|
|
|
|
_sntprintf_0(temp_path, _T("%sbin\\openvpn.exe"), openvpn_path);
|
|
|
|
_sntprintf_0(temp_path, _T("%sbin\\openvpn.exe"), openvpn_path);
|
|
|
|
if (!GetRegKey(_T("exe_path"), o.exe_path,
|
|
|
|
if (!GetRegKey(_T("exe_path"), o.exe_path,
|
|
|
|
temp_path, _tsizeof(o.exe_path))) return(false);
|
|
|
|
temp_path, _countof(o.exe_path))) return(false);
|
|
|
|
|
|
|
|
|
|
|
|
_sntprintf_0(temp_path, _T("%slog"), openvpn_path);
|
|
|
|
_sntprintf_0(temp_path, _T("%slog"), openvpn_path);
|
|
|
|
if (!GetRegKey(_T("log_dir"), o.log_dir,
|
|
|
|
if (!GetRegKey(_T("log_dir"), o.log_dir,
|
|
|
|
temp_path, _tsizeof(o.log_dir))) return(false);
|
|
|
|
temp_path, _countof(o.log_dir))) return(false);
|
|
|
|
|
|
|
|
|
|
|
|
if (!GetRegKey(_T("log_append"), o.append_string, _T("0"), _tsizeof(o.append_string))) return(false);
|
|
|
|
if (!GetRegKey(_T("log_append"), o.append_string, _T("0"), _countof(o.append_string))) return(false);
|
|
|
|
|
|
|
|
|
|
|
|
if (!GetRegKey(_T("priority"), o.priority_string,
|
|
|
|
if (!GetRegKey(_T("priority"), o.priority_string,
|
|
|
|
_T("NORMAL_PRIORITY_CLASS"), _tsizeof(o.priority_string))) return(false);
|
|
|
|
_T("NORMAL_PRIORITY_CLASS"), _countof(o.priority_string))) return(false);
|
|
|
|
|
|
|
|
|
|
|
|
_sntprintf_0(temp_path, _T("%s\\notepad.exe"), windows_dir);
|
|
|
|
_sntprintf_0(temp_path, _T("%s\\notepad.exe"), windows_dir);
|
|
|
|
if (!GetRegKey(_T("log_viewer"), o.log_viewer,
|
|
|
|
if (!GetRegKey(_T("log_viewer"), o.log_viewer,
|
|
|
|
temp_path, _tsizeof(o.log_viewer))) return(false);
|
|
|
|
temp_path, _countof(o.log_viewer))) return(false);
|
|
|
|
|
|
|
|
|
|
|
|
_sntprintf_0(temp_path, _T("%s\\notepad.exe"), windows_dir);
|
|
|
|
_sntprintf_0(temp_path, _T("%s\\notepad.exe"), windows_dir);
|
|
|
|
if (!GetRegKey(_T("editor"), o.editor,
|
|
|
|
if (!GetRegKey(_T("editor"), o.editor,
|
|
|
|
temp_path, _tsizeof(o.editor))) return(false);
|
|
|
|
temp_path, _countof(o.editor))) return(false);
|
|
|
|
|
|
|
|
|
|
|
|
if (!GetRegKey(_T("allow_edit"), o.allow_edit, _T("1"), _tsizeof(o.allow_edit))) return(false);
|
|
|
|
if (!GetRegKey(_T("allow_edit"), o.allow_edit, _T("1"), _countof(o.allow_edit))) return(false);
|
|
|
|
|
|
|
|
|
|
|
|
if (!GetRegKey(_T("allow_service"), o.allow_service, _T("0"), _tsizeof(o.allow_service))) return(false);
|
|
|
|
if (!GetRegKey(_T("allow_service"), o.allow_service, _T("0"), _countof(o.allow_service))) return(false);
|
|
|
|
|
|
|
|
|
|
|
|
if (!GetRegKey(_T("allow_password"), o.allow_password, _T("1"), _tsizeof(o.allow_password))) return(false);
|
|
|
|
if (!GetRegKey(_T("allow_password"), o.allow_password, _T("1"), _countof(o.allow_password))) return(false);
|
|
|
|
|
|
|
|
|
|
|
|
if (!GetRegKey(_T("allow_proxy"), o.allow_proxy, _T("1"), _tsizeof(o.allow_proxy))) return(false);
|
|
|
|
if (!GetRegKey(_T("allow_proxy"), o.allow_proxy, _T("1"), _countof(o.allow_proxy))) return(false);
|
|
|
|
|
|
|
|
|
|
|
|
if (!GetRegKey(_T("service_only"), o.service_only, _T("0"), _tsizeof(o.service_only))) return(false);
|
|
|
|
if (!GetRegKey(_T("service_only"), o.service_only, _T("0"), _countof(o.service_only))) return(false);
|
|
|
|
|
|
|
|
|
|
|
|
if (!GetRegKey(_T("show_balloon"), o.show_balloon, _T("1"), _tsizeof(o.show_balloon))) return(false);
|
|
|
|
if (!GetRegKey(_T("show_balloon"), o.show_balloon, _T("1"), _countof(o.show_balloon))) return(false);
|
|
|
|
|
|
|
|
|
|
|
|
if (!GetRegKey(_T("silent_connection"), o.silent_connection, _T("0"), _tsizeof(o.silent_connection))) return(false);
|
|
|
|
if (!GetRegKey(_T("silent_connection"), o.silent_connection, _T("0"), _countof(o.silent_connection))) return(false);
|
|
|
|
|
|
|
|
|
|
|
|
if (!GetRegKey(_T("show_script_window"), o.show_script_window, _T("1"), _tsizeof(o.show_script_window))) return(false);
|
|
|
|
if (!GetRegKey(_T("show_script_window"), o.show_script_window, _T("1"), _countof(o.show_script_window))) return(false);
|
|
|
|
|
|
|
|
|
|
|
|
if (!GetRegKey(_T("disconnect_on_suspend"), o.disconnect_on_suspend, _T("1"),
|
|
|
|
if (!GetRegKey(_T("disconnect_on_suspend"), o.disconnect_on_suspend, _T("1"),
|
|
|
|
_tsizeof(o.disconnect_on_suspend))) return(false);
|
|
|
|
_countof(o.disconnect_on_suspend))) return(false);
|
|
|
|
|
|
|
|
|
|
|
|
if (!GetRegKey(_T("passphrase_attempts"), o.psw_attempts_string, _T("3"),
|
|
|
|
if (!GetRegKey(_T("passphrase_attempts"), o.psw_attempts_string, _T("3"),
|
|
|
|
_tsizeof(o.psw_attempts_string))) return(false);
|
|
|
|
_countof(o.psw_attempts_string))) return(false);
|
|
|
|
o.psw_attempts = _ttoi(o.psw_attempts_string);
|
|
|
|
o.psw_attempts = _ttoi(o.psw_attempts_string);
|
|
|
|
if ((o.psw_attempts < 1) || (o.psw_attempts > 9))
|
|
|
|
if ((o.psw_attempts < 1) || (o.psw_attempts > 9))
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -125,7 +125,7 @@ GetRegistryKeys()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!GetRegKey(_T("connectscript_timeout"), o.connectscript_timeout_string, _T("15"),
|
|
|
|
if (!GetRegKey(_T("connectscript_timeout"), o.connectscript_timeout_string, _T("15"),
|
|
|
|
_tsizeof(o.connectscript_timeout_string))) return(false);
|
|
|
|
_countof(o.connectscript_timeout_string))) return(false);
|
|
|
|
o.connectscript_timeout = _ttoi(o.connectscript_timeout_string);
|
|
|
|
o.connectscript_timeout = _ttoi(o.connectscript_timeout_string);
|
|
|
|
if ((o.connectscript_timeout < 0) || (o.connectscript_timeout > 99))
|
|
|
|
if ((o.connectscript_timeout < 0) || (o.connectscript_timeout > 99))
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -135,7 +135,7 @@ GetRegistryKeys()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!GetRegKey(_T("disconnectscript_timeout"), o.disconnectscript_timeout_string, _T("10"),
|
|
|
|
if (!GetRegKey(_T("disconnectscript_timeout"), o.disconnectscript_timeout_string, _T("10"),
|
|
|
|
_tsizeof(o.disconnectscript_timeout_string))) return(false);
|
|
|
|
_countof(o.disconnectscript_timeout_string))) return(false);
|
|
|
|
o.disconnectscript_timeout = _ttoi(o.disconnectscript_timeout_string);
|
|
|
|
o.disconnectscript_timeout = _ttoi(o.disconnectscript_timeout_string);
|
|
|
|
if ((o.disconnectscript_timeout <= 0) || (o.disconnectscript_timeout > 99))
|
|
|
|
if ((o.disconnectscript_timeout <= 0) || (o.disconnectscript_timeout > 99))
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -145,7 +145,7 @@ GetRegistryKeys()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!GetRegKey(_T("preconnectscript_timeout"), o.preconnectscript_timeout_string, _T("10"),
|
|
|
|
if (!GetRegKey(_T("preconnectscript_timeout"), o.preconnectscript_timeout_string, _T("10"),
|
|
|
|
_tsizeof(o.preconnectscript_timeout_string))) return(false);
|
|
|
|
_countof(o.preconnectscript_timeout_string))) return(false);
|
|
|
|
o.preconnectscript_timeout = _ttoi(o.preconnectscript_timeout_string);
|
|
|
|
o.preconnectscript_timeout = _ttoi(o.preconnectscript_timeout_string);
|
|
|
|
if ((o.preconnectscript_timeout <= 0) || (o.preconnectscript_timeout > 99))
|
|
|
|
if ((o.preconnectscript_timeout <= 0) || (o.preconnectscript_timeout > 99))
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -173,7 +173,7 @@ int GetRegKey(const TCHAR name[], TCHAR *data, const TCHAR default_data[], DWORD
|
|
|
|
if (data[0] != 0)
|
|
|
|
if (data[0] != 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Expand environment variables inside the string.
|
|
|
|
// Expand environment variables inside the string.
|
|
|
|
ExpandEnvironmentStrings(data, expanded_string, _tsizeof(expanded_string));
|
|
|
|
ExpandEnvironmentStrings(data, expanded_string, _countof(expanded_string));
|
|
|
|
_tcsncpy(data, expanded_string, max_len);
|
|
|
|
_tcsncpy(data, expanded_string, max_len);
|
|
|
|
return(true);
|
|
|
|
return(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -232,7 +232,7 @@ int GetRegKey(const TCHAR name[], TCHAR *data, const TCHAR default_data[], DWORD
|
|
|
|
RegCloseKey(openvpn_key);
|
|
|
|
RegCloseKey(openvpn_key);
|
|
|
|
|
|
|
|
|
|
|
|
// Expand environment variables inside the string.
|
|
|
|
// Expand environment variables inside the string.
|
|
|
|
ExpandEnvironmentStrings(data, expanded_string, _tsizeof(expanded_string));
|
|
|
|
ExpandEnvironmentStrings(data, expanded_string, _countof(expanded_string));
|
|
|
|
_tcsncpy(data, expanded_string, max_len);
|
|
|
|
_tcsncpy(data, expanded_string, max_len);
|
|
|
|
|
|
|
|
|
|
|
|
return(true);
|
|
|
|
return(true);
|
|
|
|