Commit Graph

55 Commits (577d982b51670f7f68d6dad9d0bf08f8a01879ba)

Author SHA1 Message Date
Selva Nair d6775b9b71 Persistent connections: show an error msg when connect fails
If '--management' option cannot be parsed in the config file of a
persistent profile (due to missing option, unreadable password etc.),
connecting it from the GUI menu fails.
In such cases show an error message instead of silently failing.
The message is shown only during manual connect attempts,
not during auto-connect or resume.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
2022-10-19 09:49:15 -04:00
Selva Nair 7f794eec3d Add a button for detaching from the management interface
Useful for releasing the management interface if the user wants to
connect to it by other means.

Detached connections are set to state = detached (no disconnected)
and auto_connect disabled, so that they could be handled properly
during a re-attach.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
2022-08-08 10:11:25 -04:00
Selva Nair 0e76e4b544 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>
2022-08-08 10:11:25 -04:00
Selva Nair 428ee29246 Add support for marking connections as persistent
Persistent connections have openvpn.exe daemon started
external to the GUI (e.g., by the automatic service).
This patch adds support for attaching to the management
i/f of such daemons from the GUI and control the connection.

The GUI never stops or starts the openvpn.exe process in this
case. Instead, connect and disconnect buttons signal the
management interface of a running openvpn.exe process to start
the tunnel by attaching to mgmt i/f and sending hold-release if
needed  or stop it and wait in management-hold state
(see DisconnectDaemon()).

When the GUI process exits, persistent connections are left in their
current state using DetachOpenVPN().

No connections are marked as persistent as yet. That is done
in a following commit.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
2022-08-08 10:11:25 -04:00
Selva Nair 84be448777 Handle pkcs11-id query from daemon
Add support for selecting pkcs11-id  from the GUI.
Requires --management-pkcs11-id in the config file.
This option is not added by the GUI.

A list of all available pkcs11 certificates are presented to the
user with buttons OK, Cancel, Retry. OK submits the selected
entry, Cancel closes the connection, Retry reconstructs the
list of certificates by querying the daemon again. The latter
can be used to retry after inserting a token.

If no certificates are found, a message suggesting to insert
a token and press 'Retry' is displayed.

The list shows the "Issued-to", "Issued-by" names
(usually the subject & issuer common names) and valid-until
date in current locale for each certificate.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
2022-07-19 12:08:02 +02: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 9c82e666d8 Show a prompt during profile import using --import
The user is prompted with a message showing the config
name that will be imported. The user can accept or cancel
the operation.

If the user was already prompted for over-write permission
because a config with the same name exists, no further dialog
is shown.

Import using the menu (Import File...) is not affected.

Rationale:
We want to set "Import" as the default verb for the context
menu of .ovpn files. This will allow import of configs by
double-click. Also when .ovpn file is downloaded using a browser,
setting the default bowser action to "open" will result in an import.
In such cases a silent import action could be surprising, and a
prompt showing what is being imported could provide a better UX.

On the flip-side, the prompt/dialog will also be shown when import
is done from the context menu of .ovpn by "right click and
choose import" or when "openvpn-gui.exe --import foo"
or "openvpn-gui.exe --command import foo" is executed. As import
is an action that does not result in an immediately visible result
(unlike, say, edit or print), a prompt requiring user action is of
some value even in these cases. At worst it's a minor annoyance.

See also: https://github.com/OpenVPN/openvpn-build/pull/227
and discussions there-in

Signed-off-by: Selva Nair <selva.nair@gmail.com>
2021-11-18 14:33:09 -05:00
Selva Nair e80a39c825 Implement importing profile from a generic URL
ParseUrl extended to parse generic URLs and parse
the path. DownloadProfile() function re-factored
for reuse with generic URL.

Also:
- INTERNET_FLAG_RELOAD added to the request
  call to force reloading the data from server instead
  of using possibly cached data.
- Input box for URL extended in length to about
   50 characters wide.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
2021-08-31 21:55:59 -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
Lev Stipakov c7beb04ff5 URL profile import: download and import profile
Use WinInet to download profile into memory buffer.
If there are certain certificate errors (invalid CN,
wrong date, unknown CA, revocation check failed),
ask if user wants to continue.

Extract profile name from content, sanitize name and
save profile in temp directory. Then import profile
using existing facilities.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2021-08-23 12:07:18 -04:00
Lev Stipakov 9ded7996ab URL profile import: add profile import dialog
This is the first patch from series which implemets
importing profile from URL, currently implemented
by OpenVPN Access Server.

Move "Import from file" menu item under new "Import"
item. Add "Import from AS..." item under "Import", which
opens new profile import dialog.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2021-08-23 12:07:18 -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 1c0c159d21 Have unique and non-zero IDs for all controls
Should fix duplicate control id warnings from resource
compiler.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
2021-05-24 07:52:29 -04: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 3f896b002b Implement display of echo message window
- Add a message box that support appending messages with
  a title formatted at a larger font and a text
  displayed in the default font.
- A global instance of the message box is used to
  display messages from all profiles.

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
Selva Nair b696a7c16d Optionally allow overwrite when importing a config
- Prompt the user for permission if import may overwrite
  an existing config.

- Also raise an error if the import file source matches the
  global or local config directory. Reimporting a config on to
  itself is not supported. This also  avoids ERROR_SHARING_VIOLATION
  in CopyFile() when source and destination are the same.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
2020-02-27 12:36:17 -05:00
Selva Nair 89509747f1 Remove service-only checkbox from settings menu
- This checkbox is inactive and does nothing.

  The service-only  usage can be still activated using the command
  line option --service_only  or by editing the registry, but its
  not a recommended use case for GUI version 11.0 and above.

See also issue: #264

Signed-off-by: Selva Nair <selva.nair@gmail.com>
2018-06-16 16:32:27 -04:00
Ilya Shipitsin 4a4a6ab52f remove unused resource
after https://github.com/OpenVPN/openvpn-gui/pull/188 that string
is not used anymore
2018-04-23 15:39:47 +03:00
Selva Nair ecb8e50c0f Display assigned IPs and connection stats on status window
- Show the assigned IP numbers, traffic stats (bytes in/out), and
  the GUI and OpenVPN core versions on the status window.

Note: IDS_TXT_BYTECOUNT = "Bytes in: %s out %s" needs translation.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
2018-01-30 10:20:58 +02: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 31896ce33b Add restart button to connection menus
- This works the same way as restart button in the status window
  but is more conveniently accessible from the tray menu.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
2018-01-20 11:41:19 -05:00
Selva Nair 5fb23f6ad9 Auto submit saved auth-user-pass credentials after a brief delay
- Effective only when username and password are saved.
- The user may interrupt auto submission and edit the username/password.
- If silent_connection is on the dialog is bypassed without any delay.

v2 changes:
- Display message in normal text color and show remaining time

Signed-off-by: Selva Nair <selva.nair@gmail.com>
2017-12-26 13:41:55 -05:00
Selva Nair 301a5e5644 Check for invalid characters in user inputs
- Flag password and username input if these contain an invalid character
  (currently only embedded '\n' is disallowed). Shows a popup when OK
  is pressed so that the user can correct the input and resubmit.

- Add an error message to the log when the management i/f returns
  ERROR for incorrectly parsed commands. Otherwise such errors go
  unnoticed.

Note: IDS_ERR_INVALID_USERNAME/PASSWORD need translations.

Reported and tested by: Florian Beier (H4ndl3 on github)
Fixes Trac: #958

Signed-off-by: Selva Nair <selva.nair@gmail.com>
2017-11-20 09:53:31 -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 be417bb38f Support pkcs11 token insertion request and pin input
Note: IDS_NFO_TOKEN_PASSWORD_CAPTION and IDS_NFO_TOKEN_PASSWORD_REQUEST
strings need translation.

TODO: support for selecting pkcs11-id from the GUI

Signed-off-by: Selva Nair <selva.nair@gmail.com>
2016-11-15 19:29:23 -05:00
Selva Nair 1a5ce44a99 Handle dynamic challenge/response
- Add a base64 decode function using Windows CyptoAPI
- Move multibyte to widechar conversions to a function
- Add config name to caption of password dialogs to help user
  identify the request
- Add new dialog template for generic password/PIN requests
  and use it to handle dynamic challenge

Note 1: if dynamic challenge response verification fails, an auth-failed
message is returned by the server causing the GUI to clear any saved
password even if the user-auth dialog itself succeeeded.

Note 2: Dialog template ID_DLG_CHALLENGE_RESPONSE added to language
files may require translation.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
2016-11-15 19:14:32 -05:00
Samuli Seppänen 135f177546 Merge pull request #86 from selvanair/get-pid-v2
Some bug fixes
2016-10-18 10:00:02 +03:00
Selva Nair fcd0efa479 Terminate any openvpn processes that fail to stop
Sometimes gracefully stopping openvpn fails leaving the
process running in background. This causes restarting of
connections to fail until those processes are manually killed.

- Read process ID from interactive service to get process
  handle when openvpn is started by the service.
- Add a last resort method to forcefully terminate openvpn
  process that fails to exit aftier sending stop signal. Terminate
  is triggered after a 3 second timeout following Stop.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
2016-10-08 16:25:38 -04:00
Ilya Shipitsin 0f531dc3ee cleaned up unused resource 2016-09-24 17:17:23 +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 5880fdcd02 Save username and optionally passwords
- Username and, optionally, password as well as the private
  key passphrase are saved in config-specific registry keys
- All saved data are kept encrypted using DPAPI
- The passphrase dialog is skipped if a valid saved private
  key password is available. However, the user-auth dialog
  is always presented, prefilled with the saved username
  and password.

Note: A text string "Save password" is added to three dialogs
in all language resource files. Additional text with ids
IDS_MENU_CLEARPASS and IDS_NFO_DELETE_PASS are added to the
STRINGTABLE only in the English language resource file.
All these need translations.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
2016-05-29 19:35:30 -04:00
Leonardo Basilio ece6aef6a6 Launch on startup setting 2016-05-22 22:05:42 -03: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
Soar Qin fe5a1c9b71 Adding static-challenge support 2016-02-27 13:51:13 +08:00
Samuli Seppänen c3e2584674 Merge pull request #17 from leobasilio/master
Add "Import file" menu option
2016-02-22 10:13:29 +02:00
Leonardo Basilio b47d3545e4 Improving feedback messages when importing 2016-02-21 12:15:40 -03:00
Selva Nair 5ce1298452 Warn if interative service is not installed or not running
Signed-off-by: Selva Nair <selva.nair@gmail.com>
2016-02-16 20:09:20 -05:00
Leonardo Basilio 46a1bc715c Adding "Import file" feature 2016-02-16 22:23:23 -02:00
Selva Nair 352e44f03d Better error reporting when connection fails to come up
- Handle early errors (openvpn exits before management connection is up)
    with a helpful error message that points the user to view log.
- Include only readable config files in the connection list
- Warn if no connection profiles found

TODO: handle startup errors from interactive service
2016-02-16 15:57:37 -05:00
Selva Nair 4437ce7a8c Change default log file location to a OpenVPN/log in user's profile directory
Change the default log file location to OpenVPN/log in user's profile directory
to support running without admin privileges using the interactive service.
The registry keys are moved to HKCU from HKLM to allow for user-specific
settings as well as to avoid the need for running the GUI as admin at the
first instance.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
2016-02-15 11:09:45 -05:00
Heiko Hund 22ff456888 check if "log_dir" exists or create it 2012-07-26 10:54:14 +02:00
Heiko Hund 66b77868b4 move "About" dialog to settings tab 2011-11-30 17:20:23 +01:00
Heiko Hund 9d918954d5 ask for HTTP proxy credentials on demand
* use "auto" parameter for --http-proxy option
 * pass proxy credentialsls via management interface
 * also closes #3223163
2011-03-24 17:54:53 +01:00
Heiko Hund 4bcebba60f use managment interface 2010-09-10 11:39:39 +02:00
Heiko Hund 7c4bea3f7e remove support for openvpn version < 2.0 2010-06-29 16:12:17 +02:00
Heiko Hund b0c1bd562c reformat and fix config file code
* make sure strings are \0 terminated
 * remove obsolete string IDS_ERR_LOG_CONSTRUCT
2010-03-21 21:32:48 +01:00
Heiko Hund 5963a4a49d fixed error string for failed MSIE proxy retrieval 2009-02-09 17:22:44 +00:00
Heiko Hund b8f520be05 config number for status dialog is now stored as property 2009-02-05 14:22:57 +00:00
Heiko Hund 2ba8e6eee0 fill in about dialog version info at build time instead of runtime 2009-02-04 16:26:14 +00:00