Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ CClient::CClient ( const quint16 iPortNumber,
bMuteOutStream ( false ),
fMuteOutStreamGain ( 1.0f ),
bIPv6Available ( false ),
Socket ( &Channel, iPortNumber, iQosNumber, "", bNDisableIPv6, bIPv6Available ),
Socket ( &Channel, iPortNumber, iQosNumber, "", "", bNDisableIPv6, bIPv6Available ),
Sound ( AudioCallback, this, bNoAutoJackConnect, strNClientName ),
iAudioInFader ( AUD_FADER_IN_MIDDLE ),
bReverbOnLeftChan ( false ),
Expand Down
50 changes: 37 additions & 13 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ int main ( int argc, char** argv )
QString strServerInfo = "";
QString strServerPublicIP = "";
QString strServerBindIP = "";
QString strServerBindIP6 = "";
QString strServerListFilter = "";
QString strWelcomeMessage = "";
QString strClientName = "";
Expand Down Expand Up @@ -455,6 +456,21 @@ int main ( int argc, char** argv )
continue;
}

// Server Bind IPv6 --------------------------------------------------

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add --serverbindip4 as an alias for --serverbindip, too, please. (Once full Directory support is available, we can add --noipv4, as well...)

if ( GetStringArgument ( argc,
argv,
i,
"--serverbindip6", // no short form
"--serverbindip6",
strArgument ) )
{
strServerBindIP6 = strArgument;
qInfo() << qUtf8Printable ( QString ( "- server bind IPv6: %1" ).arg ( strServerBindIP6 ) );
CommandLineOptions << "--serverbindip6";
ServerOnlyOptions << "--serverbindip6";
continue;
}

// Use multithreading --------------------------------------------------
if ( GetFlagArgument ( argv, i, "-T", "--multithreading" ) )
{
Expand Down Expand Up @@ -787,20 +803,17 @@ int main ( int argc, char** argv )
}
}

if ( strDirectoryAddress.isEmpty() )
if ( !strServerPublicIP.isEmpty() )
{
if ( !strServerPublicIP.isEmpty() )
if ( strDirectoryAddress.isEmpty() )
{
qWarning() << "Server Public IP will only take effect when registering a server with a directory.";
strServerPublicIP = "";
}
}
else
{
if ( !strServerPublicIP.isEmpty() )
else
{
QHostAddress InetAddr;
if ( !InetAddr.setAddress ( strServerPublicIP ) )
QHostAddress InetAddr ( strServerPublicIP );
if ( InetAddr.protocol() != QAbstractSocket::IPv4Protocol )
{
qWarning() << "Server Public IP is invalid. Only plain IP addresses are supported.";
strServerPublicIP = "";
Expand All @@ -811,13 +824,23 @@ int main ( int argc, char** argv )

if ( !strServerBindIP.isEmpty() )
{
QHostAddress InetAddr;
if ( !InetAddr.setAddress ( strServerBindIP ) )
QHostAddress InetAddr ( strServerBindIP );
if ( InetAddr.protocol() != QAbstractSocket::IPv4Protocol )
{
qWarning() << "Server Bind IP is invalid. Only plain IP addresses are supported.";
strServerBindIP = "";
}
}

if ( !strServerBindIP6.isEmpty() )
{
QHostAddress InetAddr ( strServerBindIP6 );
if ( InetAddr.protocol() != QAbstractSocket::IPv6Protocol )
{
qWarning() << "Server Bind IPv6 is invalid. Only plain IPv6 addresses are supported.";
strServerBindIP6 = "";
}
}
#ifndef NO_JSON_RPC

// strJsonRpcBind address defaults to loopback and should not be empty, but
Expand All @@ -832,8 +855,8 @@ int main ( int argc, char** argv )
// we do it here as an upfront check. The downstream network calls will error
// out on malformed addresses not caught here.
{
QHostAddress InetAddr;
if ( !InetAddr.setAddress ( strJsonRpcBindIP ) )
QHostAddress InetAddr ( strJsonRpcBindIP );
if ( InetAddr.protocol() != QAbstractSocket::IPv4Protocol )
{
qCritical() << qUtf8Printable ( QString ( "The JSON-RPC address specified is not valid, exiting. " ) );
exit ( 1 );
Expand Down Expand Up @@ -1007,6 +1030,7 @@ int main ( int argc, char** argv )
CServer Server ( iNumServerChannels,
strLoggingFileName,
strServerBindIP,
strServerBindIP6,
iPortNumber,
iQosNumber,
strDirectoryAddress,
Expand Down Expand Up @@ -1148,7 +1172,7 @@ QString UsageArguments ( char** argv )
" --noraw disable raw audio\n"
" -s, --server start Server\n"
" --serverbindip IPv4 address the Server will bind to (rather than all)\n"
" (only works if IPv6 is unavailable or disabled with --noipv6)\n"
" --serverbindip6 IPv6 address the Server will bind to (rather than all)\n"
" -T, --multithreading use multithreading to make better use of\n"
" multi-core CPUs and support more Clients\n"
" -u, --numchannels maximum number of channels\n"
Expand Down
3 changes: 2 additions & 1 deletion src/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
CServer::CServer ( const int iNewMaxNumChan,
const QString& strLoggingFileName,
const QString& strServerBindIP,
const QString& strServerBindIP6,
const quint16 iPortNumber,
const quint16 iQosNumber,
const QString& strDirectoryAddress,
Expand All @@ -74,7 +75,7 @@ CServer::CServer ( const int iNewMaxNumChan,
iCurNumChannels ( 0 ),
bDisableRaw ( bNDisableRaw ),
bIPv6Available ( false ),
Socket ( this, iPortNumber, iQosNumber, strServerBindIP, bNDisableIPv6, bIPv6Available ),
Socket ( this, iPortNumber, iQosNumber, strServerBindIP, strServerBindIP6, bNDisableIPv6, bIPv6Available ),
Logging(),
iFrameCount ( 0 ),
HighPrecisionTimer ( bNUseDoubleSystemFrameSize ),
Expand Down
1 change: 1 addition & 0 deletions src/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ class CServer : public QObject, public CServerSlots<MAX_NUM_CHANNELS>
CServer ( const int iNewMaxNumChan,
const QString& strLoggingFileName,
const QString& strServerBindIP,
const QString& strServerBindIP6,
const quint16 iPortNumber,
const quint16 iQosNumber,
const QString& strDirectoryAddress,
Expand Down
Loading
Loading