mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 21:43:13 +02:00
re-attempt keypair generation for domain check in if missing
This commit is contained in:
parent
4b4ea25ed6
commit
540d1615cd
3 changed files with 37 additions and 18 deletions
|
@ -588,6 +588,12 @@ void AccountManager::requestProfileError(QNetworkReply::NetworkError error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void AccountManager::generateNewKeypair(bool isUserKeypair, const QUuid& domainID) {
|
void AccountManager::generateNewKeypair(bool isUserKeypair, const QUuid& domainID) {
|
||||||
|
|
||||||
|
if (thread() != QThread::currentThread()) {
|
||||||
|
QMetaObject::invokeMethod(this, "generateNewKeypair", Q_ARG(bool, isUserKeypair), Q_ARG(QUuid, domainID));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!isUserKeypair && domainID.isNull()) {
|
if (!isUserKeypair && domainID.isNull()) {
|
||||||
qCWarning(networking) << "AccountManager::generateNewKeypair called for domain keypair with no domain ID. Will not generate keypair.";
|
qCWarning(networking) << "AccountManager::generateNewKeypair called for domain keypair with no domain ID. Will not generate keypair.";
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -107,6 +107,7 @@ private slots:
|
||||||
void processGeneratedKeypair();
|
void processGeneratedKeypair();
|
||||||
void publicKeyUploadSucceeded(QNetworkReply& reply);
|
void publicKeyUploadSucceeded(QNetworkReply& reply);
|
||||||
void publicKeyUploadFailed(QNetworkReply& reply);
|
void publicKeyUploadFailed(QNetworkReply& reply);
|
||||||
|
void generateNewKeypair(bool isUserKeypair = true, const QUuid& domainID = QUuid());
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AccountManager();
|
AccountManager();
|
||||||
|
@ -119,8 +120,6 @@ private:
|
||||||
void passSuccessToCallback(QNetworkReply* reply);
|
void passSuccessToCallback(QNetworkReply* reply);
|
||||||
void passErrorToCallback(QNetworkReply* reply);
|
void passErrorToCallback(QNetworkReply* reply);
|
||||||
|
|
||||||
void generateNewKeypair(bool isUserKeypair = true, const QUuid& domainID = QUuid());
|
|
||||||
|
|
||||||
QUrl _authURL;
|
QUrl _authURL;
|
||||||
QMap<QNetworkReply*, JSONCallbackParameters> _pendingCallbackMap;
|
QMap<QNetworkReply*, JSONCallbackParameters> _pendingCallbackMap;
|
||||||
|
|
||||||
|
|
|
@ -265,6 +265,28 @@ void NodeList::sendDomainServerCheckIn() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check if we're missing a keypair we need to verify ourselves with the domain-server
|
||||||
|
auto& accountManager = AccountManager::getInstance();
|
||||||
|
const QUuid& connectionToken = _domainHandler.getConnectionToken();
|
||||||
|
|
||||||
|
// we assume that we're on the same box as the DS if it has the same local address and
|
||||||
|
// it didn't present us with a connection token to use for username signature
|
||||||
|
bool localhostDomain = _domainHandler.getSockAddr().getAddress() == QHostAddress::LocalHost
|
||||||
|
|| (_domainHandler.getSockAddr().getAddress() == _localSockAddr.getAddress() && connectionToken.isNull());
|
||||||
|
|
||||||
|
bool requiresUsernameSignature = !_domainHandler.isConnected() && !connectionToken.isNull() && !localhostDomain;
|
||||||
|
|
||||||
|
if (requiresUsernameSignature && !accountManager.getAccountInfo().hasPrivateKey()) {
|
||||||
|
qWarning() << "A keypair is required to present a username signature to the domain-server"
|
||||||
|
<< "but no keypair is present. Waiting for keypair generation to complete.";
|
||||||
|
accountManager.generateNewUserKeypair();
|
||||||
|
|
||||||
|
connect(&accountManager, &AccountManager::newKeypair, this, &NodeList::sendDomainServerCheckIn);
|
||||||
|
|
||||||
|
// don't send the check in packet - wait for the keypair first
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto domainPacket = NLPacket::create(domainPacketType);
|
auto domainPacket = NLPacket::create(domainPacketType);
|
||||||
|
|
||||||
QDataStream packetStream(domainPacket.get());
|
QDataStream packetStream(domainPacket.get());
|
||||||
|
@ -289,23 +311,15 @@ void NodeList::sendDomainServerCheckIn() {
|
||||||
|
|
||||||
// pack our data to send to the domain-server
|
// pack our data to send to the domain-server
|
||||||
packetStream << _ownerType << _publicSockAddr << _localSockAddr << _nodeTypesOfInterest.toList();
|
packetStream << _ownerType << _publicSockAddr << _localSockAddr << _nodeTypesOfInterest.toList();
|
||||||
|
|
||||||
// if this is a connect request, and we can present a username signature, send it along
|
if (!_domainHandler.isConnected()) {
|
||||||
if (!_domainHandler.isConnected() ) {
|
DataServerAccountInfo& accountInfo = accountManager.getAccountInfo();
|
||||||
|
|
||||||
DataServerAccountInfo& accountInfo = AccountManager::getInstance().getAccountInfo();
|
|
||||||
packetStream << accountInfo.getUsername();
|
packetStream << accountInfo.getUsername();
|
||||||
|
|
||||||
// get connection token from the domain-server
|
// if this is a connect request, and we can present a username signature, send it along
|
||||||
const QUuid& connectionToken = _domainHandler.getConnectionToken();
|
if (requiresUsernameSignature && accountManager.getAccountInfo().hasPrivateKey()) {
|
||||||
|
const QByteArray& usernameSignature = accountManager.getAccountInfo().getUsernameSignature(connectionToken);
|
||||||
if (!connectionToken.isNull()) {
|
packetStream << usernameSignature;
|
||||||
|
|
||||||
const QByteArray& usernameSignature = AccountManager::getInstance().getAccountInfo().getUsernameSignature(connectionToken);
|
|
||||||
|
|
||||||
if (!usernameSignature.isEmpty()) {
|
|
||||||
packetStream << usernameSignature;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue