mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-23 23:45:35 +08:00
Fix cmd line arguments to allow passing client id and key pair
Before this commit, a user was able to pass a FSD key only via command line arguments. However, changing the key itself is not enough. The key always needs to be set together with its corresponding id. refs #795
This commit is contained in:
committed by
Klaus Basan
parent
969c077182
commit
dd0d9f1133
@@ -109,10 +109,17 @@ namespace BlackCore
|
||||
clientCapabilities |= vatCapsStealth;
|
||||
}
|
||||
|
||||
static const QByteArray pk(this->getCmdLineFsdKey().isEmpty() ? CBuildConfig::vatsimPrivateKey().toLocal8Bit() : this->getCmdLineFsdKey().toLocal8Bit());
|
||||
int clientId = 0;
|
||||
QString clientKey;
|
||||
if (!getCmdLineClientIdAndKey(clientId, clientKey))
|
||||
{
|
||||
clientId = CBuildConfig::vatsimClientId();
|
||||
clientKey = CBuildConfig::vatsimPrivateKey();
|
||||
}
|
||||
|
||||
m_net.reset(Vat_CreateNetworkSession(vatServerLegacyFsd, sApp->swiftVersionChar(),
|
||||
CVersion::versionMajor(), CVersion::versionMinor(),
|
||||
"None", CBuildConfig::vatsimClientId(), pk.constData(),
|
||||
"None", clientId, clientKey.toLocal8Bit().constData(),
|
||||
clientCapabilities));
|
||||
|
||||
Vat_SetStateChangeHandler(m_net.data(), onConnectionStatusChanged, this);
|
||||
@@ -658,18 +665,26 @@ namespace BlackCore
|
||||
static const QList<QCommandLineOption> e;
|
||||
static const QList<QCommandLineOption> opts
|
||||
{
|
||||
QCommandLineOption({ "key", "fsdkey" },
|
||||
QCoreApplication::translate("application", "Key for FSD"),
|
||||
"fsdkey")
|
||||
QCommandLineOption({ "idAndKey", "clientIdAndKey" },
|
||||
QCoreApplication::translate("application", "Client id and key pair separated by ':', e.g. <id>:<key>."),
|
||||
"clientIdAndKey")
|
||||
};
|
||||
|
||||
// only in not officially shipped versions
|
||||
return (CBuildConfig::isShippedVersion() && !CBuildConfig::isBetaTest()) ? e : opts;
|
||||
}
|
||||
|
||||
QString CNetworkVatlib::getCmdLineFsdKey() const
|
||||
bool CNetworkVatlib::getCmdLineClientIdAndKey(int &id, QString &key) const
|
||||
{
|
||||
return sApp->getParserValue("fsdkey").toLower();
|
||||
QString clientIdAndKey = sApp->getParserValue("clientIdAndKey").toLower();
|
||||
if (clientIdAndKey.isEmpty() || !clientIdAndKey.contains(':')) { return false; }
|
||||
auto stringList = clientIdAndKey.split(':');
|
||||
QString clientIdAsString = stringList[0];
|
||||
bool ok = true;
|
||||
id = clientIdAsString.toInt(&ok, 0);
|
||||
if (!ok) { return false; }
|
||||
key = stringList[1];
|
||||
return true;
|
||||
}
|
||||
|
||||
void CNetworkVatlib::sendCustomFsinnQuery(const BlackMisc::Aviation::CCallsign &callsign)
|
||||
|
||||
@@ -121,8 +121,8 @@ namespace BlackCore
|
||||
//! Cmd.line options this library can handle
|
||||
static const QList<QCommandLineOption> &getCmdLineOptions();
|
||||
|
||||
//! Key if any from cmd.line arguments
|
||||
QString getCmdLineFsdKey() const;
|
||||
//! Client id and key if any from command line arguments
|
||||
bool getCmdLineClientIdAndKey(int &id, QString &key) const;
|
||||
|
||||
private slots:
|
||||
void replyToFrequencyQuery(const BlackMisc::Aviation::CCallsign &callsign);
|
||||
|
||||
Reference in New Issue
Block a user