mirror of https://github.com/Icinga/icinga2.git
Merge pull request #8466 from Icinga/feature/one-connection
ApiListener#NewClientHandlerInternal(): reject connections from already connected endpoints
This commit is contained in:
commit
c154d4d50e
|
@ -679,17 +679,22 @@ void ApiListener::NewClientHandlerInternal(
|
||||||
if (ctype == ClientJsonRpc) {
|
if (ctype == ClientJsonRpc) {
|
||||||
Log(LogNotice, "ApiListener", "New JSON-RPC client");
|
Log(LogNotice, "ApiListener", "New JSON-RPC client");
|
||||||
|
|
||||||
|
if (endpoint && endpoint->GetConnected()) {
|
||||||
|
Log(LogNotice, "ApiListener")
|
||||||
|
<< "Ignoring JSON-RPC connection " << conninfo
|
||||||
|
<< ". We're already connected to Endpoint '" << endpoint->GetName() << "'.";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
JsonRpcConnection::Ptr aclient = new JsonRpcConnection(identity, verify_ok, client, role);
|
JsonRpcConnection::Ptr aclient = new JsonRpcConnection(identity, verify_ok, client, role);
|
||||||
|
|
||||||
if (endpoint) {
|
if (endpoint) {
|
||||||
bool needSync = !endpoint->GetConnected();
|
|
||||||
|
|
||||||
endpoint->AddClient(aclient);
|
endpoint->AddClient(aclient);
|
||||||
|
|
||||||
IoEngine::SpawnCoroutine(IoEngine::Get().GetIoContext(), [this, aclient, endpoint, needSync](asio::yield_context yc) {
|
IoEngine::SpawnCoroutine(IoEngine::Get().GetIoContext(), [this, aclient, endpoint](asio::yield_context yc) {
|
||||||
CpuBoundWork syncClient (yc);
|
CpuBoundWork syncClient (yc);
|
||||||
|
|
||||||
SyncClient(aclient, endpoint, needSync);
|
SyncClient(aclient, endpoint, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
} else if (!AddAnonymousClient(aclient)) {
|
} else if (!AddAnonymousClient(aclient)) {
|
||||||
|
|
Loading…
Reference in New Issue