mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 18:23:54 +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());
|
||||
}
|
||||
}
|
||||
} 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) {
|
||||
|
||||
// construct the requested assignment from the packet data
|
||||
|
|
|
@ -26,14 +26,15 @@ void DomainInfo::reset() {
|
|||
_hostname = QString();
|
||||
_sockAddr.setAddress(QHostAddress::Null);
|
||||
_connectionSecret = QString();
|
||||
_registrationToken = QString();
|
||||
_registrationToken = QByteArray();
|
||||
_rootAuthenticationURL = QUrl();
|
||||
_publicKey = QString();
|
||||
}
|
||||
|
||||
void DomainInfo::parseAuthInformationFromJsonObject(const QJsonObject& jsonObject) {
|
||||
_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();
|
||||
}
|
||||
|
||||
|
|
|
@ -43,8 +43,7 @@ public:
|
|||
const QUuid& getConnectionSecret() const { return _connectionSecret; }
|
||||
void setConnectionSecret(const QUuid& connectionSecret) { _connectionSecret = connectionSecret; }
|
||||
|
||||
const QString& getRegistrationToken() const { return _registrationToken; }
|
||||
void setRegistrationToken(const QString& registrationToken);
|
||||
const QByteArray& getRegistrationToken() const { return _registrationToken; }
|
||||
|
||||
const QUrl& getRootAuthenticationURL() const { return _rootAuthenticationURL; }
|
||||
void setRootAuthenticationURL(const QUrl& rootAuthenticationURL) { _rootAuthenticationURL = rootAuthenticationURL; }
|
||||
|
@ -60,7 +59,7 @@ private:
|
|||
QString _hostname;
|
||||
HifiSockAddr _sockAddr;
|
||||
QUuid _connectionSecret;
|
||||
QString _registrationToken;
|
||||
QByteArray _registrationToken;
|
||||
QUrl _rootAuthenticationURL;
|
||||
QString _publicKey;
|
||||
};
|
||||
|
|
|
@ -90,7 +90,7 @@ bool NodeList::packetVersionAndHashMatch(const QByteArray& packet) {
|
|||
}
|
||||
|
||||
const QSet<PacketType> NON_VERIFIED_PACKETS = QSet<PacketType>() << PacketTypeDomainList
|
||||
<< PacketTypeDomainListRequest << PacketTypeDomainServerAuthRequest
|
||||
<< PacketTypeDomainListRequest << PacketTypeDomainServerAuthRequest << PacketTypeDomainConnectRequest
|
||||
<< PacketTypeStunResponse << PacketTypeDataServerConfirm
|
||||
<< PacketTypeDataServerGet << PacketTypeDataServerPut << PacketTypeDataServerSend
|
||||
<< PacketTypeCreateAssignment << PacketTypeRequestAssignment;
|
||||
|
@ -476,21 +476,27 @@ void NodeList::sendDomainServerCheckIn() {
|
|||
// send a STUN request to figure it out
|
||||
sendSTUNRequest();
|
||||
} else if (!_domainInfo.getIP().isNull()) {
|
||||
if (_domainInfo.getRootAuthenticationURL().isEmpty() || !_sessionUUID.isNull()
|
||||
|| !_domainInfo.getRegistrationToken().isEmpty()) {
|
||||
if (_domainInfo.getRootAuthenticationURL().isEmpty()
|
||||
|| !_sessionUUID.isNull()
|
||||
|| !_domainInfo.getRegistrationToken().isEmpty() ) {
|
||||
// construct the DS check in packet
|
||||
|
||||
PacketType domainPacketType = _domainInfo.getRegistrationToken().isEmpty()
|
||||
? PacketTypeDomainListRequest
|
||||
: PacketTypeDomainConnectRequest;
|
||||
? PacketTypeDomainListRequest : PacketTypeDomainConnectRequest;
|
||||
|
||||
QByteArray domainServerPacket = byteArrayWithPopluatedHeader(domainPacketType);
|
||||
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
|
||||
packetStream << _ownerType << _publicSockAddr
|
||||
<< HifiSockAddr(QHostAddress(getHostOrderLocalAddress()), _nodeSocket.localPort())
|
||||
<< (quint8) _nodeTypesOfInterest.size();
|
||||
<< HifiSockAddr(QHostAddress(getHostOrderLocalAddress()), _nodeSocket.localPort())
|
||||
<< (quint8) _nodeTypesOfInterest.size();
|
||||
|
||||
// copy over the bytes for node types of interest, if required
|
||||
foreach (NodeType_t nodeTypeOfInterest, _nodeTypesOfInterest) {
|
||||
|
@ -508,8 +514,7 @@ void NodeList::sendDomainServerCheckIn() {
|
|||
|
||||
// increment the count of un-replied check-ins
|
||||
_numNoReplyDomainCheckIns++;
|
||||
} else if (!_domainInfo.getRootAuthenticationURL().isEmpty() && _sessionUUID.isNull()
|
||||
&& AccountManager::getInstance().hasValidAccessToken()) {
|
||||
} else if (AccountManager::getInstance().hasValidAccessToken()) {
|
||||
// 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
|
||||
requestAuthForDomainServer();
|
||||
|
|
Loading…
Reference in a new issue