if (!endpoint->GetSyncing()) {
Log(LogNotice, "ApiListener")
- << "Sending message to '" << endpoint->GetName() << "'";
+ << "Sending message '" << message->Get("method") << "' to '" << endpoint->GetName() << "'";
double maxTs = 0;
Zone::Ptr myZone = Zone::GetLocalZone();
- /* only relay the message to a) the same zone, b) the parent zone and c) direct child zones */
- if (targetZone != myZone && targetZone != myZone->GetParent() && targetZone->GetParent() != myZone)
+ /* only relay the message to a) the same zone, b) the parent zone and c) direct child zones. Exception is a global zone. */
+ if (!targetZone->GetGlobal() &&
+ targetZone != myZone &&
+ targetZone != myZone->GetParent() &&
+ targetZone->GetParent() != myZone) {
+ Log(LogCritical, "ApiListener")
+ << "Not relaying message '" << message->Get("method") << "'. Not in the same/parent/child zone.";
return true;
+ }
Endpoint::Ptr myEndpoint = GetLocalEndpoint();
bool relayed = false, log_needed = false, log_done = false;
- for (const Endpoint::Ptr& endpoint : targetZone->GetEndpoints()) {
+ std::set<Endpoint::Ptr> targetEndpoints;
+
+ if (targetZone->GetGlobal()) {
+ targetEndpoints = myZone->GetEndpoints();
+
+ for (const Zone::Ptr& zone : ConfigType::GetObjectsByType<Zone>()) {
+ /* Fetch immediate child zone members */
+ if (zone->GetParent() == myZone) {
+ std::set<Endpoint::Ptr> endpoints = zone->GetEndpoints();
+ targetEndpoints.insert(endpoints.begin(), endpoints.end());
+ }
+ }
+ } else {
+ targetEndpoints = targetZone->GetEndpoints();
+ }
+
+ for (const Endpoint::Ptr& endpoint : targetEndpoints) {
/* don't relay messages to ourselves */
if (endpoint == GetLocalEndpoint())
continue;