diff --git a/app/backend/computermanager.cpp b/app/backend/computermanager.cpp index dfd34d5f..e603e4dd 100644 --- a/app/backend/computermanager.cpp +++ b/app/backend/computermanager.cpp @@ -629,12 +629,17 @@ private: // Perform initial serverinfo fetch over HTTP since we don't know which cert to use QString serverInfo = fetchServerInfo(http); + if (serverInfo.isEmpty() && !m_MdnsIpv6Address.isNull()) { + // Retry using the global IPv6 address if the IPv4 or link-local IPv6 address fails + http.setAddress(m_MdnsIpv6Address.toString()); + serverInfo = fetchServerInfo(http); + } if (serverInfo.isEmpty()) { return; } // Create initial newComputer using HTTP serverinfo with no pinned cert - NvComputer* newComputer = new NvComputer(m_Address, serverInfo, QSslCertificate()); + NvComputer* newComputer = new NvComputer(http.address(), serverInfo, QSslCertificate()); // Check if we have a record of this host UUID to pull the pinned cert NvComputer* existingComputer; @@ -654,7 +659,7 @@ private: } // Update the polled computer with the HTTPS information - NvComputer httpsComputer(m_Address, serverInfo, QSslCertificate()); + NvComputer httpsComputer(http.address(), serverInfo, QSslCertificate()); newComputer->update(httpsComputer); } diff --git a/app/backend/nvhttp.cpp b/app/backend/nvhttp.cpp index 4f7038c1..b974dedd 100644 --- a/app/backend/nvhttp.cpp +++ b/app/backend/nvhttp.cpp @@ -18,18 +18,15 @@ #define QUIT_TIMEOUT_MS 30000 NvHTTP::NvHTTP(QString address, QSslCertificate serverCert) : - m_Address(address), m_ServerCert(serverCert) { - Q_ASSERT(!address.isEmpty()); - m_BaseUrlHttp.setScheme("http"); m_BaseUrlHttps.setScheme("https"); - m_BaseUrlHttp.setHost(address); - m_BaseUrlHttps.setHost(address); m_BaseUrlHttp.setPort(47989); m_BaseUrlHttps.setPort(47984); + setAddress(address); + // Never use a proxy server QNetworkProxy noProxy(QNetworkProxy::NoProxy); m_Nam.setProxy(noProxy); @@ -42,6 +39,21 @@ void NvHTTP::setServerCert(QSslCertificate serverCert) m_ServerCert = serverCert; } +void NvHTTP::setAddress(QString address) +{ + Q_ASSERT(!address.isEmpty()); + + m_Address = address; + + m_BaseUrlHttp.setHost(address); + m_BaseUrlHttps.setHost(address); +} + +QString NvHTTP::address() +{ + return m_Address; +} + QVector NvHTTP::parseQuad(QString quad) { diff --git a/app/backend/nvhttp.h b/app/backend/nvhttp.h index 7c7d6612..b2bccc4f 100644 --- a/app/backend/nvhttp.h +++ b/app/backend/nvhttp.h @@ -156,6 +156,10 @@ public: void setServerCert(QSslCertificate serverCert); + void setAddress(QString address); + + QString address(); + static QVector parseQuad(QString quad);