Skip to content
Open
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
6 changes: 1 addition & 5 deletions src/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -570,11 +570,7 @@ void CClient::SetRemoteChanPan ( const int iId, const float fPan )
bool CClient::SetServerAddr ( QString strNAddr )
{
CHostAddress HostAddress;
#ifdef CLIENT_NO_SRV_CONNECT
if ( NetworkUtil().ParseNetworkAddress ( strNAddr, HostAddress, bEnableIPv6 ) )
#else
if ( NetworkUtil().ParseNetworkAddressWithSrvDiscovery ( strNAddr, HostAddress, bEnableIPv6 ) )
#endif
if ( NetworkUtil::ParseNetworkAddress ( strNAddr, HostAddress, bEnableIPv6 ) )
{
// apply address to the channel
Channel.SetAddress ( HostAddress );
Expand Down
4 changes: 2 additions & 2 deletions src/clientdlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -588,12 +588,12 @@ CClientDlg::CClientDlg ( CClient* pNCliP,
// Send the request to two servers for redundancy if either or both of them
// has a higher release version number, the reply will trigger the notification.

if ( NetworkUtil().ParseNetworkAddress ( UPDATECHECK1_ADDRESS, UpdateServerHostAddress, bEnableIPv6 ) )
if ( NetworkUtil::ParseNetworkAddress ( UPDATECHECK1_ADDRESS, UpdateServerHostAddress, bEnableIPv6 ) )
Copy link
Collaborator

Choose a reason for hiding this comment

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

See comment in global.h -- I think these should go through ...Bare (for safety).

{
pClient->CreateCLServerListReqVerAndOSMes ( UpdateServerHostAddress );
}

if ( NetworkUtil().ParseNetworkAddress ( UPDATECHECK2_ADDRESS, UpdateServerHostAddress, bEnableIPv6 ) )
if ( NetworkUtil::ParseNetworkAddress ( UPDATECHECK2_ADDRESS, UpdateServerHostAddress, bEnableIPv6 ) )
{
pClient->CreateCLServerListReqVerAndOSMes ( UpdateServerHostAddress );
}
Expand Down
4 changes: 3 additions & 1 deletion src/clientrpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ CClientRpc::CClientRpc ( CClient* pClient, CRpcServer* pRpcServer, QObject* pare
}

CHostAddress haDirectoryAddress;
if ( NetworkUtil().ParseNetworkAddress ( jsonDirectoryIp.toString(), haDirectoryAddress, false ) )

// Allow IPv4 only for communicating with Directories
if ( NetworkUtil::ParseNetworkAddress ( jsonDirectoryIp.toString(), haDirectoryAddress, false ) )
{
// send the request for the server list
pClient->CreateCLReqServerListMes ( haDirectoryAddress );
Expand Down
7 changes: 4 additions & 3 deletions src/connectdlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,13 +318,13 @@ void CConnectDlg::RequestServerList()
}
cbxDirectory->blockSignals ( false );

// Get the IP address of the directory server (using the ParseNetworAddress
// Get the IP address of the directory server (using the ParseNetworkAddress
// function) when the connect dialog is opened, this seems to be the correct
// time to do it. Note that in case of custom directories we
// use iCustomDirectoryIndex as an index into the vector.

// Allow IPv4 only for communicating with Directories
if ( NetworkUtil().ParseNetworkAddress (
if ( NetworkUtil::ParseNetworkAddress (
NetworkUtil::GetDirectoryAddress ( pSettings->eDirectoryType, pSettings->vstrDirectoryAddress[pSettings->iCustomDirectoryIndex] ),
haDirectoryAddress,
false ) )
Expand Down Expand Up @@ -856,7 +856,8 @@ void CConnectDlg::OnTimerPing()

// try to parse host address string which is stored as user data
// in the server list item GUI control element
Copy link
Collaborator

Choose a reason for hiding this comment

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

As per serverlist.cpp comment -- I think these are meant to be plain text, not resolved addresses, so that dynamic DNS can be used at all times, which would include dynamic SRV in my opinion (i.e. a temporary server moving port and IP but keeping the same "simple" registered server name).

if ( NetworkUtil().ParseNetworkAddress ( pCurListViewItem->data ( LVC_NAME, Qt::UserRole ).toString(), haServerAddress, bEnableIPv6 ) )
// the data to be parsed is just IP:port, so no SRV discovery is needed
if ( NetworkUtil::ParseNetworkAddressBare ( pCurListViewItem->data ( LVC_NAME, Qt::UserRole ).toString(), haServerAddress, bEnableIPv6 ) )
{
// if address is valid, send ping message using a new thread
#if QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 )
Expand Down
4 changes: 2 additions & 2 deletions src/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ LED bar: lbr
#define MAX_DELAY_PANNING_SAMPLES 64

// default server address and port numbers
#define DEFAULT_QOS_NUMBER 128 // CS4 (Quality of Service)
#define DEFAULT_SERVER_ADDRESS "anygenre1.jamulus.io"
#define DEFAULT_QOS_NUMBER 128 // CS4 (Quality of Service)
#define DEFAULT_SERVER_ADDRESS "anygenre1.jamulus.io:22124" // default port explicit to avoid unneeded SRV lookup
#define DEFAULT_PORT_NUMBER 22124
#define CENTSERV_ANY_GENRE2 "anygenre2.jamulus.io:22224"
#define CENTSERV_ANY_GENRE3 "anygenre3.jamulus.io:22624"
Expand Down
4 changes: 2 additions & 2 deletions src/serverdlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -482,12 +482,12 @@ CServerDlg::CServerDlg ( CServer* pNServP, CServerSettings* pNSetP, const bool b
// Send the request to two servers for redundancy if either or both of them
// has a higher release version number, the reply will trigger the notification.

if ( NetworkUtil().ParseNetworkAddress ( UPDATECHECK1_ADDRESS, UpdateServerHostAddress, pServer->IsIPv6Enabled() ) )
if ( NetworkUtil::ParseNetworkAddress ( UPDATECHECK1_ADDRESS, UpdateServerHostAddress, pServer->IsIPv6Enabled() ) )
Copy link
Collaborator

Choose a reason for hiding this comment

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

As client.

{
pServer->CreateCLServerListReqVerAndOSMes ( UpdateServerHostAddress );
}

if ( NetworkUtil().ParseNetworkAddress ( UPDATECHECK2_ADDRESS, UpdateServerHostAddress, pServer->IsIPv6Enabled() ) )
if ( NetworkUtil::ParseNetworkAddress ( UPDATECHECK2_ADDRESS, UpdateServerHostAddress, pServer->IsIPv6Enabled() ) )
{
pServer->CreateCLServerListReqVerAndOSMes ( UpdateServerHostAddress );
}
Expand Down
16 changes: 14 additions & 2 deletions src/serverlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,9 @@ bool CServerListManager::Load()
continue;
}

NetworkUtil::ParseNetworkAddress ( slLine[0], haServerHostAddr, bEnableIPv6 );
// This uses ParseNetworkAddressBare because it is just parsing ip:host that was saved to the file.
// Therefore no SRV lookup is appropriate.
NetworkUtil::ParseNetworkAddressBare ( slLine[0], haServerHostAddr, bEnableIPv6 );
Copy link
Collaborator

Choose a reason for hiding this comment

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

Needs a comment explaining why

Copy link
Member

Choose a reason for hiding this comment

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

Done

Copy link
Collaborator

@pljones pljones Jan 24, 2026

Choose a reason for hiding this comment

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

I think it stores the registered string, not the resolved string, to allow for dynamic DNS. (Same with the server list returned from the Directory to the Client -- it's unresolved entries.)

int iIdx = IndexOf ( haServerHostAddr );
if ( iIdx != INVALID_INDEX )
{
Expand Down Expand Up @@ -969,13 +971,23 @@ void CServerListManager::SetRegistered ( const bool bIsRegister )
return;
}

// It is very important to unlock the Mutex before doing address resolution,
// so that the event loop can run and any other timers that need the mutex
// can obtain it. Otherwise there is the possibility of deadlock when doing
// the SRV lookup, if another timer fires that needs the same mutex.
locker.unlock();

// get the correct directory address
// Note that we always have to parse the server address again since if
// it is an URL of a dynamic IP address, the IP address might have
// changed in the meanwhile.
// Allow IPv4 only for communicating with Directories
// Use SRV DNS discovery for directory connections, fallback to A/AAAA if none.
const QString strNetworkAddress = NetworkUtil::GetDirectoryAddress ( DirectoryType, strDirectoryAddress );
const bool bDirectoryAddressValid = NetworkUtil().ParseNetworkAddress ( strNetworkAddress, DirectoryAddress, false );
const bool bDirectoryAddressValid = NetworkUtil::ParseNetworkAddress ( strNetworkAddress, DirectoryAddress, false );

// lock the mutex again now that the address has been resolved.
locker.relock();

if ( bIsRegister )
{
Expand Down
12 changes: 7 additions & 5 deletions src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ bool NetworkUtil::ParseNetworkAddressString ( QString strAddress, QHostAddress&
return false;
}

#ifndef CLIENT_NO_SRV_CONNECT
#ifndef DISABLE_SRV_DNS
bool NetworkUtil::ParseNetworkAddressSrv ( QString strAddress, CHostAddress& HostAddress, bool bEnableIPv6 )
{
// init requested host address with invalid address first
Expand Down Expand Up @@ -806,20 +806,22 @@ bool NetworkUtil::ParseNetworkAddressSrv ( QString strAddress, CHostAddress& Hos
}
return false;
}
#endif

bool NetworkUtil::ParseNetworkAddressWithSrvDiscovery ( QString strAddress, CHostAddress& HostAddress, bool bEnableIPv6 )
bool NetworkUtil::ParseNetworkAddress ( QString strAddress, CHostAddress& HostAddress, bool bEnableIPv6 )
{
#ifndef DISABLE_SRV_DNS
// Try SRV-based discovery first:
if ( ParseNetworkAddressSrv ( strAddress, HostAddress, bEnableIPv6 ) )
{
return true;
}
#endif
// Try regular connect via plain IP or host name lookup (A/AAAA):
return ParseNetworkAddress ( strAddress, HostAddress, bEnableIPv6 );
return ParseNetworkAddressBare ( strAddress, HostAddress, bEnableIPv6 );
}
#endif

bool NetworkUtil::ParseNetworkAddress ( QString strAddress, CHostAddress& HostAddress, bool bEnableIPv6 )
bool NetworkUtil::ParseNetworkAddressBare ( QString strAddress, CHostAddress& HostAddress, bool bEnableIPv6 )
{
QHostAddress InetAddr;
unsigned int iNetPort = DEFAULT_PORT_NUMBER;
Expand Down
6 changes: 3 additions & 3 deletions src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
#include <QElapsedTimer>
#include <QTextBoundaryFinder>
#include <QTimer>
#ifndef CLIENT_NO_SRV_CONNECT
#ifndef DISABLE_SRV_DNS
# include <QDnsLookup>
#endif
#ifndef _WIN32
Expand Down Expand Up @@ -1055,11 +1055,11 @@ class NetworkUtil
public:
static bool ParseNetworkAddressString ( QString strAddress, QHostAddress& InetAddr, bool bEnableIPv6 );

#ifndef CLIENT_NO_SRV_CONNECT
#ifndef DISABLE_SRV_DNS
static bool ParseNetworkAddressSrv ( QString strAddress, CHostAddress& HostAddress, bool bEnableIPv6 );
static bool ParseNetworkAddressWithSrvDiscovery ( QString strAddress, CHostAddress& HostAddress, bool bEnableIPv6 );
#endif
static bool ParseNetworkAddress ( QString strAddress, CHostAddress& HostAddress, bool bEnableIPv6 );
static bool ParseNetworkAddressBare ( QString strAddress, CHostAddress& HostAddress, bool bEnableIPv6 );

static QString FixAddress ( const QString& strAddress );
static CHostAddress GetLocalAddress();
Expand Down