allow servatrice to exit early based on commandline options (#4504)

This commit is contained in:
ebbit1q 2021-12-26 16:47:37 +01:00 committed by GitHub
parent 07e6aadbbe
commit a9f2fc427b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 9 deletions

View file

@ -79,7 +79,7 @@ requiredfeatures=""
; You can define custom warnings that users are sent when the moderation staff uses the right client warn user ; You can define custom warnings that users are sent when the moderation staff uses the right client warn user
; menu option. This list is comma seperated that each item will appear in the drop down list for staff members ; menu option. This list is comma seperated that each item will appear in the drop down list for staff members
; to choose from. Example: "Flaming,Foul Language" ; to choose from. Example: "Flaming,Foul Language"
officialwarnings="Flamming,Spamming,Causing Drama,Abusive Language" officialwarnings="Flaming,Spamming,Causing Drama,Abusive Language"
; Maximum time in seconds a player can stay connected but idle. Default is 3600 (0 = disabled) ; Maximum time in seconds a player can stay connected but idle. Default is 3600 (0 = disabled)
; Clients will be notified at the 90% time period of pending disconnection if they do not take action. ; Clients will be notified at the 90% time period of pending disconnection if they do not take action.

View file

@ -30,6 +30,7 @@
#include <QCommandLineParser> #include <QCommandLineParser>
#include <QCoreApplication> #include <QCoreApplication>
#include <QDateTime> #include <QDateTime>
#include <QFile>
#include <QMetaType> #include <QMetaType>
#include <QTextCodec> #include <QTextCodec>
#include <QtGlobal> #include <QtGlobal>
@ -140,7 +141,12 @@ int main(int argc, char *argv[])
qRegisterMetaType<QList<int>>("QList<int>"); qRegisterMetaType<QList<int>>("QList<int>");
configPath = SettingsCache::guessConfigurationPath(configPath); if (configPath.isEmpty()) {
configPath = SettingsCache::guessConfigurationPath();
} else if (!QFile::exists(configPath)) {
qCritical() << "Could not find configuration file at" << configPath;
return 1;
}
qWarning() << "Using configuration file: " << configPath; qWarning() << "Using configuration file: " << configPath;
settingsCache = new SettingsCache(configPath); settingsCache = new SettingsCache(configPath);
@ -167,10 +173,15 @@ int main(int argc, char *argv[])
PasswordHasher::initialize(); PasswordHasher::initialize();
if (testRandom) if (testRandom) {
testRNG(); testRNG();
if (testHashFunction) }
if (testHashFunction) {
testHash(); testHash();
}
if (testRandom || testHashFunction) {
return 0;
}
smtpClient = new SmtpClient(); smtpClient = new SmtpClient();

View file

@ -23,7 +23,7 @@ SettingsCache::SettingsCache(const QString &fileName, QSettings::Format format,
} }
} }
QString SettingsCache::guessConfigurationPath(QString &specificPath) QString SettingsCache::guessConfigurationPath()
{ {
const QString fileName = "servatrice.ini"; const QString fileName = "servatrice.ini";
if (QFile::exists(qApp->applicationDirPath() + "/portable.dat")) { if (QFile::exists(qApp->applicationDirPath() + "/portable.dat")) {
@ -32,9 +32,6 @@ QString SettingsCache::guessConfigurationPath(QString &specificPath)
} }
QString guessFileName; QString guessFileName;
// specific path
if (!specificPath.isEmpty() && QFile::exists(specificPath))
return specificPath;
// application directory path // application directory path
guessFileName = QCoreApplication::applicationDirPath() + "/" + fileName; guessFileName = QCoreApplication::applicationDirPath() + "/" + fileName;

View file

@ -16,7 +16,7 @@ public:
SettingsCache(const QString &fileName = "servatrice.ini", SettingsCache(const QString &fileName = "servatrice.ini",
QSettings::Format format = QSettings::IniFormat, QSettings::Format format = QSettings::IniFormat,
QObject *parent = 0); QObject *parent = 0);
static QString guessConfigurationPath(QString &specificPath); static QString guessConfigurationPath();
QList<QRegExp> disallowedRegExp; QList<QRegExp> disallowedRegExp;
bool getIsPortableBuild() const bool getIsPortableBuild() const
{ {