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

229 Commits

Author SHA1 Message Date
James Yonan
4eaa46a879 MbedTLS: added MBEDTLS_DISABLE_NAME_CONSTRAINTS preprocessor flag
This allows building a client against a generic mbedTLS library.

Signed-off-by: James Yonan <james@openvpn.net>
2019-07-17 10:53:46 -06:00
Lev Stipakov
03a906771e win: add OpenSSL as solution configuration
This also removes unittest.vcxproj from solution, since
it is deprecated in favor of CMake-based unit tests.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2019-06-05 13:54:13 +03:00
David Sommerseth
a55fe2b554
tests: Added unit test for linux/cputime.hpp
This test attempts to assure that the measurements we get from
openvpn::cpu_time() is within a reasonable range of what we should
normally expect.

This is achieved by using a simple worker thread which ensures the
process is not "idling" (like it would with sleep()) but in a real busy
loop which takes some time.  Then we measure the time spent in the busy
loop, both using a simplistic time() and comparing that with what
cpu_time() returns.

This unit test also supports measuring multiple running threads
individually too.

Signed-off-by: David Sommerseth <davids@openvpn.net>
2019-06-03 19:05:34 +02:00
Lev Stipakov
a2496a3616 Wintun: experimental support
This introduces experimental support for Wintun
as an alternative for tap-windows6.

In order to use wintun, set "ClientAPI::Config::wintun"
flag to "true" or use "-w" option in test client.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2019-05-29 20:21:28 +03:00
Lev Stipakov
b55f78dd1d test_sitnl.cpp: account for old iptools output
On CentOS 7 "ip route get" produces different
output comparison to Ubuntu 18 etc.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2019-05-14 16:32:03 +03:00
Arne Schwabe
d56e049ea4 Refactor dependencies to be in a cmake script
This allows the dependencies to be used by multiple parts of the project,
e.g. non public unit tests, ovpncli etc.

Building ovpncli demostrates this
2019-05-13 14:49:36 +02:00
Lev Stipakov
e9dc75ec90 sitnl: add unit tests
This adds unit tests for sitnl code.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2019-05-10 10:48:53 +03:00
Lev Stipakov
dfcc4bc437 [OVPN3-354] cli.cpp: support for round-robin DNS and redirect gw
This takes into use new TunSetup API which enables to create bypass
routes before establishing connection.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2019-05-10 10:48:53 +03:00
Lev Stipakov
7150f72e09 tun: remove code duplications in Linux tun implementations
There are two ways how Linux tun can be manipulated -
by using iproute2 or netlink. Both implementations have
defined identical Setup class implementation.

This commit factors out Setup class from tun implementations
and templatizes it, which removes need in duplicated code.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2019-05-02 21:34:20 +03:00
Lev Stipakov
8112f0cd7c [OVPN3-378] cli: support for TunBuilder API
This enables to use TunBuidler API by test client
on Linux and Mac platforms.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2019-05-02 21:34:20 +03:00
Arne Schwabe
aba98471fc Fix base64 unit test with mbedtls and windows
- the output buffer was sometimes too small in mbed tls
- msvc compiler does not like stack arrays with dynamic sizes
2019-04-18 14:47:16 +02:00
Arne Schwabe
9f84174f0b Add unit tests for Base64 2019-04-15 17:23:37 +02:00
Arne Schwabe
dfdd528dc1 Convert unit test to Googletest
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2019-04-15 17:23:37 +02:00
Arne Schwabe
bd9ee482e6 Add copyright header to test_comp 2019-04-15 17:23:37 +02:00
Arne Schwabe
059f20f2b2 Move compression unit test from common to core repository
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2019-04-15 17:05:09 +02:00
James Yonan
5a024cde5c Added Snappy corpus for testing compression/decompression.
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2019-04-15 17:05:09 +02:00
Arne Schwabe
6ef089164e Allow unit tests to be also compiled with mbed TLS and on Windows 2019-03-12 11:36:29 +01:00
Arne Schwabe
7c67bf7f50 Add unit tests for route emulation and establish common test suite
This puts the log demo unit test and real route emulation into the same
unit test compilation unit to save compilation time.
2019-03-12 11:36:29 +01:00
Arne Schwabe
64a7b2f124 Add build file for core unit tests
Currently we only have unit test build file for Visual Studio. Add one
that is compatible with Unix like systems.
2019-03-12 11:36:29 +01:00
Lev Stipakov
1bf3fc0e4a win: update project files
Remove Win32 target, set platform version to Windows 10 and set platform toolset to v141.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2018-12-21 10:30:31 +02:00
Arne Schwabe
84dbc5b9b2 Allow test/cli.cpp to be used with NetCfg Tunbuilder client
This requires cli.cpp to be included in openvpn3-linux build environment
and the right defines set before the test.cpp is included.

This workaround is necessary since the dbus dependencies are not part
of the core and to adding an extra copy of cli.cpp to openvpn3-linux

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2018-12-06 11:49:30 +01:00
Antonio Quartulli
9814079944
tls-crypt-v2: implement abstract metadata parser
The metadata that may be possibly be contained in the WKc has to be
verified by means of a user implemented behaviour.

Implement an abstract class that exports a verify() method to be
used for this purpose.

Users can extend this class and override the verify() method with
their own.

A basic implementation is also provided: it will just ignore the
metadata (if any) and report success to the core.

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2018-12-06 09:19:22 +10:00
Antonio Quartulli
be38bbeb84
tls-crypt-v2: test/ssl/proto.cpp - extend protocol test
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2018-12-06 09:19:22 +10:00
Arne Schwabe
2ea88a93ba Add Remote endpoint information to protect_socket call
On the linux client we need the information to which remote the client
is connecting to query the route information to ultimately discover the
device. On other platform that do not need these extra information we
ignore the extra arguments

The API uses std::string and bool instead of passing of passing IPAddr as
the API needs to be understand by Swig/Java and similar methods also opt in
favour of call by value and simply types.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2018-12-04 13:33:18 +01:00
Antonio Quartulli
0a081ee17f
[OVPN3-315] cli/go: add option to compile SITNL component
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2018-11-30 08:51:14 +10:00
David Sommerseth
4a25059f5c
test/ovpncli: Don't override PROF env variable
If the PROF env variable is already set, respect that original value
instead of enforcing a value which might be wrong on the build host.

Signed-off-by: David Sommerseth <davids@openvpn.net>
2018-11-07 17:57:08 +01:00
Antonio Quartulli
8d9834b793
cli: build with OPENVPN_VERSION generated from commit id
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2018-06-25 16:37:51 +08:00
James Yonan
0e673f1e0b Cleaned up cli build script
Also added an option to build with OpenSSL
instead of mbedTLS.

Signed-off-by: James Yonan <james@openvpn.net>
2018-05-21 11:34:01 +03:00
Antonio Quartulli
d9b5055cda
[OVPN3-169] cli.cpp: compile with -DOPENVPN_TLS_LINK when requested
Compile with -DOPENVPN_TLS_LINK if TLS=1 was specified on
the command line

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2018-04-19 17:38:19 +08:00
James Yonan
59de63fa65
cli.cpp: added OPENVPN_REMOTE_OVERRIDE
For testing, add the capability to get the next "remote"
directive from the output of an external script or binary.

Signed-off-by: James Yonan <james@openvpn.net>
2018-03-26 23:58:35 +08:00
Lev Stipakov
0edec4a097
[OVPN3-206] win: update directories in VS projects
Signed-off-by: Lev Stipakov <lev@openvpn.net>
2018-03-26 23:58:33 +08:00
James Yonan
01ee1f5a41
Added ClientAPI::Config::retryOnAuthFailed parameter
// If true, consider AUTH_FAILED to be a non-fatal error,
  // and retry the connection after a pause.
  bool retryOnAuthFailed = false;

Signed-off-by: James Yonan <james@openvpn.net>
2018-03-10 02:28:33 +08:00
James Yonan
eedee4fa6d
cli.cpp: allow -s server override to reference a friendly name
The OpenVPN 3 config file parser allows an embedded server list,
given as:

  setenv SERVER <HOST1>/<FRIENDLY_NAME1>
  setenv SERVER <HOST2>/<FRIENDLY_NAME2>
  . . .

This patch allows the -s server override to specify
a friendly name and will substitute the host or IP
address given in the server list.

Signed-off-by: James Yonan <james@openvpn.net>
2018-03-10 02:28:32 +08: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
Antonio Quartulli
577b5ca7b4 cli.cpp: fix typ0 in define
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2017-12-22 17:59:39 +08:00
Antonio Quartulli
3928069caa [OVPN3-119] mbedTLS: create INSECURE profile including MD5
Following an high number of users complaints, it was suggested
to re-enable MD5 and to give our users a notice period of some
months before dropping its support entirely.

With this patch we add a new certificate profile called "insecure"
which is equal to "legacy" with the addition of MD5.

By default OpenVPN3 still use legacy and the insecure profile
must be enabled explicitly by the client app.

The new profile is also enveloped in an ifdef so that
such support is not introduced, unless who builds the core
knows about it.

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2017-12-22 17:59:39 +08:00
James Yonan
121e9752e7 client API: added portOverride
portOverride, like serverOverride, will override the port used
in the remote directive of the profile.

Signed-off-by: James Yonan <james@openvpn.net>
2017-12-22 17:59:38 +08:00
James Yonan
106981c3e2 JSON: allow alternative JSON library implementations
Allow source files that require JSON library functionality
to include a single file (openvpn/common/jsonlib.hpp) which
will then draw in the appropriate JSON library header based
on configuration #defines.

Code can #ifdef on HAVE_JSON to test whether or not JSON
functionality is available (previously, HAVE_JSONCPP
was used).

Currently supports JsonCpp and an OpenVPN-internal JSON
implementation.

This model assumes that alternative JSON implementations
are API-compatible with JsonCpp.

Signed-off-by: James Yonan <james@openvpn.net>
2017-12-22 17:59:38 +08:00
Antonio Quartulli
f33e7c2968 [OVPN3-5] tls-crypt: add tls-crypt support in proto.hpp test unit
By default tls-crypt is now enabled instead of tls-auth.
It can be easily changed by editing the define at the top
of test/ssl/proto.hpp

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2017-09-27 16:16:18 +08:00
Antonio Quartulli
389353c243 proto.cpp: uninit process at the end of the execution
Not really important, but worth fixing to avoid polluting
any memchecker output with unreleased (leaked) resources.

Release process resources before exiting the main function.

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2017-09-27 16:16:18 +08:00
Lev Stipakov
8ae2a3f7cf Integrate Google Test framework
Implemented sample test for LogInfo class.

OVPN3-27
2017-09-27 16:16:18 +08:00
Lev Stipakov
96e0d89454 Revert "Merged in OVPN3-21-prepend-log-record-with-unique- (pull request #7)"
This reverts commit 62423c91cb, reversing
changes made to f26b08b6ef.
2017-09-27 16:16:18 +08:00
Lev Stipakov
cce245587b Prepend log string with unique reference.
OVPN3-21

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2017-08-08 11:35:37 +03:00
James Yonan
f89da9619e OpenVPN 3 client: added single-thread mode:
* enabled by OPENVPN_OVPNCLI_SINGLE_THREAD compile flag.

* turns off the signal blocker.

* Adds overrideable clock_tick() virtual method with
  configurable frequency that is used when processing
  signals when the OpenVPN client is running in
  single-thread mode.

Signed-off-by: James Yonan <james@openvpn.net>
2017-04-12 12:37:41 -06: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
b2cd82a5bf copyright: updated to 2017.
Signed-off-by: James Yonan <james@openvpn.net>
2017-03-18 13:11:09 -06:00
James Yonan
fc85b371ab logging: removed #ifdef OPENVPN_INSTRUMENTATION, and made
the previously conditional code always included.
2017-03-18 12:24:54 -06:00
James Yonan
88ae6eba36 SSL : added tls-cert-profile directive for mbedTLS.
legacy            -- allow 1024-bit RSA certs signed with SHA1
preferred         -- require at least 2048-bit RSA certs signed
                     with SHA256 or higher
suiteb            -- require NSA Suite-B

The current default is legacy.

The directive can be set in the profile or overridden/defaulted
in the client API via ClientAPI::Config::tlsCertProfileOverride
var.

TODO: implement for OpenSSL.
2017-03-18 12:24:54 -06:00
James Yonan
050e8717f1 mbedTLS: Port from polarssl-1.3 to mbedtls-2.3 (symbol renames)
This patch renames internal OpenVPN 3 symbols
from polarssl -> mbedtls.

Signed-off-by: James Yonan <james@openvpn.net>
2017-03-18 12:24:54 -06:00