mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 05:37:22 +02:00
repairs to failure case for keypair generation
This commit is contained in:
parent
bfdf74367e
commit
83e8c248bd
3 changed files with 28 additions and 10 deletions
|
@ -1057,9 +1057,17 @@ void DomainServer::sendHeartbeatToIceServer() {
|
||||||
if (!_iceServerSocket.getAddress().isNull()) {
|
if (!_iceServerSocket.getAddress().isNull()) {
|
||||||
|
|
||||||
auto& accountManager = AccountManager::getInstance();
|
auto& accountManager = AccountManager::getInstance();
|
||||||
|
auto limitedNodeList = DependencyManager::get<LimitedNodeList>();
|
||||||
|
|
||||||
if (!accountManager.getAccountInfo().hasPrivateKey()) {
|
if (!accountManager.getAccountInfo().hasPrivateKey()) {
|
||||||
qWarning() << "Cannot send an ice-server heartbeat without a private key for signature.";
|
qWarning() << "Cannot send an ice-server heartbeat without a private key for signature.";
|
||||||
qWarning() << "Please re-launch your domain-server to generate a new keypair.";
|
qWarning() << "Waiting for keypair generation to complete before sending ICE heartbeat.";
|
||||||
|
|
||||||
|
if (!limitedNodeList->getSessionUUID().isNull()) {
|
||||||
|
accountManager.generateNewDomainKeypair(limitedNodeList->getSessionUUID());
|
||||||
|
} else {
|
||||||
|
qWarning() << "Attempting to send ICE server heartbeat with no domain ID. This is not supported";
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1068,9 +1076,7 @@ void DomainServer::sendHeartbeatToIceServer() {
|
||||||
// QDataStream and the possibility of IPv6 address for the sockets.
|
// QDataStream and the possibility of IPv6 address for the sockets.
|
||||||
static auto heartbeatPacket = NLPacket::create(PacketType::ICEServerHeartbeat);
|
static auto heartbeatPacket = NLPacket::create(PacketType::ICEServerHeartbeat);
|
||||||
|
|
||||||
bool shouldRecreatePacket = false;
|
bool shouldRecreatePacket = false
|
||||||
|
|
||||||
auto limitedNodeList = DependencyManager::get<LimitedNodeList>();
|
|
||||||
|
|
||||||
if (heartbeatPacket->getPayloadSize() > 0) {
|
if (heartbeatPacket->getPayloadSize() > 0) {
|
||||||
// if either of our sockets have changed we need to re-sign the heartbeat
|
// if either of our sockets have changed we need to re-sign the heartbeat
|
||||||
|
|
|
@ -359,6 +359,8 @@ void AccountManager::passSuccessToCallback(QNetworkReply* requestReply) {
|
||||||
qCDebug(networking) << "Received JSON response from metaverse API that has no matching callback.";
|
qCDebug(networking) << "Received JSON response from metaverse API that has no matching callback.";
|
||||||
qCDebug(networking) << QJsonDocument::fromJson(requestReply->readAll());
|
qCDebug(networking) << QJsonDocument::fromJson(requestReply->readAll());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
requestReply->deleteLater();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -378,6 +380,8 @@ void AccountManager::passErrorToCallback(QNetworkReply* requestReply) {
|
||||||
qCDebug(networking) << "Error" << requestReply->error() << "-" << requestReply->errorString();
|
qCDebug(networking) << "Error" << requestReply->error() << "-" << requestReply->errorString();
|
||||||
qCDebug(networking) << requestReply->readAll();
|
qCDebug(networking) << requestReply->readAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
requestReply->deleteLater();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -607,7 +611,6 @@ void AccountManager::generateNewKeypair(bool isUserKeypair, const QUuid& domainI
|
||||||
if (!isUserKeypair) {
|
if (!isUserKeypair) {
|
||||||
keypairGenerator->setDomainID(domainID);
|
keypairGenerator->setDomainID(domainID);
|
||||||
_accountInfo.setDomainID(domainID);
|
_accountInfo.setDomainID(domainID);
|
||||||
qDebug() << "The account info domain ID is now" << _accountInfo.getDomainID();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// start keypair generation when the thread starts
|
// start keypair generation when the thread starts
|
||||||
|
@ -630,7 +633,7 @@ void AccountManager::generateNewKeypair(bool isUserKeypair, const QUuid& domainI
|
||||||
|
|
||||||
void AccountManager::processGeneratedKeypair() {
|
void AccountManager::processGeneratedKeypair() {
|
||||||
|
|
||||||
qCDebug(networking) << "Generated 2048-bit RSA keypair. Storing private key and uploading public key.";
|
qCDebug(networking) << "Generated 2048-bit RSA keypair. Uploading public key now.";
|
||||||
|
|
||||||
RSAKeypairGenerator* keypairGenerator = qobject_cast<RSAKeypairGenerator*>(sender());
|
RSAKeypairGenerator* keypairGenerator = qobject_cast<RSAKeypairGenerator*>(sender());
|
||||||
|
|
||||||
|
@ -677,7 +680,9 @@ void AccountManager::processGeneratedKeypair() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AccountManager::publicKeyUploadSuceeded() {
|
void AccountManager::publicKeyUploadSucceeded(QNetworkReply& reply) {
|
||||||
|
qDebug() << "Uploaded public key to Metaverse API. RSA keypair generation is completed.";
|
||||||
|
|
||||||
// public key upload complete - store the matching private key and persist the account to settings
|
// public key upload complete - store the matching private key and persist the account to settings
|
||||||
_accountInfo.setPrivateKey(_pendingPrivateKey);
|
_accountInfo.setPrivateKey(_pendingPrivateKey);
|
||||||
_pendingPrivateKey.clear();
|
_pendingPrivateKey.clear();
|
||||||
|
@ -687,16 +692,23 @@ void AccountManager::publicKeyUploadSuceeded() {
|
||||||
_isWaitingForKeypairResponse = false;
|
_isWaitingForKeypairResponse = false;
|
||||||
|
|
||||||
emit newKeypair();
|
emit newKeypair();
|
||||||
|
|
||||||
|
// delete the reply object now that we are done with it
|
||||||
|
reply.deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AccountManager::publicKeyUploadFailed() {
|
void AccountManager::publicKeyUploadFailed(QNetworkReply& reply) {
|
||||||
// the public key upload has failed
|
// the public key upload has failed
|
||||||
|
qWarning() << "Public key upload failed from AccountManager" << reply.errorString();
|
||||||
|
|
||||||
// we aren't waiting for a response any longer
|
// we aren't waiting for a response any longer
|
||||||
_isWaitingForKeypairResponse = false;
|
_isWaitingForKeypairResponse = false;
|
||||||
|
|
||||||
// clear our pending private key
|
// clear our pending private key
|
||||||
_pendingPrivateKey.clear();
|
_pendingPrivateKey.clear();
|
||||||
|
|
||||||
|
// delete the reply object now that we are done with it
|
||||||
|
reply.deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AccountManager::handleKeypairGenerationError() {
|
void AccountManager::handleKeypairGenerationError() {
|
||||||
|
|
|
@ -105,8 +105,8 @@ private slots:
|
||||||
void processReply();
|
void processReply();
|
||||||
void handleKeypairGenerationError();
|
void handleKeypairGenerationError();
|
||||||
void processGeneratedKeypair();
|
void processGeneratedKeypair();
|
||||||
void publicKeyUploadSuceeded();
|
void publicKeyUploadSucceeded(QNetworkReply& reply);
|
||||||
void publicKeyUploadFailed();
|
void publicKeyUploadFailed(QNetworkReply& reply);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AccountManager();
|
AccountManager();
|
||||||
|
|
Loading…
Reference in a new issue