Commit Graph

38 Commits (577d982b51670f7f68d6dad9d0bf08f8a01879ba)

Author SHA1 Message Date
Selva Nair 477c61ff83 Parse config-auto directory for persistent connections
- Parse the config-auto folder used by automatic service
  and mark these profiles as persistent.

- These connections are marked as auto_connect to try
attaching to them at start up with periodic retry in
case the daemon or service are restarted.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
2022-08-08 10:11:25 -04:00
Selva Nair 8f0dbbc8a3 Always check status of automatic service
- Remove service-only mode (start/stop service) which has not been in
  use since we moved to running the GUI as limited user.
  Also its not very useful as it does not allow any control of
  service-started daemons

- Keep CheckServiceStatus and always check the status of
automatic service.

The status of the service will be used to toggle supporting
control of persistent connections started by the service.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
2022-08-08 10:11:25 -04:00
Lev Stipakov d60325acde Support for OpenVPN 3
This adds optional support for using OpenVPN3 client
as an alternative to openvpn2.

Just replacing one client with another will not work:

 - OpenVPN3 doesn't use interactive service, it uses
"agent" service with completely different protocol. OpenVPN GUI
needs to talk to agent using HTTP and JSON.

 - OpenVPN3 management interface realtime notifications must be
explicitly turned on in order for GUI to work.

To enable using openvpn3:

 - use any of *-ovpn3 presets (cmake build system)

 - ./configure --enable-ovpn3 (mingw)

To switch betweet openvpn2 and openvpn3, see "OpenVPN Engine"
radiobutton group in Settings -> Advanced dialog.

OnReady() implementation was slighly changed - "log all on"
replaced with "log on all" - according to management interface
documentation this is the right way to do it, and also OpenVPN3
only supports "on all" order.

Management interface - enabled OpenVPN3 client (omiclient.exe) and
agent (ovpnagent.exe) are now part of openvpn3 repo.

Co-authored-by: Christopher Ng <facboy@gmail.com>
Signed-off-by: Christopher Ng <facboy@gmail.com>
Signed-off-by: Lev Stipakov <lev@openvpn.net>
2022-06-15 10:32:36 -04:00
Selva Nair 24b9d06957 Update OpenSSL initialization
- Set env variables such as OPENSSL_CONF and OPENSSL_MODULES
- Replace deprecated initialization (since OpenSSL 1.1.0)
  by OpenSSL_init_crypto()

Signed-off-by: Selva Nair <selva.nair@gmail.com>
2022-02-10 09:30:05 -05:00
Selva Nair 56ee704501 Use C standrad compliant printf specifications
%S --> %hs in wide format strings, %ls otherwise
%s --> %ls in wide format strings, unchanged otherwise
%c --> %lc in wide format strings

Resource files together have about 970 lines affected and
were edited by looping through all with
sed -i 's/%S/%hs/g' $file
sed -i 's/%s/%ls/g' $file
All other files were manually changed (about 85 lines).

Recent versions of mingw-w64 implicitly turns on __USE_MINGW_ANSI_STDIO
if _GNU_SOURCE, _XOPEN_SOURCE etc are defined (which we do usei).

This breaks non-standard spec such as %S. Anyway, we have been
gradually getting rid of those.

MSVC builds should not be affected.

v2: multiple occurrences in same line was missed in v1 (/g missing in
sed expression). Fixed.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
2021-11-03 16:20:17 -04:00
Selva Nair ef14a62d34 Ensure dialogResult is initialized before use
Signed-off-by: Selva Nair <selva.nair@gmail.com>
2021-11-03 16:20:17 -04:00
Selva Nair 8e4183f9a9 Add '--command import' command line option
Import a config file from command line as

`openvpn-gui.exe --command import <file-path>`

The command is send to a running instance if any.
Otherwise the GUI extecutable is started and
the import processed.

`openvpn-gui --import <file-path>`

is interpreted as the same command.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
2021-08-31 14:48:20 -04:00
Selva Nair 7faa16846d Option to disable echo messages from settings menu
- Also add an edit box for setting the mute interval for
  repeated echo messages. To be specified in hours
  >=0. A zero value disables muting.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
2021-06-25 20:48:02 -04:00
Selva Nair 4ef560c649 Add command line option for management_port_offset
Signed-off-by: Selva Nair <selva.nair@gmail.com>
2021-03-05 09:45:32 -05:00
Selva Nair f098f2fee4 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>
2021-02-24 09:26:05 +02:00
Selva Nair 82e17b239e Mute echo message if repeated or disabled
- Suppress messages with exactly same content as previously
  displayed within popup_mute_interval (24h by default). This parameter
  may be set on command line as "--popup_mute_interval n" where n is
  in hours.

- Command line option '--disable_popup_messages' disables all echo
  message popups (window and notification).

This patch only handles suppression of repeated messages during
reconnections.
TODO: Persist message history in the registry and use it to mute
repeated messages after disconnects and across restarts of the GUI.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
2021-01-07 23:29:02 -05:00
Lev Stipakov 1715746477 Introduce "Always use interactive service" option
We didn't use interactive service when gui was running
under admin because of some privilege escalation vulnerability in Vista.

Apparently this issue doesn't exist on Win7 and newer versions so
it is safe to use iservice on those systems.

Introduce "Always use interactive service" option,
which is "on" by default. This should enable users,
who by various reasons run gui as admin, use Wintun.

When gui is running as admin and interactive service
cannot be started or not installed, warn that wintun will not work.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2020-09-18 00:03:03 -04:00
Wouter bf47b62c36 Use IFileOpenDialog instead of SHBrowseForFolder 2020-09-11 11:15:14 -04:00
ikreb7 849d4641eb fix typo 2020-03-24 16:57:34 -04:00
Selva Nair 9ad57eb415 Add '--command rescan' to rescan config folders
Add an new command 'rescan' that may be sent to a running
instance of the GUI to force it rescan the config folders.

Use case: with an instance of the is GUI running, one can
manually copy a config file to the config folder and start
it using "openvpn-gui --command rescan" followed by
"openvpn-gui --command connect foo"

v2: The calls to rebuild config file list and recreate
menus is refactored into a function.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
2020-01-12 16:32:51 -05:00
Selva Nair f55eeb1da8 Eliminate MAX_CONFIGS limit using a dynamic array
The number of configs is now unlimited. But there is a limit
of 2^16 menu items which permits only about 2^12 configs to be
displayed in the menu. A warning is shown if the number of
configs exceeds this value.

For a responsive menu keep the number of configs under ~1000.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
2019-02-11 11:51:23 -05:00
Selva Nair a9898d3819 Add a registry key for choosing config menu view
Add a new registry key (DWORD): config_menu_vew
   possible values:  0 (auto), 1 (flat), 2 (nested).

Default value is 0 which renders nested menu if the number of
configs is > 50, else displays the current flat view. To force
the flat menu view set it to 1. A value of 2 forces the nested
view even if there are only a few configs.

A new command line option "--config_menu_view n" does the same.
Command line options take precedence over any value set in the
registry.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
2019-02-11 11:51:23 -05:00
Selva Nair 1cb07f92f3 Fix detection of running instance
When openvpn is run with --help option it pops up a help
message and exits when that window is closed. Such instances
cannot accept any commands and should not be treated as a
running instance.

Fix by
(i) When run with --help, promptly release the semaphore used
to restrict to a single running instance.

(ii) Wait for a short interval (200 msec) before timing out of
locking the semaphore. This helps avoid race conditions.

While at it also make sure the semaphore is released and closed
on exit.

Fixes issue: #237

Signed-off-by: Selva Nair <selva.nair@gmail.com>
2018-04-24 09:03:16 +03:00
Selva Nair eb52950f7a Treat --connect as --command connect in case GUI is already running
- This makes the behaviour more intuitive for those used to the
  auto connect option (--connect xxx). Note: this will work only for
  the first occurrence of --connect as --command allows only one profile
  to be speciifed.
- Also make '--command connect' behave as '--connect' if the GUI is not
  already running.

Based on comment by larson0815 here:
https://github.com/selvanair/openvpn-gui/issues/5

Signed-off-by: Selva Nair <selva.nair@gmail.com>
2018-01-20 11:42:23 -05:00
Selva Nair 0f21030774 Support sending commands to running instance
- New option --command <action> <params> to send commands to
  a running instance of openvpn-gui.exe
  Supported actions are
      connect, disconnect, reconnect
  each of which takes the name of the config (with or without the
  extension .ovpn) as a parameter;
      disconnect_all, exit
  which take no parameter and
      silent_connection
  which takes an optional parameter = 0 or 1 (1 is the default)

  Examples: with the gui running, start a new instance as

  openvpn-gui.exe --command disconnect myvpn : ask running instance
                        to disconnect myvpn if connected
  openvpn-gui.exe --command status myvpn     : ask running instance
                        to show the status window for myvpn if available
  openvpn-gui.exe --command disconnect_all   : ask running instance
                        to disconnect all active connections

- The second instance exits after issuing a SendMessage to the
  already running instance. If no action is specified, the running
  instance is notified to show a balloon to alert the user

- These messages may also be sent from scripts as COPYDATA messages
  with the wData element specifying the action to execute and lpData
  a pointer to the parameter. The dwData param must be one of
  WM_OVPN_xxx with xxx = START, STOP, RESTART, STOPALL, EXIT or
  SILENT. See main.h for their values.

v2: Bug fixes based on test reports from larson0815
here: https://github.com/selvanair/openvpn-gui/issues/5
and cron410 here: https://github.com/OpenVPN/openvpn-gui/issues/104

Signed-off-by: Selva Nair <selva.nair@gmail.com>
2018-01-20 11:42:23 -05:00
Selva Nair 1bd5a6faa9 Add a warning message when authentication is retried due to wrong credentials
- "Wrong username or password" message shown in the auth userpass dialog after
  an auth failure
- "Wrong password" message shown in the private key password dialog after a
  password failure.

These message texts are colored red by default (TODO: make the color customizable)

Signed-off-by: Selva Nair <selva.nair@gmail.com>
2017-06-27 16:01:18 -04:00
Selva Nair 25be842a96 Merge pull request #117 from selvanair/nay-to-savepass
Add a system-wide option to disable the password save feature
2017-03-08 21:37:31 -05:00
Selva Nair 778cc3d225 Add a system-wide option to disable the password save feature
- A new registry HKLM\Software\OpenVPN\disable_save_passwords
  (32 bit DWORD value) may be set to a non-zero value to
  disable password saving by users. Applies to both auth and
  private key passwords. Usernames are always saved.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
2017-03-07 11:49:03 -05:00
Selva Nair 4b716b4666 Fix truncation of usage message shown when --help is used
- Increase the buffer size used to load the usage string to 2048
  chars (defined by USAGE_BUF_SIZE in main.h)
- Make GetGUILanguage() visible outside localization.c

Trac: #833

Signed-off-by: Selva Nair <selva.nair@gmail.com>
2017-01-30 22:30:26 -05:00
Selva Nair 5a47986ccb Make options saved in registry editable by user
Option ediitng dialogs are in two tabs: General and Advanced.
Proxy related options are left in the proxy tab. Options
config_dir, config_ext, log_dir, script timeouts and
service-only flag are in the Advanced tab. All other more commonly
used flags and options are in the General tab.

- As options are editable, save values in registry only when they differ
  from the default values. This leaves the registry clean and makes changing
  options and their defaults during updates easier.

- Entries for config_dir and log_dir must be absolute paths.
  Environemental variables such as %PROFILEDIR% may be used
  to construct these.

- Empty config_dir, config_ext and log_dir entries are silently
  ignored (i.e., the current values are left unchanged).

- Store all numeric and boolean parameters in registry as DWORD instead of
  strings.

- On startup, the default parameters are loaded, then the registry is read
  and finally command-line parameters parsedi.

- Out of range script timeout values in registry truncated with a
  warning instead of fatal error. This allows the user to access the
  settings dialog and make corrections.

- Save proxy and language settings under the same
  HKCU\Software\OpenVPN-GUI key as other options instead of under Nilings.

- Save the current version of the GUI in regsitry so that updates
  can be detected and any needed registry cleanup done.

- If no version info is present in the registry any values in OpenVPN-GUI
  key in HKCU are deleted for a clean start as this is the first version
  to save registry values in HKCU. Language and proxy data if present
  under Nilings is migrated.

Note: new controls in the General tab and newly added Advanced tab dialog
are copied to all language files from the English version. These need to
be translated.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
2016-08-06 11:46:15 -04:00
Selva Nair 1c748e382d Simplify some parameters and registry keys
- Replace allow_password by a runtime check that enables password
  change menu only when the user has write-access to the key file.
- Read exe_path and priority from HKLM and do not duplicate in HKCU.
- Always allow the user to view the config: edit will succeed if user
  has write access.
- Always include the proxy settings tab which is the default.
- Remove the unused power event handling and disconnect_on_suspend key.
- Remove password_attempts -- user can stop the password dilaog
  by clicking cancel.
- Remove allow_service: implicitly enabled if service_only is used.
- Deprecate removed options in cmd-line parser
- Update README.rst
- Close config file before exit in GetKeyFileName
- Close thread and dialog handles in passphrase.c

Signed-off-by: Selva Nair <selva.nair@gmail.com>
2016-08-06 11:46:15 -04:00
Selva Nair 43d0ef3a5a Handle interactive service policy restrictions
When a connection is attempted using a config in a location
that would fail, offer an option to add the user to the "OpenVPN
Administrators" group. This is done using shell-execute which will
show a UAC prompt for elevation. If it fails (due to user chooses
NO or the UAC dialog fails) the connection is not started.

v2 Changes
 - Rebase to master
 - Automaticlaly add the admin group if it doesn't exist
 - Allow unicode strings in debug output
 - Use domain\username to identify user
 - Fix the PrintDebug macro

Minor changes based on user feedback
 - Bring the window back to foreground after UAC prompt completion
 - Show a message if another connection is tried during authorization
 - Do not add user to ovpn_admin_group if it is same as the built-in admin group

Signed-off-by: Selva Nair <selva.nair@gmail.com>
2016-03-13 20:23:20 -04:00
Heiko Hund 82eb645a5e localize buttons in message boxes when possible 2012-07-20 17:44:48 +02:00
Heiko Hund f420d7dcbb use CRT's _countof instead of proprietary _tsizeof 2012-03-29 17:40:34 +02:00
Alon Bar-Lev c9eb68c77f use automake in build
Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>

Edited to not use libtool and implicit automake rule to build resource object
2012-03-28 10:59:44 +00:00
Heiko Hund 4bcebba60f use managment interface 2010-09-10 11:39:39 +02:00
Heiko Hund a6e6d88115 refactor option handling code 2010-04-09 06:18:58 +02:00
Heiko Hund 61cb987f4d make it work when compiled as unicode 2010-03-21 10:07:14 +01:00
Heiko Hund 6939cb8792 replace GUI_* with PACKAGE_* macros 2010-03-11 22:58:45 +01:00
Heiko Hund 5783d7da94 cleaned up resource IDs 2009-02-04 15:54:37 +00:00
Heiko Hund d646c7fc8c fixed compiler warnings 2009-01-19 12:28:26 +00:00
Heiko Hund 3d4aaeb5a4 switched to use of localization functions 2009-01-18 20:59:52 +00:00
Heiko Hund fd9e4ae6db import of openvpn-gui-1.0.3.zip
git-svn-id: https://openvpn-gui.svn.sourceforge.net/svnroot/openvpn-gui/trunk@2 43a1345a-9c20-4331-951f-9845fc178312
2008-12-18 11:08:35 +00:00