mirror of
https://github.com/Xahau/xahaud.git
synced 2025-11-29 06:55:49 +00:00
allow multiple datagram monitor endpoints
This commit is contained in:
@@ -1527,7 +1527,7 @@ ApplicationImp::setup(boost::program_options::variables_map const& cmdline)
|
|||||||
reportingETL_->start();
|
reportingETL_->start();
|
||||||
|
|
||||||
// Datagram monitor if applicable
|
// Datagram monitor if applicable
|
||||||
if (!config_->standalone() && config_->DATAGRAM_MONITOR != "")
|
if (!config_->standalone() && !config_->DATAGRAM_MONITOR.empty())
|
||||||
{
|
{
|
||||||
datagram_monitor_ = std::make_unique<DatagramMonitor>(*this);
|
datagram_monitor_ = std::make_unique<DatagramMonitor>(*this);
|
||||||
if (datagram_monitor_)
|
if (datagram_monitor_)
|
||||||
|
|||||||
@@ -996,15 +996,25 @@ private:
|
|||||||
void
|
void
|
||||||
monitorThread()
|
monitorThread()
|
||||||
{
|
{
|
||||||
auto endpoint = parseEndpoint(app_.config().DATAGRAM_MONITOR);
|
|
||||||
int sock = createSocket(endpoint);
|
std::vector<std::pair<EndpointInfo, int>> endpoints;
|
||||||
|
|
||||||
|
for (auto const& epStr : app_.config().DATAGRAM_MONITOR)
|
||||||
|
{
|
||||||
|
auto endpoint = parseEndpoint(epStr);
|
||||||
|
endpoints.push_back(std::make_pair(endpoint, createSocket(endpoint)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
while (running_)
|
while (running_)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
auto info = generateServerInfo();
|
auto info = generateServerInfo();
|
||||||
sendPacket(sock, endpoint, info);
|
for (auto const& ep : endpoints)
|
||||||
|
{
|
||||||
|
sendPacket(ep.second, ep.first, info);
|
||||||
|
}
|
||||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||||
}
|
}
|
||||||
catch (const std::exception& e)
|
catch (const std::exception& e)
|
||||||
@@ -1015,7 +1025,10 @@ private:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
close(sock);
|
for (auto const& ep : endpoints)
|
||||||
|
{
|
||||||
|
close(ep.second);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ public:
|
|||||||
std::map<std::string, PublicKey>
|
std::map<std::string, PublicKey>
|
||||||
IMPORT_VL_KEYS; // hex string -> class PublicKey (for caching purposes)
|
IMPORT_VL_KEYS; // hex string -> class PublicKey (for caching purposes)
|
||||||
|
|
||||||
std::string DATAGRAM_MONITOR;
|
std::vector<std::string> DATAGRAM_MONITOR;
|
||||||
|
|
||||||
enum StartUpType {
|
enum StartUpType {
|
||||||
FRESH,
|
FRESH,
|
||||||
|
|||||||
@@ -510,11 +510,10 @@ Config::loadFromString(std::string const& fileContents)
|
|||||||
NETWORK_ID = beast::lexicalCastThrow<uint32_t>(strTemp);
|
NETWORK_ID = beast::lexicalCastThrow<uint32_t>(strTemp);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getSingleSection(secConfig, SECTION_DATAGRAM_MONITOR, strTemp, j_))
|
if (auto s = getIniFileSection(secConfig, SECTION_DATAGRAM_MONITOR))
|
||||||
{
|
{
|
||||||
std::vector<std::string> vecTemp{strTemp};
|
DATAGRAM_MONITOR = *s;
|
||||||
replaceColons(vecTemp);
|
replaceColons(DATAGRAM_MONITOR);
|
||||||
DATAGRAM_MONITOR = vecTemp[0];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getSingleSection(secConfig, SECTION_PEER_PRIVATE, strTemp, j_))
|
if (getSingleSection(secConfig, SECTION_PEER_PRIVATE, strTemp, j_))
|
||||||
|
|||||||
Reference in New Issue
Block a user