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

3647 Commits

Author SHA1 Message Date
Arne Schwabe
3135d115a0 Replace throw() with noexcept and mark some exception constructors explicit
throw() is the same as noexcept(true), which is the same as noexpect.
(https://en.cppreference.com/w/cpp/language/noexcept_spec)

noexpect is more standard nowadays and less likely to create confusion.
Single argument constructors should be marked explicit so they do not
end up being acidentially called.
2022-11-16 17:22:09 +01:00
Arne Schwabe
3e34d5a6f9 Document UseCount class and make it non-copyable
There might be a better solution than using this class but at the
moment, at least give it a better documentation.
2022-11-16 17:22:09 +01:00
Arne Schwabe
3a371a9761 Move initialisation of protostack members to members 2022-11-16 17:22:09 +01:00
Arne Schwabe
4dc56df618 Change is_raw to contains_tls_ciphertext
This renames (and inverses) the is_raw function to make it easier to
understand its purpose.
2022-11-16 17:22:09 +01:00
Arne Schwabe
6bc1a7c6a0 Add CONTROL_WKC_V1 definitions and improve packetdump of tls-crypt-v2 2022-11-16 17:22:09 +01:00
Heiko Hund
067e31e34c document missing/unimplemented IV_PROTO flags
Signed-off-by: Heiko Hund <heiko@openvpn.net>
2022-11-16 16:44:07 +01:00
Heiko Hund
03917fbf9c add support for temporary authentication failures
This adds proper handling of AUTH_FAILED,TEMP server responses,
potentially modifying the restart delay time and which address
is to be used for the next connection attempt.

Changes the reconnect behavior so that all addresses of a remote
are tried in case of a connection error, instead of continuing
with the next remote immediately.

Signed-off-by: Heiko Hund <heiko@openvpn.net>
2022-11-16 16:44:07 +01:00
Heiko Hund
65dc00fe4e add RemoteList::Advance enum
By giving an advance type to RemoteList::next() optionally, the
behavior of the function can be modified to move to the next remote
instead of the next address, or not move at all.

Signed-off-by: Heiko Hund <heiko@openvpn.net>
2022-11-16 16:44:07 +01:00
Heiko Hund
49a476e904 add IV_PROTO bit for --dns option
Signed-off-by: Heiko Hund <heiko@openvpn.net>
2022-11-16 16:44:07 +01:00
Mark Deric
8c7d6e1751 Move reliability layer tests from common
The tests in common were based on running main(); the tests have been
converted to the gtest framework and are now part of the automated
unit test suite.

Signed-off-by: Mark Deric <jmark@openvpn.net>
2022-11-09 08:29:26 -08:00
Lev Stipakov
a12737b5cc mingw: adapt to vcpkg openssl portfile change
vcpkg has removed OPENSSL_VERSION from portfile.cmake
in favor of VERSION variable which is set based on port version
(https://github.com/microsoft/vcpkg/pull/27178/files).

Parse port manifest to get OpenSSL version.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2022-11-03 11:30:23 +02:00
Frank Lichtenheld
5c5d115619 Fix some "variable set but not used" errors with clang 15
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2022-10-24 13:52:28 +02:00
Lev Stipakov
8eefddd18b
dco-win: fix "agent process premature exit" handling
Commit ae99307 ("tun: add persis-tun support for dco-win")
broke handling of premature exit of agent process. Introduced
"tun_persist->close_destructor()" call in "tun_start() " also closes
agent process handle within WinCommandAgent,
which triggers fail handler (without error code).

Fix by "re-arming" fail handler after "close_destructor()"
call in "tun_start()".

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2022-10-19 17:05:32 +02:00
Arne Schwabe
8bc78392cf Ensure sending UV_ only with push-peer-info and prioritise client.peerInfo
This commit changes the way the core deals with UV_ variables. They
now also respect push-peer-info (like in OpenVPN 2.x) and if variables
are present in both client.peerInfo and as setenv in the configuration
content, only the ones from peerInfo are send to the server.

The new behaviour can be tested with

	ovpncli -I UV_TEST=cmdline conf.ovpn

and conf.ovpn having a setenv UV_TEST foobar in it as well

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2022-10-19 16:40:21 +02:00
Lev Stipakov
2958161e7f
dco-win: add halt check after connection attempt
parent->transport_connecting() might trigger stop(),
reset device handle and set halt to true if TCP server
is down. In this case we should not queue read.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2022-10-13 15:16:26 +02:00
Lev Stipakov
ae99307219
tun: add persis-tun support for dco-win
Add DcoTunPersist object to DCO::TunConfig.

DcoTunPersist stores:

 - device handle
 - tun settings
 - adapter index/name
 - pointer to TunSetup object, which itself
 stores commands to undo tun settings

When intializing client options, instantiate DcoTunPersist
object within the scope of ClientConfig, which serves as
transport and tun factory for dco. Indicate that "sock" object
(device handle) should be preserved - not replaced when persisting
tun settings.

When establishing dco-win connection in OvpnDcoWinClient,
either use tun_persist created above (if persistance is enabled)
or instantiate it in-place (no persistance).

If nothing is stored in tun_persist (means this is first
connection or reconnect without persistance), acquire device
handle from tun_setup, wrap it into ASIO's basic_stream_handle
and store it in OvpnDcoWinClient - no need to persist it yet.

When starting tun, check if persisted tun session matches
to-be-created session. If no - clear previous tun settings,
set up tun and persist tun state. If device handle is already
stored in tun_persist, it won't be replaced.

On tun stop, send DEL_PEER command, which deletes peer
from the driver but keeps adapter in connected state. Then
close locally stored ASIO handle and reset tun_persist.
In case of "short term persistance" this will undo tun settings
and close device handle. For long term persistence, tun_persist
is also stored in ClientConfig and handle won't be closed yet.

In case of disconnect, ClientConfig::finalize(disconnect=true)
is called, which resets tun_persist, which in turn
undoes tun settings and closes device handle.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2022-10-13 15:16:25 +02:00
Lev Stipakov
6a9b174f21
tunpersist: support for "no retain, no replace"
This is required for dco-win driver support.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2022-10-13 15:16:24 +02:00
Lev Stipakov
fca6465e92
tunwin: support for adapter state in TunSetup
In case of dco-win persist tun, adapter state (index and name)
persists over lifetime on TunSetup object. Add setter/getter
for adapter state to TunSetup.

While on it, ensure that TunSetup::establish() doesn't
acquire adapter handle for dco - this is done by another
dco-specific "get_handle" method. The handle is not
really used by establish() method when using dco-win.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2022-10-13 15:16:23 +02:00
Lev Stipakov
f27abef03d
tunwin: generalize adapter state in TunPersistState
Replace wintun-specific hardcoded RingBuffer with
ADAPTER_STATE template. This will be used later
for dco-win tun persist support.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2022-10-13 15:16:22 +02:00
Lev Stipakov
e01375daa0
vcpkg-ports: remove ovpn-dco-win port
The UAPI header (ovpn-dco.h) is now part of openvpn3 core
repo, so no need in separate vcpkg port.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2022-10-13 15:16:21 +02:00
Lev Stipakov
544522d990
asio: bump version to 1.24.0
Rebase "async_connect_post_open" patch.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2022-10-13 15:16:17 +02:00
James Yonan
19201beb9f AuthCert: support up to 160 bit serial numbers
Previously, we only supported int64 serial numbers.

This change renames get_sn() method to serial_number_as_int64()
for code that cares about 64-bit serial numbers.

Signed-off-by: James Yonan <james@openvpn.net>
2022-09-21 23:00:13 -06:00
James Yonan
e7ffa06f1e scripts/build: added SQLITE=1 parameter to build with sqlite3 library
Signed-off-by: James Yonan <james@openvpn.net>
2022-09-21 23:00:13 -06:00
David Sommerseth
0fae5639ac
build: Extend with a doxygen build target
If the ENABLE_DOXYGEN setting is enabled in CMake, it will look for the
local Doxygen installation and configure it.  The HTML output will be
located under doxygen/core.

Signed-off-by: David Sommerseth <davids@openvpn.net>
2022-09-21 17:21:16 +02:00
Frank Lichtenheld
515c2f7d05 ovpncli: add missing override keyword for remote_override
Found by clang:
ovpn3/core/test/ovpncli/cli.cpp:664:16: warning:
 'remote_override' overrides a member function but is not marked 'override'
[-Winconsistent-missing-override]
  virtual void remote_override(ClientAPI::RemoteOverride& ro)
               ^
ovpn3/core/cmake/../client/ovpncli.hpp:658:20: note:
 overridden virtual function is here
      virtual void remote_override(RemoteOverride&);

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2022-09-16 11:21:44 +02:00
Frank Lichtenheld
8345e99b46 ovpncli: compile kovpn variant with more flags by default
Both OPENVPN_REMOTE_OVERRIDE and PRIVATE_TUNNEL_PROXY
only enable features and do not change the behavior unless
configuration is also changed. Since the kovpn variant
is internal anyway, this should be safe to enable.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2022-09-16 11:21:44 +02:00
Frank Lichtenheld
ef62e5b02a time/epoch: include time.h
for ::clock_gettime

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2022-09-16 11:21:44 +02:00
David Sommerseth
66527fa611
Add code style configurations
This adds a clang-format with the new code style for OpenVPN 3.

A very light Emacs dir-locals configuration has also been added, but
that will most likely not cover all the formatting aspects which
clang-format does.  Running clang-format before committing is still
highly recommended to ensure the coding style is consistent.

Signed-off-by: David Sommerseth <davids@openvpn.net>
2022-09-14 17:35:30 +02:00
Arne Schwabe
5b5d80fad3
Improve dealing with unknown options
This commit add several improvements to dealing with unknown options
in client configuration files:
 - implement ignore-unknown-option
 - categorise the OpenVPN2 options in multiple categories and
   warn/error out depending on the category
 - error out when unsupported/unknown options are found. This avoids
   problems like with --tls-crypt/--tls-crypt-v2 before where client
   would ignore these options and not connect at all

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2022-09-14 17:32:53 +02:00
Arne Schwabe
ef6dbd250d
Add generic name to JY_EXPECT_THROW and improve error message
This renames the macro to OVPN_EXPECT_THROW and keeps the old name
as alias.
2022-09-14 17:32:52 +02:00
Lev Stipakov
b8e9741947
omi: better support for "state" management command
If "state" is given without parameters, treat it as "state 1",
same as in openvpn 2.

This is sent, for example, but openvpn-gui.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2022-09-07 23:33:28 +02:00
Lev Stipakov
970bed9f9b tun win: use IPAPI to add excluded routes
We already use IPAPI to add routes, so there is no reason
not to use it to add excluded routes. Example from server config:

  push "redirect-gateway def1"
  push "route 192.168.0.0 255.255.0.0 net_gateway"

This should redirect all traffic to VPN except one route. What
we should see in logs is:

  IPHelper: add route 192.168.0.0/16 21 100.64.0.1 metric=-1

(where 100.64 is a default gw on my machine)

Reported-by: Arul Thileeban <arulthileeban@vt.edu>
Signed-off-by: Lev Stipakov <lev@openvpn.net>
2022-08-31 14:14:20 +03:00
Frank Lichtenheld
2aea7ac4b5
Merge changes from coming OpenVPN 3 Core library v3.7 bugfix update
- test_cpu_time: fix unused variable
  - Allow GIT version to be reported as part of platform (version) string
  - Update OpenSSL to 3.0.5, build fat lib for macos, drop 32 bit on iOS
  - README.rst: some fixes for macOS instructions
  - extpki.hpp: ignore deprecated EC_KEY_* functions
  - mingw: fix OpenSSL on x86_64
  - mingw: fix broken OpenSSL checkout
  - test_ssl: fix ssl.enablelegacyProvider
  - dco/GeNL: ignore message for unrelated interfaces

Signed-off-by: David Sommerseth <davids@openvpn.net>
2022-08-25 15:32:11 +02:00
rstular
d0647e69f5
build: Fix typo in CMakeLists.txt
Signed-off-by: David Sommerseth <davids@openvpn.net>
2022-08-24 17:55:31 +02:00
Nate Rock
e6a18f7d8c
docs: Added xxhash to macos brew install
Signed-off-by: David Sommerseth <davids@openvpn.net>
2022-08-24 17:55:22 +02:00
Lev Stipakov
c7b696f178
tunutil.hpp: proper support for device interface list
dco-win adapter creates multiple device interfaces and in some
cases the right one is not the first one. Enumerate all interfaces
and pick the one with correct reference string.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2022-08-24 17:11:40 +02:00
Arne Schwabe
664b3d6651
Remove several no longer used or supported build scripts
- the OpenSSL build script for all platform, was only
  used on macOS and better alternatives like homebrew exit there
- mac build scripts in general, cmake/homebrew is a better alternative
- vars for Android, Android uses CMake based build, see ics-openvpn for an example
- lzo build scripts. Core can do lzo decompress witout it and if used, system lzo can
  be used

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2022-08-24 17:09:13 +02:00
Frank Lichtenheld
f48d020b67
test_cpu_time: fix unused variable
clang 13 complains:
test/unittests/test_cpu_time.cpp:110:16:
error: variable 'd' set but not used [-Werror,-Wunused-but-set-variable]
        double d=0;

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
(cherry picked from commit 9367513b4a)
2022-08-24 17:06:24 +02:00
Arne Schwabe
ec5ea70de2 Allow GIT version to be reported as part of platform (version) string
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2022-08-15 13:52:35 +02:00
Arne Schwabe
26fad3a4f6 Allow to disable route exclusion emulation
This allows disabling the route emulation for Andorid API 33
(Tiramisu/API 33) or if the app implements its own emulation (ics-openvpn)

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2022-08-03 16:41:06 +02:00
Frank Lichtenheld
4393f401f3 vcpkg.json: add xxHash
required for some unit tests now.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2022-07-29 16:58:30 +02:00
Mark Deric
f2df99ccab Fix unit test with AuthStatus::Type enum fwd decl
Signed-off-by: Mark Deric <jmark@openvpn.net>
2022-07-21 11:08:42 -07:00
Mark Deric
1a5e4a7558 Add a unit test for checking header dependencies
Signed-off-by: Mark Deric <jmark@openvpn.net>
2022-07-21 11:08:42 -07:00
Frank Lichtenheld
ef69cb6230 daemonize: ignore daemon() deprecated on macOS
Since we do not operate any servers on macOS, we
do not want to invest time in fixing this.

In most cases you would want to use launchd anyway
and not use damonize().

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2022-07-15 13:32:44 +02:00
Arne Schwabe
a1c44bd0c6
Update OpenSSL to 3.0.5, build fat lib for macos, drop 32 bit on iOS 2022-07-13 20:42:52 +02:00
Arne Schwabe
65f5b54817
Add specification to allow a server to indicate optional web import
This is useful for mixed scenarios of authentications
2022-07-13 18:17:35 +02:00
Arne Schwabe
3710fa106a Implement pushable tun-mtu and tls-mtu-max
OpenVPN 3.x has the same approach/problem for buffer allocation for the
tunnel packets that OpenVPN 2.x uses. Buffers are allocated very early
in the setup, so resizing/reacting to different frame sizes is not
really possible without major refactoring.

Therefore we use the same approach as with OpenVPN 2.x and allow a
MTU of up to 1600 by default and require setting tun-mtu-max in the
configuration file to allow larger values and allocate larger buffers.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2022-07-13 16:44:31 +02:00
Frank Lichtenheld
c3129ddac8 README.rst: some fixes for macOS instructions
- Fix rst syntax error
- Add pkg-config to list of brew packages to
  install. While here, order them alphabetically.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2022-07-11 14:47:34 +02:00
Frank Lichtenheld
15343b0133 extpki.hpp: ignore deprecated EC_KEY_* functions
Doing first -Werror builds on Linux against OpenSSL 3.0.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
(cherry picked from commit ab55c9fdb2)
2022-07-11 13:34:59 +02:00
Frank Lichtenheld
a04266120d mingw: fix OpenSSL on x86_64
Hardcode libdir to lib, because openssl3 chooses
lib64 otherwise.

While here, some small changes:
- remove dangerous "|| true" after openssl make
- remove "-j1" for openssl "make install". Speeds
  up the documentation generation.
- use set -x

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
(cherry picked from commit f27157e28b)
2022-07-11 12:21:08 +02:00