mirror of
https://github.com/lubosz/overte.git
synced 2025-04-12 01:22:10 +02:00
handle automatic networking changes with data-server
This commit is contained in:
parent
15156519b3
commit
d6572c3e2e
3 changed files with 32 additions and 12 deletions
|
@ -29,7 +29,7 @@
|
|||
"label": "IP Only: update just my IP address, I will open the port manually"
|
||||
},
|
||||
{
|
||||
"value": "none",
|
||||
"value": "disabled",
|
||||
"label": "None: use the network information I have entered for this domain at data.highfidelity.io"
|
||||
}
|
||||
]
|
||||
|
|
|
@ -74,7 +74,7 @@ DomainServer::DomainServer(int argc, char* argv[]) :
|
|||
|
||||
loadExistingSessionsFromSettings();
|
||||
|
||||
// check if we have the flag that enables dynamic IP
|
||||
// setup automatic networking settings with data server
|
||||
setupAutomaticNetworking();
|
||||
}
|
||||
}
|
||||
|
@ -310,22 +310,24 @@ bool DomainServer::optionallySetupAssignmentPayment() {
|
|||
return true;
|
||||
}
|
||||
|
||||
const QString FULL_AUTOMATIC_NETWORKING_VALUE = "full";
|
||||
const QString IP_ONLY_AUTOMATIC_NETWORKING_VALUE = "ip";
|
||||
const QString DISABLED_AUTOMATIC_NETWORKING_VALUE = "disabled";
|
||||
|
||||
void DomainServer::setupAutomaticNetworking() {
|
||||
const QString METAVERSE_AUTOMATIC_NETWORKING_KEY_PATH = "metaverse.automatic_networking";
|
||||
|
||||
const QString FULL_AUTOMATIC_NETWORKING_VALUE = "full";
|
||||
const QString IP_ONLY_AUTOMATIC_NETWORKING_VALUE = "ip";
|
||||
if (!didSetupAccountManagerWithAccessToken()) {
|
||||
qDebug() << "Cannot setup domain-server automatic networking without an access token.";
|
||||
qDebug() << "Please add an access token to your config file or via the web interface.";
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
QString automaticNetworkValue =
|
||||
_settingsManager.valueOrDefaultValueForKeyPath(METAVERSE_AUTOMATIC_NETWORKING_KEY_PATH).toString();
|
||||
|
||||
if (automaticNetworkValue == IP_ONLY_AUTOMATIC_NETWORKING_VALUE) {
|
||||
if (!didSetupAccountManagerWithAccessToken()) {
|
||||
qDebug() << "Cannot enable domain-server automatic networking without an access token.";
|
||||
qDebug() << "Please add an access token to your config file or via the web interface.";
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
LimitedNodeList* nodeList = LimitedNodeList::getInstance();
|
||||
const QUuid& domainID = nodeList->getSessionUUID();
|
||||
|
@ -353,6 +355,8 @@ void DomainServer::setupAutomaticNetworking() {
|
|||
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
updateNetworkingInfoWithDataServer(automaticNetworkValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -933,7 +937,13 @@ QJsonObject jsonForDomainSocketUpdate(const HifiSockAddr& socket) {
|
|||
return socketObject;
|
||||
}
|
||||
|
||||
const QString DOMAIN_UPDATE_AUTOMATIC_NETWORKING_KEY = "automatic_networking";
|
||||
|
||||
void DomainServer::performIPAddressUpdate(const HifiSockAddr& newPublicSockAddr) {
|
||||
updateNetworkingInfoWithDataServer(IP_ONLY_AUTOMATIC_NETWORKING_VALUE, newPublicSockAddr.getAddress().toString());
|
||||
}
|
||||
|
||||
void DomainServer::updateNetworkingInfoWithDataServer(const QString& newSetting, const QString& networkAddress) {
|
||||
const QString DOMAIN_UPDATE = "/api/v1/domains/%1";
|
||||
const QUuid& domainID = LimitedNodeList::getInstance()->getSessionUUID();
|
||||
|
||||
|
@ -941,8 +951,16 @@ void DomainServer::performIPAddressUpdate(const HifiSockAddr& newPublicSockAddr)
|
|||
const QString PUBLIC_NETWORK_ADDRESS_KEY = "network_address";
|
||||
const QString AUTOMATIC_NETWORKING_KEY = "automatic_networking";
|
||||
|
||||
const QString DOMAIN_JSON_OBJECT = "{\"domain\": { \"network_address\": \"%1\", \"automatic_networking\": \"ip\" }";
|
||||
QString domainUpdateJSON = DOMAIN_JSON_OBJECT.arg(newPublicSockAddr.getAddress().toString());
|
||||
QJsonObject domainObject;
|
||||
if (!networkAddress.isEmpty()) {
|
||||
domainObject[PUBLIC_NETWORK_ADDRESS_KEY] = networkAddress;
|
||||
}
|
||||
|
||||
qDebug() << "Updating automatic networking setting in domain-server to" << newSetting;
|
||||
|
||||
domainObject[AUTOMATIC_NETWORKING_KEY] = newSetting;
|
||||
|
||||
QString domainUpdateJSON = QString("{\"domain\": %1 }").arg(QString(QJsonDocument(domainObject).toJson()));
|
||||
|
||||
AccountManager::getInstance().authenticatedRequest(DOMAIN_UPDATE.arg(uuidStringWithoutCurlyBraces(domainID)),
|
||||
QNetworkAccessManager::PutOperation,
|
||||
|
|
|
@ -70,7 +70,9 @@ private:
|
|||
bool optionallyReadX509KeyAndCertificate();
|
||||
bool didSetupAccountManagerWithAccessToken();
|
||||
bool optionallySetupAssignmentPayment();
|
||||
|
||||
void setupAutomaticNetworking();
|
||||
void updateNetworkingInfoWithDataServer(const QString& newSetting, const QString& networkAddress = QString());
|
||||
|
||||
void processDatagram(const QByteArray& receivedPacket, const HifiSockAddr& senderSockAddr);
|
||||
|
||||
|
|
Loading…
Reference in a new issue