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

1460 Commits

Author SHA1 Message Date
Antonio Quartulli
08dfbf98c1
version: make OPENVPN_VERSION a compile time option
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2018-06-25 16:34:43 +08:00
Lev Stipakov
8aa6f2f847 Merged in feature/dco-nopg (pull request #13)
[OVPN3-230] Add client-side dco code

Approved-by: James Yonan <james@openvpn.net>
2018-06-23 18:48:33 +00:00
Lev Stipakov
2cde34e972 tunio: add missing include
Signed-off-by: Lev Stipakov <lev@openvpn.net>
2018-06-08 11:22:23 +03:00
Lev Stipakov
9e600c89e7 Merged in OVPN3-211-implement-big-mutex (pull request #5)
[OVPN3-211] bigmutex: introduce macro to ensure thread-safety

Approved-by: James Yonan <james@openvpn.net>
2018-06-08 08:03:44 +00:00
Lev Stipakov
83a041b87a Merged in OC-71-dns-search-domain-default-suffix-a (pull request #9)
[OC-71] tun: make Windows use pushed DNS search domain

Approved-by: James Yonan <james@openvpn.net>
2018-06-08 08:03:15 +00:00
Lev Stipakov
5b030ed835 Merged in OC-70-dns-search-domain-default-suffix-a (pull request #11)
macdns: refactor split-DNS and domain autocompletion logic

Approved-by: James Yonan <james@openvpn.net>
2018-06-08 08:02:51 +00:00
Lev Stipakov
fd147e450b Merged in OVPN3-229-compression (pull request #8)
OVPN3-229 compression

Approved-by: Arne Schwabe <arne@openvpn.net>
Approved-by: Antonio Quartulli <antonio@openvpn.net>
Approved-by: James Yonan <james@openvpn.net>
Approved-by: Lev Stipakov <lev@openvpn.net>
2018-06-08 08:02:35 +00:00
Lev Stipakov
ccc17a5631 [OVPN3-211] bigmutex: introduce macro to ensure thread-safety
Platforms like UWP and iOS may call core methods
from another threads. Since core is not thread-safe,
we provide OPENVPN_ASYNC_HANDLER macro which instantiates
lock guard. It follows RAII principle and locks global
mutex in constructor and unlocks in destructor. This
guarantees that code in block protected with this macro
won't be called simultaneously from different threads.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2018-06-07 21:17:42 +03:00
Lev Stipakov
643ada4395 [OVPN3-230] Add client-side dco code
Signed-off-by: Lev Stipakov <lev@openvpn.net>
2018-05-31 16:27:50 +03:00
Lev Stipakov
3d4bac496e macdns: refactor split-DNS and domain autocompletion logic
Implement domain autocompletion by adding ADAPTER_DOMAIN_SUFFIX value
to SearchDomains (see https://support.apple.com/en-ca/HT200303).

Note that autocompletion won't work in case of split-DNS, when macOS
uses network adapter's domain suffix instead of one provided by VPN.

Exclude split-DNS domains from autocompletion list.

Do not add "dhcp-option DOMAIN" values to SearchDomains
when redirecting DNS to not to use them for autocompletion.

This fixes OC-70 and OC-72.

Signed-off-by: Lev Stipakov <lev@openvpn.net>

do not add DOMAIN values to search domains when redirect DNS
2018-05-25 19:37:09 +03:00
Lev Stipakov
5c5ac5151c [OC-71] tun: make Windows use pushed DNS search domain
Signed-off-by: Lev Stipakov <lev@openvpn.net>
2018-05-24 13:36:17 +03: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
46d2a642f8 RC: added is_thread_safe() method to indicate if refcount is thread-safe
is_thread_safe() is constexpr, so it can be checked at compile time
using static_assert().

Signed-off-by: James Yonan <james@openvpn.net>
2018-05-21 11:34:02 +03:00
James Yonan
1da56fcce6 ValidateCreds: added strict flag for use with OMI
The OMI model (OpenVPN management interface) can't deal
with control characters in credentials, so we add a strict
flag to ValidateCreds::is_valid() that when true will
validate according to OMI requirements.

Also increased max length for credentials under strict=true
to 512 for OMI.

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
877464675c Implemented client-side AUTH_PENDING protocol state
AUTH_PENDING is a control channel message sent from server
to client before PUSH_REPLY or AUTH_FAILED and is intended
to signal the client that a browser-based out-of-band
authentication challenge (such as SAML) needs to occur
before the connection request can succeed or fail.

When the core receives the AUTH_PENDING message, it will
enter the AUTH_PENDING state and forward the message
to the client UI as an event.

The core will also dial back the PUSH_REQUEST transmit
frequency to one message every 8 seconds, and the server is
expected to reply with an AUTH_PENDING message after every
PUSH_REQUEST.  This is done as a sort of keepalive
replacement since the normal OpenVPN protocol keepalive
functionality isn't enabled until the crypto state is
established, which doesn't happen until the PUSH_REPLY
message is received from the server.

During the AUTH_PENDING state, the server will likely want to
push INFO messages to the client UI (such as INFO,OPEN_URL:)
to facilitate the out-of-band authentication challenge.
Normally, the client core buffers early INFO messages
and doesn't release them to the UI until 1 second after
the CONNECTED event.  This is done because it was
presumed that the server wouldn't want the client to
act on the INFO messages until the tunnel is established.

But the AUTH_PENDING state creates a need for an unbuffered
INFO message, since the server may want to message the client
UI during the AUTH_PENDING state and have that message
be immediately processed.

I've solved this problem by introducing a new control channel
message called "INFO_PRE".  INFO_PRE is handled exactly the
same as INFO except it is never buffered.  Also, note that
INFO_PRE messages are delivered to the client UI as
ordinary INFO events (I didn't actually create a new client
event for INFO_PRE since I can't think of a reason why the
client UI would need to distinguish between them).

Signed-off-by: James Yonan <james@openvpn.net>
2018-05-21 11:34:01 +03:00
James Yonan
58cfd26d20 IP Addr library: added random_addr() and random_subnet()
Signed-off-by: James Yonan <james@openvpn.net>
2018-05-21 11:34:01 +03:00
James Yonan
2c06ac24cd SessionIDType: allow generation from non-crypto RNGs
Signed-off-by: James Yonan <james@openvpn.net>
2018-05-21 11:34:01 +03:00
James Yonan
a0eb88a6ba RemoteList::next(): better handling of null return from remote_override->get()
If remote_override->get() returns null, treat as if remote_override
isn't enabled.

Signed-off-by: James Yonan <james@openvpn.net>
2018-05-21 11:34:01 +03:00
James Yonan
d6627ed480 IP::RouteType: added operator!=() method
Signed-off-by: James Yonan <james@openvpn.net>
2018-05-21 11:34:01 +03:00
James Yonan
f051a10f34 IP packet headers: Added IPv6 and ICMPv6
Signed-off-by: James Yonan <james@openvpn.net>
2018-05-21 11:34:01 +03:00
James Yonan
6224ade511 library: added quote_ip() function to return IP addr in brackets if it is IPv6
Signed-off-by: James Yonan <james@openvpn.net>
2018-05-13 23:03:09 -06:00
Antonio Quartulli
d37db831e8
tcplink: do not re-implement send_queue_size() function
send_queue_size() is already defined in LinkCommon and
does not need to be overridden by Link.

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2018-05-04 19:44:34 +08:00
Lev Stipakov
701f73c27c [OVPN3-229] proto.hpp: streamline compressor selection logic
Abort connection if server pushes unsupported compression.

Degrade compression to asym (server->client) if server pushes compression
which is supported but disabled.

This fixes problem with non-working tunnel - server pushes compression,
client has compression disabled and instantiates stub. As a result,
server uses compression and client uses stub.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2018-04-30 13:44:45 +03:00
Lev Stipakov
35bbca799d Merged in OVPN3-184-generate-warning (pull request #1)
OVPN3-184 Name Constraints

Approved-by: Antonio Quartulli <antonio@openvpn.net>
Approved-by: James Yonan <james@openvpn.net>
2018-04-25 18:10:21 +00:00
Antonio Quartulli
2d99bbfeaf
[OVPN3-169] cliopt.hpp: add support for TLS transport module
When compiled with -DOPENVPN_TLS_LINK, the core will
ship support for the TLS Transport component.
However, note that its implementation must be provided
externally.

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2018-04-19 17:38:19 +08:00
Antonio Quartulli
62c8461d26
[OVPN3-169] tcpcli.hpp: add runtime support for TLSLink
A configuration switch can now be used to tell
the TCPTransport client to use TLS.

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2018-04-19 17:38:19 +08:00
Antonio Quartulli
e0e76bb283
[OVPN3-169] tcplink: introduce LinkBase abstract class
This class is an "interface" for TCP Links. It can be used by Transport
layers instead of the actual concrete Link class.

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2018-04-19 17:38:18 +08:00
Antonio Quartulli
a71014d407
[OVPN3-169] tcplink: create LinkCommon class and inherit from it
To allow other types of TCP Link to be implemented,
factor out code that can be re-used by other implementations
and move it to the LinkCommon class.

TCPTransport::Link now inherits from LinkCommon.

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2018-04-19 17:31:51 +08:00
Lev Stipakov
3e49de7dea [OVPN3-210] ovpncli: handle "allow-name-constraints" for OpenSSL
This is mbedTLS-only option, which has no effect on OpenSSL-built client.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2018-04-19 11:11:39 +03:00
Lev Stipakov
08d72bd76d [OVPN3-184] mbedtls: handle Name Constraints
Introduce profile flag "allow-name-constraints".

mbedTLS doesn't support x509v3 'Name Constrains'
extension. To allow client to connect, make mbedTLS
not to fail on this extension and drop a warning to UI.

This depends on "Enable allowing unsupported critical extensions in runtime"
patch to mbedTLS.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2018-04-19 11:11:39 +03:00
Antonio Quartulli
ef8d11f340
[OVPN3-169] OpenSSL: implement write_ciphertext_unbuffered() function
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2018-04-19 12:10:02 +08:00
Antonio Quartulli
37dc863783
[OVPN3-169] mbedTLS: implement write_ciphertext_unbuffered() function
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2018-04-19 12:10:00 +08:00
Antonio Quartulli
5834ed401a
[OVPN3-169] SSLAPI: add write_ciphertext_unbuffered() function
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2018-04-19 12:09:58 +08:00
Antonio Quartulli
5bbfe68c3c
[OVPN3-169] Protocol: add support for TLS transport protocol type
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2018-04-19 12:09:46 +08:00
James Yonan
caf9cf6c1d
RedirectPipe: added additional flags for flexibility
COMBINE_OUT_ERR : capture combined stdout/stderr using a pipe
  ENABLE_IN       : make a string -> stdin pipe, otherwise redirect stdin from /dev/null
  IGNORE_IN       : don't touch stdin
  IGNORE_OUT      : don't touch stdout
  IGNORE_ERR      : don't touch stderr

Signed-off-by: James Yonan <james@openvpn.net>
2018-03-26 23:58:35 +08:00
James Yonan
37d848ca20
Log lines from C++ exceptions should contain the text "exception"
This makes it easier to scan log files for exceptions.

Signed-off-by: James Yonan <james@openvpn.net>
2018-03-26 23:58:35 +08: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
52e4d4a5f2
Increase client validation of password/response size to 16KB to support bundling SAML messages.
Also, don't fail (client-side) a username containing spaces
since the server side will already accept this.

Signed-off-by: James Yonan <james@openvpn.net>
2018-03-26 23:58:35 +08:00
Lev Stipakov
7b30c2f12b
[OVPN3-220] proto.hpp: send initial options set on rekeying
To maintain compatibility with openvpn2, we need to send initial options
on rekeying instead of possible NCP-caused modifications.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2018-03-26 23:58:34 +08:00
Lev Stipakov
0a3dd67dac
[OVPN3-190] tun linux: add to/from_json methods
Signed-off-by: Lev Stipakov <lev@openvpn.net>
2018-03-26 23:58:33 +08:00
Antonio Quartulli
c5bc3859e6
mbedTLS: don't set endpoint twice in conf object
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2018-03-26 23:58:32 +08:00
Lev Stipakov
37ab79fa6e
tun linux: apply changes from 362acf0
Linux tun setup: use LinuxGW46 to obtain gateway info

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2018-03-10 02:28:35 +08:00
Lev Stipakov
6a7aee2c9f
[OVPN3-190] tun: implement persistence
Preserve tun and routes across reconnects. Store tun descriptor in
TunPersist object, which is member of TunClientFactory. Handle
add/remove commands inside TunBuilderSetup::Base instance, which is
owned by TunPersist.

Tunnel is recreated if new tunnel options are different from previous
ones.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2018-03-10 02:28:35 +08:00
Lev Stipakov
1d2ebb07fc
[OVPN3-190] tun: move tun creation to separate class
Implement TunBuidlerSetup::Base, which takes care of tun creation.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2018-03-10 02:28:35 +08:00
Lev Stipakov
53e33d634f
[OVPN3-190] tun: move content of tun to tuncli
Signed-off-by: Lev Stipakov <lev@openvpn.net>
2018-03-10 02:28:35 +08:00
Lev Stipakov
85d3377c28
[OVPN3-190] tun: move tun setup methods to separate file
Signed-off-by: Lev Stipakov <lev@openvpn.net>
2018-03-10 02:28:35 +08:00
James Yonan
735b985eb5
i/o layer: wrap raw pointers embedded in closures
Found some cases where raw pointers embedded in closures and
passed via asio async methods could potentially leak if the
io_context is destroyed before the run() method is called.

With C++14 and higher supporting generalized lambda capture,
we can now wrap these pointers in a std::unique_ptr for
minimal cost.

Signed-off-by: James Yonan <james@openvpn.net>
2018-03-10 02:28:35 +08:00
James Yonan
322ae24b53
OptionList: support variadic template parameter pack in constructors
This allows usage such as:

const OptionList opt(Option("dev", "tun"),
		     Option("remote", "openvpn.example.com", "1194", "udp"));

Signed-off-by: James Yonan <james@openvpn.net>
2018-03-10 02:28:35 +08:00
James Yonan
8a012b4545
lz4: added namespace and improved error handling
* Put all methods in the LZ4 namespace.

* Throw errors instead of returning null BufferPtr().

* For decompress(), make sure that max_decompressed_size
  doesn't exceed LZ4_MAX_INPUT_SIZE.

This commit only affects the standalone LZ4 helper functions,
not the LZ4 module that is part of the OpenVPN protocol.

Signed-off-by: James Yonan <james@openvpn.net>
2018-03-10 02:28:34 +08:00