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

1801 Commits

Author SHA1 Message Date
Lev Stipakov
3d5dd9ee3b
[OVPN3-199] mac build: do not overwrite DEP_DIR
Signed-off-by: Lev Stipakov <lev@openvpn.net>
2018-03-10 02:28:36 +08:00
Lev Stipakov
b713762ba4
mbedtls: Patches from 2.7 to fix timing test failures
Changed to Changelog are removed to make patches apply on 2.6.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2018-03-10 02:28:35 +08:00
Lev Stipakov
37ab79fa6e
tun linux: apply changes from 362acf0
Linux tun setup: use LinuxGW46 to obtain gateway info

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2018-03-10 02:28:35 +08:00
Lev Stipakov
6a7aee2c9f
[OVPN3-190] tun: implement persistence
Preserve tun and routes across reconnects. Store tun descriptor in
TunPersist object, which is member of TunClientFactory. Handle
add/remove commands inside TunBuilderSetup::Base instance, which is
owned by TunPersist.

Tunnel is recreated if new tunnel options are different from previous
ones.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2018-03-10 02:28:35 +08:00
Lev Stipakov
1d2ebb07fc
[OVPN3-190] tun: move tun creation to separate class
Implement TunBuidlerSetup::Base, which takes care of tun creation.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2018-03-10 02:28:35 +08:00
Lev Stipakov
53e33d634f
[OVPN3-190] tun: move content of tun to tuncli
Signed-off-by: Lev Stipakov <lev@openvpn.net>
2018-03-10 02:28:35 +08:00
Lev Stipakov
85d3377c28
[OVPN3-190] tun: move tun setup methods to separate file
Signed-off-by: Lev Stipakov <lev@openvpn.net>
2018-03-10 02:28:35 +08:00
James Yonan
735b985eb5
i/o layer: wrap raw pointers embedded in closures
Found some cases where raw pointers embedded in closures and
passed via asio async methods could potentially leak if the
io_context is destroyed before the run() method is called.

With C++14 and higher supporting generalized lambda capture,
we can now wrap these pointers in a std::unique_ptr for
minimal cost.

Signed-off-by: James Yonan <james@openvpn.net>
2018-03-10 02:28:35 +08:00
James Yonan
322ae24b53
OptionList: support variadic template parameter pack in constructors
This allows usage such as:

const OptionList opt(Option("dev", "tun"),
		     Option("remote", "openvpn.example.com", "1194", "udp"));

Signed-off-by: James Yonan <james@openvpn.net>
2018-03-10 02:28:35 +08:00
James Yonan
8a012b4545
lz4: added namespace and improved error handling
* Put all methods in the LZ4 namespace.

* Throw errors instead of returning null BufferPtr().

* For decompress(), make sure that max_decompressed_size
  doesn't exceed LZ4_MAX_INPUT_SIZE.

This commit only affects the standalone LZ4 helper functions,
not the LZ4 module that is part of the OpenVPN protocol.

Signed-off-by: James Yonan <james@openvpn.net>
2018-03-10 02:28:34 +08:00
James Yonan
34998e94a1
zlib: removed verbose parameter
It probably makes more sense for debug logging to be handled
by the caller.

Also removed OPENVPN_GZIP_VERBOSE.

Signed-off-by: James Yonan <james@openvpn.net>
2018-03-10 02:28:34 +08:00
James Yonan
846ed217df
OpenSSL: set SSL_MODE_RELEASE_BUFFERS to conserve memory by releasing unneeded buffers
SSL_MODE_RELEASE_BUFFERS will free buffers that are fully drained
and re-allocate them as needed.  Testing with proto.cpp suggests
that this doesn't negatively affect performance.

Signed-off-by: James Yonan <james@openvpn.net>
2018-03-10 02:28:34 +08:00
James Yonan
32e3ea117c
OptionList: added show_unused_options() method
ClientOptions in cliopt.hpp now uses this method
rather than defining its own.

Signed-off-by: James Yonan <james@openvpn.net>
2018-03-10 02:28:34 +08:00
James Yonan
fe38233a82
Buffer: added typedefs for thread-safe refcounts
Also added misc comments.

Signed-off-by: James Yonan <james@openvpn.net>
2018-03-10 02:28:34 +08:00
James Yonan
b34b6271e5
compression: added compress_lz4() and decompress_lz4()
compress_lz4() and decompress_lz4() are intended for users
that want to do simple LZ4 compression/decompression on
a Buffer without involving the OpenVPN protocol compression
modules.

Signed-off-by: James Yonan <james@openvpn.net>
2018-03-10 02:28:34 +08:00
James Yonan
755e1a1810
linux/core.hpp: added exclude_from_core() function
Signed-off-by: James Yonan <james@openvpn.net>
2018-03-10 02:28:34 +08:00
James Yonan
a7f6fe64fc
ManClientInstance::Send: added userprop_local_update() virtual method
Signed-off-by: James Yonan <james@openvpn.net>
2018-03-10 02:28:34 +08:00
James Yonan
94526ac195
BufferAllocated: fixed regression in buffer copy
Fixed regression in:

    template <typename T_>
    BufferAllocatedType(const BufferType<T_>& other, const unsigned int flags)

That was introduced by commit b48a1682a7e9c666e1b6605747d3d561f2fbb5c4

    BufferAllocated: improve movability

    Added BufferAllocated move constructor for foreign
    BufferAllocated template classes.

Basically the source of the memcpy was not taking into account
the offset.

Signed-off-by: James Yonan <james@openvpn.net>
2018-03-10 02:28:34 +08:00
Antonio Quartulli
33c16812e1
[OVPN3-144] mbedTLS: fix support for 4096bit encrypted keys
Backported from mbedTLS 2.7.0

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2018-03-10 02:28:33 +08:00
Antonio Quartulli
f249ab4bd3
[OVPN3-144] build-mbedtls: run make check before compiling
This will ensure that mbedtls is still passing all its
unit test before building it.

It is important to run the checks because we backport patches
on our own and they may break during the process.

Checks are perfomed only when building for linux or for osx.

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2018-03-10 02:28:33 +08:00
Antonio Quartulli
5040aef4c1
[OVPN3-144] build-mbedtls: apply patches using git-apply instead of patch
This is required to allow git patches with binary content
to be properly applied.

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2018-03-10 02:28:33 +08:00
Antonio Quartulli
8a5e838ab7
[OVPN3-144] mbedTLS: fix incompatibility with PKI created by OpenSSL 1.1
Please check the commit messages of the new patches for a better
description.

In a nutshell, this change allows mbedTLS to properly decrypt
keys created by OpenSSL using PKCS#5v2 with PRF different from
SHA1.

This change also add their related unit-tests.

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2018-03-10 02:28:33 +08:00
Antonio Quartulli
e7badefd70
proto.hpp/tls-crypt: fix access to ACK IDs during packet validation
Due to a typ0 in the validate_tls_crypt() function,
ack_skip() is invoked with the not-yet decrypted packet
as argument instead of the decrypted one.

This leads to buffer exceptions, becuse ack_skip() will
read a bogus ACK array length instead of the proper value.

This bug may lead to renegotiations issues on clients
due to a forced rejection of soft-reset packets in
proto.hpp:control_net_recv().

Fix the issue by passing the proper packet buffer to
ack_skip().

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2018-03-10 02:28:33 +08:00
Antonio Quartulli
73fa974db5
proto.hpp: print buffer exception in case of packet access error
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2018-03-10 02:28:33 +08:00
David Sommerseth
79ad5ededb
Estblishing a stable branch
This branch is targeted for consumers of the library, where we will do
release handling.  This branch should contain reasonably well tested and
stable code only.  Features under development and testing should only be
worked on outside of this branch until it is ready and can be merged
into stable.

Since it has been quite some time since the version.hpp file was
updated, this change will now set version to 3.2 - to start this new
versioning regime.

The version numbering and release process is further described in
VersionNumbering.rst

Signed-off-by: David Sommerseth <davids@openvpn.net>
2018-03-10 02:28:33 +08:00
David Sommerseth
1c5f20ab06
Hide the @ sign in logs if username is empty
Signed-off-by: David Sommerseth <davids@openvpn.net>
2018-03-10 02:28: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
05880b136b
Added ProfileParseLimits::MAX_SERVER_LIST_SIZE and raise limit to 4096
Signed-off-by: James Yonan <james@openvpn.net>
2018-03-10 02:28:32 +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
James Yonan
6e350e9f9f
Linux tun setup: use LinuxGW46 to obtain gateway info
Using LinuxGW46 instead of the obsolete get_default_gateway_v4()
allows us to correctly implement the bypass route for
redirect-gateway ipv6.

Signed-off-by: James Yonan <james@openvpn.net>
2018-03-10 02:28:32 +08:00
James Yonan
3e044c6c79
top-level .gitignore was missing a trailing newline
Signed-off-by: James Yonan <james@openvpn.net>
2018-03-10 02:28:32 +08:00
James Yonan
a27355ac7a
Use C++11 push_back(std::move(...))) for pushing objects onto vectors
Signed-off-by: James Yonan <james@openvpn.net>
2018-03-10 02:28:32 +08:00
James Yonan
8c3af27040
HostPort::split_host_port: support unix socket filename as an alternative kind of host
Signed-off-by: James Yonan <james@openvpn.net>
2018-03-10 02:28:32 +08:00
James Yonan
14b588c861
asio: added asio_resolver_results_to_string()
Signed-off-by: James Yonan <james@openvpn.net>
2018-03-10 02:28:32 +08:00
James Yonan
fd6e8e9bf6
AsioPolySock: minor changes to remote_endpoint_str()
Add exception handling and consistent labeling of the
underlying type.

Signed-off-by: James Yonan <james@openvpn.net>
2018-03-10 02:28:32 +08:00
James Yonan
06f5e4d711
AsioBoundSocket::Socket: added to_string() method
Signed-off-by: James Yonan <james@openvpn.net>
2018-03-10 02:28:31 +08:00
James Yonan
8fd968532b
RemoteList: minor cleanup in set_endpoint_range()
Declare EPRANGE endpoint_range as const, since it is used as such.
Remove unused EPRANGE end.

Signed-off-by: James Yonan <james@openvpn.net>
2018-03-10 02:28:31 +08:00
James Yonan
f9fc2f54e6
BufferAllocated: improve movability
Added BufferAllocated move constructor for foreign
BufferAllocated template classes.

In order to make this work, we need to:

(a) generally friend BufferType and BufferAllocatedType
    to all BufferAllocatedType template classes, and

(b) require typename R (thread_unsafe_refcount or
    thread_safe_refcount) to be specified for
    BufferAllocatedType (previously it was optional
    and defaulted to thread_unsafe_refcount).

Signed-off-by: James Yonan <james@openvpn.net>
2018-03-10 02:28:31 +08:00
James Yonan
8cb8d52cda
string: added first_line() method
Signed-off-by: James Yonan <james@openvpn.net>
2018-03-10 02:28:31 +08:00
James Yonan
a26b1646b7
AsioPolySock: extend AltRouting support
Add alt_routing_enabled() method

Extend remote_endpoint_str() method

Signed-off-by: James Yonan <james@openvpn.net>
2018-03-10 02:28:31 +08:00
James Yonan
ef3a40c271
Listen::Item: added AltRouting mode
Signed-off-by: James Yonan <james@openvpn.net>
2018-03-10 02:28:31 +08:00
James Yonan
02e786bc92
write_binary_atomic: support ConstBuffer
Signed-off-by: James Yonan <james@openvpn.net>
2018-03-10 02:28:31 +08:00
James Yonan
6745799c93
fileunix: added read_binary_unix_fast()
Signed-off-by: James Yonan <james@openvpn.net>
2018-03-10 02:28:31 +08:00
James Yonan
5689c2d9c9
write_binary_unix(): added ConstBuffer variant
Signed-off-by: James Yonan <james@openvpn.net>
2018-03-10 02:28:31 +08:00
James Yonan
2b0e764534
enum_dir: refactor to allow enumeration via lambda
Signed-off-by: James Yonan <james@openvpn.net>
2018-03-10 02:28:30 +08:00
James Yonan
116a5bd5e5
bufstr: added const_buf_from_string() method
Signed-off-by: James Yonan <james@openvpn.net>
2018-03-10 02:28:30 +08:00
James Yonan
f8ec814137
Buffer: added const_buffer_ref() variant accepting a const argument
Signed-off-by: James Yonan <james@openvpn.net>
2018-03-10 02:28:30 +08:00
James Yonan
ae98aa8b6f
AsioPolySock: support AltRouting
* Added native_handle() virtual method

* Use AltRouting abstract socket when
  OPENVPN_POLYSOCK_SUPPORTS_ALT_ROUTING is defined

Signed-off-by: James Yonan <james@openvpn.net>
2018-03-10 02:28:30 +08:00
James Yonan
8f81479f1e
AsioBoundSocket::Socket: support inheritance
Signed-off-by: James Yonan <james@openvpn.net>
2018-03-10 02:28:30 +08:00
James Yonan
9598918e95
ServerProto: added schedule_disconnect() method.
Signed-off-by: James Yonan <james@openvpn.net>
2018-03-10 02:28:30 +08:00