Dobby  3.0
Dobby “Docker based Thingy” is a tool for managing and running OCI containers using crun
Public Member Functions | Private Member Functions | Private Attributes | List of all members
HttpProxyPlugin Class Reference

Used to set http proxy environment variables and optionally add additional root ca certificates to the container. More...

#include <HttpProxyPlugin.h>

Inheritance diagram for HttpProxyPlugin:
Inheritance graph
[legend]
Collaboration diagram for HttpProxyPlugin:
Collaboration graph
[legend]

Public Member Functions

 HttpProxyPlugin (std::shared_ptr< rt_dobby_schema > &containerConfig, const std::shared_ptr< DobbyRdkPluginUtils > &utils, const std::string &rootfsPath)
 
std::string name () const override
 Should return the name of the plugin. More...
 
unsigned hookHints () const override
 Set the bit flags for which hooks we're going to use. More...
 
bool postInstallation () override
 Dobby Hook - run in host namespace once when container bundle is downloaded.
 
bool preCreation () override
 Dobby Hook - run in host namespace before container creation process.
 
bool postHalt () override
 Dobby Hook - Run in host namespace when container terminates.
 
std::vector< std::string > getDependencies () const override
 Should return the names of the plugins this plugin depends on. More...
 
- Public Member Functions inherited from RdkPluginBase
virtual bool createRuntime ()
 
virtual bool createContainer ()
 
virtual bool postStart ()
 
virtual bool postStop ()
 

Private Member Functions

bool setupHttpProxy ()
 Adds the httpproxy and no_proxy environment variables to the container. More...
 
bool addProxyToRootCABundle ()
 Adds the proxy's CA cert to the bundle used by the container. More...
 
bool cleanup ()
 Cleans up any temp ca-certifice.crt files created for the container. More...
 
bool addCACertificateMount ()
 Adds a mount to the new ca-certificates.crt file created in the container's bundle directory in the preCreation hook. More...
 

Private Attributes

bool mValid
 
const std::string mName
 
std::shared_ptr< rt_dobby_schema > mContainerConfig
 
const std::string mMountedCACertsPath
 
const rt_defs_plugins_http_proxy_data * mPluginData
 
const std::shared_ptr< DobbyRdkPluginUtilsmUtils
 

Additional Inherited Members

- Public Types inherited from IDobbyRdkPlugin
enum  HintFlags : unsigned {
  PostInstallationFlag = (1 << 0) , PreCreationFlag = (1 << 1) , CreateRuntimeFlag = (1 << 2) , CreateContainerFlag = (1 << 3) ,
  PostStartFlag = (1 << 5) , PostHaltFlag = (1 << 6) , PostStopFlag = (1 << 7) , Unknown = 0
}
 Bit flags that should be returned by hookHints. More...
 

Detailed Description

Used to set http proxy environment variables and optionally add additional root ca certificates to the container.

It sets the http_proxy and no_proxy environment variables based on the plugin data. And if a root CA certificate is included in the plugin data it will append that onto the end of the /etc/ssl/certs/ca-certificates.crt file.

Member Function Documentation

◆ addCACertificateMount()

bool HttpProxyPlugin::addCACertificateMount ( )
private

Adds a mount to the new ca-certificates.crt file created in the container's bundle directory in the preCreation hook.

Returns
true on success, false on failure.

◆ addProxyToRootCABundle()

bool HttpProxyPlugin::addProxyToRootCABundle ( )
private

Adds the proxy's CA cert to the bundle used by the container.

It copies the existing /etc/ssl/certs/ca-certificates.crt file to the container bundle location and then appends the supplied .crt / .pem certificate to it.

It then adds a bind mount to the container start-up so that we overlay the modified the file into the container.

Returns
true on success, false on failure.

◆ cleanup()

bool HttpProxyPlugin::cleanup ( )
private

Cleans up any temp ca-certifice.crt files created for the container.

Returns
true on success, false on failure.

◆ getDependencies()

std::vector< std::string > HttpProxyPlugin::getDependencies ( ) const
overridevirtual

Should return the names of the plugins this plugin depends on.

This can be used to determine the order in which the plugins should be processed when running hooks.

Returns
Names of the plugins this plugin depends on.

Reimplemented from RdkPluginBase.

◆ hookHints()

unsigned HttpProxyPlugin::hookHints ( ) const
overridevirtual

Set the bit flags for which hooks we're going to use.

This plugin uses all the hooks so set all the flags

Implements IDobbyRdkPlugin.

◆ name()

std::string HttpProxyPlugin::name ( ) const
inlineoverridevirtual

Should return the name of the plugin.

Returns
string with the name of the hook.

Implements IDobbyRdkPlugin.

◆ setupHttpProxy()

bool HttpProxyPlugin::setupHttpProxy ( )
private

Adds the httpproxy and no_proxy environment variables to the container.

Returns
true on success, false on failure.

The documentation for this class was generated from the following files: