mirror of
https://github.com/overte-org/overte.git
synced 2025-04-25 20:36:38 +02:00
Cleanup and fix
This commit is contained in:
parent
50446619f5
commit
6a47884fcf
4 changed files with 25 additions and 20 deletions
|
@ -442,7 +442,7 @@ void EntityServer::domainSettingsRequestFailed() {
|
||||||
void EntityServer::startDynamicDomainVerification() {
|
void EntityServer::startDynamicDomainVerification() {
|
||||||
qCDebug(entities) << "Starting Dynamic Domain Verification...";
|
qCDebug(entities) << "Starting Dynamic Domain Verification...";
|
||||||
|
|
||||||
QString thisPlaceName = DependencyManager::get<AddressManager>()->currentAddress().authority();
|
QString thisPlaceName = DependencyManager::get<AddressManager>()->getPlaceName();
|
||||||
|
|
||||||
EntityTreePointer tree = std::static_pointer_cast<EntityTree>(_tree);
|
EntityTreePointer tree = std::static_pointer_cast<EntityTree>(_tree);
|
||||||
QHash<QString, EntityItemID> localMap(tree->getEntityCertificateIDMap());
|
QHash<QString, EntityItemID> localMap(tree->getEntityCertificateIDMap());
|
||||||
|
@ -466,7 +466,7 @@ void EntityServer::startDynamicDomainVerification() {
|
||||||
networkRequest.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true);
|
networkRequest.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true);
|
||||||
networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
|
networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
|
||||||
QUrl requestURL = NetworkingConstants::METAVERSE_SERVER_URL;
|
QUrl requestURL = NetworkingConstants::METAVERSE_SERVER_URL;
|
||||||
requestURL.setPath("/api/v1/commerce/proof_of_purchase_status/transfer");
|
requestURL.setPath("/api/v1/commerce/proof_of_purchase_status/location");
|
||||||
QJsonObject request;
|
QJsonObject request;
|
||||||
request["certificate_id"] = i.key();
|
request["certificate_id"] = i.key();
|
||||||
networkRequest.setUrl(requestURL);
|
networkRequest.setUrl(requestURL);
|
||||||
|
@ -486,8 +486,11 @@ void EntityServer::startDynamicDomainVerification() {
|
||||||
// ZRF FIXME!!!
|
// ZRF FIXME!!!
|
||||||
//if (jsonObject["place_name"].toString() != thisPlaceName) {
|
//if (jsonObject["place_name"].toString() != thisPlaceName) {
|
||||||
if (false) {
|
if (false) {
|
||||||
qCDebug(entities) << "Entity's cert's place name isn't the current place name; deleting entity" << i.value();
|
qCDebug(entities) << "Entity's cert's place name" << jsonObject["place_name"].toString()
|
||||||
|
<< "isn't the current place name" << thisPlaceName << "; deleting entity" << i.value();
|
||||||
tree->deleteEntity(i.value(), true);
|
tree->deleteEntity(i.value(), true);
|
||||||
|
} else {
|
||||||
|
qCDebug(entities) << "Entity passed dynamic domain verification:" << i.value();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
qCDebug(entities) << "Call to proof_of_purchase_status endpoint failed; deleting entity" << i.value();
|
qCDebug(entities) << "Call to proof_of_purchase_status endpoint failed; deleting entity" << i.value();
|
||||||
|
|
|
@ -750,7 +750,7 @@ void Wallet::handleChallengeOwnershipPacket(QSharedPointer<ReceivedMessage> pack
|
||||||
decryptedTextPacket->write(certID);
|
decryptedTextPacket->write(certID);
|
||||||
decryptedTextPacket->write(decryptedTextByteArray);
|
decryptedTextPacket->write(decryptedTextByteArray);
|
||||||
|
|
||||||
qCDebug(commerce) << "Sending ChallengeOwnership Packet containing decrypted text";
|
qCDebug(commerce) << "Sending ChallengeOwnership Packet containing decrypted text" << decryptedTextByteArray << "for CertID" << certID;
|
||||||
|
|
||||||
nodeList->sendPacket(std::move(decryptedTextPacket), *sendingNode);
|
nodeList->sendPacket(std::move(decryptedTextPacket), *sendingNode);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -111,7 +111,7 @@ void EntityEditPacketSender::queueEditEntityMessage(PacketType type,
|
||||||
#endif
|
#endif
|
||||||
queueOctreeEditMessage(type, bufferOut);
|
queueOctreeEditMessage(type, bufferOut);
|
||||||
if (type == PacketType::EntityAdd && !properties.getCertificateID().isEmpty()) {
|
if (type == PacketType::EntityAdd && !properties.getCertificateID().isEmpty()) {
|
||||||
emit addingEntityWithCertificate(properties.getCertificateID(), DependencyManager::get<AddressManager>()->currentAddress().authority());
|
emit addingEntityWithCertificate(properties.getCertificateID(), DependencyManager::get<AddressManager>()->getPlaceName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1187,10 +1187,25 @@ QByteArray EntityTree::computeEncryptedNonce(const QString& certID, const QStrin
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EntityTree::verifyDecryptedNonce(const QString& certID, const QString& decryptedNonce) {
|
bool EntityTree::verifyDecryptedNonce(const QString& certID, const QString& decryptedNonce) {
|
||||||
|
|
||||||
|
QReadLocker certIdMapLocker(&_entityCertificateIDMapLock);
|
||||||
|
EntityItemID id = _entityCertificateIDMap.value(certID);
|
||||||
|
|
||||||
QWriteLocker locker(&_certNonceMapLock);
|
QWriteLocker locker(&_certNonceMapLock);
|
||||||
QString actualNonce = _certNonceMap.take(certID).toString();
|
QString actualNonce = _certNonceMap.take(certID).toString();
|
||||||
|
|
||||||
return actualNonce == decryptedNonce;
|
bool verificationSuccess = (actualNonce == decryptedNonce);
|
||||||
|
if (!verificationSuccess) {
|
||||||
|
if (!id.isNull()) {
|
||||||
|
qCDebug(entities) << "Ownership challenge for Cert ID" << certID << "failed; deleting entity" << id
|
||||||
|
<< "\nActual nonce:" << actualNonce << "\nDecrypted nonce:" << decryptedNonce;
|
||||||
|
deleteEntity(id, true);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
qCDebug(entities) << "Ownership challenge for Cert ID" << certID << "succeeded; keeping entity" << id;
|
||||||
|
}
|
||||||
|
|
||||||
|
return verificationSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityTree::validatePop(const QString& certID, const EntityItemID& entityItemID, const SharedNodePointer& senderNode, bool isRetryingValidation) {
|
void EntityTree::validatePop(const QString& certID, const EntityItemID& entityItemID, const SharedNodePointer& senderNode, bool isRetryingValidation) {
|
||||||
|
@ -1289,22 +1304,9 @@ void EntityTree::processChallengeOwnershipPacket(ReceivedMessage& message, const
|
||||||
QString certID(message.read(certIDByteArraySize));
|
QString certID(message.read(certIDByteArraySize));
|
||||||
QString decryptedText(message.read(decryptedTextByteArraySize));
|
QString decryptedText(message.read(decryptedTextByteArraySize));
|
||||||
|
|
||||||
EntityItemID id;
|
|
||||||
{
|
|
||||||
QReadLocker certIdMapLocker(&_entityCertificateIDMapLock);
|
|
||||||
id = _entityCertificateIDMap.value(certID);
|
|
||||||
}
|
|
||||||
|
|
||||||
emit killChallengeOwnershipTimeoutTimer(certID);
|
emit killChallengeOwnershipTimeoutTimer(certID);
|
||||||
|
|
||||||
if (!verifyDecryptedNonce(certID, decryptedText)) {
|
verifyDecryptedNonce(certID, decryptedText);
|
||||||
if (!id.isNull()) {
|
|
||||||
qCDebug(entities) << "Ownership challenge for Cert ID" << certID << "failed; deleting entity" << id;
|
|
||||||
deleteEntity(id, true);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
qCDebug(entities) << "Ownership challenge for Cert ID" << certID << "succeeded; keeping entity" << id;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int EntityTree::processEditPacketData(ReceivedMessage& message, const unsigned char* editData, int maxLength,
|
int EntityTree::processEditPacketData(ReceivedMessage& message, const unsigned char* editData, int maxLength,
|
||||||
|
|
Loading…
Reference in a new issue