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

468 Commits

Author SHA1 Message Date
James Yonan
04175c2b84 appversion.hpp: Stringize VERSION -> MY_VERSION
Default to "0.1.0" if VERSION is undefined.

Signed-off-by: James Yonan <james@openvpn.net>
2017-09-27 16:16:18 +08:00
James Yonan
bd75cd787b RCPtr: added operator==() and operator!=() methods
Signed-off-by: James Yonan <james@openvpn.net>
2017-09-27 16:16:17 +08:00
James Yonan
7be33c5980 PThreadBarrier: fixed incorrect comment
Signed-off-by: James Yonan <james@openvpn.net>
2017-09-27 16:16:17 +08:00
James Yonan
6f5f77bc10 Link: use move semantics
Signed-off-by: James Yonan <james@openvpn.net>
2017-09-27 16:16:17 +08:00
James Yonan
17a5d89c9f inotify.hpp: no longer used
Signed-off-by: James Yonan <james@openvpn.net>
2017-09-27 16:16:17 +08:00
James Yonan
8ce39fc991 added render_hex() and render_hex_sep() methods that accept void* data
Signed-off-by: James Yonan <james@openvpn.net>
2017-09-27 16:16:17 +08:00
James Yonan
ddc8e8a434 Function: use std::forward
Signed-off-by: James Yonan <james@openvpn.net>
2017-09-27 16:16:17 +08:00
James Yonan
76ee5875a9 write_binary_atomic(): added tmpdir (temporary directory) parameter
Signed-off-by: James Yonan <james@openvpn.net>
2017-09-27 16:16:17 +08:00
James Yonan
f366d55105 base64: encode() now accepts void* data
Signed-off-by: James Yonan <james@openvpn.net>
2017-09-27 16:16:17 +08:00
James Yonan
ce0977b2ea Support Cityhash.
When running build script, add CITY=1 to build with Cityhash library.

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
4bfaafc295 AsioTimer: use expires_after() method when possible.
A common AsioTimer usage pattern is:

  expires_at(Time::now() + duration)

This is more succinctly and efficiently stated as:

  expires_after(duration).

Signed-off-by: James Yonan <james@openvpn.net>
2017-04-12 14:01:11 -06:00
James Yonan
1215912c90 Revamped Function (our own functor object) to be more flexible.
* Automatically overflow to dynamic allocation if function
  object is too large.

* Added optional N and INTERN_ONLY parameters to fine-tune
  internal allocation.

* Added default constructor.

* Added move assignment method.

* Added reset() methods.

* Added operator bool() method to test if functor has
  been defined.

Signed-off-by: James Yonan <james@openvpn.net>
2017-04-12 11:54:16 -06:00
James Yonan
10fa276421 process.hpp: added compile option to avoid async pipe usage.
Define OPENVPN_PROCESS_AVOID_PIPES to build process.hpp
without using asynchronous pipes.

Signed-off-by: James Yonan <james@openvpn.net>
2017-04-12 11:52:15 -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
2855053680 Moved asio files from openvpn/common to openvpn/asio
Signed-off-by: James Yonan <james@openvpn.net>
2017-03-30 15:48:14 -06:00
James Yonan
f221a27efc documentation: updated for reference-counted GC classes
in openvpn/common/rc.hpp.

Signed-off-by: James Yonan <james@openvpn.net>
2017-03-19 16:32:45 -06:00
James Yonan
6e8f2a73f8 Moved openvpn::to_string() to separate source file.
Signed-off-by: James Yonan <james@openvpn.net>
2017-03-18 15:46:45 -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
7e1aca0b54 Added a general-purpose Session ID class. 2017-03-18 12:24:54 -06:00
James Yonan
77c79f8905 StringTempl : added type-independent string methods. 2017-03-18 12:24:54 -06:00
James Yonan
9e55ad955a base64 changes
* Added URL-safe alternate encoding
* Verify length of altmap
* Added is_base64() method
2017-03-18 12:24:54 -06:00
James Yonan
3b399a6101 asio : the latest Asio master on Github has deprecated
user-defined service objects.  This commit attempts
to work around that but requires a specially patched
version of Asio that includes the virtual
async_connect_post_open() method.
2017-03-18 12:24:54 -06:00
James Yonan
1f69ae37e7 asio : updates for API changes to "work" object in latest github master.
The asio::io_context::work class has been replaced by a new
class having somewhat different and more verbose
semantics.

We create our own class AsioWork based on the new class
asio::executor_work_guard<asio::io_context::executor_type>
that implements the semantics of the original
asio::io_context::work class.
2017-03-18 12:24:54 -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
4de93d5f65 write_binary_atomic() changes:
1. now uses write_binary_unix() for performance
2. use a leading '.' in generated temporary filenames
2017-03-18 12:24:54 -06:00
James Yonan
ee91c99d40 library : added set of file read/write helper methods
optimized for unix (openvpn/common/fileunix.hpp).
2017-03-18 12:24:54 -06:00
James Yonan
281d08599a string : added ends_with_crlf(),
add_trailing_unless_empty_copy(), and is_alphanumeric().

Implementation changes to ends_with(), trim_crlf(),
and is_word().
2017-03-18 12:24:54 -06:00
James Yonan
295a999fef stat : added file_mod_time_nanoseconds() and
file_mod_time_milliseconds().
2017-03-18 12:24:54 -06:00
James Yonan
03d3318482 ScopedFD : added close_with_errno() 2017-03-18 12:24:54 -06:00
James Yonan
02953d8797 path : added varargs join() 2017-03-18 12:24:54 -06:00
James Yonan
d095771529 hexstr : added class RenderHexByte 2017-03-18 12:24:54 -06:00
James Yonan
fa75e9f98e enum_dir : for consistency, libc function calls should
always include a "::" prefix before the function name.
2017-03-18 12:24:54 -06:00
James Yonan
31ae0e83b8 core version : updated to 3.1.2 2017-03-18 12:24:54 -06:00
James Yonan
18eb8c7646 daemonize/log_setup : Added optional SetUserGroup parameter
to allow chown of log file.
2017-03-18 12:24:54 -06:00
James Yonan
ac6c330dc7 UserGroup : Added strict flag to constructor to allow for
construction even when user/group lookup fails.

Updated calls to std::strerror() to use a saved version
of errno.

Added chown(), gid(), and additional defined() methods.

Use uid_t as the return type for uid().
2017-03-18 12:24:54 -06:00
James Yonan
83d575893f string::join : if tail is true, don't append a
lone delimiter char to return string if passed
string vector is empty.
2017-03-18 12:24:54 -06:00
James Yonan
9c0397ebd3 Added Relay capability, a kind of proxy function similar
to HTTP CONNECT but implemented over the OpenVPN protocol.

1. Client connects to relay server as if it were connecting
   to an ordinary OpenVPN server.

2. Client authenticates to relay server using its client
   certificate.

3. Client sends a PUSH_REQUEST method to relay server which
   then replies with a RELAY message instead of PUSH_REPLY.

4. On receiving the RELAY message, the client attempts to
   reconnect using the existing transport socket.  The
   server will proxy this new connection (at the transport
   layer) to a second server (chosen by the relay server)
   that is the target of proxy.

5. The client must establish and authenticate a new session
   from scratch with the target server, only reusing the
   transport layer socket from the original connection to
   the relay server.

6. The relay acts as a man-in-the-middle only at the
   transport layer (like most proxies), i.e. it forwards
   the encrypted session between client and target server
   without decrypting or having the capability to decrypt
   the session.

7. The client is designed to protect against potentially
   untrusted or malicious relays:

   (a) The client never transmits the target server
       username/password credentials to the relay server.

   (b) The relay forwards the encrypted OpenVPN session
       between client and target server without having
       access to the session keys.

   (c) The client configuration has a special directive
       for relay server CA (<relay-extra-ca>) and relay
       server tls-auth key (<relay-tls-auth>) to allow
       for separation of TLS/crypto configuration between
       relay and target servers.

   (d) The client will reject any PUSH_REPLY messages
       from the relay itself to prevent the relay from
       trying to establish a tunnel directly with the
       client.

Example configuring a client for relay:

  # remote addresses point to the relay server
  remote ... 1194 udp
  remote ... 443 tcp

  # include all other directives for connecting
  # to the target server

  # enable relay mode
  relay-mode

  # constrain the relay server's cert type
  relay-ns-cert-type server

  # include extra CAs that validate the relay
  # server cert (optional).
  <relay-extra-ca>
  -----BEGIN CERTIFICATE-----
  . . .
  -----END CERTIFICATE-----
  </relay-extra-ca>

  # specify the TLS auth key for the relay server
  relay-key-direction 1
  <relay-tls-auth>
  -----BEGIN OpenVPN Static key V1-----
  . . .
  -----END OpenVPN Static key V1-----
  </relay-tls-auth>
2017-03-18 12:24:54 -06:00
James Yonan
b862ca8ff8 library : moved class Environ into its own source file and
added find_static() method.
2017-03-18 12:19:39 -06:00
James Yonan
a2367c5f4d process : added Environ::assign() method. 2017-03-18 12:19:39 -06:00
James Yonan
5d52181cbe runcontext : trigger async_stop before thread join(). 2017-03-18 12:19:39 -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
James Yonan
184c6d672b redir.hpp : break out pipe i/o into its own source file. 2017-03-18 12:19:39 -06:00
James Yonan
74e05d8607 library : added class RedirectNull for redirecting stdin,
stdout, and stderr to /dev/null
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
883d967bae Incremented core version to 3.1.1 2016-09-23 16:46:24 -06:00
James Yonan
cf8d5b5c3f Incremented core version to 3.1.0 2016-09-16 04:16:40 +03:00
James Yonan
971abda88f copyright : updated to 2016 2016-09-03 23:29:23 -06:00
James Yonan
3fd2c451f5 Incremented core version to 3.0.21 2016-09-02 12:57:51 -06:00