Skip to content

Commit 76fc757

Browse files
authored
Merge pull request #3720 from softins/ipv6-auto-enable
Auto-enable IPv6 by default, unless disabled
2 parents 8fa37bf + 16c242b commit 76fc757

16 files changed

Lines changed: 182 additions & 135 deletions

src/client.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ CClient::CClient ( const quint16 iPortNumber,
5454
const QString& strConnOnStartupAddress,
5555
const bool bNoAutoJackConnect,
5656
const QString& strNClientName,
57-
const bool bNEnableIPv6,
57+
const bool bNDisableIPv6,
5858
const bool bNMuteMeInPersonalMix ) :
5959
ChannelInfo(),
6060
strClientName ( strNClientName ),
@@ -72,7 +72,8 @@ CClient::CClient ( const quint16 iPortNumber,
7272
bIsInitializationPhase ( true ),
7373
bMuteOutStream ( false ),
7474
fMuteOutStreamGain ( 1.0f ),
75-
Socket ( &Channel, iPortNumber, iQosNumber, "", bNEnableIPv6 ),
75+
bIPv6Available ( false ),
76+
Socket ( &Channel, iPortNumber, iQosNumber, "", bNDisableIPv6, bIPv6Available ),
7677
Sound ( AudioCallback, this, bNoAutoJackConnect, strNClientName ),
7778
iAudioInFader ( AUD_FADER_IN_MIDDLE ),
7879
bReverbOnLeftChan ( false ),
@@ -90,7 +91,6 @@ CClient::CClient ( const quint16 iPortNumber,
9091
bEnableAudioAlerts ( false ),
9192
bEnableOPUS64 ( false ),
9293
bJitterBufferOK ( true ),
93-
bEnableIPv6 ( bNEnableIPv6 ),
9494
bMuteMeInPersonalMix ( bNMuteMeInPersonalMix ),
9595
iServerSockBufNumFrames ( DEF_NET_BUF_SIZE_NUM_BL ),
9696
bRawAudioIsSupported ( false )
@@ -621,7 +621,7 @@ void CClient::SetRemoteChanPan ( const int iId, const float fPan )
621621
bool CClient::SetServerAddr ( QString strNAddr )
622622
{
623623
CHostAddress HostAddress;
624-
if ( NetworkUtil::ParseNetworkAddress ( strNAddr, HostAddress, bEnableIPv6 ) )
624+
if ( NetworkUtil::ParseNetworkAddress ( strNAddr, HostAddress, bIPv6Available ) )
625625
{
626626
// apply address to the channel
627627
Channel.SetAddress ( HostAddress );

src/client.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ class CClient : public QObject
153153
const QString& strConnOnStartupAddress,
154154
const bool bNoAutoJackConnect,
155155
const QString& strNClientName,
156-
const bool bNEnableIPv6,
156+
const bool bNDisableIPv6,
157157
const bool bNMuteMeInPersonalMix );
158158

159159
virtual ~CClient();
@@ -164,6 +164,9 @@ class CClient : public QObject
164164
bool IsCallbackEntered() const { return Sound.IsCallbackEntered(); }
165165
bool SetServerAddr ( QString strNAddr );
166166

167+
// IPv6 Available
168+
bool IsIPv6Available() { return bIPv6Available; }
169+
167170
double GetLevelForMeterdBLeft() { return SignalLevelMeter.GetLevelForMeterdBLeftOrMono(); }
168171
double GetLevelForMeterdBRight() { return SignalLevelMeter.GetLevelForMeterdBRight(); }
169172

@@ -391,7 +394,9 @@ class CClient : public QObject
391394
float fMuteOutStreamGain;
392395
CVector<unsigned char> vecCeltData;
393396

394-
CHighPrioSocket Socket;
397+
bool bIPv6Available; // must be before Socket - passed by reference to Socket
398+
CHighPrioSocket Socket;
399+
395400
CSound Sound;
396401
CStereoSignalLevelMeter SignalLevelMeter;
397402

@@ -427,7 +432,6 @@ class CClient : public QObject
427432
bool bEnableOPUS64;
428433

429434
bool bJitterBufferOK;
430-
bool bEnableIPv6;
431435
bool bMuteMeInPersonalMix;
432436
QMutex MutexDriverReinit;
433437

src/clientdlg.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,17 @@ CClientDlg::CClientDlg ( CClient* pNCliP,
5454
const bool bNewShowComplRegConnList,
5555
const bool bShowAnalyzerConsole,
5656
const bool bMuteStream,
57-
const bool bNEnableIPv6,
5857
QWidget* parent ) :
5958
CBaseDlg ( parent, Qt::Window ), // use Qt::Window to get min/max window buttons
6059
pClient ( pNCliP ),
6160
pSettings ( pNSetP ),
6261
bConnectDlgWasShown ( false ),
6362
bDetectFeedback ( false ),
64-
bEnableIPv6 ( bNEnableIPv6 ),
6563
eLastRecorderState ( RS_UNDEFINED ), // for SetMixerBoardDeco
6664
eLastDesign ( GD_DEFAULT ), // "
6765
ClientSettingsDlg ( pNCliP, pNSetP, parent ),
6866
ChatDlg ( parent ),
69-
ConnectDlg ( pNSetP, bNewShowComplRegConnList, bNEnableIPv6, parent ),
67+
ConnectDlg ( pNCliP, pNSetP, bNewShowComplRegConnList, parent ),
7068
AnalyzerConsole ( pNCliP, parent )
7169
{
7270
setupUi ( this );
@@ -619,12 +617,12 @@ CClientDlg::CClientDlg ( CClient* pNCliP,
619617

620618
// Don't use SRV resolution when resolving update servers.
621619

622-
if ( NetworkUtil::ParseNetworkAddressBare ( UPDATECHECK1_ADDRESS, UpdateServerHostAddress, bEnableIPv6 ) )
620+
if ( NetworkUtil::ParseNetworkAddressBare ( UPDATECHECK1_ADDRESS, UpdateServerHostAddress, pClient->IsIPv6Available() ) )
623621
{
624622
pClient->CreateCLServerListReqVerAndOSMes ( UpdateServerHostAddress );
625623
}
626624

627-
if ( NetworkUtil::ParseNetworkAddressBare ( UPDATECHECK2_ADDRESS, UpdateServerHostAddress, bEnableIPv6 ) )
625+
if ( NetworkUtil::ParseNetworkAddressBare ( UPDATECHECK2_ADDRESS, UpdateServerHostAddress, pClient->IsIPv6Available() ) )
628626
{
629627
pClient->CreateCLServerListReqVerAndOSMes ( UpdateServerHostAddress );
630628
}

src/clientdlg.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ class CClientDlg : public CBaseDlg, private Ui_CClientDlgBase
105105
const bool bNewShowComplRegConnList,
106106
const bool bShowAnalyzerConsole,
107107
const bool bMuteStream,
108-
const bool bNEnableIPv6,
109108
QWidget* parent = nullptr );
110109

111110
protected:
@@ -130,7 +129,6 @@ class CClientDlg : public CBaseDlg, private Ui_CClientDlgBase
130129
bool bConnected;
131130
bool bConnectDlgWasShown;
132131
bool bDetectFeedback;
133-
bool bEnableIPv6;
134132
ERecorderState eLastRecorderState;
135133
EGUIDesign eLastDesign;
136134
QTimer TimerSigMet;

src/connectdlg.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,9 @@ bool CMappedTreeWidgetItem::operator<( const QTreeWidgetItem& other ) const
122122
return lhs.toString() < rhs.toString();
123123
}
124124

125-
CConnectDlg::CConnectDlg ( CClientSettings* pNSetP, const bool bNewShowCompleteRegList, const bool bNEnableIPv6, QWidget* parent ) :
125+
CConnectDlg::CConnectDlg ( CClient* pNCliP, CClientSettings* pNSetP, const bool bNewShowCompleteRegList, QWidget* parent ) :
126126
CBaseDlg ( parent, Qt::Dialog ),
127+
pClient ( pNCliP ),
127128
pSettings ( pNSetP ),
128129
strSelectedAddress ( "" ),
129130
strSelectedServerName ( "" ),
@@ -132,8 +133,7 @@ CConnectDlg::CConnectDlg ( CClientSettings* pNSetP, const bool bNewShowCompleteR
132133
bReducedServerListReceived ( false ),
133134
bServerListItemWasChosen ( false ),
134135
bListFilterWasActive ( false ),
135-
bShowAllMusicians ( true ),
136-
bEnableIPv6 ( bNEnableIPv6 )
136+
bShowAllMusicians ( true )
137137
{
138138
setupUi ( this );
139139

@@ -892,7 +892,9 @@ void CConnectDlg::OnTimerPing()
892892
// try to parse host address string which is stored as user data
893893
// in the server list item GUI control element
894894
// the data to be parsed is just IP:port, so no SRV discovery is needed
895-
if ( NetworkUtil::ParseNetworkAddressBare ( pCurListViewItem->data ( LVC_NAME, Qt::UserRole ).toString(), haServerAddress, bEnableIPv6 ) )
895+
if ( NetworkUtil::ParseNetworkAddressBare ( pCurListViewItem->data ( LVC_NAME, Qt::UserRole ).toString(),
896+
haServerAddress,
897+
pClient->IsIPv6Available() ) )
896898
{
897899
// if address is valid, send ping message using a new thread
898900
#if QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 )

src/connectdlg.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class CConnectDlg : public CBaseDlg, private Ui_CConnectDlgBase
8484
Q_OBJECT
8585

8686
public:
87-
CConnectDlg ( CClientSettings* pNSetP, const bool bNewShowCompleteRegList, const bool bNEnableIPv6, QWidget* parent = nullptr );
87+
CConnectDlg ( CClient* pNCliP, CClientSettings* pNSetP, const bool bNewShowCompleteRegList, QWidget* parent = nullptr );
8888

8989
void SetShowAllMusicians ( const bool bState ) { ShowAllMusicians ( bState ); }
9090
bool GetShowAllMusicians() { return bShowAllMusicians; }
@@ -127,6 +127,7 @@ class CConnectDlg : public CBaseDlg, private Ui_CConnectDlgBase
127127
void EmitCLServerListPingMes ( const CHostAddress& haServerAddress, const bool bNeedVersion );
128128
void UpdateDirectoryComboBox();
129129

130+
CClient* pClient;
130131
CClientSettings* pSettings;
131132

132133
QTimer TimerPing;
@@ -141,7 +142,6 @@ class CConnectDlg : public CBaseDlg, private Ui_CConnectDlgBase
141142
bool bServerListItemWasChosen;
142143
bool bListFilterWasActive;
143144
bool bShowAllMusicians;
144-
bool bEnableIPv6;
145145

146146
public slots:
147147
void OnServerListItemDoubleClicked ( QTreeWidgetItem* Item, int );

src/main.cpp

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ int main ( int argc, char** argv )
118118
bool bNoAutoJackConnect = false;
119119
bool bUseTranslation = true;
120120
bool bCustomPortNumberGiven = false;
121-
bool bEnableIPv6 = false;
121+
bool bDisableIPv6 = false;
122122
int iNumServerChannels = DEFAULT_USED_NUM_CHANNELS;
123123
quint16 iPortNumber = DEFAULT_PORT_NUMBER;
124124
int iJsonRpcPortNumber = INVALID_PORT;
@@ -262,11 +262,19 @@ int main ( int argc, char** argv )
262262
continue;
263263
}
264264

265+
// Disable IPv6 ---------------------------------------------------------
266+
if ( GetFlagArgument ( argv, i, "--noipv6", "--noipv6" ) )
267+
{
268+
bDisableIPv6 = true;
269+
qInfo() << "- IPv6 disabled";
270+
CommandLineOptions << "--noipv6";
271+
continue;
272+
}
273+
265274
// Enable IPv6 ---------------------------------------------------------
266275
if ( GetFlagArgument ( argv, i, "-6", "--enableipv6" ) )
267276
{
268-
bEnableIPv6 = true;
269-
qInfo() << "- IPv6 enabled";
277+
qWarning() << "IPv6 is now enabled by default: -6 and --enableipv6 have no effect and are deprecated";
270278
CommandLineOptions << "--enableipv6";
271279
continue;
272280
}
@@ -943,7 +951,8 @@ int main ( int argc, char** argv )
943951
#ifndef SERVER_ONLY
944952
if ( bIsClient )
945953
{
946-
CClient Client ( iPortNumber, iQosNumber, strConnOnStartupAddress, bNoAutoJackConnect, strClientName, bEnableIPv6, bMuteMeInPersonalMix );
954+
CClient
955+
Client ( iPortNumber, iQosNumber, strConnOnStartupAddress, bNoAutoJackConnect, strClientName, bDisableIPv6, bMuteMeInPersonalMix );
947956

948957
// Create Settings with the client pointer
949958
CClientSettings Settings ( &Client, strIniFileName );
@@ -968,14 +977,8 @@ int main ( int argc, char** argv )
968977
}
969978

970979
// GUI object
971-
CClientDlg ClientDlg ( &Client,
972-
&Settings,
973-
strConnOnStartupAddress,
974-
bShowComplRegConnList,
975-
bShowAnalyzerConsole,
976-
bMuteStream,
977-
bEnableIPv6,
978-
nullptr );
980+
CClientDlg
981+
ClientDlg ( &Client, &Settings, strConnOnStartupAddress, bShowComplRegConnList, bShowAnalyzerConsole, bMuteStream, nullptr );
979982

980983
// show dialog
981984
ClientDlg.show();
@@ -1014,7 +1017,7 @@ int main ( int argc, char** argv )
10141017
bUseMultithreading,
10151018
bDisableRecording,
10161019
bDelayPan,
1017-
bEnableIPv6,
1020+
bDisableIPv6,
10181021
eLicenceType );
10191022

10201023
#ifndef NO_JSON_RPC
@@ -1116,7 +1119,8 @@ QString UsageArguments ( char** argv )
11161119
" -Q, --qos set the QoS value. Default is 128. Disable with 0\n"
11171120
" (see the Jamulus website to enable QoS on Windows)\n"
11181121
" -t, --notranslation disable translation (use English language)\n"
1119-
" -6, --enableipv6 enable IPv6 addressing (IPv4 is always enabled)\n"
1122+
" --noipv6 disable IPv6 addressing (IPv4 is always enabled)\n"
1123+
" (recommended to leave IPv6 enabled by default)\n"
11201124
"\n"
11211125
"Server only:\n"
11221126
" -d, --discononquit disconnect all Clients on quit\n"
@@ -1138,7 +1142,8 @@ QString UsageArguments ( char** argv )
11381142
" --norecord set server not to record by default when recording is configured\n"
11391143
" --noraw disable raw audio\n"
11401144
" -s, --server start Server\n"
1141-
" --serverbindip IP address the Server will bind to (rather than all)\n"
1145+
" --serverbindip IPv4 address the Server will bind to (rather than all)\n"
1146+
" (only works if IPv6 is unavailable or disabled with --noipv6)\n"
11421147
" -T, --multithreading use multithreading to make better use of\n"
11431148
" multi-core CPUs and support more Clients\n"
11441149
" -u, --numchannels maximum number of channels\n"

src/server.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,31 +65,31 @@ CServer::CServer ( const int iNewMaxNumChan,
6565
const bool bNUseMultithreading,
6666
const bool bDisableRecording,
6767
const bool bNDelayPan,
68-
const bool bNEnableIPv6,
68+
const bool bNDisableIPv6,
6969
const ELicenceType eNLicenceType ) :
7070
bUseDoubleSystemFrameSize ( bNUseDoubleSystemFrameSize ),
7171
bUseMultithreading ( bNUseMultithreading ),
7272
iMaxNumChannels ( iNewMaxNumChan ),
7373
iCurNumChannels ( 0 ),
7474
bDisableRaw ( bNDisableRaw ),
75-
Socket ( this, iPortNumber, iQosNumber, strServerBindIP, bNEnableIPv6 ),
75+
bIPv6Available ( false ),
76+
Socket ( this, iPortNumber, iQosNumber, strServerBindIP, bNDisableIPv6, bIPv6Available ),
7677
Logging(),
7778
iFrameCount ( 0 ),
7879
HighPrecisionTimer ( bNUseDoubleSystemFrameSize ),
79-
ServerListManager ( iPortNumber,
80+
ServerListManager ( this,
81+
iPortNumber,
8082
strDirectoryAddress,
8183
strServerListFileName,
8284
strServerInfo,
8385
strServerPublicIP,
8486
strServerListFilter,
8587
iNewMaxNumChan,
86-
bNEnableIPv6,
8788
&ConnLessProtocol ),
8889
JamController ( this ),
8990
bDisableRecording ( bDisableRecording ),
9091
bAutoRunMinimized ( false ),
9192
bDelayPan ( bNDelayPan ),
92-
bEnableIPv6 ( bNEnableIPv6 ),
9393
eLicenceType ( eNLicenceType ),
9494
bDisconnectAllClientsOnQuit ( bNDisconnectAllClientsOnQuit ),
9595
pSignalHandler ( CSignalHandler::getSingletonP() )

src/server.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ class CServer : public QObject, public CServerSlots<MAX_NUM_CHANNELS>
125125
const bool bNUseMultithreading,
126126
const bool bDisableRecording,
127127
const bool bNDelayPan,
128-
const bool bNEnableIPv6,
128+
const bool bNDisableIPv6,
129129
const ELicenceType eNLicenceType );
130130

131131
virtual ~CServer();
@@ -146,8 +146,8 @@ class CServer : public QObject, public CServerSlots<MAX_NUM_CHANNELS>
146146

147147
void CreateCLServerListReqVerAndOSMes ( const CHostAddress& InetAddr ) { ConnLessProtocol.CreateCLReqVersionAndOSMes ( InetAddr ); }
148148

149-
// IPv6 Enabled
150-
bool IsIPv6Enabled() { return bEnableIPv6; }
149+
// IPv6 Available
150+
bool IsIPv6Available() { return bIPv6Available; }
151151

152152
// GUI settings ------------------------------------------------------------
153153
int GetClientNumAudioChannels ( const int iChanNum ) { return vecChannels[iChanNum].GetNumAudioChannels(); }
@@ -291,6 +291,7 @@ class CServer : public QObject, public CServerSlots<MAX_NUM_CHANNELS>
291291
CVector<uint16_t> vecChannelLevels;
292292

293293
// actual working objects
294+
bool bIPv6Available; // must be before Socket - passed by reference to Socket
294295
CHighPrioSocket Socket;
295296

296297
// logging
@@ -314,9 +315,6 @@ class CServer : public QObject, public CServerSlots<MAX_NUM_CHANNELS>
314315
// for delay panning
315316
bool bDelayPan;
316317

317-
// enable IPv6
318-
bool bEnableIPv6;
319-
320318
// messaging
321319
QString strWelcomeMessage;
322320
ELicenceType eLicenceType;

src/serverdlg.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -506,12 +506,12 @@ CServerDlg::CServerDlg ( CServer* pNServP, CServerSettings* pNSetP, const bool b
506506

507507
// Don't use SRV resolution when resolving update servers.
508508

509-
if ( NetworkUtil::ParseNetworkAddressBare ( UPDATECHECK1_ADDRESS, UpdateServerHostAddress, pServer->IsIPv6Enabled() ) )
509+
if ( NetworkUtil::ParseNetworkAddressBare ( UPDATECHECK1_ADDRESS, UpdateServerHostAddress, pServer->IsIPv6Available() ) )
510510
{
511511
pServer->CreateCLServerListReqVerAndOSMes ( UpdateServerHostAddress );
512512
}
513513

514-
if ( NetworkUtil::ParseNetworkAddressBare ( UPDATECHECK2_ADDRESS, UpdateServerHostAddress, pServer->IsIPv6Enabled() ) )
514+
if ( NetworkUtil::ParseNetworkAddressBare ( UPDATECHECK2_ADDRESS, UpdateServerHostAddress, pServer->IsIPv6Available() ) )
515515
{
516516
pServer->CreateCLServerListReqVerAndOSMes ( UpdateServerHostAddress );
517517
}

0 commit comments

Comments
 (0)