OpenVPN 3 Core Library
Loading...
Searching...
No Matches
initprocess.hpp
Go to the documentation of this file.
1
// OpenVPN -- An application to securely tunnel IP networks
2
// over a single port, with support for SSL/TLS-based
3
// session authentication and key exchange,
4
// packet encryption, packet authentication, and
5
// packet compression.
6
//
7
// Copyright (C) 2012- OpenVPN Inc.
8
//
9
// SPDX-License-Identifier: MPL-2.0 OR AGPL-3.0-only WITH openvpn3-openssl-exception
10
//
11
12
// Process-wide static initialization
13
14
#pragma once
15
16
#include <thread>
17
#include <mutex>
18
19
#include <
openvpn/common/size.hpp
>
20
#include <
openvpn/common/base64.hpp
>
21
#include <
openvpn/time/time.hpp
>
22
#include <
openvpn/compress/compress.hpp
>
23
#include <
openvpn/init/engineinit.hpp
>
24
25
namespace
openvpn::InitProcess
{
26
class
Init
27
{
28
private
:
29
class
InitImpl
30
{
31
public
:
32
InitImpl
()
33
{
34
// initialize time base
35
Time::reset_base
();
36
37
// initialize compression
38
CompressContext::init_static
();
39
40
// init OpenSSL if included
41
init_openssl
(
"auto"
);
42
43
base64_init_static
();
44
}
45
46
~InitImpl
()
47
{
48
base64_uninit_static
();
49
}
50
};
51
52
// process-wide singular instance
53
inline
static
std::weak_ptr<InitImpl>
init_instance
;
// GLOBAL
54
inline
static
std::mutex
the_instance_mutex
;
// GLOBAL
55
56
// istance of this class to refcount
57
std::shared_ptr<InitImpl>
initptr
;
58
59
public
:
60
Init
()
61
{
62
const
std::lock_guard<std::mutex> lock(
the_instance_mutex
);
63
64
initptr
=
init_instance
.lock();
65
if
(!
initptr
)
66
{
67
initptr
= std::make_shared<InitImpl>();
68
init_instance
=
initptr
;
69
}
70
}
71
72
~Init
()
73
{
74
// explicitly reset smart pointer to make the destructor run under the lock_guard
75
const
std::lock_guard<std::mutex> lock(
the_instance_mutex
);
76
initptr
.reset();
77
}
78
};
79
80
}
// namespace openvpn::InitProcess
base64.hpp
openvpn::CompressContext::init_static
static void init_static()
Definition
compress.hpp:520
openvpn::InitProcess::Init::InitImpl
Definition
initprocess.hpp:30
openvpn::InitProcess::Init::InitImpl::~InitImpl
~InitImpl()
Definition
initprocess.hpp:46
openvpn::InitProcess::Init::InitImpl::InitImpl
InitImpl()
Definition
initprocess.hpp:32
openvpn::InitProcess::Init
Definition
initprocess.hpp:27
openvpn::InitProcess::Init::init_instance
static std::weak_ptr< InitImpl > init_instance
Definition
initprocess.hpp:53
openvpn::InitProcess::Init::the_instance_mutex
static std::mutex the_instance_mutex
Definition
initprocess.hpp:54
openvpn::InitProcess::Init::initptr
std::shared_ptr< InitImpl > initptr
Definition
initprocess.hpp:57
openvpn::InitProcess::Init::Init
Init()
Definition
initprocess.hpp:60
openvpn::InitProcess::Init::~Init
~Init()
Definition
initprocess.hpp:72
openvpn::TimeType< oulong >::reset_base
static void reset_base()
Definition
time.hpp:420
compress.hpp
engineinit.hpp
openvpn::InitProcess
Definition
ovpncli.hpp:34
openvpn::init_openssl
void init_openssl(const std::string &engine)
Definition
engineinit.hpp:35
openvpn::base64_uninit_static
void base64_uninit_static()
Definition
base64.hpp:310
openvpn::base64_init_static
void base64_init_static()
Definition
base64.hpp:302
size.hpp
time.hpp
openvpn
init
initprocess.hpp
Generated by
1.9.8