Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 59 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ int main ( int argc, char** argv )
QString strLoggingFileName = "";
QString strRecordingDirName = "";
QString strCentralServer = "";
QString strServerListFileName = "";
QString strServerInfo = "";
QString strServerPublicIP = "";
QString strServerBindIP = "";
Expand Down Expand Up @@ -215,6 +216,21 @@ int main ( int argc, char** argv )
continue;
}

// Directory file ------------------------------------------------------
if ( GetStringArgument ( argc,
argv,
i,
"--directoryfile", // no short form
"--directoryfile",
strArgument ) )
{
strServerListFileName = strArgument;
qInfo() << qUtf8Printable ( QString ( "- directory server persistence file: %1" ).arg ( strServerListFileName ) );
CommandLineOptions << "--directoryfile";
ServerOnlyOptions << "--directoryfile";
continue;
}

// Server list filter --------------------------------------------------
if ( GetStringArgument ( argc, argv, i, "-f", "--listfilter", strArgument ) )
{
Expand Down Expand Up @@ -587,6 +603,12 @@ int main ( int argc, char** argv )
{
// per definition, we must be a headless server and ignoring inifile, so we have all the information

if ( !strServerListFileName.isEmpty() )
{
qWarning() << "Server list persistence file will only take effect when running as a directory server.";
strServerListFileName = "";
}

if ( !strServerListFilter.isEmpty() )
{
qWarning() << "Server list filter will only take effect when running as a directory server.";
Expand All @@ -606,14 +628,48 @@ int main ( int argc, char** argv )
// if we are not headless, certain checks cannot be made, as the inifile state is not yet known
if ( !bUseGUI && strCentralServer.compare ( "localhost", Qt::CaseInsensitive ) != 0 && strCentralServer.compare ( "127.0.0.1" ) != 0 )
{
if ( !strServerListFileName.isEmpty() )
{
qWarning() << "Server list persistence file will only take effect when running as a directory server.";
strServerListFileName = "";
}

if ( !strServerListFilter.isEmpty() )
{
qWarning() << "Server list filter will only take effect when running as a directory server.";
strServerListFilter = "";
strServerListFileName = "";
}
}
else
{
if ( !strServerListFileName.isEmpty() )
{
QFileInfo serverListFileInfo ( strServerListFileName );
if ( !serverListFileInfo.exists() )
{
QFile strServerListFile ( strServerListFileName );
if ( !strServerListFile.open ( QFile::OpenModeFlag::ReadWrite ) )
{
qWarning() << qUtf8Printable (
QString ( "Cannot create %1 for reading and writing. Please check permissions." ).arg ( strServerListFileName ) );
strServerListFileName = "";
}
}
else if ( !serverListFileInfo.isFile() )
{
qWarning() << qUtf8Printable (
QString ( "Server list file %1 must be a plain file. Please check the name." ).arg ( strServerListFileName ) );
strServerListFileName = "";
}
else if ( !serverListFileInfo.isReadable() || !serverListFileInfo.isWritable() )
{
qWarning() << qUtf8Printable (
QString ( "Server list file %1 must be readable and writeable. Please check the permissions." )
.arg ( strServerListFileName ) );
strServerListFileName = "";
}
}

if ( !strServerListFilter.isEmpty() )
{
QStringList slWhitelistAddresses = strServerListFilter.split ( ";" );
Expand Down Expand Up @@ -779,6 +835,7 @@ int main ( int argc, char** argv )
iQosNumber,
strHTMLStatusFileName,
strCentralServer,
strServerListFileName,
strServerInfo,
strServerPublicIP,
strServerListFilter,
Expand Down Expand Up @@ -885,6 +942,7 @@ QString UsageArguments ( char** argv )
" -d, --discononquit disconnect all clients on quit\n"
" -e, --directoryserver address of the directory server with which to register\n"
" (or 'localhost' to host a server list on this server)\n"
" --directoryfile enable server list persistence, set file name\n"
" -f, --listfilter server list whitelist filter. Format:\n"
" [IP address 1];[IP address 2];[IP address 3]; ...\n"
" -F, --fastupdate use 64 samples frame size mode\n"
Expand Down
10 changes: 9 additions & 1 deletion src/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ CServer::CServer ( const int iNewMaxNumChan,
const quint16 iQosNumber,
const QString& strHTMLStatusFileName,
const QString& strCentralServer,
const QString& strServerListFileName,
const QString& strServerInfo,
const QString& strServerListFilter,
const QString& strServerPublicIP,
Expand All @@ -239,7 +240,14 @@ CServer::CServer ( const int iNewMaxNumChan,
bWriteStatusHTMLFile ( false ),
strServerHTMLFileListName ( strHTMLStatusFileName ),
HighPrecisionTimer ( bNUseDoubleSystemFrameSize ),
ServerListManager ( iPortNumber, strCentralServer, strServerInfo, strServerPublicIP, strServerListFilter, iNewMaxNumChan, &ConnLessProtocol ),
ServerListManager ( iPortNumber,
strCentralServer,
strServerListFileName,
strServerInfo,
strServerPublicIP,
strServerListFilter,
iNewMaxNumChan,
&ConnLessProtocol ),
Comment thread
pljones marked this conversation as resolved.
JamController ( this ),
bDisableRecording ( bDisableRecording ),
bAutoRunMinimized ( false ),
Expand Down
1 change: 1 addition & 0 deletions src/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ class CServer : public QObject, public CServerSlots<MAX_NUM_CHANNELS>
const quint16 iQosNumber,
const QString& strHTMLStatusFileName,
const QString& strCentralServer,
const QString& strServerListFileName,
const QString& strServerInfo,
const QString& strServerListFilter,
const QString& strServerPublicIP,
Expand Down
Loading