use an ephemeral port when using auto-networking for domain-server

This commit is contained in:
Stephen Birarda 2014-10-06 12:23:49 -07:00
parent 253fe53571
commit 319cf34b83
2 changed files with 12 additions and 8 deletions

View file

@ -189,6 +189,11 @@ bool DomainServer::optionallySetupOAuth() {
const QString DOMAIN_CONFIG_ID_KEY = "id";
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";
const QString DISABLED_AUTOMATIC_NETWORKING_VALUE = "disabled";
void DomainServer::setupNodeListAndAssignments(const QUuid& sessionUUID) {
const QString CUSTOM_PORT_OPTION = "port";
@ -196,7 +201,12 @@ void DomainServer::setupNodeListAndAssignments(const QUuid& sessionUUID) {
QVariantMap& settingsMap = _settingsManager.getSettingsMap();
if (settingsMap.contains(CUSTOM_PORT_OPTION)) {
QVariant autoNetworkingValue = _settingsManager.valueOrDefaultValueForKeyPath(METAVERSE_AUTOMATIC_NETWORKING_KEY_PATH);
if (!autoNetworkingValue.isNull() && autoNetworkingValue.toString() == FULL_AUTOMATIC_NETWORKING_VALUE) {
// when using full networking use an ephemeral port
domainServerPort = 0;
} else if (settingsMap.contains(CUSTOM_PORT_OPTION)) {
domainServerPort = (unsigned short) settingsMap.value(CUSTOM_PORT_OPTION).toUInt();
}
@ -310,12 +320,7 @@ 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";
if (!didSetupAccountManagerWithAccessToken()) {
qDebug() << "Cannot setup domain-server automatic networking without an access token.";
@ -957,7 +962,6 @@ void DomainServer::transactionJSONCallback(const QJsonObject& data) {
}
void DomainServer::requestCurrentPublicSocketViaSTUN() {
qDebug() << "Sending STUN request to retrieve public socket information.";
LimitedNodeList::getInstance()->sendSTUNRequest();
}

View file

@ -580,7 +580,7 @@ void LimitedNodeList::sendSTUNRequest() {
memcpy(stunRequestPacket + packetIndex, randomUUID.toRfc4122().data(), NUM_TRANSACTION_ID_BYTES);
// lookup the IP for the STUN server
static HifiSockAddr stunSockAddr(STUN_SERVER_HOSTNAME, STUN_SERVER_PORT);
HifiSockAddr stunSockAddr(STUN_SERVER_HOSTNAME, STUN_SERVER_PORT);
_nodeSocket.writeDatagram((char*) stunRequestPacket, sizeof(stunRequestPacket),
stunSockAddr.getAddress(), stunSockAddr.getPort());