Skip to content

Commit 0ae51e2

Browse files
committed
Add CLM_TCP_SUPPORTED message generation when TCP enabled
1 parent 174eb50 commit 0ae51e2

File tree

4 files changed

+26
-1
lines changed

4 files changed

+26
-1
lines changed

src/server.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ CServer::CServer ( const int iNewMaxNumChan,
6565
strServerListFilter,
6666
iNewMaxNumChan,
6767
bNEnableIPv6,
68+
bNEnableTcp,
6869
&ConnLessProtocol ),
6970
JamController ( this ),
7071
bDisableRecording ( bDisableRecording ),
@@ -386,6 +387,12 @@ void CServer::OnNewConnection ( int iChID, int iTotChans, CHostAddress RecHostAd
386387
{
387388
QMutexLocker locker ( &Mutex );
388389

390+
// if TCP is enabled, we need to announce this first, before sending Client ID
391+
if ( bEnableTcp )
392+
{
393+
ConnLessProtocol.CreateCLTcpSupportedMes ( vecChannels[iChID].GetAddress() );
394+
}
395+
389396
// inform the client about its own ID at the server (note that this
390397
// must be the first message to be sent for a new connection)
391398
vecChannels[iChID].CreateClientIDMes ( iChID );

src/server.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,12 @@ public slots:
369369
void OnCLReqConnClientsList ( CHostAddress InetAddr, CTcpConnection* pTcpConnection )
370370
{
371371
ConnLessProtocol.CreateCLConnClientsListMes ( InetAddr, CreateChannelList(), pTcpConnection );
372+
373+
// if TCP is enabled but this request is on UDP, say TCP is supported
374+
if ( bEnableTcp && !pTcpConnection )
375+
{
376+
ConnLessProtocol.CreateCLTcpSupportedMes ( InetAddr );
377+
}
372378
}
373379

374380
void OnCLRegisterServerReceived ( CHostAddress InetAddr, CHostAddress LInetAddr, CServerCoreInfo ServerInfo )

src/serverlist.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,11 @@ CServerListManager::CServerListManager ( const quint16 iNPortNum,
128128
const QString& strServerPublicIP,
129129
const int iNumChannels,
130130
const bool bNEnableIPv6,
131+
const bool bNEnableTcp,
131132
CProtocol* pNConLProt ) :
132133
DirectoryType ( AT_NONE ),
133134
bEnableIPv6 ( bNEnableIPv6 ),
135+
bEnableTcp ( bNEnableTcp ),
134136
ServerListFileName ( strServerListFileName ),
135137
strDirectoryAddress ( "" ),
136138
bIsDirectory ( false ),
@@ -709,7 +711,9 @@ void CServerListManager::RetrieveAll ( const CHostAddress& InetAddr, CTcpConnect
709711
}
710712

711713
// do not send a "ping" to a server local to the directory (no need)
712-
if ( !serverIsInternal )
714+
// also only do so if processing a request over UDP, not TCP,
715+
// as the client will always try UDP before TCP.
716+
if ( !serverIsInternal && !pTcpConnection )
713717
{
714718
// create "send empty message" for all other registered servers
715719
// this causes the server (vecServerInfo[iIdx].HostAddr)
@@ -728,6 +732,12 @@ void CServerListManager::RetrieveAll ( const CHostAddress& InetAddr, CTcpConnect
728732
pConnLessProtocol->CreateCLRedServerListMes ( InetAddr, vecServerInfo );
729733
}
730734
pConnLessProtocol->CreateCLServerListMes ( InetAddr, vecServerInfo, pTcpConnection );
735+
736+
// if TCP is enabled but this request is on UDP, say TCP is supported
737+
if ( bEnableTcp && !pTcpConnection )
738+
{
739+
pConnLessProtocol->CreateCLTcpSupportedMes ( InetAddr );
740+
}
731741
}
732742
}
733743

src/serverlist.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ class CServerListManager : public QObject
141141
const QString& strServerPublicIP,
142142
const int iNumChannels,
143143
const bool bNEnableIPv6,
144+
const bool bNEnableTcp,
144145
CProtocol* pNConLProt );
145146

146147
void SetServerName ( const QString& strNewName );
@@ -192,6 +193,7 @@ class CServerListManager : public QObject
192193
EDirectoryType DirectoryType;
193194

194195
bool bEnableIPv6;
196+
bool bEnableTcp;
195197

196198
CHostAddress ServerPublicIP;
197199
CHostAddress ServerPublicIP6;

0 commit comments

Comments
 (0)