mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-22 05:04:30 +02:00
Funnel messages through the generic SendUnicastRequest method to take advantage of the centralised security features.
This commit is contained in:
parent
a60c7cd2a3
commit
5fa34a3e3d
@ -73,6 +73,23 @@ void EndpointManager::UnregisterEndpoint(Endpoint::Ptr endpoint)
|
|||||||
m_Endpoints.remove(endpoint);
|
m_Endpoints.remove(endpoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EndpointManager::SendUnicastRequest(Endpoint::Ptr sender, Endpoint::Ptr recipient, const JsonRpcRequest& request, bool fromLocal)
|
||||||
|
{
|
||||||
|
if (sender == recipient)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* don't forward messages between non-local endpoints */
|
||||||
|
if (!fromLocal && !recipient->IsLocal())
|
||||||
|
return;
|
||||||
|
|
||||||
|
string method;
|
||||||
|
if (!request.GetMethod(&method))
|
||||||
|
throw InvalidArgumentException("Missing 'method' parameter.");
|
||||||
|
|
||||||
|
if (recipient->IsMethodSink(method) && recipient->IsAllowedMethodSink(method))
|
||||||
|
recipient->ProcessRequest(sender, request);
|
||||||
|
}
|
||||||
|
|
||||||
void EndpointManager::SendAnycastRequest(Endpoint::Ptr sender, const JsonRpcRequest& request, bool fromLocal)
|
void EndpointManager::SendAnycastRequest(Endpoint::Ptr sender, const JsonRpcRequest& request, bool fromLocal)
|
||||||
{
|
{
|
||||||
throw NotImplementedException();
|
throw NotImplementedException();
|
||||||
@ -92,17 +109,7 @@ void EndpointManager::SendMulticastRequest(Endpoint::Ptr sender, const JsonRpcRe
|
|||||||
|
|
||||||
for (list<Endpoint::Ptr>::iterator i = m_Endpoints.begin(); i != m_Endpoints.end(); i++)
|
for (list<Endpoint::Ptr>::iterator i = m_Endpoints.begin(); i != m_Endpoints.end(); i++)
|
||||||
{
|
{
|
||||||
Endpoint::Ptr endpoint = *i;
|
SendUnicastRequest(sender, *i, request, fromLocal);
|
||||||
|
|
||||||
if (endpoint == sender)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
/* send non-local messages to just the local endpoints */
|
|
||||||
if (!fromLocal && !endpoint->IsLocal())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (endpoint->IsMethodSink(method) && endpoint->IsAllowedMethodSink(method))
|
|
||||||
endpoint->ProcessRequest(sender, request);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,6 +36,7 @@ public:
|
|||||||
void RegisterEndpoint(Endpoint::Ptr endpoint);
|
void RegisterEndpoint(Endpoint::Ptr endpoint);
|
||||||
void UnregisterEndpoint(Endpoint::Ptr endpoint);
|
void UnregisterEndpoint(Endpoint::Ptr endpoint);
|
||||||
|
|
||||||
|
void SendUnicastRequest(Endpoint::Ptr sender, Endpoint::Ptr recipient, const JsonRpcRequest& request, bool fromLocal = true);
|
||||||
void SendAnycastRequest(Endpoint::Ptr sender, const JsonRpcRequest& request, bool fromLocal = true);
|
void SendAnycastRequest(Endpoint::Ptr sender, const JsonRpcRequest& request, bool fromLocal = true);
|
||||||
void SendMulticastRequest(Endpoint::Ptr sender, const JsonRpcRequest& request, bool fromLocal = true);
|
void SendMulticastRequest(Endpoint::Ptr sender, const JsonRpcRequest& request, bool fromLocal = true);
|
||||||
|
|
||||||
|
@ -46,7 +46,8 @@ int SubscriptionComponent::SyncSubscription(Endpoint::Ptr target, string type, c
|
|||||||
subscriptionMessage.SetMethod(nmea.Method);
|
subscriptionMessage.SetMethod(nmea.Method);
|
||||||
request.SetParams(subscriptionMessage);
|
request.SetParams(subscriptionMessage);
|
||||||
|
|
||||||
target->ProcessRequest(m_SubscriptionEndpoint, request);
|
EndpointManager::Ptr endpointManager = GetIcingaApplication()->GetEndpointManager();
|
||||||
|
endpointManager->SendUnicastRequest(m_SubscriptionEndpoint, target, request);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user