Skip to content

Commit

Permalink
Use -connect-trusted from next Daemon release
Browse files Browse the repository at this point in the history
The next version of Daemon will have the -connect-trusted option for
connecting to a server. If that is available, use it (and begin to
respect the custom command line).
  • Loading branch information
slipher committed Apr 30, 2024
1 parent e8758d8 commit c6d9e60
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
4 changes: 2 additions & 2 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ QString getURLFromPositionalOptions(const QCommandLineParser& parser)
url.remove(passwordEnd, 1);
}

// When connect URL + custom command are supported together, we have to consider the pessimistic case
// of a custom command line like bash -c "%command%"
// If a custom command is used, we have to consider the pessimistic case
// of a command line like bash -c "%command%"
// so metacharacters from any common shells must be forbidden.
// What we need to accept are domain names and IP addresses.
// Also throw in '@' for limited support of the password feature (unv://[email protected])
Expand Down
15 changes: 14 additions & 1 deletion qmldownloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,18 +185,31 @@ void QmlDownloader::startGame()
StartGame(settings_, connectUrl_, false);
}

// Does our version of daemon have -connect-trusted?
static bool haveConnectTrusted(const QString& gameVersion)
{
// Updater version up to v0.2.0 may set "unknown" as game version if versions.json request fails
if (gameVersion == "unknown")
return false;
// Hacky string comparision, assume we won't go down to 0.9 or up to 0.100 :)
return gameVersion > "0.54.1";
}

void StartGame(const Settings& settings, const QString& connectUrl, bool failIfWindowsAdmin)
{
QString gameCommand = Sys::getGameCommand(settings.installPath());
QString commandLine;
if (!connectUrl.isEmpty()) {
if (!connectUrl.isEmpty() && !haveConnectTrusted(settings.currentVersion())) {
// Behave for now as the old protocol handler which ignores the custom command
commandLine = gameCommand + " -connect " + connectUrl;
} else {
commandLine = settings.commandLine().trimmed();
if (!commandLine.contains(COMMAND_REGEX)) {
commandLine = "%command% " + commandLine;
}
if (!connectUrl.isEmpty()) {
gameCommand = gameCommand + " -connect-trusted " + connectUrl;
}
commandLine.replace(COMMAND_REGEX, gameCommand);
}
qDebug() << "Starting game with command line:" << commandLine;
Expand Down

0 comments on commit c6d9e60

Please sign in to comment.