mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 16:41:02 +02:00
Merge pull request #7860 from birarda/place-referrer
send lookup hostname to DS for split counts, correct number of DS connected users
This commit is contained in:
commit
e012630db2
10 changed files with 66 additions and 21 deletions
|
@ -55,9 +55,9 @@ void DomainGatekeeper::processConnectRequestPacket(QSharedPointer<ReceivedMessag
|
||||||
if (message->getSize() == 0) {
|
if (message->getSize() == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QDataStream packetStream(message->getMessage());
|
QDataStream packetStream(message->getMessage());
|
||||||
|
|
||||||
// read a NodeConnectionData object from the packet so we can pass around this data while we're inspecting it
|
// read a NodeConnectionData object from the packet so we can pass around this data while we're inspecting it
|
||||||
NodeConnectionData nodeConnection = NodeConnectionData::fromDataStream(packetStream, message->getSenderSockAddr());
|
NodeConnectionData nodeConnection = NodeConnectionData::fromDataStream(packetStream, message->getSenderSockAddr());
|
||||||
|
|
||||||
|
@ -105,6 +105,7 @@ void DomainGatekeeper::processConnectRequestPacket(QSharedPointer<ReceivedMessag
|
||||||
DomainServerNodeData* nodeData = reinterpret_cast<DomainServerNodeData*>(node->getLinkedData());
|
DomainServerNodeData* nodeData = reinterpret_cast<DomainServerNodeData*>(node->getLinkedData());
|
||||||
nodeData->setSendingSockAddr(message->getSenderSockAddr());
|
nodeData->setSendingSockAddr(message->getSenderSockAddr());
|
||||||
nodeData->setNodeInterestSet(nodeConnection.interestList.toSet());
|
nodeData->setNodeInterestSet(nodeConnection.interestList.toSet());
|
||||||
|
nodeData->setPlaceName(nodeConnection.placeName);
|
||||||
|
|
||||||
// signal that we just connected a node so the DomainServer can get it a list
|
// signal that we just connected a node so the DomainServer can get it a list
|
||||||
// and broadcast its presence right away
|
// and broadcast its presence right away
|
||||||
|
@ -150,6 +151,7 @@ SharedNodePointer DomainGatekeeper::processAssignmentConnectRequest(const NodeCo
|
||||||
nodeData->setAssignmentUUID(matchingQueuedAssignment->getUUID());
|
nodeData->setAssignmentUUID(matchingQueuedAssignment->getUUID());
|
||||||
nodeData->setWalletUUID(it->second.getWalletUUID());
|
nodeData->setWalletUUID(it->second.getWalletUUID());
|
||||||
nodeData->setNodeVersion(it->second.getNodeVersion());
|
nodeData->setNodeVersion(it->second.getNodeVersion());
|
||||||
|
nodeData->setWasAssigned(true);
|
||||||
|
|
||||||
// cleanup the PendingAssignedNodeData for this assignment now that it's connecting
|
// cleanup the PendingAssignedNodeData for this assignment now that it's connecting
|
||||||
_pendingAssignedNodes.erase(it);
|
_pendingAssignedNodes.erase(it);
|
||||||
|
@ -282,7 +284,7 @@ SharedNodePointer DomainGatekeeper::processAgentConnectRequest(const NodeConnect
|
||||||
// set the edit rights for this user
|
// set the edit rights for this user
|
||||||
newNode->setIsAllowedEditor(isAllowedEditor);
|
newNode->setIsAllowedEditor(isAllowedEditor);
|
||||||
newNode->setCanRez(canRez);
|
newNode->setCanRez(canRez);
|
||||||
|
|
||||||
// grab the linked data for our new node so we can set the username
|
// grab the linked data for our new node so we can set the username
|
||||||
DomainServerNodeData* nodeData = reinterpret_cast<DomainServerNodeData*>(newNode->getLinkedData());
|
DomainServerNodeData* nodeData = reinterpret_cast<DomainServerNodeData*>(newNode->getLinkedData());
|
||||||
|
|
||||||
|
|
|
@ -462,7 +462,7 @@ void DomainServer::setupAutomaticNetworking() {
|
||||||
nodeList->startSTUNPublicSocketUpdate();
|
nodeList->startSTUNPublicSocketUpdate();
|
||||||
} else {
|
} else {
|
||||||
// send our heartbeat to data server so it knows what our network settings are
|
// send our heartbeat to data server so it knows what our network settings are
|
||||||
sendHeartbeatToDataServer();
|
sendHeartbeatToMetaverse();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "Cannot enable domain-server automatic networking without a domain ID."
|
qDebug() << "Cannot enable domain-server automatic networking without a domain ID."
|
||||||
|
@ -471,7 +471,7 @@ void DomainServer::setupAutomaticNetworking() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sendHeartbeatToDataServer();
|
sendHeartbeatToMetaverse();
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug() << "Updating automatic networking setting in domain-server to" << _automaticNetworkingSetting;
|
qDebug() << "Updating automatic networking setting in domain-server to" << _automaticNetworkingSetting;
|
||||||
|
@ -480,7 +480,7 @@ void DomainServer::setupAutomaticNetworking() {
|
||||||
const int DOMAIN_SERVER_DATA_WEB_HEARTBEAT_MSECS = 15 * 1000;
|
const int DOMAIN_SERVER_DATA_WEB_HEARTBEAT_MSECS = 15 * 1000;
|
||||||
|
|
||||||
QTimer* dataHeartbeatTimer = new QTimer(this);
|
QTimer* dataHeartbeatTimer = new QTimer(this);
|
||||||
connect(dataHeartbeatTimer, SIGNAL(timeout()), this, SLOT(sendHeartbeatToDataServer()));
|
connect(dataHeartbeatTimer, SIGNAL(timeout()), this, SLOT(sendHeartbeatToMetaverse()));
|
||||||
dataHeartbeatTimer->start(DOMAIN_SERVER_DATA_WEB_HEARTBEAT_MSECS);
|
dataHeartbeatTimer->start(DOMAIN_SERVER_DATA_WEB_HEARTBEAT_MSECS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -678,6 +678,9 @@ void DomainServer::processListRequestPacket(QSharedPointer<ReceivedMessage> mess
|
||||||
DomainServerNodeData* nodeData = reinterpret_cast<DomainServerNodeData*>(sendingNode->getLinkedData());
|
DomainServerNodeData* nodeData = reinterpret_cast<DomainServerNodeData*>(sendingNode->getLinkedData());
|
||||||
nodeData->setNodeInterestSet(nodeRequestData.interestList.toSet());
|
nodeData->setNodeInterestSet(nodeRequestData.interestList.toSet());
|
||||||
|
|
||||||
|
// update the connecting hostname in case it has changed
|
||||||
|
nodeData->setPlaceName(nodeRequestData.placeName);
|
||||||
|
|
||||||
sendDomainListToNode(sendingNode, message->getSenderSockAddr());
|
sendDomainListToNode(sendingNode, message->getSenderSockAddr());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1029,11 +1032,11 @@ QJsonObject jsonForDomainSocketUpdate(const HifiSockAddr& socket) {
|
||||||
const QString DOMAIN_UPDATE_AUTOMATIC_NETWORKING_KEY = "automatic_networking";
|
const QString DOMAIN_UPDATE_AUTOMATIC_NETWORKING_KEY = "automatic_networking";
|
||||||
|
|
||||||
void DomainServer::performIPAddressUpdate(const HifiSockAddr& newPublicSockAddr) {
|
void DomainServer::performIPAddressUpdate(const HifiSockAddr& newPublicSockAddr) {
|
||||||
sendHeartbeatToDataServer(newPublicSockAddr.getAddress().toString());
|
sendHeartbeatToMetaverse(newPublicSockAddr.getAddress().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DomainServer::sendHeartbeatToDataServer(const QString& networkAddress) {
|
void DomainServer::sendHeartbeatToMetaverse(const QString& networkAddress) {
|
||||||
const QString DOMAIN_UPDATE = "/api/v1/domains/%1";
|
const QString DOMAIN_UPDATE = "/api/v1/domains/%1";
|
||||||
|
|
||||||
auto nodeList = DependencyManager::get<LimitedNodeList>();
|
auto nodeList = DependencyManager::get<LimitedNodeList>();
|
||||||
|
@ -1056,20 +1059,34 @@ void DomainServer::sendHeartbeatToDataServer(const QString& networkAddress) {
|
||||||
domainObject[RESTRICTED_ACCESS_FLAG] =
|
domainObject[RESTRICTED_ACCESS_FLAG] =
|
||||||
_settingsManager.valueOrDefaultValueForKeyPath(RESTRICTED_ACCESS_SETTINGS_KEYPATH).toBool();
|
_settingsManager.valueOrDefaultValueForKeyPath(RESTRICTED_ACCESS_SETTINGS_KEYPATH).toBool();
|
||||||
|
|
||||||
// add the number of currently connected agent users
|
// figure out the breakdown of currently connected interface clients
|
||||||
int numConnectedAuthedUsers = 0;
|
int numConnectedUnassigned = 0;
|
||||||
|
QJsonObject userHostnames;
|
||||||
|
|
||||||
nodeList->eachNode([&numConnectedAuthedUsers](const SharedNodePointer& node){
|
static const QString DEFAULT_HOSTNAME = "*";
|
||||||
if (node->getLinkedData() && !static_cast<DomainServerNodeData*>(node->getLinkedData())->getUsername().isEmpty()) {
|
|
||||||
++numConnectedAuthedUsers;
|
nodeList->eachNode([&numConnectedUnassigned, &userHostnames](const SharedNodePointer& node) {
|
||||||
|
if (node->getLinkedData()) {
|
||||||
|
auto nodeData = static_cast<DomainServerNodeData*>(node->getLinkedData());
|
||||||
|
|
||||||
|
if (!nodeData->wasAssigned()) {
|
||||||
|
++numConnectedUnassigned;
|
||||||
|
|
||||||
|
// increment the count for this hostname (or the default if we don't have one)
|
||||||
|
auto hostname = nodeData->getPlaceName().isEmpty() ? DEFAULT_HOSTNAME : nodeData->getPlaceName();
|
||||||
|
userHostnames[hostname] = userHostnames[hostname].toInt() + 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const QString DOMAIN_HEARTBEAT_KEY = "heartbeat";
|
static const QString DOMAIN_HEARTBEAT_KEY = "heartbeat";
|
||||||
const QString HEARTBEAT_NUM_USERS_KEY = "num_users";
|
static const QString HEARTBEAT_NUM_USERS_KEY = "num_users";
|
||||||
|
static const QString HEARTBEAT_USER_HOSTNAMES_KEY = "user_hostnames";
|
||||||
|
|
||||||
QJsonObject heartbeatObject;
|
QJsonObject heartbeatObject;
|
||||||
heartbeatObject[HEARTBEAT_NUM_USERS_KEY] = numConnectedAuthedUsers;
|
heartbeatObject[HEARTBEAT_NUM_USERS_KEY] = numConnectedUnassigned;
|
||||||
|
heartbeatObject[HEARTBEAT_USER_HOSTNAMES_KEY] = userHostnames;
|
||||||
|
|
||||||
domainObject[DOMAIN_HEARTBEAT_KEY] = heartbeatObject;
|
domainObject[DOMAIN_HEARTBEAT_KEY] = heartbeatObject;
|
||||||
|
|
||||||
QString domainUpdateJSON = QString("{\"domain\": %1 }").arg(QString(QJsonDocument(domainObject).toJson()));
|
QString domainUpdateJSON = QString("{\"domain\": %1 }").arg(QString(QJsonDocument(domainObject).toJson()));
|
||||||
|
|
|
@ -71,7 +71,7 @@ private slots:
|
||||||
void sendPendingTransactionsToServer();
|
void sendPendingTransactionsToServer();
|
||||||
|
|
||||||
void performIPAddressUpdate(const HifiSockAddr& newPublicSockAddr);
|
void performIPAddressUpdate(const HifiSockAddr& newPublicSockAddr);
|
||||||
void sendHeartbeatToDataServer() { sendHeartbeatToDataServer(QString()); }
|
void sendHeartbeatToMetaverse() { sendHeartbeatToMetaverse(QString()); }
|
||||||
void sendHeartbeatToIceServer();
|
void sendHeartbeatToIceServer();
|
||||||
|
|
||||||
void handleConnectedNode(SharedNodePointer newNode);
|
void handleConnectedNode(SharedNodePointer newNode);
|
||||||
|
@ -103,7 +103,7 @@ private:
|
||||||
|
|
||||||
void setupAutomaticNetworking();
|
void setupAutomaticNetworking();
|
||||||
void setupICEHeartbeatForFullNetworking();
|
void setupICEHeartbeatForFullNetworking();
|
||||||
void sendHeartbeatToDataServer(const QString& networkAddress);
|
void sendHeartbeatToMetaverse(const QString& networkAddress);
|
||||||
|
|
||||||
void randomizeICEServerAddress(bool shouldTriggerHostLookup);
|
void randomizeICEServerAddress(bool shouldTriggerHostLookup);
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,12 @@ public:
|
||||||
|
|
||||||
void addOverrideForKey(const QString& key, const QString& value, const QString& overrideValue);
|
void addOverrideForKey(const QString& key, const QString& value, const QString& overrideValue);
|
||||||
void removeOverrideForKey(const QString& key, const QString& value);
|
void removeOverrideForKey(const QString& key, const QString& value);
|
||||||
|
|
||||||
|
const QString& getPlaceName() { return _placeName; }
|
||||||
|
void setPlaceName(const QString& placeName) { _placeName = placeName; }
|
||||||
|
|
||||||
|
bool wasAssigned() const { return _wasAssigned; };
|
||||||
|
void setWasAssigned(bool wasAssigned) { _wasAssigned = wasAssigned; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QJsonObject overrideValuesIfNeeded(const QJsonObject& newStats);
|
QJsonObject overrideValuesIfNeeded(const QJsonObject& newStats);
|
||||||
|
@ -75,6 +81,10 @@ private:
|
||||||
bool _isAuthenticated = true;
|
bool _isAuthenticated = true;
|
||||||
NodeSet _nodeInterestSet;
|
NodeSet _nodeInterestSet;
|
||||||
QString _nodeVersion;
|
QString _nodeVersion;
|
||||||
|
|
||||||
|
QString _placeName;
|
||||||
|
|
||||||
|
bool _wasAssigned { false };
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_DomainServerNodeData_h
|
#endif // hifi_DomainServerNodeData_h
|
||||||
|
|
|
@ -23,7 +23,7 @@ NodeConnectionData NodeConnectionData::fromDataStream(QDataStream& dataStream, c
|
||||||
|
|
||||||
dataStream >> newHeader.nodeType
|
dataStream >> newHeader.nodeType
|
||||||
>> newHeader.publicSockAddr >> newHeader.localSockAddr
|
>> newHeader.publicSockAddr >> newHeader.localSockAddr
|
||||||
>> newHeader.interestList;
|
>> newHeader.interestList >> newHeader.placeName;
|
||||||
|
|
||||||
newHeader.senderSockAddr = senderSockAddr;
|
newHeader.senderSockAddr = senderSockAddr;
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@ public:
|
||||||
HifiSockAddr localSockAddr;
|
HifiSockAddr localSockAddr;
|
||||||
HifiSockAddr senderSockAddr;
|
HifiSockAddr senderSockAddr;
|
||||||
QList<NodeType_t> interestList;
|
QList<NodeType_t> interestList;
|
||||||
|
QString placeName;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -295,14 +295,20 @@ void AddressManager::goToAddressFromObject(const QVariantMap& dataObject, const
|
||||||
// set our current root place name to the name that came back
|
// set our current root place name to the name that came back
|
||||||
const QString PLACE_NAME_KEY = "name";
|
const QString PLACE_NAME_KEY = "name";
|
||||||
QString placeName = rootMap[PLACE_NAME_KEY].toString();
|
QString placeName = rootMap[PLACE_NAME_KEY].toString();
|
||||||
|
|
||||||
if (!placeName.isEmpty()) {
|
if (!placeName.isEmpty()) {
|
||||||
if (setHost(placeName, trigger)) {
|
if (setHost(placeName, trigger)) {
|
||||||
trigger = LookupTrigger::Internal;
|
trigger = LookupTrigger::Internal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_placeName = placeName;
|
||||||
} else {
|
} else {
|
||||||
if (setHost(domainIDString, trigger)) {
|
if (setHost(domainIDString, trigger)) {
|
||||||
trigger = LookupTrigger::Internal;
|
trigger = LookupTrigger::Internal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// this isn't a place, so clear the place name
|
||||||
|
_placeName.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if we had a path to override the path returned
|
// check if we had a path to override the path returned
|
||||||
|
@ -580,7 +586,9 @@ bool AddressManager::setHost(const QString& host, LookupTrigger trigger, quint16
|
||||||
bool AddressManager::setDomainInfo(const QString& hostname, quint16 port, LookupTrigger trigger) {
|
bool AddressManager::setDomainInfo(const QString& hostname, quint16 port, LookupTrigger trigger) {
|
||||||
bool hostChanged = setHost(hostname, trigger, port);
|
bool hostChanged = setHost(hostname, trigger, port);
|
||||||
|
|
||||||
|
// clear any current place information
|
||||||
_rootPlaceID = QUuid();
|
_rootPlaceID = QUuid();
|
||||||
|
_placeName.clear();
|
||||||
|
|
||||||
qCDebug(networking) << "Possible domain change required to connect to domain at" << hostname << "on" << port;
|
qCDebug(networking) << "Possible domain change required to connect to domain at" << hostname << "on" << port;
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,7 @@ public:
|
||||||
const QString currentPath(bool withOrientation = true) const;
|
const QString currentPath(bool withOrientation = true) const;
|
||||||
|
|
||||||
const QUuid& getRootPlaceID() const { return _rootPlaceID; }
|
const QUuid& getRootPlaceID() const { return _rootPlaceID; }
|
||||||
|
const QString& getPlaceName() const { return _placeName; }
|
||||||
|
|
||||||
const QString& getHost() const { return _host; }
|
const QString& getHost() const { return _host; }
|
||||||
|
|
||||||
|
@ -141,6 +142,7 @@ private:
|
||||||
|
|
||||||
QString _host;
|
QString _host;
|
||||||
quint16 _port;
|
quint16 _port;
|
||||||
|
QString _placeName;
|
||||||
QUuid _rootPlaceID;
|
QUuid _rootPlaceID;
|
||||||
PositionGetter _positionGetter;
|
PositionGetter _positionGetter;
|
||||||
OrientationGetter _orientationGetter;
|
OrientationGetter _orientationGetter;
|
||||||
|
|
|
@ -314,8 +314,10 @@ void NodeList::sendDomainServerCheckIn() {
|
||||||
packetStream << connectUUID;
|
packetStream << connectUUID;
|
||||||
}
|
}
|
||||||
|
|
||||||
// pack our data to send to the domain-server
|
// pack our data to send to the domain-server including
|
||||||
packetStream << _ownerType << _publicSockAddr << _localSockAddr << _nodeTypesOfInterest.toList();
|
// the hostname information (so the domain-server can see which place name we came in on)
|
||||||
|
packetStream << _ownerType << _publicSockAddr << _localSockAddr << _nodeTypesOfInterest.toList()
|
||||||
|
<< DependencyManager::get<AddressManager>()->getPlaceName();
|
||||||
|
|
||||||
if (!_domainHandler.isConnected()) {
|
if (!_domainHandler.isConnected()) {
|
||||||
DataServerAccountInfo& accountInfo = accountManager->getAccountInfo();
|
DataServerAccountInfo& accountInfo = accountManager->getAccountInfo();
|
||||||
|
|
|
@ -58,6 +58,9 @@ PacketVersion versionForPacketType(PacketType packetType) {
|
||||||
case PacketType::AssetUpload:
|
case PacketType::AssetUpload:
|
||||||
// Removal of extension from Asset requests
|
// Removal of extension from Asset requests
|
||||||
return 18;
|
return 18;
|
||||||
|
case PacketType::DomainConnectRequest:
|
||||||
|
// addition of referring hostname information
|
||||||
|
return 18;
|
||||||
default:
|
default:
|
||||||
return 17;
|
return 17;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue