mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 22:56:54 +02:00
Clean up domain-server setup
This commit is contained in:
parent
18e4c3b94c
commit
b6b73af2b4
2 changed files with 32 additions and 40 deletions
|
@ -104,23 +104,25 @@ DomainServer::DomainServer(int argc, char* argv[]) :
|
||||||
connect(&_settingsManager, &DomainServerSettingsManager::updateNodePermissions,
|
connect(&_settingsManager, &DomainServerSettingsManager::updateNodePermissions,
|
||||||
&_gatekeeper, &DomainGatekeeper::updateNodePermissions);
|
&_gatekeeper, &DomainGatekeeper::updateNodePermissions);
|
||||||
|
|
||||||
if (optionallyReadX509KeyAndCertificate() && optionallySetupOAuth()) {
|
// if we were given a certificate/private key or oauth credentials they must succeed
|
||||||
// we either read a certificate and private key or were not passed one
|
if (!(optionallyReadX509KeyAndCertificate() && optionallySetupOAuth())) {
|
||||||
// and completed login or did not need to
|
return;
|
||||||
|
|
||||||
qDebug() << "Setting up LimitedNodeList and assignments.";
|
|
||||||
setupNodeListAndAssignments();
|
|
||||||
|
|
||||||
// setup automatic networking settings with data server
|
|
||||||
setupAutomaticNetworking();
|
|
||||||
|
|
||||||
// preload some user public keys so they can connect on first request
|
|
||||||
_gatekeeper.preloadAllowedUserPublicKeys();
|
|
||||||
|
|
||||||
optionallyGetTemporaryName(args);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qDebug() << "Setting up domain-server";
|
||||||
|
setupNodeListAndAssignments();
|
||||||
|
setupAutomaticNetworking();
|
||||||
|
_gatekeeper.preloadAllowedUserPublicKeys(); // so they can connect on first request
|
||||||
|
|
||||||
_metadata = new DomainMetadata(this);
|
_metadata = new DomainMetadata(this);
|
||||||
|
|
||||||
|
// check for the temporary name parameter
|
||||||
|
const QString GET_TEMPORARY_NAME_SWITCH = "--get-temp-name";
|
||||||
|
if (args.contains(GET_TEMPORARY_NAME_SWITCH)) {
|
||||||
|
getTemporaryName();
|
||||||
|
}
|
||||||
|
|
||||||
|
qDebug() << "domain-server" << nullptr << "is running";
|
||||||
}
|
}
|
||||||
|
|
||||||
DomainServer::~DomainServer() {
|
DomainServer::~DomainServer() {
|
||||||
|
@ -233,34 +235,25 @@ bool DomainServer::optionallySetupOAuth() {
|
||||||
|
|
||||||
static const QString METAVERSE_DOMAIN_ID_KEY_PATH = "metaverse.id";
|
static const QString METAVERSE_DOMAIN_ID_KEY_PATH = "metaverse.id";
|
||||||
|
|
||||||
void DomainServer::optionallyGetTemporaryName(const QStringList& arguments) {
|
void DomainServer::getTemporaryName(bool force) {
|
||||||
// check for the temporary name parameter
|
// check if we already have a domain ID
|
||||||
const QString GET_TEMPORARY_NAME_SWITCH = "--get-temp-name";
|
const QVariant* idValueVariant = valueForKeyPath(_settingsManager.getSettingsMap(), METAVERSE_DOMAIN_ID_KEY_PATH);
|
||||||
|
|
||||||
if (arguments.contains(GET_TEMPORARY_NAME_SWITCH)) {
|
if (idValueVariant) {
|
||||||
|
qWarning() << "Temporary domain name requested but a domain ID is already present in domain-server settings.";
|
||||||
// make sure we don't already have a domain ID
|
if (force) {
|
||||||
const QVariant* idValueVariant = valueForKeyPath(_settingsManager.getSettingsMap(), METAVERSE_DOMAIN_ID_KEY_PATH);
|
qWarning() << "Temporary domain name will be requested to replace it.";
|
||||||
if (idValueVariant) {
|
} else {
|
||||||
qWarning() << "Temporary domain name requested but a domain ID is already present in domain-server settings."
|
qWarning() << "Temporary domain name will not be requested.";
|
||||||
<< "Will not request temporary name.";
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// we've been asked to grab a temporary name from the API
|
|
||||||
// so fire off that request now
|
|
||||||
auto accountManager = DependencyManager::get<AccountManager>();
|
|
||||||
|
|
||||||
// get callbacks for temporary domain result
|
|
||||||
JSONCallbackParameters callbackParameters;
|
|
||||||
callbackParameters.jsonCallbackReceiver = this;
|
|
||||||
callbackParameters.jsonCallbackMethod = "handleTempDomainSuccess";
|
|
||||||
callbackParameters.errorCallbackReceiver = this;
|
|
||||||
callbackParameters.errorCallbackMethod = "handleTempDomainError";
|
|
||||||
|
|
||||||
accountManager->sendRequest("/api/v1/domains/temporary", AccountManagerAuth::None,
|
|
||||||
QNetworkAccessManager::PostOperation, callbackParameters);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// request a temporary name from the metaverse
|
||||||
|
auto accountManager = DependencyManager::get<AccountManager>();
|
||||||
|
JSONCallbackParameters callbackParameters { this, "handleTempDomainSuccess", this, "handleTempDomainError" };
|
||||||
|
accountManager->sendRequest("/api/v1/domains/temporary", AccountManagerAuth::None,
|
||||||
|
QNetworkAccessManager::PostOperation, callbackParameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DomainServer::handleTempDomainSuccess(QNetworkReply& requestReply) {
|
void DomainServer::handleTempDomainSuccess(QNetworkReply& requestReply) {
|
||||||
|
@ -333,7 +326,6 @@ bool DomainServer::packetVersionMatch(const udt::Packet& packet) {
|
||||||
|
|
||||||
|
|
||||||
void DomainServer::setupNodeListAndAssignments(const QUuid& sessionUUID) {
|
void DomainServer::setupNodeListAndAssignments(const QUuid& sessionUUID) {
|
||||||
|
|
||||||
const QString CUSTOM_LOCAL_PORT_OPTION = "metaverse.local_port";
|
const QString CUSTOM_LOCAL_PORT_OPTION = "metaverse.local_port";
|
||||||
|
|
||||||
QVariant localPortValue = _settingsManager.valueOrDefaultValueForKeyPath(CUSTOM_LOCAL_PORT_OPTION);
|
QVariant localPortValue = _settingsManager.valueOrDefaultValueForKeyPath(CUSTOM_LOCAL_PORT_OPTION);
|
||||||
|
|
|
@ -100,7 +100,7 @@ private:
|
||||||
bool optionallySetupOAuth();
|
bool optionallySetupOAuth();
|
||||||
bool optionallyReadX509KeyAndCertificate();
|
bool optionallyReadX509KeyAndCertificate();
|
||||||
|
|
||||||
void optionallyGetTemporaryName(const QStringList& arguments);
|
void getTemporaryName(bool force = false);
|
||||||
|
|
||||||
static bool packetVersionMatch(const udt::Packet& packet);
|
static bool packetVersionMatch(const udt::Packet& packet);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue