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

134 Commits

Author SHA1 Message Date
Mark Deric
989dd7ead5 Port the psid cookie defense from ovpn2
The psid cookie defense is designed to thwart resource exhaustion and
amplification attacks wherein a malicious client sends the server a
flood of CONTROL_HARD_RESET_CLIENT_V2 packets with spooofed source
addresses.  This patch allows the server to defer client tracking
state creation until the client responds to the server's
CONTROL_HARD_RESET_SERVER_V2 message.

Signed-off-by: Mark Deric <jmark@openvpn.net>
2023-10-03 12:42:29 -07:00
James Yonan
64a535c65d ManClientInstance: refactor Send into two classes, Send and SendBase
This refactoring moves all generic methods into SendBase
that are independent of VPN protocol, while OpenVPN
protocol-specific methods will remain in Send.

Signed-off-by: James Yonan <james@openvpn.net>
2023-09-17 10:08:36 -06: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
David Sommerseth
dde1574596
Reformatting source code to new coding style
This is the result after running 'clang-format -i' on all C++ files and
headers, with the defined formatting rules in .clang-format.

Only the openvpn/common/unicode-impl.hpp has been excluded, as that is
mostly a copy of an external project.

Signed-off-by: David Sommerseth <davids@openvpn.net>
2023-01-18 19:24:15 +01:00
David Sommerseth
4996c38ed4
Merge lastest changes from Core v3.7.2 2022-12-14 17:34:29 +01:00
David Sommerseth
8c94a8f774
copyright: Update to 2022
Signed-off-by: David Sommerseth <davids@openvpn.net>
2022-09-29 12:00:26 +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
James Yonan
b2df3ca663 Renamed VPN_CONNECTION_PROFILES -> VPN_BINDING_PROFILES for clarity
VPN Binding Profiles (previously committed as VPN Connection
Profiles) contain information on an active VPN client session
such as local VPN IPs, gateway, and DNS resolver addresses
that can be directly used by higher-layer HTTP/REST-API
clients to (a) ensure that sessions are routed over the VPN,
and (b) privately use the VPN-server-pushed DNS resolvers
without publishing them in /etc/resolv.conf.

Signed-off-by: James Yonan <james@openvpn.net>
2022-06-29 08:39:22 -06:00
James Yonan
9b5d87fd43 HTTP client/server: support binding to VPN connection profiles
A VPN connection profile is basically a JSON representation
of the server-pushed parameters of a VPN session such as
VPN IPs, Gateway IPs, and DNS servers.  It can be obtained
on the client via TunBuilderCapture::to_json()

This patch allows an HTTP client or server to bind to the
VPN connection profile, so that the VPN IP is used as the
local address, the Gateway IP is optionally used as the
destination address, and DNS lookups are performed using
the pushed DNS servers (without needing to overwrite
/etc/resolv.conf).

For example, suppose the VPN connection profile
is in /pg/uplink-connection-info

Then we can bind to the VPN IP addresses on the server side:

  http-listen @/pg/uplink-connection-info 8443 tcp4 ssl
  http-listen @/pg/uplink-connection-info 8443 tcp6 ssl

Or connect to a remote REST API using the VPN session
and VPN server-provided resolvers.

  <aws-client>
  host mybucket.s3.amazonaws.com
  port 443
  vpn-connection-info /pg/uplink-connection-info
  ...
  </aws-client>

Signed-off-by: James Yonan <james@openvpn.net>
2022-05-14 01:39:37 -06:00
James Yonan
ea5c978be4 VPNServerNetblock::Netblock: added route() method
Signed-off-by: James Yonan <james@openvpn.net>
2022-05-13 19:09:09 -06:00
James Yonan
0e2ecc5641 Listen::List: added new load mode AllowVPNClientConnectionProfile
AllowVPNClientConnectionProfile tells us to support
special address case for WS::ViaVPN, where address
begins with '@' followed by a client connection
profile filename.

Signed-off-by: James Yonan <james@openvpn.net>
2022-05-13 19:09:09 -06:00
James Yonan
5392a9e197 Listen::List: use opt.get_index_ptr() optimization to avoid linear search through option list
This removes the feature of allowing directive to be a
prefix, but I didn't find any users of this method that
require it.

Signed-off-by: James Yonan <james@openvpn.net>
2022-05-13 19:09:09 -06:00
James Yonan
7baf7b5978 ManClientInstance, ServerProto::Session, TransportClientInstance::Recv: added ipma_notify() virtual method
Signed-off-by: James Yonan <james@openvpn.net>
2022-02-07 13:56:13 -07:00
James Yonan
994ae2eed8 VPNServerNetblock: allow null configuration
Signed-off-by: James Yonan <james@openvpn.net>
2021-11-24 13:18:35 -07:00
James Yonan
a133c248fa ServerProto constructor: for performance, use move constructor for man_factory and tun_factory
Signed-off-by: James Yonan <james@openvpn.net>
2021-11-24 13:18:35 -07:00
James Yonan
677b6edf1f
ServerProto: prefix all logging with client name
Signed-off-by: James Yonan <james@openvpn.net>
2021-08-03 10:42:35 +02:00
Heiko Hund
f3133090a6 remove unnecessary const from return type qualifier
Adding const here serves no purpose, since the return type is
a rvalue and cannot be modified anyways.

Signed-off-by: Heiko Hund <heiko@openvpn.net>
2021-05-18 06:13:31 +02:00
Heiko Hund
69ed0a6f10
make Protocol::mod_addr_version() take a Version
Change method signature from

    void Protocol::mod_addr_version(const IP::Addr&)
to
    void Protocol::mod_addr_version(const IP::Addr::Version)

This is done in preparation for allowing to override the protocol
version of a RemoteList::Item, where mod_addr_version() will be used.

Signed-off-by: Heiko Hund <heiko@openvpn.net>
2021-05-05 19:46:56 +02:00
James Yonan
1fe87f0842
Allow management layer to override keepalive parameters
Signed-off-by: James Yonan <james@openvpn.net>
2020-09-23 20:00:41 +02:00
James Yonan
b06e30a3a5
PeerAddr: make copyable by inheriting from RCCopyable<thread_unsafe_refcount>
Unit tests need PeerAddr to be copyable

Signed-off-by: James Yonan <james@openvpn.net>
2020-08-19 18:53:04 +02:00
James Yonan
2ba720fdfb
ManClientInstance::Send: added doma_acl() method
Signed-off-by: James Yonan <james@openvpn.net>
2020-08-19 18:52:52 +02:00
James Yonan
97a4b8f9f2
HaltRestart: added to_string() method
Signed-off-by: James Yonan <james@openvpn.net>
2020-08-19 18:52:49 +02:00
James Yonan
9978ea2e65
PeerStats: use C++11 member initializers
Signed-off-by: James Yonan <james@openvpn.net>
2020-08-19 18:52:48 +02:00
Arne Schwabe
35d01b8a71 Fix indentation and unused variables related warnings from Clang 10
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2020-04-29 11:55:38 +02:00
Arne Schwabe
f8fe13e07c Add missing overrides
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2020-04-29 11:55:38 +02:00
James Yonan
edc62cd3b4 PeerStats: added to_string() method
Signed-off-by: James Yonan <james@openvpn.net>
2020-04-13 16:29:45 -06:00
David Sommerseth
3fbe0a2701
Update copyrights
Signed-off-by: David Sommerseth <davids@openvpn.net>
2020-03-18 19:37:32 +01:00
Arne Schwabe
984c601090
Fix multiple instances of comparison of signed with unsigned 2020-01-15 23:08:30 +01:00
James Yonan
23c14a3e32 AddrPort, PeerAddr: added to_json() methods
Signed-off-by: James Yonan <james@openvpn.net>
2019-12-26 03:44:14 -07:00
James Yonan
725ee04593 VPNServerNetblock::Netblock::to_string(): show prefix_len
Signed-off-by: James Yonan <james@openvpn.net>
2019-09-09 21:07:13 -06:00
James Yonan
409d1c52b8 ManClientInstance::Send::describe_user(): added bool show_userprop parameter
Signed-off-by: James Yonan <james@openvpn.net>
2019-09-09 21:05:11 -06:00
James Yonan
c00b6f6302
Listen::List: refactored and extended expand_ports()
Renamed expand_ports() to expand_ports_by_n_threads() and
added expand_ports_by_unit().  Both methods extend a set
of Listen::Item entries to span a port range.

Signed-off-by: James Yonan <james@openvpn.net>
2019-05-16 14:50:06 +02:00
James Yonan
ae22f155fd
server: determine when server-side session ID should be preserved on soon-to-be-closed connections
Provides a callback should_preserve_session_id() for the management
layer to query.

Signed-off-by: James Yonan <james@openvpn.net>
2019-05-15 18:56:45 +02:00
James Yonan
68170941fb manage: pass ProtoContext::Config::Ptr by value
Signed-off-by: James Yonan <james@openvpn.net>
2018-05-21 11:34:02 +03:00
James Yonan
96f6347839 ServerProto: misc changes for AUTH_PENDING
* Added schedule_auth_pending_timeout()

* Removed the throw_on_error parameter to set_acl_index()

* Forward all PUSH_REQUEST messages to the management layer,
  not just the first message.

* Added enum DisconnectType for labeling the disconnect type,
  since there are now several different disconnect types
  including halt/restart, relay transition, and auth pending.

Signed-off-by: James Yonan <james@openvpn.net>
2018-05-21 11:34:02 +03:00
James Yonan
f05802cf95
Increase server validation of password size to 16KB to support bundling SAML messages.
Also allow password to be multi-line UTF-8 text.

Signed-off-by: James Yonan <james@openvpn.net>
2018-03-26 23:58:35 +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
ef3a40c271
Listen::Item: added AltRouting mode
Signed-off-by: James Yonan <james@openvpn.net>
2018-03-10 02:28:31 +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
James Yonan
4516cf67b5
ServerProto: reset CoarseTime object when AsioTimer is canceled
CoarseTime objects that track an AsioTimer must always be
reset when the AsioTimer is cancelled.  Not doing so can
cause a bug if the AsioTimer is reused after cancellation.

Signed-off-by: James Yonan <james@openvpn.net>
2018-03-10 02:28:30 +08:00
David Sommerseth
16b10559f2 [OVPN3-140] Update company names in copyrights
OpenVPN Technologies, Inc. change their name to OpenVPN Inc. during the
autumn of 2017.

Signed-off-by: David Sommerseth <davids@openvpn.net>
2017-12-22 17:59:39 +08:00
David Sommerseth
6caca2c313 [OVPN3-140] Relicense back to AGPLv3
This is essentially a revert of commit 04b2a3c9b7 and commit
ef42e59e05.

Signed-off-by: David Sommerseth <davids@openvpn.net>
2017-12-22 17:59:39 +08:00
James Yonan
b948cde4c3 ManClientInstance::Factory: added virtual stop() method.
Signed-off-by: James Yonan <james@openvpn.net>
2017-12-22 17:59:38 +08:00
James Yonan
1fbff4fed1 tls-crypt: revised server-side validate_initial_packet()
methods to use a BufferAllocated rather than a Buffer.

Signed-off-by: James Yonan <james@openvpn.net>
2017-12-22 17:59:38 +08:00
James Yonan
18f45c244e ManClientInstance::Send: added AuthStatus::Type parameter
to disconnect_user() method.

Signed-off-by: James Yonan <james@openvpn.net>
2017-12-22 17:59:38 +08:00
James Yonan
4bba803f33 Listen::List: added expand_ports() method.
Signed-off-by: James Yonan <james@openvpn.net>
2017-12-22 17:59:38 +08:00
James Yonan
5122e7dc0f Listen::List: in port_offset(), set n_threads to 0 since
number-of-threads data for port_offset items isn't really
relevant.

Signed-off-by: James Yonan <james@openvpn.net>
2017-12-22 17:59:38 +08:00
Antonio Quartulli
74c5f4f38f [OVPN3-5] tls-crypt: introduce tls-crypt support
backported from OpenVPN 2.4.x

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2017-09-27 16:16:18 +08:00
James Yonan
1d941aa7bd VPNServerNetblock::Netblock refactor
In VPNServerNetblock::Netblock, break out IP::Range clients
and IP::Addr bcast into a separate derived class ClientNetblock,
which provides a more minimalisic Netblock for use cases that
don't need to manage client VPN IP address pools.

Signed-off-by: James Yonan <james@openvpn.net>
2017-09-27 16:16:18 +08:00
James Yonan
7190495421 Server-side renamings to break up long class names using namespaces.
* renamed ManClientInstanceSend to ManClientInstance::Send
* renamed ManClientInstanceRecv to ManClientInstance::Recv
* renamed ManClientInstanceFactory to ManClientInstance::Factory
* renamed TransportClientInstanceSend to TransportClientInstance::Send
* renamed TransportClientInstanceRecv to TransportClientInstance::Recv
* renamed TransportClientInstanceFactory to TransportClientInstance::Factory
* renamed TunClientInstanceRecv to TunClientInstance::Recv
* renamed TunClientInstanceSend to TunClientInstance::Send
* renamed TunClientInstanceFactory to TunClientInstance::Factory

Other related refactorings/removals:

Changes to ManClientInstance::Send:

* Added pre_stop() method.
* Renamed set_acl_id() to set_acl_index().

Changes to ManClientInstance::Recv:

* In push_reply(), removed routes and initial_fwmark parameters.
* Removed set_fwmark() method.
* Added tun_native_handle() method to return the tun socket
  file descriptor and peer_id of a client instance.

Changes to ServerProto:

* Added C++11 override attribute to overridden virtual methods

Signed-off-by: James Yonan <james@openvpn.net>
2017-09-27 16:16:18 +08:00