0
0
mirror of https://github.com/OpenVPN/openvpn3.git synced 2024-09-20 04:02:15 +02:00
Commit Graph

41 Commits

Author SHA1 Message Date
Lev Stipakov
a6151cdeab wintun: use auto-reset events
Wintun documentation clearly states that we must use auto-reset events in ring buffers.
Auto-reset sets event back to non-signalled state after calling WaitForSingleObject.
Without auto-reset and explicit ResetEvent call we got a busy loop.

To avoid confusion move event.hpp from common/ to win/, since it is
Windows-specific code.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2019-09-05 13:45:41 +03:00
Lev Stipakov
48f2b5100b wintun: support for privilege separation
This allows to run openvpn under normal user account,
in which case ring buffers registration is performed
by a separate privileged process.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2019-08-21 19:09:11 +03:00
Antonio Quartulli
47046cf6d2
Merge branch 'qa' 2019-07-19 14:39:43 +02:00
Lev Stipakov
5485de19a2 win/impersonate: refactor impersonate logic
Extend existing Impersonate class and move there
impersonate_as_system code from tunwin.hpp

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2019-06-20 10:34:38 +03:00
Lev Stipakov
980ef1eff8 win/call.hpp: re-encode command output to utf8
Command output can be in any encoding, for example cp866
in Russian edition of Windows and cp850 in English one.

This ensures that output is always utf8 encoded.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2019-05-06 17:10:12 +03:00
Lev Stipakov
fddb440e99 unicode.hpp: customize utf16 conversion routine
Enable to use other than utf8 encoding for incoming string.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2019-05-03 15:02:28 +03:00
Lev Stipakov
4d7c12ac4d [OVPN3-405] Support for non-ASCII profile path on Windows
This uses Windows-specific wchar_t override of std::ifstream
to make it work with UNICODE paths. It is assumed that caller
passes UTF8-encoded string.

To support passing non-ASCII chars via command line, we
read it as wstring and then convert to UTF-8 encoded string.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2019-04-30 17:45:01 +03:00
Lev Stipakov
5a4a875520 cosmetics: helper function to check registry errors
Signed-off-by: Lev Stipakov <lev@openvpn.net>
2018-08-31 17:56:17 +03:00
Lev Stipakov
fc52fd8a58 [OC-78] proxy: support PROXY_AUTO_CONFIG_URL on Windows
Set proxy settings in registry:

HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings

If process is running under SYSTEM account, we impersonate to
logged-in user to access HKEY_CURRENT_USER.

After modifying proxy setting we need to tell Windows to refresh those,
we do it if process is running under user account. Unfortunately WinInet API
we use is not available for services, even with impersonation, so
user application should take care of refreshing settings.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2018-08-31 17:56:16 +03:00
David Sommerseth
16b10559f2 [OVPN3-140] Update company names in copyrights
OpenVPN Technologies, Inc. change their name to OpenVPN Inc. during the
autumn of 2017.

Signed-off-by: David Sommerseth <davids@openvpn.net>
2017-12-22 17:59:39 +08:00
David Sommerseth
6caca2c313 [OVPN3-140] Relicense back to AGPLv3
This is essentially a revert of commit 04b2a3c9b7 and commit
ef42e59e05.

Signed-off-by: David Sommerseth <davids@openvpn.net>
2017-12-22 17:59:39 +08:00
Lev Stipakov
d7f8c47a2e nrpt: create separate policy per dns suffix
Contrary to what documentation says, on Windows 10 only first DNS suffix is respected.

OVPN3-133

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2017-12-22 17:59:39 +08:00
James Yonan
691a641a43 Added i/o abstraction layer.
Created a lightweight abstraction layer so that another i/o
reactor can be dropped in place of asio.

The basic approach is to rename all references to asio::xxx
types to openvpn_io::xxx and then make openvpn_io a
preprocessor variable that points to the top-level namespace
of the i/o reactor implementation.

All of the source files that currently include <asio.hpp> now
include <openvpn/io/io.hpp> instead:

This gives us a lightweight abstraction layer that allows us
to define openvpn_io to be something other than asio.

Other changes:

* Inclusion of asio by scripts/build is now optional, and is
  enabled by passing ASIO=1 or ASIO_DIR=<dir>.

* Refactored openvpn/common/socktypes.hpp to no longer
  require asio.

* Refactored openvpn/log/logthread.hpp to no longer require
  asio.

* Added openvpn::get_hostname() method as alternative to
  calling asio directly.

* openvpn/openssl/util/init.hpp will now #error
  if USE_ASIO is undefined.

Signed-off-by: James Yonan <james@openvpn.net>
2017-03-30 15:48:14 -06:00
James Yonan
6e8f2a73f8 Moved openvpn::to_string() to separate source file.
Signed-off-by: James Yonan <james@openvpn.net>
2017-03-18 15:46:45 -06:00
James Yonan
b2cd82a5bf copyright: updated to 2017.
Signed-off-by: James Yonan <james@openvpn.net>
2017-03-18 13:11:09 -06:00
Samuli Seppänen
04b2a3c9b7 Switch from AGPLv3 to GPLv3
Signed-off-by: Samuli Seppänen <samuli@openvpn.net>
2017-03-16 14:43:55 +02:00
James Yonan
971abda88f copyright : updated to 2016 2016-09-03 23:29:23 -06:00
James Yonan
1ed095c719 Minor Win edit: forgot to add leading "::" before
::wcslen() call in openvpn/win/unicode.hpp.
2016-02-24 23:42:17 -07:00
James Yonan
6b79923ccf Win client: Modifed WFP rules to be more aggressive in
preventing DNS leakage.

  Filter #1 -- permit IPv4 DNS requests from OpenVPN app
  Filter #2 -- permit IPv6 DNS requests from OpenVPN app
  Filter #3 -- block IPv4 DNS requests from other apps
  Filter #4 -- block IPv6 DNS requests from other apps
  Filter #5 -- allow IPv4 traffic from TAP
  Filter #6 -- allow IPv6 traffic from TAP

This change has the unfortunate side-effect of causing
lags in DNS resolution, so for now the capability is
disabled in tunsetup.hpp, pending evaluation of
NRPT-based approaches.
2016-02-24 12:14:44 -07:00
James Yonan
eb2141c648 Removed JsonCpp support from some Action-derived classes. 2015-11-10 23:18:27 -07:00
James Yonan
98143f7ec5 In Windows class ScopedHANDLE, added a reset() method (without
arguments) that acts the same as close().
2015-11-10 23:14:13 -07:00
James Yonan
2f40c52fbc Change to calls of Windows API methods:
* Where unicode/ansi versions of a method exist, always
  explicitly call one of unicode or ansi methods by
  appending a 'W' or 'A' to the end of the method name.
  Never omit the 'W' or 'A' because that will cause the
  default method to be used which may vary according to
  build flags.

* Prepend all Windows API method references with "::" to
  indicate that the method names should be resolved from
  the top-level namespace.
2015-11-09 14:56:08 -07:00
James Yonan
eb9ac6eb83 Added regex verification of WinCmd command strings.
Includes new source file openvpn/addr/regex.hpp
containing validating regular expressions for
IPv4/v6.
2015-11-01 15:11:36 -07:00
James Yonan
9fac4c0770 win/call.hpp mostly stylistic cleanup:
* Prefix Windows API calls with "::"
* Fix comment alignment
2015-11-01 15:03:05 -07:00
James Yonan
4ea436667e Windows TAP interface code:
* Work with new polymorphic ActionList objects.

* Implemented TAP setup code for pre-Vista Windows
  (when _WIN32_WINNT < 0x0600).

* Still to do: sanity check input to from_json_untrusted()
  methods.
2015-10-27 18:56:02 -06:00
James Yonan
94d6a7419f Added Win::Error and Win::LastError wrappers
around asio::error_code (openvpn/win/winerr.hpp).
2015-10-18 07:25:48 -06:00
James Yonan
98dcae166c In class ScopedHANDLE (Windows), added C++11 move
construction/assignment.
2015-10-16 20:57:28 -06:00
James Yonan
c4a9cea3e1 Updated Windows client for VS 2015. 2015-06-09 11:21:41 -06:00
James Yonan
b75c780cab Renamed boost::intrusive_ptr<T> usage to RCPtr<T>. 2015-05-17 21:26:53 -06:00
James Yonan
35ac9f6229 Renamed types.hpp to size.hpp since it now only defines
size_t and ssize_t.
2015-05-17 13:27:34 -06:00
James Yonan
fe6fcefa61 C++11 : rename NULL to nullptr 2015-05-17 02:53:37 -06:00
James Yonan
68b8f12b25 Refactored ScopedPtr usage to std::unique_ptr.
Removed ScopedPtr.
2015-05-17 01:41:16 -06:00
James Yonan
36550cd35e Update to C++11 noncopyable semantics.
Instead of inheriting from boost::noncopyable,
use the C++11 delete qualifier:

    Class(const Class&) = delete;
    Class& operator=(const Class&) = delete;
2015-04-23 15:10:43 -06:00
James Yonan
c2c7292a70 Updated copyright to 2015. 2015-01-06 12:56:21 -07:00
James Yonan
2c6d972ad6 Added AGPL copyright/licensing language. 2014-07-20 21:22:06 -06:00
James Yonan
141182e21e Support pushed DNS search domains in TunWin::Client. 2014-03-06 00:27:41 -07:00
James Yonan
9e35e41fb4 Added ActionThread class to allow Action objects to be
executed asynchronously in a worker thread.

Needed to make some changes to logthread as well
to allow log context to be made available to
the worker thread.
2014-03-06 00:27:41 -07:00
James Yonan
aa26213b3e Modified Win::call() method to use SHGetFolderPath
instead of SHGetKnownFolderPath when built on
pre-Vista.
2014-02-21 12:22:39 -07:00
James Yonan
8b3dd0b8d5 Added Win::call() method for executing system commands from Windows
in a way that is path-safe and usable in non-console apps.

Modified WinCommandList to use Win::call().
2014-02-20 17:17:56 -07:00
James Yonan
86ed980149 Added ScopedHANDLE::ref() method. 2014-02-20 17:12:38 -07:00
James Yonan
b84b48fb75 Ported to Windows.
Implemented full TunClient class for Windows with TAP driver
support.  For now, we use netsh (rather than TAP driver DHCP)
to set all tunnel adapter properties, as this appears to work
great on Windows 7.

IPv6 is fully supported.

Known isues:

* netsh doesn't have a command for adding DNS search domains, so
  we don't support them yet.

* While we always try to remove routes and added properties from
  TAP adapter instance when we close out the session, for robustness,
  when we bring up TAP adapter, we should try to delete any stale
  routes on interface left over from previous session.

* Right now we call netsh with system().  For security and
  compatibility with Windows apps (not only console apps),
  we should use CreateProcess instead.
2014-02-16 01:13:26 -07:00