Skip to content

Commit

Permalink
Merge pull request #1092 from hoffie/fix-633-stop-cloudflare-traffic
Browse files Browse the repository at this point in the history
Server: Stop opening a TCP connection for external IP detection
  • Loading branch information
hoffie authored Feb 26, 2021
2 parents 00b7f4e + cd8ba80 commit 8a2d54d
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@

- Avoid screen from sleeping or starting screen saver for Mac (#834)

- stop sending traffic to CloudFlare as part of the external IP detection
logic (#633, #1092), suggested by atsampson, coded by hoffie



### 3.6.2 (2020-12-12) ###
Expand Down
10 changes: 6 additions & 4 deletions src/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/serverlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1025,7 +1025,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 ) )
Expand Down
2 changes: 1 addition & 1 deletion src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#pragma once

#include <QCoreApplication>
#include <QTcpSocket>
#include <QUdpSocket>
#include <QHostAddress>
#include <QHostInfo>
#ifndef HEADLESS
Expand Down

0 comments on commit 8a2d54d

Please sign in to comment.