repairs to issues discovered during ID change

This commit is contained in:
Stephen Birarda 2016-02-23 10:57:54 -08:00
parent d510ee0e47
commit e2f02347dd
3 changed files with 17 additions and 4 deletions

View file

@ -1055,6 +1055,15 @@ void DomainServer::sendHeartbeatToDataServer(const QString& networkAddress) {
void DomainServer::sendHeartbeatToIceServer() {
if (!_iceServerSocket.getAddress().isNull()) {
auto& accountManager = AccountManager::getInstance();
if (!accountManager.getAccountInfo().hasPrivateKey()) {
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.";
return;
}
// NOTE: I'd love to specify the correct size for the packet here, but it's a little trickey with
// QDataStream and the possibility of IPv6 address for the sockets.
static auto heartbeatPacket = NLPacket::create(PacketType::ICEServerHeartbeat);
@ -1073,7 +1082,9 @@ void DomainServer::sendHeartbeatToIceServer() {
HifiSockAddr publicSocket, localSocket;
heartbeatStream >> senderUUID >> publicSocket >> localSocket;
if (publicSocket != limitedNodeList->getPublicSockAddr() || localSocket != limitedNodeList->getLocalSockAddr()) {
if (senderUUID != limitedNodeList->getSessionUUID()
|| publicSocket != limitedNodeList->getPublicSockAddr()
|| localSocket != limitedNodeList->getLocalSockAddr()) {
shouldRecreatePacket = true;
}
} else {
@ -1095,7 +1106,6 @@ void DomainServer::sendHeartbeatToIceServer() {
auto plaintext = QByteArray::fromRawData(heartbeatPacket->getPayload(), heartbeatPacket->getPayloadSize());
// generate a signature for the plaintext data in the packet
auto& accountManager = AccountManager::getInstance();
auto signature = accountManager.getAccountInfo().signPlaintext(plaintext);
// pack the signature with the data

View file

@ -237,8 +237,7 @@ void IceServer::publicKeyReplyFinished(QNetworkReply* reply) {
if (responseObject[STATUS_KEY].toString() == SUCCESS_VALUE) {
auto dataObject = responseObject[DATA_KEY].toObject();
if (dataObject.contains(PUBLIC_KEY_KEY)) {
_domainPublicKeys.emplace(domainID,
QByteArray::fromBase64(dataObject[PUBLIC_KEY_KEY].toString().toUtf8()));
_domainPublicKeys[domainID] = QByteArray::fromBase64(dataObject[PUBLIC_KEY_KEY].toString().toUtf8());
} else {
qWarning() << "There was no public key present in response for domain with ID" << domainID;
}

View file

@ -589,6 +589,10 @@ void AccountManager::generateNewKeypair(bool isUserKeypair, const QUuid& domainI
return;
}
// clear the current private key
qDebug() << "Clearing current private key in DataServerAccountInfo";
_accountInfo.setPrivateKey(QByteArray());
// setup a new QThread to generate the keypair on, in case it takes a while
QThread* generateThread = new QThread(this);
generateThread->setObjectName("Account Manager Generator Thread");