From af7fa97e5fd195542004d37d4b067e57827d95d4 Mon Sep 17 00:00:00 2001 From: Rick Dicaire Date: Wed, 5 Nov 2025 18:21:57 -0500 Subject: [PATCH 1/3] Provides SRV support for --directoryaddress --- src/serverlist.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/serverlist.cpp b/src/serverlist.cpp index 0488aa28d3..538a6a2bed 100644 --- a/src/serverlist.cpp +++ b/src/serverlist.cpp @@ -974,8 +974,13 @@ void CServerListManager::SetRegistered ( const bool bIsRegister ) // 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 - const QString strNetworkAddress = NetworkUtil::GetDirectoryAddress ( DirectoryType, strDirectoryAddress ); - const bool bDirectoryAddressValid = NetworkUtil().ParseNetworkAddress ( strNetworkAddress, DirectoryAddress, false ); + // Use SRV DNS discovery for directory connections + const QString strNetworkAddress = NetworkUtil::GetDirectoryAddress ( DirectoryType, strDirectoryAddress ); +#ifndef CLIENT_NO_SRV_CONNECT + const bool bDirectoryAddressValid = NetworkUtil().ParseNetworkAddressWithSrvDiscovery ( strNetworkAddress, DirectoryAddress, false ); +#else + const bool bDirectoryAddressValid = NetworkUtil().ParseNetworkAddress ( strNetworkAddress, DirectoryAddress, false ); +#endif if ( bIsRegister ) { From 5ba919d55cabe44aafd36f188265d7fb794b183e Mon Sep 17 00:00:00 2001 From: Rick Dicaire Date: Wed, 5 Nov 2025 19:26:58 -0500 Subject: [PATCH 2/3] Update comment for clarity --- src/serverlist.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/serverlist.cpp b/src/serverlist.cpp index 538a6a2bed..e5900548a7 100644 --- a/src/serverlist.cpp +++ b/src/serverlist.cpp @@ -974,7 +974,7 @@ void CServerListManager::SetRegistered ( const bool bIsRegister ) // 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 + // Use SRV DNS discovery for directory connections, fallback to A/AAAA if none. const QString strNetworkAddress = NetworkUtil::GetDirectoryAddress ( DirectoryType, strDirectoryAddress ); #ifndef CLIENT_NO_SRV_CONNECT const bool bDirectoryAddressValid = NetworkUtil().ParseNetworkAddressWithSrvDiscovery ( strNetworkAddress, DirectoryAddress, false ); From 0fa4fe6e0fff349a3a80d894bbad7aa15fd342e2 Mon Sep 17 00:00:00 2001 From: Tony Mountifield Date: Tue, 13 Jan 2026 17:42:21 +0000 Subject: [PATCH 3/3] Unlock mutex before resolving SRV --- src/serverlist.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/serverlist.cpp b/src/serverlist.cpp index e5900548a7..1a50ca1c1f 100644 --- a/src/serverlist.cpp +++ b/src/serverlist.cpp @@ -969,6 +969,12 @@ 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 @@ -982,6 +988,9 @@ void CServerListManager::SetRegistered ( const bool bIsRegister ) const bool bDirectoryAddressValid = NetworkUtil().ParseNetworkAddress ( strNetworkAddress, DirectoryAddress, false ); #endif + // lock the mutex again now that the address has been resolved. + locker.relock(); + if ( bIsRegister ) { if ( bDirectoryAddressValid )