diff --git a/ChangeLog b/ChangeLog index 6164a1d5a5..688bef18cf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -42,6 +42,9 @@ - bug fix: fix crash if settings are changed in ASIO4ALL during a connection (contained in #796). Reverts #727 for Windows +- stop sending traffic to CloudFlare as part of the external IP detection + logic (#633, #1092), suggested by atsampson, coded by hoffie + diff --git a/src/global.h b/src/global.h index 73fe4be94d..0a8a26f028 100755 --- a/src/global.h +++ b/src/global.h @@ -109,10 +109,12 @@ LED bar: lbr #define SOFTWARE_MANUAL_URL "https://jamulus.io/wiki/Software-Manual" // determining server internal address uses well-known host and port -// (You can change the service used here to something like Cloudflare (1.1.1.1), Google DNS (8.8.8.8), or something else reliable) -#define WELL_KNOWN_HOST "1.1.1.1" // CloudFlare -#define WELL_KNOWN_PORT 53 // DNS -#define IP_LOOKUP_TIMEOUT 500 // ms +// We just need a valid, public Internet IP here. We will not send any +// traffic there as we will only set up an UDP socket without sending any +// data. +#define WELL_KNOWN_HOST "1.1.1.1" // CloudFlare +#define WELL_KNOWN_PORT DEFAULT_PORT_NUMBER +#define IP_LOOKUP_TIMEOUT 500 // ms // system sample rate (the sound card and audio coder works on this sample rate) #define SYSTEM_SAMPLE_RATE_HZ 48000 // Hz diff --git a/src/serverlist.cpp b/src/serverlist.cpp index 79d0c4768d..86dcb53e4c 100755 --- a/src/serverlist.cpp +++ b/src/serverlist.cpp @@ -53,6 +53,7 @@ CServerListManager::CServerListManager ( const quint16 iNPortNum, // User-supplied --serverpublicip qhaServerPublicIP = QHostAddress ( strServerPublicIP ); } + qDebug() << "Using" << qhaServerPublicIP.toString() << "as external IP."; SlaveCurLocalHostAddress = CHostAddress ( qhaServerPublicIP, iNPortNum ); // prepare the server info information diff --git a/src/util.cpp b/src/util.cpp index e549ac9cf3..7a1f2307be 100755 --- a/src/util.cpp +++ b/src/util.cpp @@ -1024,7 +1024,10 @@ bool NetworkUtil::ParseNetworkAddress ( QString strAddress, CHostAddress NetworkUtil::GetLocalAddress() { - QTcpSocket socket; + QUdpSocket socket; + // As we are using UDP, the connectToHost() does not generate any traffic at all. + // We just require a socket which is pointed towards the Internet in + // order to find out the IP of our own external interface: socket.connectToHost ( WELL_KNOWN_HOST, WELL_KNOWN_PORT ); if ( socket.waitForConnected ( IP_LOOKUP_TIMEOUT ) ) diff --git a/src/util.h b/src/util.h index 3c8d766de7..f821f2c32e 100755 --- a/src/util.h +++ b/src/util.h @@ -25,7 +25,7 @@ #pragma once #include -#include +#include #include #include #ifndef HEADLESS