OpenVPN 3 Core Library
Loading...
Searching...
No Matches
manage.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// Server-side client manager
13
14#ifndef OPENVPN_SERVER_MANAGE_H
15#define OPENVPN_SERVER_MANAGE_H
16
17#include <string>
18#include <vector>
19
22#include <openvpn/common/rc.hpp>
27#include <openvpn/ssl/proto.hpp>
32
33
35// Auth constants
36enum Type : unsigned short;
37} // namespace openvpn::AuthStatus
38
39
40
41// used by ipma_notify()
42struct ovpn_tun_head_ipma;
43
45
46// Base class for the per-client-instance state of the ManServer.
47// Each client instance uses this class to send data to the man layer.
48// The methods here are VPN protocol agnostic.
49struct SendBase : public virtual RC<thread_unsafe_refcount>
50{
52
53 // clang-format off
54
55 // ID
56 virtual std::string instance_name() const = 0;
57 virtual std::uint64_t instance_id() const = 0;
58
59 // Status
60 virtual bool is_stopped() const = 0;
61
62 // Retrieve any potentially collected debug state.
63 virtual std::string to_string_debug() const = 0;
64
65 // IP-mapped ACL (IPMA) notification
66 virtual void ipma_notify(const struct ovpn_tun_head_ipma &ipma) = 0;
67
68 // return a JSON string describing connected user
69 virtual std::string describe_user(const bool show_userprop) = 0;
70
71 // disconnect
72 virtual void disconnect_user(const HaltRestart::Type type,
73 const AuthStatus::Type auth_status,
74 const std::string &reason,
75 const std::string &client_reason) = 0;
76
77 // set ACL index for user
78 virtual void set_acl_index(const int acl_index,
79 const std::string *username,
80 const bool challenge) = 0;
81
82 // notify of local user properties update
83 virtual void userprop_local_update() = 0;
84
85 // create, update, or delete a DOMA ACL
86 virtual Json::Value doma_acl(const Json::Value &root) = 0;
87
88 // send a control channel message to client
89 virtual void post_info_user(BufferPtr &&info) = 0;
90
91 // clang-format on
92};
93
94// Send builds on SendBase but also adds OpenVPN
95// protocol-specific methods.
96struct Send : public SendBase
97{
99
100 virtual void pre_stop() = 0;
101 virtual void stop() = 0;
102
103 // clang-format off
104 virtual void auth_request(const AuthCreds::Ptr &auth_creds,
105 const AuthCert::Ptr &auth_cert,
106 const PeerAddr::Ptr &peer_addr) = 0;
108
110 virtual void app_control(const std::string &msg) = 0;
111
112 // bandwidth stats notification
113 virtual void stats_notify(const PeerStats &ps, const bool final) = 0;
114
115 // client float notification
116 virtual void float_notify(const PeerAddr::Ptr &addr) = 0;
117
118 // override keepalive parameters
119 virtual void keepalive_override(unsigned int &keepalive_ping,
120 unsigned int &keepalive_timeout) = 0;
121 // clang-format on
122};
123
124// Base class for the client instance receiver. Note that all
125// client instance receivers (transport, routing, management,
126// etc.) must inherit virtually from RC because the client instance
127// object will inherit from multiple receivers.
128struct Recv : public virtual RC<thread_unsafe_refcount>
129{
131
132 virtual void stop() = 0;
133
134 // clang-format off
135 virtual void auth_failed(const std::string &reason,
136 const std::string &client_reason) = 0;
137
138 virtual void push_reply(std::vector<BufferPtr> &&push_msgs) = 0;
139
140 // push a halt or restart message to client
142 const std::string &reason,
143 const std::string &client_reason) = 0;
144 // clang-format on
145
146 // send control channel message
147 virtual void post_cc_msg(BufferPtr &&msg) = 0;
148
149 // schedule a low-level connection disconnect in seconds
150 virtual void schedule_disconnect(const unsigned int seconds) = 0;
151
152 // schedule an auth pending disconnect in seconds
153 virtual void schedule_auth_pending_timeout(const unsigned int seconds) = 0;
154
155 // set up relay to target
156 virtual void relay(const IP::Addr &target, const int port) = 0;
157
158 // get client bandwidth stats
159 virtual PeerStats stats_poll() = 0;
160
161 // return true if management layer should preserve session ID
162 virtual bool should_preserve_session_id() = 0;
163
164 // get native reference to client instance
166};
167
168struct Factory : public RC<thread_unsafe_refcount>
169{
171
172 virtual void start() = 0;
173 virtual void stop() = 0;
174
175 virtual Send::Ptr new_man_obj(Recv *instance) = 0;
176};
177
178} // namespace openvpn::ManClientInstance
179
180#endif
The smart pointer class.
Definition rc.hpp:119
Reference count base class for objects tracked by RCPtr. Disallows copying and assignment.
Definition rc.hpp:912
virtual Send::Ptr new_man_obj(Recv *instance)=0
virtual bool should_preserve_session_id()=0
virtual void schedule_auth_pending_timeout(const unsigned int seconds)=0
virtual void post_cc_msg(BufferPtr &&msg)=0
virtual TunClientInstance::NativeHandle tun_native_handle()=0
virtual void relay(const IP::Addr &target, const int port)=0
virtual PeerStats stats_poll()=0
virtual void auth_failed(const std::string &reason, const std::string &client_reason)=0
virtual void push_halt_restart_msg(const HaltRestart::Type type, const std::string &reason, const std::string &client_reason)=0
virtual void schedule_disconnect(const unsigned int seconds)=0
virtual void push_reply(std::vector< BufferPtr > &&push_msgs)=0
virtual std::uint64_t instance_id() const =0
virtual void post_info_user(BufferPtr &&info)=0
virtual std::string to_string_debug() const =0
virtual void disconnect_user(const HaltRestart::Type type, const AuthStatus::Type auth_status, const std::string &reason, const std::string &client_reason)=0
virtual bool is_stopped() const =0
virtual std::string describe_user(const bool show_userprop)=0
virtual Json::Value doma_acl(const Json::Value &root)=0
virtual void ipma_notify(const struct ovpn_tun_head_ipma &ipma)=0
virtual std::string instance_name() const =0
virtual void set_acl_index(const int acl_index, const std::string *username, const bool challenge)=0
virtual void auth_request(const AuthCreds::Ptr &auth_creds, const AuthCert::Ptr &auth_cert, const PeerAddr::Ptr &peer_addr)=0
virtual void app_control(const std::string &msg)=0
virtual void keepalive_override(unsigned int &keepalive_ping, unsigned int &keepalive_timeout)=0
virtual void float_notify(const PeerAddr::Ptr &addr)=0
virtual void stats_notify(const PeerStats &ps, const bool final)=0
virtual void push_request(ProtoContext::ProtoConfig::Ptr pconf)=0
proxy_host_port port
#define msg(flags,...)