Skip to content

Commit

Permalink
Certain other rewording
Browse files Browse the repository at this point in the history
  • Loading branch information
pljones committed Oct 25, 2021
1 parent 7051ab3 commit 9ea13f0
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 38 deletions.
2 changes: 1 addition & 1 deletion src/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ LED bar: lbr
// time interval for sending ping messages to servers in the server list
#define SERVLIST_UPDATE_PING_SERVERS_MS 59000 // ms

// time until a slave server registers in the server list
// time between server registration refreshes
#define SERVLIST_REGIST_INTERV_MINUTES 15 // minutes

// defines the minimum time a server must run to be a permanent server
Expand Down
4 changes: 2 additions & 2 deletions src/protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,8 @@ CONNECTION LESS MESSAGES
NOTE: In the PROTMESSID_CLM_SERVER_LIST list, this field will be empty
as only the initial IP address should be used by the client. Where
necessary, that value will contain the server internal address.
When running a directory server and a slave server behind the same NAT,
this field is used the other way round: It will contain the public
When running a directory server and a registered server behind the same
NAT, this field is used the other way round: It will contain the public
IP in this case which will be served to clients from the Internet.
Expand Down
2 changes: 1 addition & 1 deletion src/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ void CServer::OnAboutToQuit()
// if server was registered at the directory server, unregister on shutdown
if ( GetServerRegistered() )
{
UnregisterSlaveServer();
Unregister();
}

if ( bWriteStatusHTMLFile )
Expand Down
2 changes: 1 addition & 1 deletion src/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ class CServer : public QObject, public CServerSlots<MAX_NUM_CHANNELS>
// Server list management --------------------------------------------------
void UpdateServerList() { ServerListManager.Update(); }

void UnregisterSlaveServer() { ServerListManager.SlaveServerUnregister(); }
void Unregister() { ServerListManager.Unregister(); }

void SetServerRegistered ( const bool bState ) { ServerListManager.SetEnabled ( bState ); }

Expand Down
4 changes: 2 additions & 2 deletions src/serverdlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -469,10 +469,10 @@ void CServerDlg::OnRegisterServerStateChanged ( int value )
// apply new setting to the server and update it
pServer->SetServerRegistered ( bRegState );

// if registering is disabled, unregister slave server
// if registering is disabled, unregister server
if ( !bRegState )
{
pServer->UnregisterSlaveServer();
pServer->Unregister();
}

pServer->UpdateServerList();
Expand Down
46 changes: 22 additions & 24 deletions src/serverlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ CServerListManager::CServerListManager ( const quint16 iNPortNum,
qhaServerPublicIP = QHostAddress ( strServerPublicIP );
}
qDebug() << "Using" << qhaServerPublicIP.toString() << "as external IP.";
SlaveCurLocalHostAddress = CHostAddress ( qhaServerPublicIP, iNPortNum );
ServerPublicIP = CHostAddress ( qhaServerPublicIP, iNPortNum );

if ( bEnableIPv6 )
{
Expand All @@ -134,7 +134,7 @@ CServerListManager::CServerListManager ( const quint16 iNPortNum,

qhaServerPublicIP6 = NetworkUtil::GetLocalAddress6().InetAddr;
qDebug() << "Using" << qhaServerPublicIP6.toString() << "as external IPv6.";
SlaveCurLocalHostAddress6 = CHostAddress ( qhaServerPublicIP6, iNPortNum );
ServerPublicIP6 = CHostAddress ( qhaServerPublicIP6, iNPortNum );
}

// prepare the server info information
Expand All @@ -154,8 +154,7 @@ CServerListManager::CServerListManager ( const quint16 iNPortNum,
// definition the client substitutes the IP address of the directory server
// itself for his server list. If we are a directory server, we assume that
// we are a permanent server.
CServerListEntry
ThisServerListEntry ( CHostAddress(), SlaveCurLocalHostAddress, "", QLocale::system().country(), "", iNumChannels, bIsDirectoryServer );
CServerListEntry ThisServerListEntry ( CHostAddress(), ServerPublicIP, "", QLocale::system().country(), "", iNumChannels, bIsDirectoryServer );

// parse the server info string according to definition:
// [this server name];[this server city];[this server country as QLocale ID] (; ... ignored)
Expand Down Expand Up @@ -219,8 +218,8 @@ CServerListManager::CServerListManager ( const quint16 iNPortNum,
}
}

// for slave servers start the one shot timer for determining if it is a
// permanent server
// start the one shot timer for determining if this is a
// permanent registered server
if ( !bIsDirectoryServer )
{
// 1 minute = 60 * 1000 ms
Expand Down Expand Up @@ -256,7 +255,7 @@ void CServerListManager::SetDirectoryAddress ( const QString sNDirectoryAddress
// if we are registered to a custom directory server, unregister before updating the name
if ( eDirectoryType == AT_CUSTOM && GetSvrRegStatus() == SRS_REGISTERED )
{
SlaveServerUnregister();
Unregister();
}

QMutexLocker locker ( &Mutex );
Expand All @@ -272,7 +271,7 @@ void CServerListManager::SetDirectoryType ( const EDirectoryType eNCSAT )
// if the type is changing, unregister before updating
if ( eNCSAT != eDirectoryType && GetSvrRegStatus() == SRS_REGISTERED )
{
SlaveServerUnregister();
Unregister();
}

QMutexLocker locker ( &Mutex );
Expand Down Expand Up @@ -315,10 +314,9 @@ void CServerListManager::Update()
else
{
// initiate registration right away so that we do not have to wait
// for the first time out of the timer until the slave server gets
// registered at the directory server, note that we have to unlock
// the mutex before calling the function since inside this function
// the mutex is locked, too
// for the first time out of the timer to get registered.
// note that we have to unlock the mutex before calling the function
// since inside this function the mutex is locked, too
locker.unlock();
{
OnTimerRefreshRegistration();
Expand All @@ -339,7 +337,7 @@ void CServerListManager::Update()
// keep the port open at the NAT router.
// If no NAT is used, we send the messages anyway since they do
// not hurt (very low traffic). We also reuse the same update
// time as used in the directory server for pinging the slave
// time as used in the directory server for pinging the registered
// servers.
TimerPingServers.start ( SERVLIST_UPDATE_PING_SERVERS_MS );
}
Expand Down Expand Up @@ -372,7 +370,7 @@ void CServerListManager::OnTimerPingServerInList()
// server entry)
for ( int iIdx = 1; iIdx < iCurServerListSize; iIdx++ )
{
// send empty message to keep NAT port open at slave server
// send empty message to keep NAT port open at registered server
pConnLessProtocol->CreateCLEmptyMes ( ServerList[iIdx].HostAddr );
}
}
Expand Down Expand Up @@ -536,7 +534,7 @@ void CServerListManager::RetrieveAll ( const CHostAddress& InetAddr )
// but it supplied an additional public address using
// --serverpublicip.
// In this case, use the latter.
// This is common when running a directory server with slave
// This is common when running a directory with registered
// servers behind a NAT and dealing with external, public
// clients. In this case, sending a ping would not open
// a NAT port.
Expand Down Expand Up @@ -663,7 +661,7 @@ void CServerListManager::Save()
}
}

/* Slave server functionality *************************************************/
/* Registered server functionality *************************************************/
void CServerListManager::StoreRegistrationResult ( ESvrRegResult eResult )
{
// we need the lock since the user might change the server properties at
Expand Down Expand Up @@ -702,11 +700,11 @@ void CServerListManager::OnTimerPingServers()
QMutexLocker locker ( &Mutex );

// first check if directory server address is valid
if ( !( SlaveCurCentServerHostAddress == CHostAddress() ) )
if ( !( DirectoryAddress == CHostAddress() ) )
{
// send empty message to directory server to keep NAT port open -> we do
// not require any answer from the directory server
pConnLessProtocol->CreateCLEmptyMes ( SlaveCurCentServerHostAddress );
pConnLessProtocol->CreateCLEmptyMes ( DirectoryAddress );
}
}

Expand Down Expand Up @@ -736,7 +734,7 @@ void CServerListManager::OnTimerCLRegisterServerResp()
}
}

void CServerListManager::SlaveServerRegisterServer ( const bool bIsRegister )
void CServerListManager::SetRegistered ( const bool bIsRegister )
{
// we need the lock since the user might change the server properties at
// any time
Expand All @@ -745,29 +743,29 @@ void CServerListManager::SlaveServerRegisterServer ( const bool bIsRegister )
// get the correct directory server address
const QString strCurrentDirectoryAddress = NetworkUtil::GetDirectoryAddress ( eDirectoryType, strDirectoryAddress );

// For the slave server, the slave server properties are stored in the
// For a registered server, the server properties are stored in the
// very first item in the server list (which is actually no server list
// but just one item long for the slave server).
// but just one item long for the registered server).
// 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 Directory Servers
if ( NetworkUtil().ParseNetworkAddress ( strCurrentDirectoryAddress, SlaveCurCentServerHostAddress, false ) )
if ( NetworkUtil().ParseNetworkAddress ( strCurrentDirectoryAddress, DirectoryAddress, false ) )
{
if ( bIsRegister )
{
// register server
SetSvrRegStatus ( SRS_REQUESTED );

pConnLessProtocol->CreateCLRegisterServerExMes ( SlaveCurCentServerHostAddress, SlaveCurLocalHostAddress, ServerList[0] );
pConnLessProtocol->CreateCLRegisterServerExMes ( DirectoryAddress, ServerPublicIP, ServerList[0] );
}
else
{
// unregister server
SetSvrRegStatus ( SRS_UNREGISTERED );

pConnLessProtocol->CreateCLUnregisterServerMes ( SlaveCurCentServerHostAddress );
pConnLessProtocol->CreateCLUnregisterServerMes ( DirectoryAddress );
}
}
else
Expand Down
12 changes: 6 additions & 6 deletions src/serverlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class CServerListManager : public QObject
void SetEnabled ( const bool bState ) { bEnabled = bState; }
bool GetEnabled() const { return bEnabled; }

void SlaveServerUnregister() { SlaveServerRegisterServer ( false ); }
void Unregister() { SetRegistered ( false ); }

// set server infos -> per definition the server info of this server is
// stored in the first entry of the list, we assume here that the first
Expand Down Expand Up @@ -185,7 +185,7 @@ class CServerListManager : public QObject
int IndexOf ( CHostAddress haSearchTerm );
void Load ( const QString strServerList );
void Save();
void SlaveServerRegisterServer ( const bool bIsRegister );
void SetRegistered ( const bool bIsRegister );
void SetSvrRegStatus ( ESvrRegStatus eNSvrRegStatus );

QMutex Mutex;
Expand All @@ -202,9 +202,9 @@ class CServerListManager : public QObject
// server registration status
ESvrRegStatus eSvrRegStatus;

CHostAddress SlaveCurCentServerHostAddress;
CHostAddress SlaveCurLocalHostAddress;
CHostAddress SlaveCurLocalHostAddress6;
CHostAddress DirectoryAddress;
CHostAddress ServerPublicIP;
CHostAddress ServerPublicIP6;

QString ServerListFileName;

Expand All @@ -226,7 +226,7 @@ public slots:
void OnTimerPollList();
void OnTimerPingServerInList();
void OnTimerPingServers();
void OnTimerRefreshRegistration() { SlaveServerRegisterServer ( true ); }
void OnTimerRefreshRegistration() { SetRegistered ( true ); }
void OnTimerCLRegisterServerResp();

void OnTimerIsPermanent() { ServerList[0].bPermanentOnline = true; }
Expand Down
2 changes: 1 addition & 1 deletion src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ inline QString DirectoryTypeToString ( EDirectoryType eAddrType )
}
}

// Slave server registration state ---------------------------------------------
// Server registration state ---------------------------------------------
enum ESvrRegStatus
{
SRS_UNREGISTERED,
Expand Down

0 comments on commit 9ea13f0

Please sign in to comment.