Dobby  3.0
Dobby “Docker based Thingy” is a tool for managing and running OCI containers using crun
HttpProxyPlugin.h
1 /*
2 * If not stated otherwise in this file or this component's LICENSE file the
3 * following copyright and licenses apply:
4 *
5 * Copyright 2020 Sky UK
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 */
19 
20 #ifndef HTTPPROXYPLUGIN_H
21 #define HTTPPROXYPLUGIN_H
22 
23 #include <RdkPluginBase.h>
24 #include "DobbyRdkPluginUtils.h"
25 
26 #include <string>
27 #include <memory>
28 
29 // -----------------------------------------------------------------------------
44 {
45 public:
46  HttpProxyPlugin(std::shared_ptr<rt_dobby_schema>& containerConfig,
47  const std::shared_ptr<DobbyRdkPluginUtils> &utils,
48  const std::string &rootfsPath);
49 
50 public:
51  inline std::string name() const override
52  {
53  return mName;
54  };
55 
56  unsigned hookHints() const override;
57 
58 public:
59  bool postInstallation() override;
60  bool preCreation() override;
61  bool postHalt() override;
62 
63 public:
64  std::vector<std::string> getDependencies() const override;
65 
66 private:
67  bool setupHttpProxy();
69  bool cleanup();
70  bool addCACertificateMount();
71 
72 private:
73  bool mValid;
74  const std::string mName;
75  std::shared_ptr<rt_dobby_schema> mContainerConfig;
76  const std::string mMountedCACertsPath;
77  const rt_defs_plugins_http_proxy_data *mPluginData;
78  const std::shared_ptr<DobbyRdkPluginUtils> mUtils;
79 };
80 
81 #endif // HTTPPROXYPLUGIN_H
Used to set http proxy environment variables and optionally add additional root ca certificates to th...
Definition: HttpProxyPlugin.h:44
unsigned hookHints() const override
Set the bit flags for which hooks we're going to use.
Definition: HttpProxyPlugin.cpp:61
bool preCreation() override
Dobby Hook - run in host namespace before container creation process.
Definition: HttpProxyPlugin.cpp:108
bool postHalt() override
Dobby Hook - Run in host namespace when container terminates.
Definition: HttpProxyPlugin.cpp:128
bool cleanup()
Cleans up any temp ca-certifice.crt files created for the container.
Definition: HttpProxyPlugin.cpp:330
bool setupHttpProxy()
Adds the httpproxy and no_proxy environment variables to the container.
Definition: HttpProxyPlugin.cpp:181
bool postInstallation() override
Dobby Hook - run in host namespace once when container bundle is downloaded.
Definition: HttpProxyPlugin.cpp:75
std::string name() const override
Should return the name of the plugin.
Definition: HttpProxyPlugin.h:51
std::vector< std::string > getDependencies() const override
Should return the names of the plugins this plugin depends on.
Definition: HttpProxyPlugin.cpp:161
bool addCACertificateMount()
Adds a mount to the new ca-certificates.crt file created in the container's bundle directory in the p...
Definition: HttpProxyPlugin.cpp:250
bool addProxyToRootCABundle()
Adds the proxy's CA cert to the bundle used by the container.
Definition: HttpProxyPlugin.cpp:285
Basic object that provides the default overrides for a plugin.
Definition: RdkPluginBase.h:34