Leosac  0.8.0
Open Source Access Control
Leosac::RemoteControl Class Reference

This class handle the remote control of leosac. More...

#include <RemoteControl.hpp>

+ Collaboration diagram for Leosac::RemoteControl:

Public Member Functions

 RemoteControl (zmqpp::context &ctx, Kernel &kernel, const boost::property_tree::ptree &cfg)
 
void update ()
 

Private Types

using CommandHandlerMap = std::map< std::string, std::function< bool(zmqpp::message *msg_in, zmqpp::message *msg_out)> >
 

Private Member Functions

bool handle_module_config (zmqpp::message *msg_in, zmqpp::message *msg_out)
 Extract and verify content from user-message and call implementation. More...
 
bool handle_module_list (zmqpp::message *msg_in, zmqpp::message *msg_out)
 Extract and verify content from message and call implementation. More...
 
bool handle_sync_from (zmqpp::message *msg_in, zmqpp::message *msg_out)
 Extract and verify content from message and call sync_from() More...
 
bool handle_save (zmqpp::message *msg_in, zmqpp::message *msg_out)
 Save the current configuration to disk. More...
 
bool handle_general_config (zmqpp::message *msg_in, zmqpp::message *msg_out)
 Command handler for GENERAL_CONFIG. More...
 
bool handle_config_version (zmqpp::message *msg_in, zmqpp::message *msg_out)
 Command handler for CONFIG_VERSION command. More...
 
void module_list (zmqpp::message *message_out)
 Implements the module list command. More...
 
void module_config (const std::string &module, ConfigManager::ConfigFormat cfg_format, zmqpp::message *message_out)
 Implements the MODULE_CONFIG command. More...
 
void general_config (ConfigManager::ConfigFormat cfg_format, zmqpp::message *msg_out)
 Implements GLOBAL_CONFIG API call. More...
 
void handle_msg ()
 Register by core and called when message arrives. More...
 
void process_config (const boost::property_tree::ptree &cfg)
 
bool gather_remote_module_list (zmqpp::socket &s, std::list< std::string > &remote_modules)
 Build the list of modules (their name) running on the remote host. More...
 
bool receive_remote_config (zmqpp::socket &s, std::map< std::string, bool > &cfg)
 After sending a bunch of MODULE_CONFIG command, wait for reply. More...
 
bool gather_remote_config (zmqpp::socket &s, std::list< std::string > &start_list, std::list< std::string > &stop_list)
 Will retrieve the config for a remote leosac unit. More...
 

Private Attributes

Kernelkernel_
 
zmqpp::socket socket_
 Public ROUTER. More...
 
std::string public_key_
 z85 encoded public curve key More...
 
std::string secret_key_
 z85 encoded private curve key More...
 
zmqpp::auth auth_
 
zmqpp::context & context_
 
CommandHandlerMap command_handlers_
 
RemoteControlSecurity security_
 Object to check remote user permission before processing their request. More...
 
std::string current_client_idt_
 

Friends

class Kernel
 

Detailed Description

This class handle the remote control of leosac.

It's responsibility is to expose a secure socket on the network and filter request from the world, passing legit message to the rest of the application.

See also
Remote Control Documentation For an overview of the Remote Control functionality.

Definition at line 40 of file RemoteControl.hpp.

Member Typedef Documentation

◆ CommandHandlerMap

using Leosac::RemoteControl::CommandHandlerMap = std::map<std::string, std::function<bool(zmqpp::message *msg_in, zmqpp::message *msg_out)> >
private

Definition at line 174 of file RemoteControl.hpp.

Constructor & Destructor Documentation

◆ RemoteControl()

RemoteControl::RemoteControl ( zmqpp::context &  ctx,
Kernel kernel,
const boost::property_tree::ptree &  cfg 
)

Definition at line 39 of file RemoteControl.cpp.

Member Function Documentation

◆ gather_remote_config()

bool Leosac::RemoteControl::gather_remote_config ( zmqpp::socket &  s,
std::list< std::string > &  start_list,
std::list< std::string > &  stop_list 
)
private

Will retrieve the config for a remote leosac unit.

The socket shall be already connected to the remote endpoint.

It will populate the stop_list and start_list with a list of to respectively stop and start.

◆ gather_remote_module_list()

bool Leosac::RemoteControl::gather_remote_module_list ( zmqpp::socket &  s,
std::list< std::string > &  remote_modules 
)
private

Build the list of modules (their name) running on the remote host.

We issue the MODULE_LIST command in order to do that.

Returns
false if we can't get this list.

◆ general_config()

void RemoteControl::general_config ( ConfigManager::ConfigFormat  cfg_format,
zmqpp::message *  msg_out 
)
private

Implements GLOBAL_CONFIG API call.

This returns configuration information unrelated to modules.

Definition at line 207 of file RemoteControl.cpp.

◆ handle_config_version()

bool RemoteControl::handle_config_version ( zmqpp::message *  msg_in,
zmqpp::message *  msg_out 
)
private

Command handler for CONFIG_VERSION command.

It shall return the current version of the configuration. This is used for synchronization purpose.

Definition at line 361 of file RemoteControl.cpp.

◆ handle_general_config()

bool RemoteControl::handle_general_config ( zmqpp::message *  msg_in,
zmqpp::message *  msg_out 
)
private

Command handler for GENERAL_CONFIG.

Returning false means the source message was malformed.

Definition at line 345 of file RemoteControl.cpp.

◆ handle_module_config()

bool RemoteControl::handle_module_config ( zmqpp::message *  msg_in,
zmqpp::message *  msg_out 
)
private

Extract and verify content from user-message and call implementation.

Returning false means the source message was malformed.

Definition at line 229 of file RemoteControl.cpp.

◆ handle_module_list()

bool RemoteControl::handle_module_list ( zmqpp::message *  msg_in,
zmqpp::message *  msg_out 
)
private

Extract and verify content from message and call implementation.

Returning false means the source message was malformed.

Definition at line 246 of file RemoteControl.cpp.

◆ handle_msg()

void RemoteControl::handle_msg ( )
private

Register by core and called when message arrives.

Definition at line 94 of file RemoteControl.cpp.

◆ handle_save()

bool RemoteControl::handle_save ( zmqpp::message *  msg_in,
zmqpp::message *  msg_out 
)
private

Save the current configuration to disk.

Returning false means the source message was malformed.

Definition at line 327 of file RemoteControl.cpp.

◆ handle_sync_from()

bool RemoteControl::handle_sync_from ( zmqpp::message *  msg_in,
zmqpp::message *  msg_out 
)
private

Extract and verify content from message and call sync_from()

Returning false means the source message was malformed.

Definition at line 260 of file RemoteControl.cpp.

◆ module_config()

void RemoteControl::module_config ( const std::string &  module,
ConfigManager::ConfigFormat  cfg_format,
zmqpp::message *  message_out 
)
private

Implements the MODULE_CONFIG command.

Definition at line 163 of file RemoteControl.cpp.

◆ module_list()

void RemoteControl::module_list ( zmqpp::message *  message_out)
private

Implements the module list command.

It fetch the list of module from the module manager object.

Definition at line 154 of file RemoteControl.cpp.

◆ process_config()

void RemoteControl::process_config ( const boost::property_tree::ptree &  cfg)
private

Definition at line 51 of file RemoteControl.cpp.

◆ receive_remote_config()

bool Leosac::RemoteControl::receive_remote_config ( zmqpp::socket &  s,
std::map< std::string, bool > &  cfg 
)
private

After sending a bunch of MODULE_CONFIG command, wait for reply.

Update the configuration manager object with the newly received configuration. Also update additional configuration if needed.

If receiving command timeout (>3s) return false;

◆ update()

void RemoteControl::update ( )

Definition at line 375 of file RemoteControl.cpp.

Friends And Related Function Documentation

◆ Kernel

friend class Kernel
friend

Definition at line 186 of file RemoteControl.hpp.

Member Data Documentation

◆ auth_

zmqpp::auth Leosac::RemoteControl::auth_
private

Definition at line 168 of file RemoteControl.hpp.

◆ command_handlers_

CommandHandlerMap Leosac::RemoteControl::command_handlers_
private

Definition at line 176 of file RemoteControl.hpp.

◆ context_

zmqpp::context& Leosac::RemoteControl::context_
private

Definition at line 169 of file RemoteControl.hpp.

◆ current_client_idt_

std::string Leosac::RemoteControl::current_client_idt_
private

Definition at line 183 of file RemoteControl.hpp.

◆ kernel_

Kernel& Leosac::RemoteControl::kernel_
private

Definition at line 151 of file RemoteControl.hpp.

◆ public_key_

std::string Leosac::RemoteControl::public_key_
private

z85 encoded public curve key

Definition at line 161 of file RemoteControl.hpp.

◆ secret_key_

std::string Leosac::RemoteControl::secret_key_
private

z85 encoded private curve key

Definition at line 166 of file RemoteControl.hpp.

◆ security_

RemoteControlSecurity Leosac::RemoteControl::security_
private

Object to check remote user permission before processing their request.

Definition at line 181 of file RemoteControl.hpp.

◆ socket_

zmqpp::socket Leosac::RemoteControl::socket_
private

Public ROUTER.

Definition at line 156 of file RemoteControl.hpp.


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