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

3172 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
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
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
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
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
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
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
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
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
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
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
Charlie Vigue
4aca9606c6 Change ::value --> _v and ::type --> _t
Also add doxygen and make requested changes from code review

Signed-off-by: Charlie Vigue <charlie.vigue@openvpn.com>
2024-07-22 17:36:18 +00:00
Charlie Vigue
18c3dfe103 Respect data encapsulation 2024-07-22 17:36:18 +00:00
Charlie Vigue
6b3db207d2 Move all impl to bottom 2024-07-22 17:36:18 +00:00
Charlie Vigue
8443be9f6d Move BufferType impl into ConstBufferType 2024-07-22 17:36:18 +00:00
Charlie Vigue
28787e03a1 Move all impl from declarations
Move ConstBufferType BufferType BufferAllocatedType member function
implementations out of declaration
2024-07-22 17:36:18 +00:00
Frank Lichtenheld
bf6f42dc19 Merge current state of releaseprep/3.10 to master
* origin/releaseprep/3.10:
  Do not reject control message with trailing newlines
  aws: account for RandomAPI change
  Allow disabling TLS 1.3 in certcheck to more easily debug problems
  Implement changes to allow test dpc certcheck to be tested
  Allow setting a maximum TLS version
  Change cxa1 protocol tag to dpc1
  Fix spelling errors raised by Debian linter
  mac agent: reinstall host route during restart
  Preparing QA cycle for OpenVPN 3 Core library release v3.10

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2024-07-16 17:19:49 +02:00
Razvan Cojocaru
f15261b8dd Fix crash if no tls-auth section is present in the config
We are now only initializing TLS-related objects if TLS auth mode
is enabled.

This fixes internal Jira issue PG-122.

Signed-off-by: Razvan Cojocaru <razvan.cojocaru@openvpn.com>
2024-07-12 09:29:27 +00:00
Leonard Ossa
e929058607 Refactor by getting rid of redundant value in loop
Signed-off-by: Leonard Ossa <leonard.ossa@openvpn.com>
2024-07-10 16:43:19 +02:00
Leonard Ossa
a8b6cb01fc Refactor iterating to range-based loop in find()
Signed-off-by: Leonard Ossa <leonard.ossa@openvpn.com>
2024-07-10 16:43:19 +02:00
Leonard Ossa
c52419411e Refactor enum to enum class in addrspacesplit
Signed-off-by: Leonard Ossa <leonard.ossa@openvpn.com>
2024-07-10 16:43:19 +02:00
Leonard Ossa
a00a4c6241 Refactor empty constructor to default
Signed-off-by: Leonard Ossa <leonard.ossa@openvpn.com>
2024-07-10 16:43:19 +02:00
Razvan Cojocaru
5329d67521 Update the copyright years used by core consumers
Signed-off-by: Razvan Cojocaru <razvan.cojocaru@openvpn.com>
2024-07-09 15:28:13 +00:00
Leonard Ossa
3819357192 Refactor iterating to range-based loop
Do we actually need / use this code?

Signed-off-by: Leonard Ossa <leonard.ossa@openvpn.com>
2024-07-09 14:39:33 +02:00
Leonard Ossa
f2856ec8ba Refactor exists method in AddrList to use std::find
Signed-off-by: Leonard Ossa <leonard.ossa@openvpn.com>
2024-07-09 14:33:52 +02:00
Arne Schwabe
b201027807 Do not reject control message with trailing newlines
The previous fix to reject invalid control message was a bit too aggressive
as scripts often accidentally include an extra newline at the end of the
control message.

Jira: OVPN3-1225
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2024-07-05 12:54:03 +02:00
Leonard Ossa
3646265d15 Refactor nested namespace to C++17 style
Signed-off-by: Leonard Ossa <leonard.ossa@openvpn.com>
2024-07-03 10:20:11 +00:00
Frank Lichtenheld
5d60f0dbee openvpn_PRF: Tell compiler some restrictions on arguments
To avoid false-positives.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2024-07-03 10:20:10 +00:00