From 9ea13f04a3b7cdfcfa65cc545644d4132c8ef9bd Mon Sep 17 00:00:00 2001 From: Peter L Jones Date: Sun, 24 Oct 2021 22:28:03 +0100 Subject: [PATCH] Certain other rewording --- src/global.h | 2 +- src/protocol.cpp | 4 ++-- src/server.cpp | 2 +- src/server.h | 2 +- src/serverdlg.cpp | 4 ++-- src/serverlist.cpp | 46 ++++++++++++++++++++++------------------------ src/serverlist.h | 12 ++++++------ src/util.h | 2 +- 8 files changed, 36 insertions(+), 38 deletions(-) diff --git a/src/global.h b/src/global.h index f48f07df6c..b54649ea35 100644 --- a/src/global.h +++ b/src/global.h @@ -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 diff --git a/src/protocol.cpp b/src/protocol.cpp index 46aac578b3..c0e6be99e7 100644 --- a/src/protocol.cpp +++ b/src/protocol.cpp @@ -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. diff --git a/src/server.cpp b/src/server.cpp index 60bcf7fb0d..8db5f0d0d3 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -687,7 +687,7 @@ void CServer::OnAboutToQuit() // if server was registered at the directory server, unregister on shutdown if ( GetServerRegistered() ) { - UnregisterSlaveServer(); + Unregister(); } if ( bWriteStatusHTMLFile ) diff --git a/src/server.h b/src/server.h index 472e39acce..5e646ff43f 100644 --- a/src/server.h +++ b/src/server.h @@ -218,7 +218,7 @@ class CServer : public QObject, public CServerSlots // Server list management -------------------------------------------------- void UpdateServerList() { ServerListManager.Update(); } - void UnregisterSlaveServer() { ServerListManager.SlaveServerUnregister(); } + void Unregister() { ServerListManager.Unregister(); } void SetServerRegistered ( const bool bState ) { ServerListManager.SetEnabled ( bState ); } diff --git a/src/serverdlg.cpp b/src/serverdlg.cpp index 572831645d..9ea9c37f79 100644 --- a/src/serverdlg.cpp +++ b/src/serverdlg.cpp @@ -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(); diff --git a/src/serverlist.cpp b/src/serverlist.cpp index 0c8c89696a..bae2269a5e 100644 --- a/src/serverlist.cpp +++ b/src/serverlist.cpp @@ -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 ) { @@ -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 @@ -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) @@ -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 @@ -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 ); @@ -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 ); @@ -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(); @@ -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 ); } @@ -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 ); } } @@ -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. @@ -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 @@ -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 ); } } @@ -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 @@ -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 diff --git a/src/serverlist.h b/src/serverlist.h index 07c5868669..75616463e0 100644 --- a/src/serverlist.h +++ b/src/serverlist.h @@ -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 @@ -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; @@ -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; @@ -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; } diff --git a/src/util.h b/src/util.h index 8e37b777a2..e660714511 100644 --- a/src/util.h +++ b/src/util.h @@ -572,7 +572,7 @@ inline QString DirectoryTypeToString ( EDirectoryType eAddrType ) } } -// Slave server registration state --------------------------------------------- +// Server registration state --------------------------------------------- enum ESvrRegStatus { SRS_UNREGISTERED,