Clean up on tunnel disconnect and prevent 3 authenticated connections

more-debug
Simon Stürz 2018-08-15 17:40:24 +02:00
parent 26fe64fdfb
commit adee6b62be
2 changed files with 17 additions and 3 deletions

View File

@ -44,6 +44,7 @@ void AuthenticationProcess::startVerificationProcess()
env.insert("AWS_DEFAULT_REGION", "eu-west-1"); env.insert("AWS_DEFAULT_REGION", "eu-west-1");
if (m_dynamicCredentials) { if (m_dynamicCredentials) {
qCDebug(dcAuthenticationProcess()) << "Using dynamic credentials" << m_awsAccessKeyId << m_awsSecretAccessKey << m_awsSessionToken;
env.insert("AWS_ACCESS_KEY_ID", m_awsAccessKeyId); env.insert("AWS_ACCESS_KEY_ID", m_awsAccessKeyId);
env.insert("AWS_SECRET_ACCESS_KEY", m_awsSecretAccessKey); env.insert("AWS_SECRET_ACCESS_KEY", m_awsSecretAccessKey);
env.insert("AWS_SESSION_TOKEN", m_awsSessionToken); env.insert("AWS_SESSION_TOKEN", m_awsSessionToken);

View File

@ -141,13 +141,20 @@ void ProxyServer::onClientDisconnected(const QUuid &clientId)
// Unregister from json rpc server // Unregister from json rpc server
m_jsonRpcServer->unregisterClient(proxyClient); m_jsonRpcServer->unregisterClient(proxyClient);
// Check if
if (m_tunnels.contains(proxyClient->token())) {
// There is a tunnel connection for this client, remove the tunnel and disconnect also the other client
ProxyClient *remoteClient = getRemoteClient(proxyClient);
m_tunnels.remove(remoteClient->token());
if (remoteClient) {
remoteClient->interface()->killClientConnection(remoteClient->clientId(), "Tunnel client disconnected");
}
}
// Delete the proxy client // Delete the proxy client
proxyClient->deleteLater(); proxyClient->deleteLater();
// TODO: Disconnect also the other tunnel client
} }
// TODO: Clean up this client since it does not exist any more
} }
void ProxyServer::onClientDataAvailable(const QUuid &clientId, const QByteArray &data) void ProxyServer::onClientDataAvailable(const QUuid &clientId, const QByteArray &data)
@ -203,6 +210,12 @@ void ProxyServer::onProxyClientAuthenticated()
qCDebug(dcProxyServer()) << " name:" << proxyClient->name(); qCDebug(dcProxyServer()) << " name:" << proxyClient->name();
qCDebug(dcProxyServer()) << " uuid:" << proxyClient->uuid(); qCDebug(dcProxyServer()) << " uuid:" << proxyClient->uuid();
if (m_tunnels.contains(proxyClient->token())) {
qCWarning(dcProxyServer()) << "There is already a tunnel connection for this token. A third client is not allowed.";
proxyClient->interface()->killClientConnection(proxyClient->clientId(), "There is already an established tunnel with this token.");
return;
}
// Check if we have an other authenticated client with this token // Check if we have an other authenticated client with this token
if (m_authenticatedClients.keys().contains(proxyClient->token())) { if (m_authenticatedClients.keys().contains(proxyClient->token())) {
// Found a client with this token // Found a client with this token