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>
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>
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>
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>
* 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>
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>
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>
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>
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>
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>
* 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>
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>
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>
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>
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