introduce command line argument for enabling the ping of the slave servers in the list to keep the NAT port open (central server functionality only)

This commit is contained in:
Volker Fischer 2012-07-14 16:18:09 +00:00
parent 046cb18253
commit aada1a912f
5 changed files with 67 additions and 37 deletions

View File

@ -59,6 +59,7 @@ int main ( int argc, char** argv )
bool bConnectOnStartup = false; bool bConnectOnStartup = false;
bool bDisalbeLEDs = false; bool bDisalbeLEDs = false;
bool bShowComplRegConnList = false; bool bShowComplRegConnList = false;
bool bCentServPingServerInList = false;
int iNumServerChannels = DEFAULT_USED_NUM_CHANNELS; int iNumServerChannels = DEFAULT_USED_NUM_CHANNELS;
quint16 iPortNumber = LLCON_DEFAULT_PORT_NUMBER; quint16 iPortNumber = LLCON_DEFAULT_PORT_NUMBER;
QString strIniFileName = ""; QString strIniFileName = "";
@ -143,6 +144,18 @@ int main ( int argc, char** argv )
} }
// Ping servers in list for central server -----------------------------
if ( GetFlagArgument ( argv,
i,
"-g",
"--pingservers" ) )
{
bCentServPingServerInList = true;
tsConsole << "- ping servers in slave server list" << endl;
continue;
}
// Show all registered servers in the server list ---------------------- // Show all registered servers in the server list ----------------------
// Undocumented debugging command line argument: Show all registered // Undocumented debugging command line argument: Show all registered
// servers in the server list regardless if a ping to the server is // servers in the server list regardless if a ping to the server is
@ -391,7 +404,8 @@ int main ( int argc, char** argv )
strHistoryFileName, strHistoryFileName,
strServerName, strServerName,
strCentralServer, strCentralServer,
strServerInfo ); strServerInfo,
bCentServPingServerInList );
if ( bUseGUI ) if ( bUseGUI )
{ {
@ -469,30 +483,32 @@ QString UsageArguments ( char **argv )
return return
"Usage: " + QString ( argv[0] ) + " [option] [argument]\n" "Usage: " + QString ( argv[0] ) + " [option] [argument]\n"
"\nRecognized options:\n" "\nRecognized options:\n"
" -s, --server start server\n"
" -n, --nogui disable GUI (server only)\n"
" -u, --numchannels maximum number of channels (server only)\n"
" -z, --startminimized start minimizied (server only)\n"
" -l, --log enable logging, set file name\n"
" -i, --inifile initialization file name (client only)\n"
" -p, --port local port number (server only)\n"
" -m, --htmlstatus enable HTML status file, set file name (server\n"
" only)\n"
" -a, --servername server name, required for HTML status (server\n" " -a, --servername server name, required for HTML status (server\n"
" only)\n" " only)\n"
" -y, --history enable connection history and set file\n" " -c, --connect connect to last server on startup (client\n"
" name (server only)\n" " only)\n"
" -d, --disableleds disable LEDs in main window (client only)\n"
" -e, --centralserver address of the central server (server only)\n" " -e, --centralserver address of the central server (server only)\n"
" -g, --pingservers ping servers in list to keep NAT port open\n"
" (central server only)\n"
" -h, -?, --help this help text\n"
" -i, --inifile initialization file name (client only)\n"
" -l, --log enable logging, set file name\n"
" -m, --htmlstatus enable HTML status file, set file name (server\n"
" only)\n"
" -n, --nogui disable GUI (server only)\n"
" -o, --serverinfo infos of the server(s) in the format:\n" " -o, --serverinfo infos of the server(s) in the format:\n"
" [name];[city];[country as QLocale ID]; ...\n" " [name];[city];[country as QLocale ID]; ...\n"
" [server1 address];[server1 name]; ...\n" " [server1 address];[server1 name]; ...\n"
" [server1 city]; ...\n" " [server1 city]; ...\n"
" [server1 country as QLocale ID]; ...\n" " [server1 country as QLocale ID]; ...\n"
" [server2 address]; ... (server only)\n" " [server2 address]; ... (server only)\n"
" -c, --connect connect to last server on startup (client\n" " -p, --port local port number (server only)\n"
" only)\n" " -s, --server start server\n"
" -d, --disableleds disable LEDs in main window (client only)\n" " -u, --numchannels maximum number of channels (server only)\n"
" -h, -?, --help this help text\n" " -y, --history enable connection history and set file\n"
" name (server only)\n"
" -z, --startminimized start minimizied (server only)\n"
"\nExample: " + QString ( argv[0] ) + " -l -inifile myinifile.ini\n"; "\nExample: " + QString ( argv[0] ) + " -l -inifile myinifile.ini\n";
} }

View File

@ -171,7 +171,8 @@ CServer::CServer ( const int iNewNumChan,
const QString& strHistoryFileName, const QString& strHistoryFileName,
const QString& strServerNameForHTMLStatusFile, const QString& strServerNameForHTMLStatusFile,
const QString& strCentralServer, const QString& strCentralServer,
const QString& strServerInfo ) : const QString& strServerInfo,
const bool bNCentServPingServerInList ) :
iNumChannels ( iNewNumChan ), iNumChannels ( iNewNumChan ),
Socket ( this, iPortNumber ), Socket ( this, iPortNumber ),
bWriteStatusHTMLFile ( false ), bWriteStatusHTMLFile ( false ),
@ -179,6 +180,7 @@ CServer::CServer ( const int iNewNumChan,
strCentralServer, strCentralServer,
strServerInfo, strServerInfo,
iNewNumChan, iNewNumChan,
bNCentServPingServerInList,
&ConnLessProtocol ), &ConnLessProtocol ),
bAutoRunMinimized ( false ) bAutoRunMinimized ( false )
{ {

View File

@ -110,7 +110,8 @@ public:
const QString& strHistoryFileName, const QString& strHistoryFileName,
const QString& strServerNameForHTMLStatusFile, const QString& strServerNameForHTMLStatusFile,
const QString& strCentralServer, const QString& strCentralServer,
const QString& strServerInfo ); const QString& strServerInfo,
const bool bNCentServPingServerInList );
void Start(); void Start();
void Stop(); void Stop();

View File

@ -30,11 +30,13 @@ CServerListManager::CServerListManager ( const quint16 iNPortNum,
const QString& sNCentServAddr, const QString& sNCentServAddr,
const QString& strServerInfo, const QString& strServerInfo,
const int iNumChannels, const int iNumChannels,
const bool bNCentServPingServerInList,
CProtocol* pNConLProt ) CProtocol* pNConLProt )
: iPortNumber ( iNPortNum ), : iPortNumber ( iNPortNum ),
iNumPredefinedServers ( 0 ), iNumPredefinedServers ( 0 ),
bUseDefaultCentralServerAddress ( false ), bUseDefaultCentralServerAddress ( false ),
pConnLessProtocol ( pNConLProt ) pConnLessProtocol ( pNConLProt ),
bCentServPingServerInList ( bNCentServPingServerInList )
{ {
// set the central server address // set the central server address
SetCentralServerAddress ( sNCentServAddr ); SetCentralServerAddress ( sNCentServAddr );
@ -200,9 +202,12 @@ void CServerListManager::Update()
// 1 minute = 60 * 1000 ms // 1 minute = 60 * 1000 ms
TimerPollList.start ( SERVLIST_POLL_TIME_MINUTES * 60000 ); TimerPollList.start ( SERVLIST_POLL_TIME_MINUTES * 60000 );
if ( bCentServPingServerInList )
{
// start timer for sending ping messages to servers in the list // start timer for sending ping messages to servers in the list
TimerPingServerInList.start ( SERVLIST_UPDATE_PING_SERVERS_MS ); TimerPingServerInList.start ( SERVLIST_UPDATE_PING_SERVERS_MS );
} }
}
else else
{ {
// initiate registration right away so that we do not have to wait // initiate registration right away so that we do not have to wait
@ -235,8 +240,12 @@ void CServerListManager::Update()
if ( bIsCentralServer ) if ( bIsCentralServer )
{ {
TimerPollList.stop(); TimerPollList.stop();
if ( bCentServPingServerInList )
{
TimerPingServerInList.stop(); TimerPingServerInList.stop();
} }
}
else else
{ {
TimerRegistering.stop(); TimerRegistering.stop();

View File

@ -129,6 +129,7 @@ public:
const QString& sNCentServAddr, const QString& sNCentServAddr,
const QString& strServerInfo, const QString& strServerInfo,
const int iNumChannels, const int iNumChannels,
const bool bNCentServPingServerInList,
CProtocol* pNConLProt ); CProtocol* pNConLProt );
// the update has to be called if any change to the server list // the update has to be called if any change to the server list
@ -194,6 +195,7 @@ protected:
bool bEnabled; bool bEnabled;
bool bIsCentralServer; bool bIsCentralServer;
bool bUseDefaultCentralServerAddress; bool bUseDefaultCentralServerAddress;
bool bCentServPingServerInList;
CHostAddress SlaveCurCentServerHostAddress; CHostAddress SlaveCurCentServerHostAddress;