mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 17:49:27 +02:00
store registration token in more compact form, begin parse on domain-server
This commit is contained in:
parent
949f79e945
commit
b0895ea83a
4 changed files with 27 additions and 14 deletions
|
@ -373,6 +373,14 @@ void DomainServer::readAvailableDatagrams() {
|
||||||
senderSockAddr.getAddress(), senderSockAddr.getPort());
|
senderSockAddr.getAddress(), senderSockAddr.getPort());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (requestType == PacketTypeDomainConnectRequest) {
|
||||||
|
QDataStream packetStream(receivedPacket);
|
||||||
|
packetStream.skipRawData(numBytesForPacketHeader(receivedPacket));
|
||||||
|
|
||||||
|
QByteArray registrationToken;
|
||||||
|
packetStream >> registrationToken;
|
||||||
|
|
||||||
|
qDebug() << "The token received is" << registrationToken.toHex();
|
||||||
} else if (requestType == PacketTypeRequestAssignment) {
|
} else if (requestType == PacketTypeRequestAssignment) {
|
||||||
|
|
||||||
// construct the requested assignment from the packet data
|
// construct the requested assignment from the packet data
|
||||||
|
|
|
@ -26,14 +26,15 @@ void DomainInfo::reset() {
|
||||||
_hostname = QString();
|
_hostname = QString();
|
||||||
_sockAddr.setAddress(QHostAddress::Null);
|
_sockAddr.setAddress(QHostAddress::Null);
|
||||||
_connectionSecret = QString();
|
_connectionSecret = QString();
|
||||||
_registrationToken = QString();
|
_registrationToken = QByteArray();
|
||||||
_rootAuthenticationURL = QUrl();
|
_rootAuthenticationURL = QUrl();
|
||||||
_publicKey = QString();
|
_publicKey = QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DomainInfo::parseAuthInformationFromJsonObject(const QJsonObject& jsonObject) {
|
void DomainInfo::parseAuthInformationFromJsonObject(const QJsonObject& jsonObject) {
|
||||||
_connectionSecret = QUuid(jsonObject["connection_uuid"].toString());
|
_connectionSecret = QUuid(jsonObject["connection_uuid"].toString());
|
||||||
_registrationToken = jsonObject["registration_token"].toString();
|
qDebug() << jsonObject["registration_token"];
|
||||||
|
_registrationToken = QByteArray::fromHex(jsonObject["registration_token"].toString().toUtf8());
|
||||||
_publicKey = jsonObject["public_key"].toString();
|
_publicKey = jsonObject["public_key"].toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,8 +43,7 @@ public:
|
||||||
const QUuid& getConnectionSecret() const { return _connectionSecret; }
|
const QUuid& getConnectionSecret() const { return _connectionSecret; }
|
||||||
void setConnectionSecret(const QUuid& connectionSecret) { _connectionSecret = connectionSecret; }
|
void setConnectionSecret(const QUuid& connectionSecret) { _connectionSecret = connectionSecret; }
|
||||||
|
|
||||||
const QString& getRegistrationToken() const { return _registrationToken; }
|
const QByteArray& getRegistrationToken() const { return _registrationToken; }
|
||||||
void setRegistrationToken(const QString& registrationToken);
|
|
||||||
|
|
||||||
const QUrl& getRootAuthenticationURL() const { return _rootAuthenticationURL; }
|
const QUrl& getRootAuthenticationURL() const { return _rootAuthenticationURL; }
|
||||||
void setRootAuthenticationURL(const QUrl& rootAuthenticationURL) { _rootAuthenticationURL = rootAuthenticationURL; }
|
void setRootAuthenticationURL(const QUrl& rootAuthenticationURL) { _rootAuthenticationURL = rootAuthenticationURL; }
|
||||||
|
@ -60,7 +59,7 @@ private:
|
||||||
QString _hostname;
|
QString _hostname;
|
||||||
HifiSockAddr _sockAddr;
|
HifiSockAddr _sockAddr;
|
||||||
QUuid _connectionSecret;
|
QUuid _connectionSecret;
|
||||||
QString _registrationToken;
|
QByteArray _registrationToken;
|
||||||
QUrl _rootAuthenticationURL;
|
QUrl _rootAuthenticationURL;
|
||||||
QString _publicKey;
|
QString _publicKey;
|
||||||
};
|
};
|
||||||
|
|
|
@ -90,7 +90,7 @@ bool NodeList::packetVersionAndHashMatch(const QByteArray& packet) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const QSet<PacketType> NON_VERIFIED_PACKETS = QSet<PacketType>() << PacketTypeDomainList
|
const QSet<PacketType> NON_VERIFIED_PACKETS = QSet<PacketType>() << PacketTypeDomainList
|
||||||
<< PacketTypeDomainListRequest << PacketTypeDomainServerAuthRequest
|
<< PacketTypeDomainListRequest << PacketTypeDomainServerAuthRequest << PacketTypeDomainConnectRequest
|
||||||
<< PacketTypeStunResponse << PacketTypeDataServerConfirm
|
<< PacketTypeStunResponse << PacketTypeDataServerConfirm
|
||||||
<< PacketTypeDataServerGet << PacketTypeDataServerPut << PacketTypeDataServerSend
|
<< PacketTypeDataServerGet << PacketTypeDataServerPut << PacketTypeDataServerSend
|
||||||
<< PacketTypeCreateAssignment << PacketTypeRequestAssignment;
|
<< PacketTypeCreateAssignment << PacketTypeRequestAssignment;
|
||||||
|
@ -476,17 +476,23 @@ void NodeList::sendDomainServerCheckIn() {
|
||||||
// send a STUN request to figure it out
|
// send a STUN request to figure it out
|
||||||
sendSTUNRequest();
|
sendSTUNRequest();
|
||||||
} else if (!_domainInfo.getIP().isNull()) {
|
} else if (!_domainInfo.getIP().isNull()) {
|
||||||
if (_domainInfo.getRootAuthenticationURL().isEmpty() || !_sessionUUID.isNull()
|
if (_domainInfo.getRootAuthenticationURL().isEmpty()
|
||||||
|| !_domainInfo.getRegistrationToken().isEmpty()) {
|
|| !_sessionUUID.isNull()
|
||||||
|
|| !_domainInfo.getRegistrationToken().isEmpty() ) {
|
||||||
// construct the DS check in packet
|
// construct the DS check in packet
|
||||||
|
|
||||||
PacketType domainPacketType = _domainInfo.getRegistrationToken().isEmpty()
|
PacketType domainPacketType = _domainInfo.getRegistrationToken().isEmpty()
|
||||||
? PacketTypeDomainListRequest
|
? PacketTypeDomainListRequest : PacketTypeDomainConnectRequest;
|
||||||
: PacketTypeDomainConnectRequest;
|
|
||||||
|
|
||||||
QByteArray domainServerPacket = byteArrayWithPopluatedHeader(domainPacketType);
|
QByteArray domainServerPacket = byteArrayWithPopluatedHeader(domainPacketType);
|
||||||
QDataStream packetStream(&domainServerPacket, QIODevice::Append);
|
QDataStream packetStream(&domainServerPacket, QIODevice::Append);
|
||||||
|
|
||||||
|
if (domainPacketType == PacketTypeDomainConnectRequest) {
|
||||||
|
// we have a registration token to present to the domain-server
|
||||||
|
// send that along in each packet until we get a list back from the domain-server
|
||||||
|
packetStream << _domainInfo.getRegistrationToken();
|
||||||
|
}
|
||||||
|
|
||||||
// pack our data to send to the domain-server
|
// pack our data to send to the domain-server
|
||||||
packetStream << _ownerType << _publicSockAddr
|
packetStream << _ownerType << _publicSockAddr
|
||||||
<< HifiSockAddr(QHostAddress(getHostOrderLocalAddress()), _nodeSocket.localPort())
|
<< HifiSockAddr(QHostAddress(getHostOrderLocalAddress()), _nodeSocket.localPort())
|
||||||
|
@ -508,8 +514,7 @@ void NodeList::sendDomainServerCheckIn() {
|
||||||
|
|
||||||
// increment the count of un-replied check-ins
|
// increment the count of un-replied check-ins
|
||||||
_numNoReplyDomainCheckIns++;
|
_numNoReplyDomainCheckIns++;
|
||||||
} else if (!_domainInfo.getRootAuthenticationURL().isEmpty() && _sessionUUID.isNull()
|
} else if (AccountManager::getInstance().hasValidAccessToken()) {
|
||||||
&& AccountManager::getInstance().hasValidAccessToken()) {
|
|
||||||
// we have an access token we can use for the authentication server the domain-server requested
|
// we have an access token we can use for the authentication server the domain-server requested
|
||||||
// so ask that server to provide us with information to connect to the domain-server
|
// so ask that server to provide us with information to connect to the domain-server
|
||||||
requestAuthForDomainServer();
|
requestAuthForDomainServer();
|
||||||
|
|
Loading…
Reference in a new issue