OpenVPN 3 Core Library
Loading...
Searching...
No Matches
proxy.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#pragma once
13
16
17namespace openvpn {
18class ProxySettings : public RC<thread_unsafe_refcount>
19{
20 public:
21 OPENVPN_EXCEPTION(proxy_error);
22
24
25 class ProxyAction : public Action
26 {
27 public:
29
30 ProxyAction(ProxySettings::Ptr parent_arg, bool del_arg)
31 : parent(parent_arg), del(del_arg)
32 {
33 }
34
35 virtual void execute(std::ostream &os) override
36 {
37 os << to_string() << std::endl;
38 if (parent)
39 parent->set_proxy(del);
40 }
41
42 virtual std::string to_string() const override
43 {
44 std::ostringstream os;
45 if (parent && parent->config.defined())
46 os << "ProxyAction: auto config: " << parent->config.to_string();
47 return os.str();
48 }
49
50 private:
52 bool del;
53 };
54
56 : config(config_arg)
57 {
58 }
59
60 virtual void set_proxy(bool del) = 0;
61
62 template <class T>
63 static void add_actions(const TunBuilderCapture &settings,
64 ActionList &create,
65 ActionList &destroy)
66 {
67 ProxySettings::Ptr proxy(new T(settings.proxy_auto_config_url));
68 ProxyAction::Ptr create_action(new ProxyAction(proxy, false));
69 ProxyAction::Ptr destroy_action(new ProxyAction(proxy, true));
70 create.add(create_action);
71 destroy.add(destroy_action);
72 }
73
74 const std::string sname = "OpenVPNConnect";
75
77};
78} // namespace openvpn
void add(Action *action)
Definition action.hpp:57
ProxyAction(ProxySettings::Ptr parent_arg, bool del_arg)
Definition proxy.hpp:30
virtual std::string to_string() const override
Definition proxy.hpp:42
const ProxySettings::Ptr parent
Definition proxy.hpp:51
virtual void execute(std::ostream &os) override
Definition proxy.hpp:35
RCPtr< ProxyAction > Ptr
Definition proxy.hpp:28
OPENVPN_EXCEPTION(proxy_error)
ProxySettings(const TunBuilderCapture::ProxyAutoConfigURL &config_arg)
Definition proxy.hpp:55
RCPtr< ProxySettings > Ptr
Definition proxy.hpp:23
const std::string sname
Definition proxy.hpp:74
virtual void set_proxy(bool del)=0
static void add_actions(const TunBuilderCapture &settings, ActionList &create, ActionList &destroy)
Definition proxy.hpp:63
TunBuilderCapture::ProxyAutoConfigURL config
Definition proxy.hpp:76
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
Class for handling Proxy Auto-Configuration (PAC) URLs.
Definition capture.hpp:403
ProxyAutoConfigURL proxy_auto_config_url
Definition capture.hpp:1096
std::ostringstream os