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

1586 Commits

Author SHA1 Message Date
James Yonan
4029579e75 AsioPolySock: support bind to local address.
Signed-off-by: James Yonan <james@openvpn.net>
2017-06-22 16:48:38 -06: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
3ba37fcb91 OpenVPN 3 client: added OPENVPN_OVPNCLI_ASYNC_SETUP flag.
Added OPENVPN_OVPNCLI_ASYNC_SETUP flag, which causes most
of ClientAPI::OpenVPNClient::connect() setup to run as an
openvpn_io::post() handler.  This is potentially useful in
i/o layer implementations to guarantee sequenced execution
of core setup and handlers.

Signed-off-by: James Yonan <james@openvpn.net>
2017-04-17 23:28:36 -06:00
James Yonan
4095565b4d OpenVPN 3 client: added tun abstraction layer.
To enable, #define OPENVPN_EXTERNAL_TUN_FACTORY

Then add override in your client class (that derives from
ClientAPI::OpenVPNClient):

  virtual TunClientFactory* new_tun_factory(const ExternalTun::Config& conf, const OptionList& opt) override
  {
    ...
  }

Signed-off-by: James Yonan <james@openvpn.net>
2017-04-13 13:28:34 -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
782e8eb4ff Apple: moved some source files.
Moved Apple non-crypto source files from openvpn/applecrypto
to openvpn/apple.

Signed-off-by: James Yonan <james@openvpn.net>
2017-04-12 13:28:08 -06:00
James Yonan
f89da9619e OpenVPN 3 client: added single-thread mode:
* enabled by OPENVPN_OVPNCLI_SINGLE_THREAD compile flag.

* turns off the signal blocker.

* Adds overrideable clock_tick() virtual method with
  configurable frequency that is used when processing
  signals when the OpenVPN client is running in
  single-thread mode.

Signed-off-by: James Yonan <james@openvpn.net>
2017-04-12 12:37:41 -06:00
James Yonan
233dfde2c2 OpenVPN 3 client: fixed state->session typos.
Fixed some minor typos where state->session was used even
though a direct pointer to session was available.

Signed-off-by: James Yonan <james@openvpn.net>
2017-04-12 12:35:57 -06:00
James Yonan
d689b6dd20 Added new Apple Core Foundation wrappers:
CFHost
CFSocket
CFStream

Signed-off-by: James Yonan <james@openvpn.net>
2017-04-12 12:32:20 -06:00
James Yonan
3838a629d7 i/o layer: added OPENVPN_IO_REQUIRES_STOP compile flag.
Some non-Asio i/o reactors (such as CFRunLoop) require an
explicit action to exit the event loop.  This patch adds a
new compile flag (OPENVPN_IO_REQUIRES_STOP) that instructs
the client core to call io_context.stop(), after the
Disconnect event has been delivered, to explicitly exit
the i/o event loop.

Signed-off-by: James Yonan <james@openvpn.net>
2017-04-12 12:26:08 -06:00
James Yonan
138ec9606e asiopolysock.hpp: don't call SockOpt::set_cloexec(fd)
if fd is undefined (i.e. fd == -1).

Signed-off-by: James Yonan <james@openvpn.net>
2017-04-12 12:24:32 -06:00
James Yonan
10eb7233f2 Apple CF wrapper: renamed OWN/BORROW.
In keeping with Apple terminology, do the following renames:

  CF::BORROW -> CF::GET
  CF::OWN -> CF::CREATE

This more clearly ties into Apple's "Get" and "Create" rules
for object allocation and wrapping.

Signed-off-by: James Yonan <james@openvpn.net>
2017-04-12 12:20:02 -06:00
James Yonan
962fe87103 Apple CF wrapper: simplify cf.hpp dependency profile.
simplify cf.hpp dependency profile so that it
can easily be included without drawing in too many other
dependencies.  In particular, move code that depends
on buffer.hpp to cfhelper.hpp and remove dependency on
exception.hpp.

Signed-off-by: James Yonan <james@openvpn.net>
2017-04-12 12:16:32 -06:00
James Yonan
4fcc99c37f Objective C++: fix symbol conflicts.
Do some trivial renaming to prevent symbol
conflicts when the OpenVPN 3 client is compiled as
Objective C++ with CoreFoundation.h.

Signed-off-by: James Yonan <james@openvpn.net>
2017-04-12 12:05:28 -06:00
James Yonan
8f63cbbb6f tunwrapasio.hpp: make generic with respect to i/o layer.
Make tunwrapasio.hpp sufficiently generic that it can work
with non-Asio openvpn_io layer.

Signed-off-by: James Yonan <james@openvpn.net>
2017-04-12 12:01:55 -06:00
James Yonan
67e001349b AsioTimer: added expires_after() method.
Signed-off-by: James Yonan <james@openvpn.net>
2017-04-12 12:00:26 -06:00
James Yonan
fc7eaafd82 Apple CF wrappers: moved CFRunLoop/CFRunLoopSource wrapper
to applecrypto/cf, where all other CF wrappers currently
reside.

Signed-off-by: James Yonan <james@openvpn.net>
2017-04-12 11:59:22 -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
9e0945134e gwv4.hpp: added missing includes
Signed-off-by: James Yonan <james@openvpn.net>
2017-04-12 11:50:51 -06:00
James Yonan
916856d9b7 build script: updated Objective-C support when OBJC=1.
Signed-off-by: James Yonan <james@openvpn.net>
2017-04-12 11:42:41 -06:00
James Yonan
da99df6949 Windows: added /DUSE_ASIO to build script.
Because Asio use is now optional, USE_ASIO must be
explicitly defined by Windows build script.
2017-04-03 15:21:23 -06:00
James Yonan
b6e676f346 Work around missing thread_local in some C++ compilers.
Define USE_ASIO_THREADLOCAL if your C++ compiler doesn't
support the "thread_local" storage attribute, to fall
back to an Asio-supported alternative.  Also requires
that USE_ASIO is defined.

Signed-off-by: James Yonan <james@openvpn.net>
2017-03-30 16:12:45 -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
15b356e315 README: colorize C++ code.
Signed-off-by: James Yonan <james@openvpn.net>
2017-03-20 03:38:20 -06:00
James Yonan
2bc561857c README: fix Github em-dash issue.
Github doesn't like |mdash| in restructuredText, so replace
with a literal unicode em-dash char.

Signed-off-by: James Yonan <james@openvpn.net>
2017-03-20 03:04:55 -06:00
James Yonan
66dbbb985e README: added Developer Guide.
Signed-off-by: James Yonan <james@openvpn.net>
2017-03-20 02:26:55 -06:00
James Yonan
69ccd555ea README: note that "cli" config file must have .ovpn
extension.

Signed-off-by: James Yonan <james@openvpn.net>
2017-03-19 16:32:45 -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
2625cf1e6f README: added OpenVPN 3 Client API section.
Signed-off-by: James Yonan <james@openvpn.net>
2017-03-18 21:20:55 -06:00
James Yonan
569ec782c4 Added top-level .gitignore
Signed-off-by: James Yonan <james@openvpn.net>
2017-03-18 21:20:34 -06:00
James Yonan
0f595b236c README: added Linux section.
Signed-off-by: James Yonan <james@openvpn.net>
2017-03-18 18:08:59 -06:00
James Yonan
2fa0547367 mbedTLS: In MbedTLSRandom, add missing init/free.
In class MbedTLSRandom, added calls to mbedtls_ctr_drbg_init
and mbedtls_ctr_drbg_free that are now required by
mbedTLS 2.x.

Also added code to show mbedTLS-specific error messages
on fail.

Signed-off-by: James Yonan <james@openvpn.net>
2017-03-18 17:45:14 -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
f9af3c7910 crypto: in class CryptoDCInstance, added new virtual
method init_remote_peer_id().  This allows the DCO
layer (Data Channel Offload) to have access to the
remote peer ID.
2017-03-18 12:24:54 -06:00
James Yonan
fc85b371ab logging: removed #ifdef OPENVPN_INSTRUMENTATION, and made
the previously conditional code always included.
2017-03-18 12:24:54 -06:00
James Yonan
f8876e5ef3 build script: added new parameters
PROF=<platform> -- source vars/vars-<platform> before running
ASIO_DIR=<dir> -- specify ASIO tree
MTLS_SYS=1 -- use system mbedTLS
LZ4_SYS=1 -- build with system LZ4 compression library
2017-03-18 12:24:54 -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
1d1632da22 TokenEncrypt : standardize on 128-bit tokens
Algorithm is considerably simplified (as well as
having stronger security assurances) by making the
token size equal to the AES block size.
2017-03-18 12:24:54 -06:00
James Yonan
3ac83e36b8 manage : added new ManClientInstanceSend virtual methods
Added instance_name() and instance_id()
2017-03-18 12:24:54 -06:00
James Yonan
ceef1169af HTTP Header: minor refactor
* added name_match()
* use std::move where appropriate
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
189afb4730 proto.hpp : show Peer ID when OPENVPN_DEBUG_CLIPROTO is
defined.
2017-03-18 12:24:54 -06:00
James Yonan
14e2bb4c4a asio : added another patch (Android appears to not
support pthread_condattr_setclock).
2017-03-18 12:24:54 -06:00
James Yonan
b5b4e3a48f asio : added patches 2017-03-18 12:24:54 -06:00
James Yonan
f685303f6b asio : version update 2017-03-18 12:24:54 -06:00