Compare commits

...

2 Commits

Author SHA1 Message Date
Richard Holland
0eba2092ac clang 2024-12-14 08:55:29 +11:00
Richard Holland
ae34bbb080 allow multiple datagram monitor endpoints 2024-12-14 08:53:58 +11:00
4 changed files with 21 additions and 10 deletions

View File

@@ -1527,7 +1527,7 @@ ApplicationImp::setup(boost::program_options::variables_map const& cmdline)
reportingETL_->start();
// Datagram monitor if applicable
if (!config_->standalone() && config_->DATAGRAM_MONITOR != "")
if (!config_->standalone() && !config_->DATAGRAM_MONITOR.empty())
{
datagram_monitor_ = std::make_unique<DatagramMonitor>(*this);
if (datagram_monitor_)

View File

@@ -996,15 +996,24 @@ private:
void
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_)
{
try
{
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));
}
catch (const std::exception& e)
@@ -1015,7 +1024,10 @@ private:
}
}
close(sock);
for (auto const& ep : endpoints)
{
close(ep.second);
}
}
public:

View File

@@ -155,7 +155,7 @@ public:
std::map<std::string, PublicKey>
IMPORT_VL_KEYS; // hex string -> class PublicKey (for caching purposes)
std::string DATAGRAM_MONITOR;
std::vector<std::string> DATAGRAM_MONITOR;
enum StartUpType {
FRESH,

View File

@@ -510,11 +510,10 @@ Config::loadFromString(std::string const& fileContents)
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};
replaceColons(vecTemp);
DATAGRAM_MONITOR = vecTemp[0];
DATAGRAM_MONITOR = *s;
replaceColons(DATAGRAM_MONITOR);
}
if (getSingleSection(secConfig, SECTION_PEER_PRIVATE, strTemp, j_))