mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 05:58:27 +02:00
Merge branch 'master' of https://github.com/highfidelity/hifi into temp1
This commit is contained in:
commit
20764e9917
4 changed files with 35 additions and 1 deletions
|
@ -74,6 +74,14 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "maximum_user_capacity",
|
||||||
|
"label": "Maximum User Capacity",
|
||||||
|
"help": "The limit on how many avatars can be connected at once. 0 means no limit.",
|
||||||
|
"placeholder": "0",
|
||||||
|
"default": "0",
|
||||||
|
"advanced": false
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "allowed_editors",
|
"name": "allowed_editors",
|
||||||
"type": "table",
|
"type": "table",
|
||||||
|
|
|
@ -44,6 +44,7 @@ const QString ICE_SERVER_DEFAULT_HOSTNAME = "ice.highfidelity.io";
|
||||||
|
|
||||||
|
|
||||||
const QString ALLOWED_USERS_SETTINGS_KEYPATH = "security.allowed_users";
|
const QString ALLOWED_USERS_SETTINGS_KEYPATH = "security.allowed_users";
|
||||||
|
const QString MAXIMUM_USER_CAPACITY = "security.maximum_user_capacity";
|
||||||
const QString ALLOWED_EDITORS_SETTINGS_KEYPATH = "security.allowed_editors";
|
const QString ALLOWED_EDITORS_SETTINGS_KEYPATH = "security.allowed_editors";
|
||||||
|
|
||||||
|
|
||||||
|
@ -667,9 +668,22 @@ void DomainServer::handleConnectRequest(const QByteArray& packet, const HifiSock
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
unsigned int DomainServer::countConnectedUsers() {
|
||||||
|
unsigned int result = 0;
|
||||||
|
auto nodeList = DependencyManager::get<LimitedNodeList>();
|
||||||
|
nodeList->eachNode([&](const SharedNodePointer& otherNode){
|
||||||
|
if (otherNode->getType() == NodeType::Agent) {
|
||||||
|
result++;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool DomainServer::shouldAllowConnectionFromNode(const QString& username,
|
bool DomainServer::shouldAllowConnectionFromNode(const QString& username,
|
||||||
const QByteArray& usernameSignature,
|
const QByteArray& usernameSignature,
|
||||||
const HifiSockAddr& senderSockAddr) {
|
const HifiSockAddr& senderSockAddr) {
|
||||||
|
|
||||||
const QVariant* allowedUsersVariant = valueForKeyPath(_settingsManager.getSettingsMap(),
|
const QVariant* allowedUsersVariant = valueForKeyPath(_settingsManager.getSettingsMap(),
|
||||||
ALLOWED_USERS_SETTINGS_KEYPATH);
|
ALLOWED_USERS_SETTINGS_KEYPATH);
|
||||||
QStringList allowedUsers = allowedUsersVariant ? allowedUsersVariant->toStringList() : QStringList();
|
QStringList allowedUsers = allowedUsersVariant ? allowedUsersVariant->toStringList() : QStringList();
|
||||||
|
@ -680,6 +694,18 @@ bool DomainServer::shouldAllowConnectionFromNode(const QString& username,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QVariant* maximumUserCapacityVariant = valueForKeyPath(_settingsManager.getSettingsMap(), MAXIMUM_USER_CAPACITY);
|
||||||
|
unsigned int maximumUserCapacity = maximumUserCapacityVariant ? maximumUserCapacityVariant->toUInt() : 0;
|
||||||
|
if (maximumUserCapacity > 0) {
|
||||||
|
unsigned int connectedUsers = countConnectedUsers();
|
||||||
|
if (connectedUsers >= maximumUserCapacity) {
|
||||||
|
// too many users, deny the new connection.
|
||||||
|
qDebug() << connectedUsers << "/" << maximumUserCapacity << "users connected, denying new connection.";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
qDebug() << connectedUsers << "/" << maximumUserCapacity << "users connected, perhaps allowing new connection.";
|
||||||
|
}
|
||||||
|
|
||||||
if (allowedUsers.count() > 0) {
|
if (allowedUsers.count() > 0) {
|
||||||
if (allowedUsers.contains(username, Qt::CaseInsensitive)) {
|
if (allowedUsers.contains(username, Qt::CaseInsensitive)) {
|
||||||
// it's possible this user can be allowed to connect, but we need to check their username signature
|
// it's possible this user can be allowed to connect, but we need to check their username signature
|
||||||
|
|
|
@ -83,6 +83,7 @@ private:
|
||||||
void processDatagram(const QByteArray& receivedPacket, const HifiSockAddr& senderSockAddr);
|
void processDatagram(const QByteArray& receivedPacket, const HifiSockAddr& senderSockAddr);
|
||||||
|
|
||||||
void handleConnectRequest(const QByteArray& packet, const HifiSockAddr& senderSockAddr);
|
void handleConnectRequest(const QByteArray& packet, const HifiSockAddr& senderSockAddr);
|
||||||
|
unsigned int countConnectedUsers();
|
||||||
bool shouldAllowConnectionFromNode(const QString& username, const QByteArray& usernameSignature,
|
bool shouldAllowConnectionFromNode(const QString& username, const QByteArray& usernameSignature,
|
||||||
const HifiSockAddr& senderSockAddr);
|
const HifiSockAddr& senderSockAddr);
|
||||||
|
|
||||||
|
|
|
@ -342,7 +342,6 @@ void PhysicsEngine::stepSimulation() {
|
||||||
}
|
}
|
||||||
|
|
||||||
unlock();
|
unlock();
|
||||||
_avatarData->unlock();
|
|
||||||
_entityTree->unlock();
|
_entityTree->unlock();
|
||||||
|
|
||||||
computeCollisionEvents();
|
computeCollisionEvents();
|
||||||
|
|
Loading…
Reference in a new issue