mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 16:36:54 +02:00
Add support for replicating by username
This commit is contained in:
parent
9322637d80
commit
ea56c568a7
5 changed files with 43 additions and 6 deletions
|
@ -117,6 +117,8 @@ DomainServer::DomainServer(int argc, char* argv[]) :
|
||||||
// if permissions are updated, relay the changes to the Node datastructures
|
// if permissions are updated, relay the changes to the Node datastructures
|
||||||
connect(&_settingsManager, &DomainServerSettingsManager::updateNodePermissions,
|
connect(&_settingsManager, &DomainServerSettingsManager::updateNodePermissions,
|
||||||
&_gatekeeper, &DomainGatekeeper::updateNodePermissions);
|
&_gatekeeper, &DomainGatekeeper::updateNodePermissions);
|
||||||
|
connect(&_settingsManager, &DomainServerSettingsManager::settingsUpdated,
|
||||||
|
this, &DomainServer::updateReplicatedNodes);
|
||||||
|
|
||||||
setupGroupCacheRefresh();
|
setupGroupCacheRefresh();
|
||||||
|
|
||||||
|
@ -2210,9 +2212,34 @@ void DomainServer::refreshStaticAssignmentAndAddToQueue(SharedAssignmentPointer&
|
||||||
_unfulfilledAssignments.enqueue(assignment);
|
_unfulfilledAssignments.enqueue(assignment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DomainServer::updateReplicatedNodes() {
|
||||||
|
static const QString REPLICATION_SETTINGS_KEY = "replication";
|
||||||
|
_replicatedUsernames.clear();
|
||||||
|
auto settings = _settingsManager.getSettingsMap();
|
||||||
|
if (settings.contains(REPLICATION_SETTINGS_KEY)) {
|
||||||
|
auto replicationSettings = settings.value(REPLICATION_SETTINGS_KEY).toJsonObject();
|
||||||
|
auto usersSettings = replicationSettings.value("users").toArray();
|
||||||
|
for (auto& username : usersSettings) {
|
||||||
|
_replicatedUsernames.push_back(username.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
auto nodeList = DependencyManager::get<LimitedNodeList>();
|
||||||
|
nodeList->eachNode([&](const SharedNodePointer& otherNode) {
|
||||||
|
if (shouldReplicateNode(*otherNode)) {
|
||||||
|
otherNode->setIsReplicated(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DomainServer::shouldReplicateNode(const Node& node) {
|
||||||
|
QString verifiedUsername = node.getPermissions().getVerifiedUserName();
|
||||||
|
auto it = find(_replicatedUsernames.cbegin(), _replicatedUsernames.cend(), verifiedUsername);
|
||||||
|
return it != _replicatedUsernames.end() && node.getType() == NodeType::Agent;
|
||||||
|
};
|
||||||
|
|
||||||
void DomainServer::nodeAdded(SharedNodePointer node) {
|
void DomainServer::nodeAdded(SharedNodePointer node) {
|
||||||
// TODO Check to see if node is in list of replicated nodes
|
if (shouldReplicateNode(*node)) {
|
||||||
if (node->getType() == NodeType::Agent) {
|
|
||||||
node->setIsReplicated(true);
|
node->setIsReplicated(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -102,6 +102,8 @@ private slots:
|
||||||
|
|
||||||
void handleOctreeFileReplacement(QByteArray octreeFile);
|
void handleOctreeFileReplacement(QByteArray octreeFile);
|
||||||
|
|
||||||
|
void updateReplicatedNodes();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void iceServerChanged();
|
void iceServerChanged();
|
||||||
void userConnected();
|
void userConnected();
|
||||||
|
@ -161,12 +163,16 @@ private:
|
||||||
QJsonObject jsonForSocket(const HifiSockAddr& socket);
|
QJsonObject jsonForSocket(const HifiSockAddr& socket);
|
||||||
QJsonObject jsonObjectForNode(const SharedNodePointer& node);
|
QJsonObject jsonObjectForNode(const SharedNodePointer& node);
|
||||||
|
|
||||||
|
bool DomainServer::shouldReplicateNode(const Node& node);
|
||||||
|
|
||||||
void setupGroupCacheRefresh();
|
void setupGroupCacheRefresh();
|
||||||
|
|
||||||
QString pathForRedirect(QString path = QString()) const;
|
QString pathForRedirect(QString path = QString()) const;
|
||||||
|
|
||||||
SubnetList _acSubnetWhitelist;
|
SubnetList _acSubnetWhitelist;
|
||||||
|
|
||||||
|
std::vector<QString> _replicatedUsernames;
|
||||||
|
|
||||||
DomainGatekeeper _gatekeeper;
|
DomainGatekeeper _gatekeeper;
|
||||||
|
|
||||||
HTTPManager _httpManager;
|
HTTPManager _httpManager;
|
||||||
|
|
|
@ -991,6 +991,7 @@ bool DomainServerSettingsManager::handleAuthenticatedHTTPRequest(HTTPConnection
|
||||||
unpackPermissions();
|
unpackPermissions();
|
||||||
apiRefreshGroupInformation();
|
apiRefreshGroupInformation();
|
||||||
emit updateNodePermissions();
|
emit updateNodePermissions();
|
||||||
|
emit settingsUpdated();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -1196,13 +1197,14 @@ QJsonObject DomainServerSettingsManager::settingDescriptionFromGroup(const QJson
|
||||||
bool DomainServerSettingsManager::recurseJSONObjectAndOverwriteSettings(const QJsonObject& postedObject) {
|
bool DomainServerSettingsManager::recurseJSONObjectAndOverwriteSettings(const QJsonObject& postedObject) {
|
||||||
static const QString SECURITY_ROOT_KEY = "security";
|
static const QString SECURITY_ROOT_KEY = "security";
|
||||||
static const QString AC_SUBNET_WHITELIST_KEY = "ac_subnet_whitelist";
|
static const QString AC_SUBNET_WHITELIST_KEY = "ac_subnet_whitelist";
|
||||||
|
static const QString REPLICATION_KEY = "replication";
|
||||||
|
|
||||||
auto& settingsVariant = _configMap.getConfig();
|
auto& settingsVariant = _configMap.getConfig();
|
||||||
bool needRestart = false;
|
bool needRestart = false;
|
||||||
|
|
||||||
// Iterate on the setting groups
|
// Iterate on the setting groups
|
||||||
foreach(const QString& rootKey, postedObject.keys()) {
|
foreach(const QString& rootKey, postedObject.keys()) {
|
||||||
QJsonValue rootValue = postedObject[rootKey];
|
const QJsonValue& rootValue = postedObject[rootKey];
|
||||||
|
|
||||||
if (!settingsVariant.contains(rootKey)) {
|
if (!settingsVariant.contains(rootKey)) {
|
||||||
// we don't have a map below this key yet, so set it up now
|
// we don't have a map below this key yet, so set it up now
|
||||||
|
@ -1247,7 +1249,7 @@ bool DomainServerSettingsManager::recurseJSONObjectAndOverwriteSettings(const QJ
|
||||||
|
|
||||||
if (!matchingDescriptionObject.isEmpty()) {
|
if (!matchingDescriptionObject.isEmpty()) {
|
||||||
updateSetting(rootKey, rootValue, *thisMap, matchingDescriptionObject);
|
updateSetting(rootKey, rootValue, *thisMap, matchingDescriptionObject);
|
||||||
if (rootKey != SECURITY_ROOT_KEY) {
|
if (rootKey != SECURITY_ROOT_KEY && rootKey != REPLICATION_KEY) {
|
||||||
needRestart = true;
|
needRestart = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1261,9 +1263,9 @@ bool DomainServerSettingsManager::recurseJSONObjectAndOverwriteSettings(const QJ
|
||||||
|
|
||||||
// if we matched the setting then update the value
|
// if we matched the setting then update the value
|
||||||
if (!matchingDescriptionObject.isEmpty()) {
|
if (!matchingDescriptionObject.isEmpty()) {
|
||||||
QJsonValue settingValue = rootValue.toObject()[settingKey];
|
const QJsonValue& settingValue = rootValue.toObject()[settingKey];
|
||||||
updateSetting(settingKey, settingValue, *thisMap, matchingDescriptionObject);
|
updateSetting(settingKey, settingValue, *thisMap, matchingDescriptionObject);
|
||||||
if (rootKey != SECURITY_ROOT_KEY || settingKey == AC_SUBNET_WHITELIST_KEY) {
|
if ((rootKey != SECURITY_ROOT_KEY && rootKey != REPLICATION_KEY) || settingKey == AC_SUBNET_WHITELIST_KEY) {
|
||||||
needRestart = true;
|
needRestart = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -108,6 +108,7 @@ public:
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void updateNodePermissions();
|
void updateNodePermissions();
|
||||||
|
void settingsUpdated();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void apiGetGroupIDJSONCallback(QNetworkReply& requestReply);
|
void apiGetGroupIDJSONCallback(QNetworkReply& requestReply);
|
||||||
|
|
|
@ -105,6 +105,7 @@ private:
|
||||||
bool _isUpstream { false };
|
bool _isUpstream { false };
|
||||||
tbb::concurrent_unordered_set<QUuid, UUIDHasher> _ignoredNodeIDSet;
|
tbb::concurrent_unordered_set<QUuid, UUIDHasher> _ignoredNodeIDSet;
|
||||||
mutable QReadWriteLock _ignoredNodeIDSetLock;
|
mutable QReadWriteLock _ignoredNodeIDSetLock;
|
||||||
|
std::vector<QString> _replicatedUsernames { };
|
||||||
|
|
||||||
std::atomic_bool _ignoreRadiusEnabled;
|
std::atomic_bool _ignoreRadiusEnabled;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue