From f0a3a3390568a63b1472cfb28c364b392291fce2 Mon Sep 17 00:00:00 2001 From: ksuprynowicz Date: Fri, 1 Dec 2023 21:15:11 +0100 Subject: [PATCH] Fix setting external port and IP address for manual networking modes --- domain-server/resources/web/settings/js/settings.js | 10 ++++++++-- domain-server/src/DomainServer.cpp | 11 +++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/domain-server/resources/web/settings/js/settings.js b/domain-server/resources/web/settings/js/settings.js index cc7451e3f2..d3792cf36e 100644 --- a/domain-server/resources/web/settings/js/settings.js +++ b/domain-server/resources/web/settings/js/settings.js @@ -601,7 +601,7 @@ $(document).ready(function(){ form += ''; form += ' Edit'; form += ''; - form += '
This defines how nodes will connect to your domain. You can read more about automatic networking here.
'; + form += '
This defines how nodes will connect to your domain. Since the displayed setting is read back from directory server, it takes some time to update after being edited. You can read more about automatic networking here.
'; form += ''; form = $(form); @@ -664,7 +664,13 @@ $(document).ready(function(){ success: function(xhr) { console.log(xhr, parseJSONResponse(xhr)); dialog.modal('hide'); - reloadDomainInfo(); + reloadDomainInfo(); // TODO: this one doesn't work since directory server still has old data + setTimeout(function() { + reloadDomainInfo(); + }, 16000); + setTimeout(function() { + reloadDomainInfo(); + }, 64000); }, error:function(xhr) { var data = parseJSONResponse(xhr); diff --git a/domain-server/src/DomainServer.cpp b/domain-server/src/DomainServer.cpp index 060fcfa4d8..7d9456f059 100644 --- a/domain-server/src/DomainServer.cpp +++ b/domain-server/src/DomainServer.cpp @@ -1570,12 +1570,19 @@ void DomainServer::performIPAddressPortUpdate(const SockAddr& newPublicSockAddr) const QString& publicSocketAddress = newPublicSockAddr.getAddress().toString(); const int publicSocketPort = newPublicSockAddr.getPort(); - sendHeartbeatToMetaverse(publicSocketAddress, publicSocketPort); + if (_automaticNetworkingSetting == IP_ONLY_AUTOMATIC_NETWORKING_VALUE) { + sendHeartbeatToMetaverse(publicSocketAddress, 0); + } else { + // Full automatic networking, update both port and IP address + sendHeartbeatToMetaverse(publicSocketAddress, publicSocketPort); + } QJsonObject rootObject; QJsonObject domainServerObject; domainServerObject.insert(PUBLIC_SOCKET_ADDRESS_KEY, publicSocketAddress); - domainServerObject.insert(PUBLIC_SOCKET_PORT_KEY, publicSocketPort); + if (_automaticNetworkingSetting == FULL_AUTOMATIC_NETWORKING_VALUE) { + domainServerObject.insert(PUBLIC_SOCKET_PORT_KEY, publicSocketPort); + } rootObject.insert(DOMAIN_SERVER_SETTINGS_KEY, domainServerObject); QJsonDocument doc(rootObject); qDebug() << "DomainServer::performIPAddressPortUpdate: " << doc;