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

3855 Commits

Author SHA1 Message Date
David Sommerseth
75dbcdfa93
Merge OpenVPN 3 Core v3.8.2 into master
Signed-off-by: David Sommerseth <davids@openvpn.net>
2023-09-13 16:46:05 +02:00
David Sommerseth
ea747cba84
Release: OpenVPN 3 Core Library, version 3.8.2
Signed-off-by: David Sommerseth <davids@openvpn.net>
2023-09-13 15:02:35 +02:00
Frank Lichtenheld
6c3aa11aaa vcpkg-ports/mbedtls: unused, removed
We haven't done any mbedtls builds for Windows in a long
time. Let's not pretend that is something we support by
having this cruft lying around.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2023-09-08 12:11:58 +02:00
Frank Lichtenheld
358280f72f deps/mbedtls: drop old patch
mbedtls clearly don't want to apply this patch. So
affected users will need to find other solutions.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2023-09-08 12:10:36 +02:00
Heiko Hund
6f538ca0fd
dns option: fix split DNS on Windows
Unlike OpenVPN v2, v3 support split DNS already, so we need to make sure
that --dns options are added in a way that results in NRPT rules to be set. At
this time that means the --dns resolve-domains are added as search
domains and --dns search-domains (only the first one really) as an
adapter specific domain suffix.

Signed-off-by: Heiko Hund <heiko@openvpn.net>
2023-09-06 16:45:22 +02:00
Frank Lichtenheld
a5914b80fa test_sitnl: Allow to pass on systems with iproute 6.1.0
On some systems, probably depending on the glibc version,
the ipv6 address will be truncated in the output.
Currently affects only Fedora 38.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2023-09-05 10:42:51 +02:00
Lev Stipakov
7fc0b701a1
Parse meta options from content_list
At the moment meta options are parsed only from
content. This doesn't work well with iOS where
config is imported via content_list. The config might
contain meta options, which currently won't be
recognized as meta and connection won't be established
due to "unknown option" error.

This adds meta options parsing to content_list.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2023-08-30 18:00:35 +02:00
Arne Schwabe
f159710100
Rename ProtoContext::Config to ProtoContext::ProtoConfig
The name Config is very generic and often leads to confusion which
class in particular is used in a given context. Rename Config to
ProtoConfig to give some more clue about the context.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2023-08-23 21:13:02 +02:00
Arne Schwabe
ff80eca4e5
Rename ProtoContextOptions to ProtoContextCompressOptions
This might have been used or intended to be used for more than compression
but currently it is only used for compression, so rename it accordingly.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2023-08-23 21:13:01 +02:00
Arne Schwabe
896b63aff1
Split process_push into smaller more managable methods
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2023-08-23 21:13:00 +02:00
Arne Schwabe
83b856eaaf
Split control_recv into smaller methods
control_recv looks at the incoming messages and dispatches it to
different handlers depending on the message. Split of these handlers
into their own methods. Also rename/align process_halt_restart to
recv_halt_rest to make all handlers consistent.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2023-08-23 21:12:40 +02:00
Charlie Vigue
ae663c573a
Using new numeric conversion tools
Using is_safe_conversion in places where it is a better fit than
numeric_cast.

Signed-off-by: Charlie Vigue <charlie.vigue@openvpn.com>
2023-08-23 18:44:29 +02:00
Charlie Vigue
a9e152522a
Enhancing clamp_ tooling
Signed-off-by: Charlie Vigue <charlie.vigue@openvpn.com>
2023-08-23 18:44:22 +02:00
Charlie Vigue
de2f6d422e
Switched C casts to static_cast
Signed-off-by: Charlie Vigue <charlie.vigue@openvpn.com>
2023-08-23 18:44:16 +02:00
Charlie Vigue
5cb215d3fc
Revert write_ex refactor
- Went back to a simple numeric_cast since the better way had issues
on other paltforms

Signed-off-by: Charlie Vigue <charlie.vigue@openvpn.com>
2023-08-23 18:44:08 +02:00
Charlie Vigue
ebe58f8613
Changed bio_memq_stream to write_ex semantics
Signed-off-by: Charlie Vigue <charlie.vigue@openvpn.com>
2023-08-23 18:43:49 +02:00
David Sommerseth
0a690f5dff
ssl/proto: Clarify sending peer-info debug details
Making it more explicit that the listed items is data being sent to the
server.

Signed-off-by: David Sommerseth <davids@openvpn.net>
2023-08-23 17:03:23 +02:00
Frank Lichtenheld
1fa0e9589f deps: update mbedTLS to 2.28.4
We're specifically interested in the fix for the unit tests.
("Update test data to avoid failures of unit tests after
2023-08-07")

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2023-08-23 11:58:44 +02:00
Charlie Vigue
b6b8282d33 Addressed 2nd set of -Wconversion warnings
- Used static_cast instead of direct type conversions in places where
it's safe
- Used numeric_cast where failure is possible
- Changed types of arguments and locals when practical

Signed-off-by: Charlie Vigue <charlie.vigue@openvpn.com>
2023-08-21 13:51:50 +00:00
Arne Schwabe
b755783a13 Fix reading MAC address on macOS
The confusing overlapping structs and memory accesses with the
struct lead to use missing a few bytes from being copied. Fix
this by copying from the correct struct.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2023-08-17 12:43:29 +02:00
Mark Deric
8b93eb0b0a Fix randapi UBSAN bug, signed T:min map to >= 0
The undefined behavior is unary negation of T:min of a signed type
attempting to get a positive value of the same signed type.

This commit adds a unit test that exposes the original bug and well as
a fix for it.

Signed-off-by: Mark Deric <jmark@openvpn.net>
2023-08-15 07:28:35 -07:00
James Yonan
5c27ed24b1
enum_dir: restore move semantics
This commit mostly reverts a previous commit:

commit b7bc687396

    Avoid compiler warning with gcc by not using move semantics

The previous commit changed the semantics of the client
callback to use copy instead of move semantics on the
filename string to placate a compiler warning which was
later determined to be a false positive.

We revert to calling the client-provided func()
with move semantics on the filename parameter.

We also retain the use of std::invoke to call the
client-provided callback.

Signed-off-by: James Yonan <james@openvpn.net>
2023-08-09 20:04:34 +02:00
Frank Lichtenheld
aec6902cd2 CMake: Set warning options for MSVC so we can enable /WX
Reduce default set from /W3 to /W2 and disable two
additional warnings that we do not care about.

With these settings successful builds with /WX are possible.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2023-08-03 18:11:02 +02:00
Frank Lichtenheld
d7e8375fc5
CMake: disable -Wmaybe-uninitialized for GCC builds
This is very noisy with lots of false positives, especially
in newer version of GCC. So for now disable this.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2023-08-02 18:15:25 +02:00
Frank Lichtenheld
bb61350ae5
CMake: replace FindPythonIntp with FindPython3
The earlier were deprecated since CMake 3.12.
Since CMake 3.27 this causes deprecation warnings.
Should be safe nowadays to require CMake 3.12.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2023-08-02 18:08:42 +02:00
Frank Lichtenheld
964b7cbd30
Use [[fallthrough]] where appropriate
Since we use C++17 now, the attribute is guaranteed
to be available.

Should silence some Coverity warnings.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2023-08-02 18:05:33 +02:00
Frank Lichtenheld
df5f6d5810
mingw/build: Fix xxHash build
Adapt to vcpkg changes.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2023-08-02 17:33:37 +02:00
Frank Lichtenheld
d446e18b50
.travis.yml: remove unused file
Other Travis CI related files were already deleted in commit
4666c7f9c1.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2023-08-02 17:25:18 +02:00
Frank Lichtenheld
13d42f5f2d
CMakePresets.json: add test presets for all msvc build presets
Also run tests in GHA.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2023-08-02 17:25:17 +02:00
Frank Lichtenheld
775ff02527
dlgoogletest: update GoogleTest to latest upstream
This fixes deprecation warnings with latest CMake.
("Compatibility with CMake < 3.5 will be removed
from a future version of CMake.")

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2023-08-02 17:25:16 +02:00
Frank Lichtenheld
ea8bc75e01
GHA: new workflow coverity-scan
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2023-08-02 17:25:15 +02:00
Frank Lichtenheld
90cd1f59c4
GHA: msbuild: update vcpkg/run-vcpkg
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2023-08-02 17:25:14 +02:00
Lev Stipakov
85b92afe96
win/client/tunsetup.hpp: fix IPv4 redirect-gw with IPv6 remote
redirect-gw is implemented by changing default route to
a GW provided by VPN. For IPv4 before doing that we add
a bypass route to a remote. This is needed only when remote
is not on local network.

The check "is remote on local network" has a wrong assumtion
that remote is IPv4. This is obviously not always the case
since remote could be IPv6. In this case if we want to redirect
IPv4 traffic an exception is thrown inside BestGateway class
while trying to convert IPv6 address to IPv4.

Fix by specifying correct address family based on remote's "ipv6"
flag. Later we add bypass route only if remote is IPv4.

Fixes OVPN3-1004.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2023-08-02 16:49:44 +02:00
Arne Schwabe
53614a0cce Properly implement OpenVPN3 checking of --client mode
Earlier implementations just assumed that --client mode is always
present in the config, which lead to config behaving different in
OpenVPN 2.x and 3.x. This creates hard to debug corner cases.

Additionally OpenVPN 3.x was not parsing the tls-client and pull
options. This lead to OpenVPN 3.x erroring on a perfectly legal
config with --pull in it.

Note the original patch was by Merten Fermont <merten.fermont@gmail.com>
but his patch got mangled in the email and when I started to apply
it manually I instead wrote my own version of it since we need
unit tests anyway.
2023-08-02 10:33:05 +02:00
David Sommerseth
43669510ed
Merging in OpenVPN 3 Core Library v3.8.1
Signed-off-by: David Sommerseth <davids@openvpn.net>
2023-08-01 14:42:25 +02:00
Arne Schwabe
3b46b64d13 Do not enforce DH parameters in TLS server mode
As also explained in OpenVPN 2.x commit bd9aa06feb4, Diffie Hellman
key exchanges can be optionally be disabled and OpenSSL will then use
only ECDH instead.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2023-08-01 14:28:51 +02:00
David Sommerseth
cd0c404275
Release: OpenVPN 3 Core Library, version 3.8.1
Signed-off-by: David Sommerseth <davids@openvpn.net>
2023-07-31 18:58:00 +02:00
Arne Schwabe
75dbf4b5d2 Rename generate_tun_builder_capture_event to camelcase
This makes this option have the same style as the other options in
the client config to ensure consistencyv

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2023-07-25 12:00:48 +02:00
Frank Lichtenheld
6585480389 ConfigCommon: do not include actual profile
This is not required in ClientConfigParsed, and actually makes
the object significantly bigger, due to the contained certificates.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2023-07-25 12:00:48 +02:00
Arne Schwabe
0c5e356075 Simplify client options classes
The current passing of client options is very confusing since it is
three classes that largely have the same attributes and the code is
copying them around between the classes.

Instead create a new base class that hold the settings that can be shared
between the classes and only parse/copy the settings that need special
handling. This might keep an extra copy of some settings around but in
constract greatly reduces the code complexity of the options handling.

Also move the check_dco_compatibility function to client options to
be able to avoid carrying around the dco_compatiblity flag.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2023-07-25 12:00:48 +02:00
Lev Stipakov
07e7a0c237
maclife.hpp: synchronize start and stop of lifecycle thread
A main thread might attempt to stop livecycle thread by stopping the runloop
and waiting on joining the lifecycle thread. However if this happens
before lifecycle thread has started runloop, main thread will hang on join
since runloop won't be stopped.

Fix by introducing atomic bool "halt" flag, which is set in the main
thread when it wants to stop the livecycle thread. Before starting runloop,
a one-shot timer task is scheduled to be executed, which checks halt
and stops runloop if needed.

Fixes OVPN3-992.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2023-07-19 22:13:00 +02:00
Arne Schwabe
2219ccfb8d
Use inline to ensure only one copy of crypto::algs is present
We need to ensure that there is only one copy of these algorithms defined
as we modify them with the method allow_default_dc_algs to set the
F_DC_ALLOW flag on. Having more than one copy means that we have different
copies with different flags which we want to avoid.

The use of inline to a normal variable is a C++17 feature.

From https://en.cppreference.com/w/cpp/language/inline

An inline function or variable (since C++17) with external linkage
(e.g. not declared static) has the following additional properties:

There may be more than one definition of an inline function or variable
(since C++17) in the program as long as each definition appears in a
different translation unit and (for non-static inline functions and
variables (since C++17)) all definitions are identical. For example,
an inline function or an inline variable (since C++17) may be defined
in a header file that is included in multiple source files.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2023-07-18 14:54:00 +02:00
Arne Schwabe
bfdfa13082 Make RC pointer class a bit nicer
- use = default for constructur/deconstructors
- deleted constructors should be public

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2023-07-05 14:16:09 +02:00
Lev Stipakov
1b11c994ab aws: support for IMDSv2
IMDSv2 requires to obtain token for instance metadata requests

  https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-metadata-v2-how-it-works.html

IMDSv2 works on all reasonably modern instances and can be optionally
forced to be used instead of v1.

Fixes https://github.com/OpenVPN/openvpn3-linux/issues/192

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2023-07-05 09:05:45 +00:00
Lev Stipakov
528ec40c11 aws: fix ReplaceRoute error handling
Commit 5b524b1f ("WS::ClientSet: added new TransactionSet flag
retry_on_http_4xx") sets E_BAD_REQUEST transport status in case of
HTTP 400. This breaks replace_create_route() behavior, which
doesn't expect transport error for ReplaceRoute and fails the
whole transaction set.

Fix by setting retry_on_http_4xx flag to false before executing
ReplaceRoute. We expect to get 400 if route doesn't exist, so no
need to retry.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2023-07-04 14:07:55 +00:00
Arne Schwabe
71e94d9e8f Disable dangling warnings for json helper
This is though to be a bug in the GCC compiler.
Ignore these warnings on GCC 12/13 to avoid breaking
Werror.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2023-07-04 14:44:22 +02:00
Arne Schwabe
b7bc687396
Avoid compiler warning with gcc by not using move semantics
gcc 12+ warn about temporary that used after its lifetime when we use
the move semantics here. Since the code here is not super performance
critical just remove the move semantics to be able to compile with
Werror.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2023-07-03 13:29:48 +02:00
Frank Lichtenheld
dabc3a0009 Fix various problems with implicit size_t casts
All of these cases are safe casts since the
value is checked before-hand. So convert them
to explicit casts.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2023-06-28 14:22:31 +02:00
Frank Lichtenheld
6b222bccd8 remove some unused variables in catch clauses
MSVC complains about those.
warning C4101: 'e': unreferenced local variable

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2023-06-28 14:22:31 +02:00
David Sommerseth
8f5afdd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u0qLLLXwFIDBiagIVuotcxwOWPz1+tTyUICc4KsLS
 zzkuube2aSBRtbwa8C4FfDuKSWosCOTv56ZE/3Ioq6v0Hf7sDqMDCvUxBjNlQLWu
 m604/yxWxAEnu6lHPY5rj3+9U5TSpErXJk/DqW6ewJjh/TFWG5nA1Z2Q/IF0XIR9
 pbqnhL1Dhd7Z350s7bjsl2ejxj7FmrEXaCh3geK8ovfYfurpX5me8i389LcaM/TD
 MvBStvZIJa2inYxU5IUQnGtqGYdtU4IW8VM3aq8pNy2+U9WNnC/3Q1msplOjPPur
 a2WzNnRcFqxxeVgNmYZgdiS3m6FvAaG3bGUN9haFz3Rjz0yaumbhA4VrLmcimghj
 9AarITBznK8h+JqHdEIarZWwOfLj7A7sdsKQwe7ycBs29WbRW6+iSkhNxnI0BcLu
 mgwf00il4czEWIUthlTF7KcREj/WE/rMSDGAcW+TKJZpdffS2FVQeQITG9SLuBJa
 fVD9C1UYfrrkk408YuButJK2aEYICVFkDfmWcRxF2s8zxyPaVhCLyx2jTaIILV5M
 7HzgnHjlc8e5mhwI3/bE09pzrogtXd3n0s2Yf+f1h8y31GgUHKZRIqY2ESIZghML
 9BZmMAnOprRuWw==
 =HH92
 -----END PGP SIGNATURE-----

Release Merge: OpenVPN 3 Core library version 3.8

Signed-off-by: David Sommerseth <davids@openvpn.net>
2023-06-28 09:13:00 +02:00