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

114 Commits

Author SHA1 Message Date
Arne Schwabe
8bac99143a Use C++11 syntax instead GNUism to initialise array
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2020-04-29 11:55:38 +02:00
James Yonan
81e9714326 BufferType: added constructor accepting a void *
Signed-off-by: James Yonan <james@openvpn.net>
2020-04-10 16:53:39 -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
050f994347 Buffer: added some useful debugging info to buffer_full exception
Signed-off-by: James Yonan <james@openvpn.net>
2019-12-05 11:20:10 +01:00
James Yonan
c82644c03a Added BufferLineIterator
Iterate over the lines in a buffer by returning
a sub-buffer for each line.  Zero-copy.

Signed-off-by: James Yonan <james@openvpn.net>
2019-09-06 22:24:56 -06:00
James Yonan
ebfce58513 Added StaticBuffer, a constant-length Buffer for writing that cannot be extended
Signed-off-by: James Yonan <james@openvpn.net>
2019-09-06 22:24:56 -06:00
Arne Schwabe
4d18aaeb88 Fix LLVM warnings reported during OS X build
const modifies on primitive return types (int, bool, etc.) do not
do anything and Clang complains about these.

Zero initialisation in C++ is done by = {} or class().

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2019-08-29 16:59:33 +02:00
James Yonan
dcb0c94520 BufferType: append() argument can now be a flexible buffer type
Signed-off-by: James Yonan <james@openvpn.net>
2018-12-12 23:26:12 -07:00
James Yonan
1d2ce460d7 BufferType: added read_alloc_buf() method
Signed-off-by: James Yonan <james@openvpn.net>
2018-08-30 13:00:27 +03:00
James Yonan
148ae60853 BufferType: added reset_offset() method
Signed-off-by: James Yonan <james@openvpn.net>
2018-08-30 13:00:27 +03:00
James Yonan
5e29e6628c BufferType: added typedef T value_type
Signed-off-by: James Yonan <james@openvpn.net>
2018-08-30 13:00:27 +03: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
James Yonan
34998e94a1
zlib: removed verbose parameter
It probably makes more sense for debug logging to be handled
by the caller.

Also removed OPENVPN_GZIP_VERBOSE.

Signed-off-by: James Yonan <james@openvpn.net>
2018-03-10 02:28:34 +08:00
James Yonan
fe38233a82
Buffer: added typedefs for thread-safe refcounts
Also added misc comments.

Signed-off-by: James Yonan <james@openvpn.net>
2018-03-10 02:28:34 +08:00
James Yonan
b34b6271e5
compression: added compress_lz4() and decompress_lz4()
compress_lz4() and decompress_lz4() are intended for users
that want to do simple LZ4 compression/decompression on
a Buffer without involving the OpenVPN protocol compression
modules.

Signed-off-by: James Yonan <james@openvpn.net>
2018-03-10 02:28:34 +08:00
James Yonan
94526ac195
BufferAllocated: fixed regression in buffer copy
Fixed regression in:

    template <typename T_>
    BufferAllocatedType(const BufferType<T_>& other, const unsigned int flags)

That was introduced by commit b48a1682a7e9c666e1b6605747d3d561f2fbb5c4

    BufferAllocated: improve movability

    Added BufferAllocated move constructor for foreign
    BufferAllocated template classes.

Basically the source of the memcpy was not taking into account
the offset.

Signed-off-by: James Yonan <james@openvpn.net>
2018-03-10 02:28:34 +08:00
James Yonan
f9fc2f54e6
BufferAllocated: improve movability
Added BufferAllocated move constructor for foreign
BufferAllocated template classes.

In order to make this work, we need to:

(a) generally friend BufferType and BufferAllocatedType
    to all BufferAllocatedType template classes, and

(b) require typename R (thread_unsafe_refcount or
    thread_safe_refcount) to be specified for
    BufferAllocatedType (previously it was optional
    and defaulted to thread_unsafe_refcount).

Signed-off-by: James Yonan <james@openvpn.net>
2018-03-10 02:28:31 +08:00
James Yonan
116a5bd5e5
bufstr: added const_buf_from_string() method
Signed-off-by: James Yonan <james@openvpn.net>
2018-03-10 02:28:30 +08:00
James Yonan
f8ec814137
Buffer: added const_buffer_ref() variant accepting a const argument
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
462fe90807 BufferType: added read(), write(), and prepend() variants that accept void* data
Signed-off-by: James Yonan <james@openvpn.net>
2017-09-27 16:16:17 +08:00
James Yonan
1e855667a1 Use openvpn::strerror_str() instead of std::strerror().
std::strerror() doesn't claim to be thread-safe, so
add openvpn::strerror_str() which is thread-safe by
virtue of the fact that it backs to strerror_r().

Signed-off-by: James Yonan <james@openvpn.net>
2017-04-22 17:54:01 -06:00
James Yonan
691a641a43 Added i/o abstraction layer.
Created a lightweight abstraction layer so that another i/o
reactor can be dropped in place of asio.

The basic approach is to rename all references to asio::xxx
types to openvpn_io::xxx and then make openvpn_io a
preprocessor variable that points to the top-level namespace
of the i/o reactor implementation.

All of the source files that currently include <asio.hpp> now
include <openvpn/io/io.hpp> instead:

This gives us a lightweight abstraction layer that allows us
to define openvpn_io to be something other than asio.

Other changes:

* Inclusion of asio by scripts/build is now optional, and is
  enabled by passing ASIO=1 or ASIO_DIR=<dir>.

* Refactored openvpn/common/socktypes.hpp to no longer
  require asio.

* Refactored openvpn/log/logthread.hpp to no longer require
  asio.

* Added openvpn::get_hostname() method as alternative to
  calling asio directly.

* openvpn/openssl/util/init.hpp will now #error
  if USE_ASIO is undefined.

Signed-off-by: James Yonan <james@openvpn.net>
2017-03-30 15:48:14 -06:00
James Yonan
b2cd82a5bf copyright: updated to 2017.
Signed-off-by: James Yonan <james@openvpn.net>
2017-03-18 13:11:09 -06:00
James Yonan
ef42e59e05 Switch from AGPLv3 to GPLv3 on recently added files.
Signed-off-by: James Yonan <james@openvpn.net>
2017-03-18 12:47:11 -06:00
James Yonan
ad1989a547 asio: deal with symbol renaming in latest github master
mutable_buffers_1 -> mutable_buffer
const_buffers_1 -> const_buffer

This patch is a granularization of a patch by David Sommerseth
<davids@openvpn.net> where only the above renames are included.
2017-03-18 12:24:54 -06:00
James Yonan
8cbce45545 buf_read : removed accidently-committed debugging code. 2017-03-18 12:24:54 -06:00
James Yonan
f0cfa5e18f Buffer : added is_zeroed() method. 2017-03-18 12:24:54 -06:00
James Yonan
85b49d89b5 TempFile : added additional methods including reset(),
truncate(), read(), and set_delete().

Added buf_read() methods to read from a file descriptor
into a Buffer.
2017-03-18 12:19:39 -06:00
Samuli Seppänen
04b2a3c9b7 Switch from AGPLv3 to GPLv3
Signed-off-by: Samuli Seppänen <samuli@openvpn.net>
2017-03-16 14:43:55 +02:00
James Yonan
971abda88f copyright : updated to 2016 2016-09-03 23:29:23 -06:00
James Yonan
46d32a692d BufferVector : fixed a thinko that resulted in BufferVector
actually being a BufferList.
2016-06-09 17:20:42 -06:00
James Yonan
7e1242769a Buffer : Added c_str() and length() methods to Buffer so it
can be used like a std::string.
2016-06-09 16:54:26 -06:00
James Yonan
4083281bd1 buffer : added Buffer::null_terminate() method to
null-terminate a buffer that is not already null-terminated.
2016-05-10 17:50:03 -06:00
James Yonan
74d89fab7c OpenVPN protocol core : when passing objects to methods that
may assert ownership over them, use C++11 rvalue/move
semantics.
2016-05-10 13:02:11 -06:00
James Yonan
2255bab03a OpenVPN protocol core : added logic to control channel
receive path to reassemble messages fragmented by the
SSL layer up to a max message size of 64 KB.

Ramifications:

* Peer info data and pushed options can be significantly
  larger (i.e. approaching 64 KB).

* Less need for the options continuation feature.

Limitations:

* While this patch doesn't change the underlying OpenVPN
  protocol, it can result in messages being sent that are
  fragmented by the receiving SSL implementation into
  multiple buffers.  Implementations that lack reassembly
  capabilities (such as OpenVPN 2.x at this point in time)
  would see each buffer fragment as a separate message.

* This patch running on the server will break negotiation
  with pre-peer-info clients.  Basically this means it will
  interoperate with any OpenVPN 3 version or OpenVPN 2.x
  version that includes the June 2010 commit "Implemented a
  key/value auth channel from client to server.
  Version 2.1.1i".
2016-05-09 21:39:04 -06:00
James Yonan
fc73acfade class SafeString std::string constructor should accept
the string as a const reference.
2015-12-22 19:08:25 -07:00
James Yonan
dfbd8a9ce9 Added openvpn/buffer/bufhex.hpp for converting
POD objects to/from hex strings.
2015-12-14 14:54:25 -07:00
James Yonan
1b0ac32140 In BufferList, added put_consume() method. 2015-10-28 22:37:04 -06:00
James Yonan
79fdea43d2 buffer.hpp changes:
* added const_buffers_1_limit() method that is like
  const_buffers_1_clamp() but includes an upper-bound size
  constraint.

* realign() should be a no-op if headroom == offset_

* added additional reset() convenience method that also calls
  init_headroom()
2015-10-28 22:33:26 -06:00
James Yonan
a267d9b32a In bufstr.hpp, added buf_append_string() methods. 2015-10-27 18:18:09 -06:00
James Yonan
97384f66f6 Added to_string() method to BufferList. 2015-10-23 11:12:49 -06:00
James Yonan
7b14dae436 In zlib.hpp, don't compile zlib code unless
HAVE_ZLIB is defined.

In scripts/build-extras/zlib.sh, define
HAVE_ZLIB when running build script with
ZLIB=1.
2015-10-16 13:49:11 -06:00
James Yonan
3e42c09790 In zlib.hpp, make verbosity setting (verbose) into an
optional run-time parameter, but retain the compile-time
setting (OPENVPN_GZIP_DEBUG) to determine the default.
2015-10-15 23:34:16 -07:00
James Yonan
59c5950949 In ZLib::decompress_gzip(), allow max_size to be disabled
(i.e. no limit on size) by setting to zero.
2015-10-15 23:31:21 -07:00
James Yonan
d38101d5c2 In buflist.hpp:
* Added explicit flag to turn on size=1 optimization.
* Added join() method without arguments.
* Added copy() method.
2015-09-18 10:14:03 -07:00
James Yonan
1871d5671d Added ZLib::decompress_gzip() method. 2015-09-07 06:16:54 -07:00
James Yonan
26501d28a3 Added BufferList class for building a list of BufferPtrs
then merging them via the join() method.
2015-09-07 06:11:46 -07:00