Merge pull request #8466 from Icinga/feature/one-connection

ApiListener#NewClientHandlerInternal(): reject connections from already connected endpoints
This commit is contained in:
Julian Brost 2020-11-24 16:33:15 +01:00 committed by GitHub
commit c154d4d50e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 4 deletions

View File

@ -679,17 +679,22 @@ void ApiListener::NewClientHandlerInternal(
if (ctype == ClientJsonRpc) {
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);
if (endpoint) {
bool needSync = !endpoint->GetConnected();
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);
SyncClient(aclient, endpoint, needSync);
SyncClient(aclient, endpoint, true);
});
} else if (!AddAnonymousClient(aclient)) {