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

4167 Commits

Author SHA1 Message Date
Arne Schwabe
c78aaecad7 Differentiate Packet ID types into data channel and control channel ids
Data channel packet ids (in the formats that OpenVPN 3.x supports)
are plain 32 or 64 bit ids while control channel is a 32 bit time + 32
bit counter id. Seperate these more clearly and let CBC mode use the
same Packet ID implementation that AEAD mode uses.

Also add more unit tests related to data channel tests packets by
adapting the control channel test where applicable and add a few more
related to packet id wrapping

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2024-09-11 13:23:31 +00:00
Arne Schwabe
16b2c4afe0 Remove UDP/TCP mode from PacketIDReceiveType
This mode is only relevant for old OpenVPN 2.3.x clients in CBC mode
ciphers when using kovpn. Remove the mode from PID control and move
logic to kovpn key logic.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2024-09-11 13:23:31 +00:00
Lev Stipakov
3d3e333c0e tunbase.hpp: add doxygen to apply_push_update()
Commit

  adacc16 ("push update: base implementation")

added apply_push_update() method to TunClient class
but didn't add doxygen comments. This adds missing
comments.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2024-09-11 13:23:30 +00:00
Lev Stipakov
906434b237 tunbuilder: add support for client-side push-updates
This implements apply_push_update() method for
tunbuilder tun client.

For tunbuilder tun client, no specific actions are required
except calling stop() and tun_start(). This will undo
existing options and apply the merged ones.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2024-09-11 13:23:30 +00:00
Lev Stipakov
ce68e3c415 ovpncli: bring tunbuilder variant back to life
Signed-off-by: Lev Stipakov <lev@openvpn.net>
2024-09-11 13:23:30 +00:00
Lev Stipakov
253dc4bf98 ovpncli: add CMake presets for Linux
Signed-off-by: Lev Stipakov <lev@openvpn.net>
2024-09-11 13:23:30 +00:00
Charlie Vigue
ef8da98bd4 Buffer: Prepare to decouple allocated buffer / RC
Rename BufferAllocated --> BufferAllocatedRc

Buffer: split RC from BufferAllocated
Also make changes as needed where BufferAllocated is used

Buffer: Split allocation flags into own struct
Leaving flags in template causes each alias to have identical flags
by different names, which requires each type to pointlessly use
the nested name.

Make RC: Clean up headers buffer.hpp, make_rc.hpp

Signed-off-by: Charlie Vigue <charlie.vigue@openvpn.com>
2024-09-11 13:23:28 +00:00
RenovateBot
5ce80fc300 Update vcpkg digest to b4624c3 2024-09-10 04:00:28 +00:00
RenovateBot
59bbe89413 Update github actions 2024-09-02 15:00:37 +00:00
Leonard Ossa
0cc1ce7d67 addr/macaddr: Refactor to modern C++
Remove unused include directives.
Change internal member C-style array to std::arry for better safety.
Adjust methods to use std::array.
Default constructor.
Use std::copy_n algorithm to clearly express intention.

Signed-off-by: Leonard Ossa <leonard.ossa@openvpn.com>
2024-08-27 18:31:11 +02:00
Leonard Ossa
9cafba7c7e Refactor IPv4 IPv6 to modern C++
Signed-off-by: Leonard Ossa <leonard.ossa@openvpn.com>
2024-08-26 12:21:55 +00:00
Arne Schwabe
b5f677e0b0 Fix iv_ciphers_legacy unit test if TLS library does not support BF-CBC
When running the unit test with mbed TLS 3.0, the library does not support
BF-CBC anymore. So we need to exclude BF-CBC from the expected result in
this case.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2024-08-22 12:42:46 +00:00
Arne Schwabe
e46f663b07 Make ssl related unit tests verbosity not print debug output by default
These unit tests are quite nosiy on a normal unit test run. Lower the
SSL verbosity for them to avoid a lot of debug output during unit tests.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2024-08-22 12:42:46 +00:00
Arne Schwabe
3fe0138d9e Use std::chrono::milliseconds instead of raw integer in client connect logic
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2024-08-22 12:42:46 +00:00
Arne Schwabe
fe91436cc4 Trigger events on common TLS alerts
OpenVPN 2.7/master will no longer suppress TLS Alerts but send them
out to the client. Create event for the common events that occur and
notify them to the UI process.

Jira: OVPN-1215
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2024-08-22 12:42:46 +00:00
Arne Schwabe
ae3f94a1f5 Refactor client_proto_terminate to avoid code duplication
Also move auth fail logic into own method.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2024-08-22 12:42:46 +00:00
Arne Schwabe
b8f7761e66 Correctly set the debug level for ssl alert logging
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2024-08-22 12:42:46 +00:00
David Sommerseth
d57522dc9c OpenVPN 3 Core library version 3.10
Noticable changes:
 
 * CVE-2024-5594: control channel: refuse control channel messages with
   nonprintable characters in them
 * Bugfix (macOS): Fixed dropped direct route to VPN server on reconnect
 * Bugfix: Fix incorrect handling of ClientOptions::Config::disableClientCert boolean flag
 * Bugfix: Fix incorrect RandomAPI API usage in aws/awsroute
 * Improvement: Avoid LOG_DEBUG/LOG_INFO macro conflicts with syslog.h
 * Feature: Expose the VPN profile CA certificate via the EvalConfig class
 * Feature: Initial support for custom appcontrol channel
 * Feature: Initial support for certificate checks via appcontrol channel
 -----BEGIN PGP SIGNATURE-----
 
 iQJHBAABCAAxFiEEgDq5E1p1aZrNLFFkhs+UTJZx/fIFAma+GWATHGRhdmlkc0Bv
 cGVudnBuLm5ldAAKCRCGz5RMlnH98gV3EACLQS3EMhbCzgm0juwtlK3xsJp35eF0
 7FUoLrqvJ4piirkX35lwFffYHZ3VWlzE+zpreYj8oKbHqJKB3TN1iCg2fEFqWVT+
 Xp7TrX8DV2jN+/ZU7k7O1wx5hPOat29+OKo/6dtiikMxOhMitmm2piMAAh1XQeqa
 7VKrQhEXM/LB2pg8qXCm29o2Lmnt0e64c2XaNV69v/EqYbO32TWeihfMtHFkG0rh
 PHL37b7xN8cQEJ/zVm76Xi9QBMmuIV3Ccw0mJ+wPqpxShJUpyQ9rokb8v1LsJEeT
 iMUfLpur3Z0ekoBWykslCnXrJ+lXPc6Fr/i2fkqeQZydPxKb/YzEMV/FGu9qgx1K
 VINeMSd1hvOTryjeS9o7uMcdRlEdi5ygLR2u4D0fDps1Byt3mrfbj6CYMzmOigCg
 FnRH/itVMg9q3mH6wfD4E3VyRHJd2A+2j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TY
 HcuuYGM3N8pobA==
 =a4sj
 -----END PGP SIGNATURE-----

Merge OpenVPN 3 Core library version 3.10 to master
2024-08-19 22:24:02 +02:00
Arne Schwabe
ca91f3e91c Implement data v3 features for AEAD tag at the end and 64 bit packet counter
Split the implementation of the packet counter for normal packet ID
that includes the "weird" long format for long 64 bit packet ids used
in tls-auth and tls-crypt and a simplified implementation for AEAD that
only does 32 bit and 64 bit flat counters.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2024-08-19 12:18:49 +00:00
Arne Schwabe
a384f16b32 Refactor data channel setting to CryptoDCSettingsData class
Instead of passing around a number of individual argument, use a data
holder class to describe all the settings. This will also allow adding
more data channel parameters in the future (tag location, 64 bit IV)
easier.  This has a slight cost of something passing more parameters
than needed.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2024-08-19 12:18:49 +00:00
Arne Schwabe
d52d98c7ec Assume AEAD tag at the end of input if not given seperately
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2024-08-19 12:18:49 +00:00
Razvan Cojocaru
880ebb081a server: Add new to_string_debug() pure virtual member to SendBase
This is part of a series of patches instrumenting crash checks.
Classes that implement SendBase can optionally collect debug
information for various scenarios, and create a string here that
presents them in human-readable form when requested.

Signed-off-by: Razvan Cojocaru <razvan.cojocaru@openvpn.com>
2024-08-19 10:57:32 +00:00
James Yonan
2b0960452d ServerProto: don't generate new management or tun instances after stop() has been called
This change is intended to safeguard against potential
post-stop() management activity that could result in
management agent getting into a bad state.

Signed-off-by: James Yonan <james@openvpn.net>
2024-08-17 12:53:23 -06:00
David Sommerseth
22369c80d6
Release: OpenVPN 3 Core Library, version 3.10
Signed-off-by: David Sommerseth <davids@openvpn.net>
2024-08-15 16:33:01 +02:00
Mark Deric
318d83ae43 Fix fail silently bug in pre-commit hook
Without the change and in the absence of a clang-format command in the
user's PATH, the script will fail in line 79 of the hook due to set
-e.  It will fail to produce the error message starting at line 83.

The change allows the error message to print.

Signed-off-by: Mark Deric <jmark@openvpn.net>
2024-08-13 23:26:06 -07:00
Heiko Hund
3936778c38 virtual d'tors: use '= default' instead of empty body
Signed-off-by: Heiko Hund <heiko@openvpn.net>
2024-08-13 02:05:05 +02:00
Heiko Hund
f5db521aa7 WinSvc: define virtual d'tor
The Windows Service class did not specify its destructor as virtual, but
has other virtual function. Not specifying the d'tor virtual is an
anti-pattern in this case.

Signed-off-by: Heiko Hund <heiko@openvpn.net>
2024-08-13 02:01:33 +02:00
Heiko Hund
8c8e96e138 streamline overriding virtual function syntax
In the code base three different syntaxes for overriding virtual member
functions could be found:

  1) virtual ... override
  2) virtual ...
  3) ... override

This converts all of them to the third syntax, as recommended by the ISO
C++ core guidelines in C.128

Signed-off-by: Heiko Hund <heiko@openvpn.net>
2024-08-13 02:01:24 +02:00
James Yonan
e4368fd83e CryptoAlgs: added missing #include <list>
CryptoAlgs uses std::list but did not #include <list>

Signed-off-by: James Yonan <james@openvpn.net>
2024-08-09 10:10:05 +00:00
James Yonan
6132010ea1 ManClientInstance::SendBase: added is_stopped() virtual method
is_stopped() should return true when the instance
is stopped or halted.

Signed-off-by: James Yonan <james@openvpn.net>
2024-08-09 10:10:05 +00:00
RenovateBot
7444bad773 chore(deps): update vcpkg digest to f5398d9 2024-08-08 14:43:15 +00:00
RenovateBot
8aaecdd14a chore(deps): update dependency chriskohlhoff/asio to asio-1-31-0 2024-08-08 14:43:14 +00:00
Razvan Cojocaru
98e0f1f650 logger: De-duplicate Logger::log_{trace, info, ...} logic
Add a single template function implementing the logging logic,
parametrized by log level, and have the log_{trace, info, ...}
functions call that.

While at it, const-ify a couple of member functions.

Signed-off-by: Razvan Cojocaru <razvan.cojocaru@openvpn.com>
2024-08-08 14:43:14 +00:00
Razvan Cojocaru
bd5685c921 Add -Wnon-virtual-dtor to the UNIX C++ compiler flags
Signed-off-by: Razvan Cojocaru <razvan.cojocaru@openvpn.com>
2024-08-08 14:43:12 +00:00
Razvan Cojocaru
6217fa0e1a Add default virtual destructors to base classes with virtual functions
Without this fix, the openvpn3-linux build is broken whenever a
dependency enables -Wnon-virtual-dtor (which protobuf 27.3
currently does on Arch Linux). The openvpn3-linux build treats
warnings as errors.

Jira: OVPN3-1242
Signed-off-by: Razvan Cojocaru <razvan.cojocaru@openvpn.com>
2024-08-08 14:43:12 +00:00
Lev Stipakov
cbea2d46c2 push update: support for Linux
Only tun-related options are supported, such as

  ifconfig, route, dns, dhcp-option

etc.

OVPN3-1231

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2024-08-08 14:43:11 +00:00
Lev Stipakov
0c27550736 push update: support for dco-win
Only tun-related options are supported, such as

  ifconfig, route, dns, dhcp-option

etc.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2024-08-08 14:43:11 +00:00
Lev Stipakov
6a1a641cf5 push update: support for tap-windows6
Only tun-related options are supported, such as

  ifconfig, route, dns, dhcp-option

etc.

OVPN3-1000

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2024-08-08 14:43:11 +00:00
Lev Stipakov
72c11c8232 push update: add IV_PROTO flag
This is needed to indicate to server that
we support PUSH_UPDATE control channel message.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2024-08-08 14:43:11 +00:00
Lev Stipakov
adacc16cd4 push update: base implementation
This adds support for parsing PUSH_UPDATE
control command, which enables to update
options "on the fly", without reconnect.

The options presented in the PUSH_UPDATE list
overwrite current options with the name. To unset
an option, it has to be prefixed with the "-".

For example:

  PUSH_UPDATE,route 10.10.10.0 255.255.255.0,-dns

Replaces all existing routes with this new one
and removes all "dns" options.

If the client doesn't support updating certain option,
it reconnects. Except when option is prefixed with "?" -
in this case option is considered "optional".

For example, this message

  PUSH_UPDATE,?unsupported_option_a

does nothing, but this one:

  PUSH_UPDATE,dns 0,block-ipv6,unsupported_option_b

makes client reconnect, since it contains mandatory unsupported option.

OVPN3-1234

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2024-08-08 14:43:11 +00:00
Lev Stipakov
6f9f02ff9e cmake: use multiprocessor build for MSVC
Signed-off-by: Lev Stipakov <lev@openvpn.net>
2024-08-08 14:43:11 +00:00
Lev Stipakov
fa78d9a8a9 vcpkg.json: add GTest host dependency
Signed-off-by: Lev Stipakov <lev@openvpn.net>
2024-08-08 14:43:11 +00:00
Razvan Cojocaru
961ac5d699 Collapse LOGGER_LOG_{INFO, VERBOSE, DEBUG, TRACE, ERROR} implementation
Reduced the pasted implementations of the LOGGER_LOG_<VERBOSITY>
macros to a single macro with a verbosity parameter, in an attempt
to make the code easier to read by reducing the line count, and
hopefully reduce the probability of copy / paste bugs
(LOGGER_LOG_ERROR() was already checking against LOG_LEVEL_INFO).

Signed-off-by: Razvan Cojocaru <razvan.cojocaru@openvpn.com>
2024-08-05 16:51:55 +03:00
RenovateBot
4e643142aa chore(deps): update github actions 2024-08-01 00:00:38 +00:00
Arne Schwabe
5e968be14e Report run-time OpenSSL version instead of compile time version
Returning OPENSSL_VERSION_TEXT will return the value of the library at
compile time. We rather want to know the version of the library that is
actually running, so use OpenSSL_version instead.

Jira: OVPN3-1227
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2024-07-29 13:40:32 +00:00
Arne Schwabe
b43851c7a0 Disable swig warnings for ClangCL
Swig under windows add a lot of code that clang does not like, so disable those warning

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2024-07-29 13:40:30 +00:00
Arne Schwabe
6f6cedc2a6 Make building with clang-cl under windows -Werror clean
Use empty braces to initalise the structs to zero since they
use sub structs and clang wants us to otherwise use {{ 0 }}

Ensure that methods with a return value do not return without a
value or exception by throwing an exception.

Add missing override in the unit test

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2024-07-29 13:40:30 +00:00
Leonard Ossa
b550d6bf7f IP Refactor
Signed-off-by: Leonard Ossa <leonard.ossa@openvpn.com>
2024-07-29 13:40:29 +00:00
Charlie Vigue
0faf0f89de Make runtime range check only happen if needed
In numeric_cast when casting from signed to unsigned, the second part
of the conditional might be const in some cases. This is intended to
ensure the second runtime check is only present if possibly needed.

This is better and avoids a Coverity performance warning

Signed-off-by: Charlie Vigue <charlie.vigue@openvpn.com>
2024-07-25 16:39:46 +00:00
Frank Lichtenheld
20260b27f6 CodeCoverage.cmake: Import coverage helper code
From https://github.com/bilke/cmake-modules/blob/master/CodeCoverage.cmake

Jira: OVPN3-1237
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2024-07-25 13:43:22 +00:00