22#include "gossip_thread.h"
24#include <plugins/gossip/gossip/gossip_group_manager.h>
30#define CFG_PREFIX "/gossip/"
54 std::map<std::string, GossipGroupConfiguration> groups;
55 std::set<std::string> ignored_groups;
57 std::string prefix = CFG_PREFIX
"groups/";
59 std::shared_ptr<Configuration::ValueIterator> i(
config->
search(prefix.c_str()));
61 std::string cfg_name = std::string(i->path()).substr(prefix.length());
62 cfg_name = cfg_name.substr(0, cfg_name.find(
"/"));
64 if ((groups.find(cfg_name) == groups.end())
65 && (ignored_groups.find(cfg_name) == ignored_groups.end())) {
66 std::string cfg_prefix = prefix + cfg_name +
"/";
76 std::string addr =
config->
get_string((cfg_prefix +
"broadcast-address").c_str());
78 if (
config->
exists((cfg_prefix +
"broadcast-send-port").c_str())
79 &&
config->
exists((cfg_prefix +
"broadcast-recv-port").c_str())) {
80 unsigned int send_port =
config->
get_uint((cfg_prefix +
"broadcast-send-port").c_str());
81 unsigned int recv_port =
config->
get_uint((cfg_prefix +
"broadcast-recv-port").c_str());
83 if (send_port > 0xFFFF) {
84 throw Exception(
"Port number too high: %u > %u", send_port, 0xFFFF);
86 if (recv_port > 0xFFFF) {
87 throw Exception(
"Port number too high: %u > %u", recv_port, 0xFFFF);
92 unsigned int port =
config->
get_uint((cfg_prefix +
"broadcast-port").c_str());
95 throw Exception(
"Port number too high: %u > %u", port, 0xFFFF);
102 groups[cfg_name].crypto_key =
105 groups[cfg_name].crypto_cipher =
109 groups[cfg_name].crypto_cipher =
"aes-128-ecb";
112 "Setup encryption of type %s for group '%s'",
113 groups[cfg_name].crypto_cipher.c_str(),
120 ignored_groups.insert(cfg_name);
128 group_mgr_ = std::shared_ptr<GossipGroupManager>(
130 gossip_aspect_inifin_.
set_manager(group_mgr_.get());
virtual ~GossipThread()
Destructor.
virtual void loop()
Code to execute in the thread.
GossipThread()
Constructor.
virtual void init()
Initialize the thread.
virtual void finalize()
Finalize the thread.
Thread aspect provide a new aspect.
Configuration * config
This is the Configuration member used to access the configuration.
virtual unsigned int get_uint(const char *path)=0
Get value from configuration which is of type unsigned int.
virtual bool get_bool(const char *path)=0
Get value from configuration which is of type bool.
virtual ValueIterator * search(const char *path)=0
Iterator with search results.
virtual bool exists(const char *path)=0
Check if a given value exists.
virtual std::string get_string(const char *path)=0
Get value from configuration which is of type string.
Base class for exceptions in Fawkes.
void set_manager(GossipGroupManager *gossip_group_mgr)
Set gossip group manger.
Group configuration for initial groups.
Abstract class for a Gossip group manager.
virtual void log_debug(const char *component, const char *format,...)=0
Log debug message.
Logger * logger
This is the Logger member used to access the logger.
ServicePublisher * service_publisher
Service publisher to publish services on the network.
Thread class encapsulation of pthreads.
const char * name() const
Get name of thread.
Fawkes library namespace.