Squashed 'OpenVPN Adapter/Vendors/openvpn/' changes from da99df6..4095565

4095565 OpenVPN 3 client: added tun abstraction layer.
4bfaafc AsioTimer: use expires_after() method when possible.
782e8eb Apple: moved some source files.
f89da96 OpenVPN 3 client: added single-thread mode:
233dfde OpenVPN 3 client: fixed state->session typos.
d689b6d Added new Apple Core Foundation wrappers:
3838a62 i/o layer: added OPENVPN_IO_REQUIRES_STOP compile flag.
138ec96 asiopolysock.hpp: don't call SockOpt::set_cloexec(fd) if fd is undefined (i.e. fd == -1).
10eb723 Apple CF wrapper: renamed OWN/BORROW.
962fe87 Apple CF wrapper: simplify cf.hpp dependency profile.
4fcc99c Objective C++: fix symbol conflicts.
8f63cbb tunwrapasio.hpp: make generic with respect to i/o layer.
67e0013 AsioTimer: added expires_after() method.
fc7eaaf Apple CF wrappers: moved CFRunLoop/CFRunLoopSource wrapper to applecrypto/cf, where all other CF wrappers currently reside.
1215912 Revamped Function (our own functor object) to be more flexible.
10fa276 process.hpp: added compile option to avoid async pipe usage.
9e09451 gwv4.hpp: added missing includes
916856d build script: updated Objective-C support when OBJC=1.

git-subtree-dir: OpenVPN Adapter/Vendors/openvpn
git-subtree-split: 4095565b4de2c7d738e728cae989f632100a8ce8
This commit is contained in:
Sergey Abramchuk
2017-04-15 11:59:39 +03:00
parent f65d76170b
commit 9b95600d06
39 changed files with 773 additions and 223 deletions
+7 -4
View File
@@ -156,6 +156,9 @@ namespace openvpn {
ClientEvent::Base::Ptr ev = new ClientEvent::Disconnected();
client_options->events().add_event(std::move(ev));
#ifdef OPENVPN_IO_REQUIRES_STOP
io_context.stop();
#endif
}
}
@@ -214,7 +217,7 @@ namespace openvpn {
OPENVPN_LOG("Client terminated, reconnecting in " << seconds << "...");
server_poll_timer.cancel();
client_options->remote_reset_cache_item();
restart_wait_timer.expires_at(Time::now() + Time::Duration::seconds(seconds));
restart_wait_timer.expires_after(Time::Duration::seconds(seconds));
restart_wait_timer.async_wait([self=Ptr(this), gen=generation](const openvpn_io::error_code& error)
{
self->restart_wait_callback(gen, error);
@@ -345,7 +348,7 @@ namespace openvpn {
{
if (!conn_timer_pending && conn_timeout > 0)
{
conn_timer.expires_at(Time::now() + Time::Duration::seconds(conn_timeout));
conn_timer.expires_after(Time::Duration::seconds(conn_timeout));
conn_timer.async_wait([self=Ptr(this), gen=generation](const openvpn_io::error_code& error)
{
self->conn_timer_callback(gen, error);
@@ -393,7 +396,7 @@ namespace openvpn {
server_poll_timer.cancel();
interim_finalize();
client_options->remote_reset_cache_item();
restart_wait_timer.expires_at(Time::now() + Time::Duration::milliseconds(delay_ms));
restart_wait_timer.expires_after(Time::Duration::milliseconds(delay_ms));
restart_wait_timer.async_wait([self=Ptr(this), gen=generation](const openvpn_io::error_code& error)
{
self->restart_wait_callback(gen, error);
@@ -589,7 +592,7 @@ namespace openvpn {
restart_wait_timer.cancel();
if (client_options->server_poll_timeout_enabled())
{
server_poll_timer.expires_at(Time::now() + client_options->server_poll_timeout());
server_poll_timer.expires_after(client_options->server_poll_timeout());
server_poll_timer.async_wait([self=Ptr(this), gen=generation](const openvpn_io::error_code& error)
{
self->server_poll_callback(gen, error);
+25 -15
View File
@@ -66,8 +66,9 @@
#include <openvpn/client/cliemuexr.hpp>
#endif
#if defined(OPENVPN_CUSTOM_TUN_FACTORY)
// includer of this file must define OPENVPN_CUSTOM_TUN_FACTORY class
#if defined(OPENVPN_EXTERNAL_TUN_FACTORY)
// requires that client implements ExternalTun::Factory::new_tun_factory
#include <openvpn/tun/extern/config.hpp>
#elif defined(USE_TUN_BUILDER)
#include <openvpn/tun/builder/client.hpp>
#elif defined(OPENVPN_PLATFORM_LINUX) && !defined(OPENVPN_FORCE_TUN_NULL)
@@ -151,6 +152,10 @@ namespace openvpn {
#if defined(USE_TUN_BUILDER)
TunBuilderBase* builder = nullptr;
#endif
#if defined(OPENVPN_EXTERNAL_TUN_FACTORY)
ExternalTun::Factory* extern_tun_factory = nullptr;
#endif
};
ClientOptions(const OptionList& opt, // only needs to remain in scope for duration of constructor call
@@ -191,7 +196,7 @@ namespace openvpn {
rng.reset(new SSLLib::RandomAPI(false));
prng.reset(new SSLLib::RandomAPI(true));
#if defined(ENABLE_DCO) && !defined(OPENVPN_FORCE_TUN_NULL) && !defined(OPENVPN_CUSTOM_TUN_FACTORY)
#if defined(ENABLE_DCO) && !defined(OPENVPN_FORCE_TUN_NULL) && !defined(OPENVPN_EXTERNAL_TUN_FACTORY)
if (config.dco)
dco = DCOTransport::new_controller();
#else
@@ -292,17 +297,22 @@ namespace openvpn {
}
else
{
#if defined(OPENVPN_CUSTOM_TUN_FACTORY)
#if defined(OPENVPN_EXTERNAL_TUN_FACTORY)
{
OPENVPN_CUSTOM_TUN_FACTORY::Ptr tunconf = OPENVPN_CUSTOM_TUN_FACTORY::new_obj();
tunconf->tun_prop.session_name = session_name;
tunconf->tun_prop.google_dns_fallback = config.google_dns_fallback;
ExternalTun::Config tunconf;
tunconf.tun_prop.layer = layer;
tunconf.tun_prop.session_name = session_name;
tunconf.tun_prop.google_dns_fallback = config.google_dns_fallback;
if (tun_mtu)
tunconf->tun_prop.mtu = tun_mtu;
tunconf->frame = frame;
tunconf->stats = cli_stats;
tunconf->tun_prop.remote_list = remote_list;
tun_factory = tunconf;
tunconf.tun_prop.mtu = tun_mtu;
tunconf.frame = frame;
tunconf.stats = cli_stats;
tunconf.tun_prop.remote_list = remote_list;
tunconf.tun_persist = config.tun_persist;
tunconf.stop = config.stop;
tun_factory.reset(config.extern_tun_factory->new_tun_factory(tunconf, opt));
if (!tun_factory)
throw option_error("OPENVPN_EXTERNAL_TUN_FACTORY: no tun factory");
}
#elif defined(USE_TUN_BUILDER)
{
@@ -448,7 +458,7 @@ namespace openvpn {
// IPv6
{
const unsigned int n = push_base->singleton.extend(opt, "block-ipv6");
if (!n && config.ipv6() == IPv6Setting::NO)
if (!n && config.ipv6() == IPv6Setting::No)
push_base->singleton.emplace_back("block-ipv6");
}
}
@@ -463,9 +473,9 @@ namespace openvpn {
PeerInfo::Set::Ptr pi(new PeerInfo::Set);
// IPv6
if (config.ipv6() == IPv6Setting::NO)
if (config.ipv6() == IPv6Setting::No)
pi->emplace_back("IV_IPv6", "0");
else if (config.ipv6() == IPv6Setting::YES)
else if (config.ipv6() == IPv6Setting::Yes)
pi->emplace_back("IV_IPv6", "1");
// autologin sessions
+3 -3
View File
@@ -777,7 +777,7 @@ namespace openvpn {
{
if (!received_options.partial())
{
push_request_timer.expires_at(now() + dur);
push_request_timer.expires_after(dur);
push_request_timer.async_wait([self=Ptr(this), dur](const openvpn_io::error_code& error)
{
self->send_push_request_callback(dur, error);
@@ -865,7 +865,7 @@ namespace openvpn {
void schedule_inactive_timer()
{
inactive_timer.expires_at(now() + inactive_duration);
inactive_timer.expires_after(inactive_duration);
inactive_timer.async_wait([self=Ptr(this)](const openvpn_io::error_code& error)
{
self->inactive_callback(error);
@@ -955,7 +955,7 @@ namespace openvpn {
void schedule_info_hold_callback()
{
Base::update_now();
info_hold_timer.expires_at(now() + Time::Duration::seconds(1));
info_hold_timer.expires_after(Time::Duration::seconds(1));
info_hold_timer.async_wait([self=Ptr(this)](const openvpn_io::error_code& error)
{
self->info_hold_callback(error);