mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-21 10:01:27 -07:00
use clientsettings to fetch version
This commit is contained in:
parent
947993e446
commit
e77f8c1c65
@ -10,6 +10,7 @@ using Bloxstrap.Dialogs.BootstrapperDialogs;
|
|||||||
using Bloxstrap.Helpers;
|
using Bloxstrap.Helpers;
|
||||||
using Bloxstrap.Helpers.Integrations;
|
using Bloxstrap.Helpers.Integrations;
|
||||||
using Bloxstrap.Helpers.RSMM;
|
using Bloxstrap.Helpers.RSMM;
|
||||||
|
using Bloxstrap.Models;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
|
||||||
namespace Bloxstrap
|
namespace Bloxstrap
|
||||||
@ -131,7 +132,8 @@ namespace Bloxstrap
|
|||||||
{
|
{
|
||||||
Dialog.Message = "Connecting to Roblox...";
|
Dialog.Message = "Connecting to Roblox...";
|
||||||
|
|
||||||
VersionGuid = await Program.HttpClient.GetStringAsync($"{DeployManager.BaseUrl}/version");
|
ClientVersion clientVersion = await DeployManager.GetLastDeploy(Program.Settings.Channel);
|
||||||
|
VersionGuid = clientVersion.VersionGuid;
|
||||||
VersionFolder = Path.Combine(Directories.Versions, VersionGuid);
|
VersionFolder = Path.Combine(Directories.Versions, VersionGuid);
|
||||||
VersionPackageManifest = await PackageManifest.Get(VersionGuid);
|
VersionPackageManifest = await PackageManifest.Get(VersionGuid);
|
||||||
}
|
}
|
||||||
|
@ -343,10 +343,10 @@ namespace Bloxstrap.Dialogs
|
|||||||
{
|
{
|
||||||
ChannelInfo = "Getting latest version info, please wait...\n";
|
ChannelInfo = "Getting latest version info, please wait...\n";
|
||||||
|
|
||||||
VersionDeploy info = await DeployManager.GetLastDeploy(channel);
|
ClientVersion info = await DeployManager.GetLastDeploy(channel, true);
|
||||||
string strTimestamp = info.Timestamp.ToString("MM/dd/yyyy h:mm:ss tt", Program.CultureFormat);
|
string? strTimestamp = info.Timestamp?.ToString("MM/dd/yyyy h:mm:ss tt", Program.CultureFormat);
|
||||||
|
|
||||||
ChannelInfo = $"Version: v{info.FileVersion} ({info.VersionGuid})\nDeployed: {strTimestamp}";
|
ChannelInfo = $"Version: v{info.Version} ({info.VersionGuid})\nDeployed: {strTimestamp}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
using System.IO;
|
using System.Net.Http;
|
||||||
using System.Net.Http;
|
using System.Text.Json;
|
||||||
|
|
||||||
using Bloxstrap.Models;
|
using Bloxstrap.Models;
|
||||||
|
|
||||||
namespace Bloxstrap.Helpers
|
namespace Bloxstrap.Helpers
|
||||||
@ -99,67 +98,36 @@ namespace Bloxstrap.Helpers
|
|||||||
return $"{DefaultBaseUrl}/channel/{channel.ToLower()}";
|
return $"{DefaultBaseUrl}/channel/{channel.ToLower()}";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task<VersionDeploy> GetLastDeploy(string channel)
|
public static async Task<ClientVersion> GetLastDeploy(string channel, bool timestamp = false)
|
||||||
{
|
{
|
||||||
string baseUrl = BuildBaseUrl(channel);
|
HttpResponseMessage deployInfoResponse = await Program.HttpClient.GetAsync($"https://clientsettings.roblox.com/v2/client-version/WindowsPlayer/channel/{channel}");
|
||||||
string lastDeploy = "";
|
|
||||||
|
|
||||||
string deployHistory = await Program.HttpClient.GetStringAsync($"{baseUrl}/DeployHistory.txt");
|
if (!deployInfoResponse.IsSuccessStatusCode)
|
||||||
|
|
||||||
using (StringReader reader = new(deployHistory))
|
|
||||||
{
|
{
|
||||||
string? line;
|
// 400 = Invalid binaryType.
|
||||||
|
// 404 = Could not find version details for binaryType.
|
||||||
|
// 500 = Error while fetching version information.
|
||||||
|
// either way, we throw
|
||||||
|
throw new Exception($"Could not get latest deploy for channel {channel}");
|
||||||
|
}
|
||||||
|
|
||||||
while ((line = await reader.ReadLineAsync()) is not null)
|
string rawJson = await deployInfoResponse.Content.ReadAsStringAsync();
|
||||||
|
ClientVersion clientVersion = JsonSerializer.Deserialize<ClientVersion>(rawJson)!;
|
||||||
|
|
||||||
|
// for preferences
|
||||||
|
if (timestamp)
|
||||||
|
{
|
||||||
|
string channelUrl = BuildBaseUrl(channel);
|
||||||
|
|
||||||
|
HttpResponseMessage pkgMessage = await Program.HttpClient.GetAsync($"{channelUrl}/{clientVersion.VersionGuid}-rbxPkgManifest.txt");
|
||||||
|
if (pkgMessage.Content.Headers.TryGetValues("last-modified", out var values))
|
||||||
{
|
{
|
||||||
if (line.Contains("WindowsPlayer"))
|
string lastModified = values.First();
|
||||||
lastDeploy = line;
|
clientVersion.Timestamp = DateTime.Parse(lastModified);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (String.IsNullOrEmpty(lastDeploy))
|
return clientVersion;
|
||||||
throw new Exception($"Could not get latest deploy for channel {channel}");
|
|
||||||
|
|
||||||
// here's to hoping roblox doesn't change their deployment entry format
|
|
||||||
// (last time they did so was may 2021 so we should be fine?)
|
|
||||||
// example entry: 'New WindowsPlayer version-29fb7cdd06e84001 at 8/23/2022 2:07:27 PM, file version: 0, 542, 100, 5420251, git hash: b98d6b2bea36fa2161f48cca979fb620bb0c24fd ...'
|
|
||||||
|
|
||||||
// there's a proper way, and then there's the lazy way
|
|
||||||
// this here is the lazy way but it should just work™
|
|
||||||
|
|
||||||
lastDeploy = lastDeploy[18..]; // 'version-29fb7cdd06e84001 at 8/23/2022 2:07:27 PM, file version: 0, 542, 100, 5420251, git hash: b98d6b2bea36fa2161f48cca979fb620bb0c24fd ...'
|
|
||||||
string versionGuid = lastDeploy[..lastDeploy.IndexOf(" at")]; // 'version-29fb7cdd06e84001'
|
|
||||||
|
|
||||||
lastDeploy = lastDeploy[(versionGuid.Length + 4)..]; // '8/23/2022 2:07:27 PM, file version: 0, 542, 100, 5420251, git hash: b98d6b2bea36fa2161f48cca979fb620bb0c24fd ...'
|
|
||||||
string strTimestamp = lastDeploy[..lastDeploy.IndexOf(", file")]; // '8/23/2022 2:07:27 PM'
|
|
||||||
|
|
||||||
lastDeploy = lastDeploy[(strTimestamp.Length + 16)..]; // '0, 542, 100, 5420251, git hash: b98d6b2bea36fa2161f48cca979fb620bb0c24fd ...'
|
|
||||||
string fileVersion = "";
|
|
||||||
|
|
||||||
if (lastDeploy.Contains("git hash"))
|
|
||||||
{
|
|
||||||
// ~may 2021 entry: ends like 'file version: 0, 542, 100, 5420251, git hash: b98d6b2bea36fa2161f48cca979fb620bb0c24fd ...'
|
|
||||||
fileVersion = lastDeploy[..lastDeploy.IndexOf(", git")]; // '0, 542, 100, 5420251'
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// pre-may 2021 entry: ends like 'file version: 0, 448, 0, 411122...'
|
|
||||||
fileVersion = lastDeploy[..lastDeploy.IndexOf("...")]; // '0, 448, 0, 411122'
|
|
||||||
}
|
|
||||||
|
|
||||||
// deployment timestamps are UTC-5
|
|
||||||
strTimestamp += " -05";
|
|
||||||
DateTime dtTimestamp = DateTime.ParseExact(strTimestamp, "M/d/yyyy h:mm:ss tt zz", Program.CultureFormat).ToLocalTime();
|
|
||||||
|
|
||||||
// convert to traditional version format
|
|
||||||
fileVersion = fileVersion.Replace(" ", "").Replace(',', '.');
|
|
||||||
|
|
||||||
return new VersionDeploy
|
|
||||||
{
|
|
||||||
VersionGuid = versionGuid,
|
|
||||||
Timestamp = dtTimestamp,
|
|
||||||
FileVersion = fileVersion
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
18
Bloxstrap/Models/ClientVersion.cs
Normal file
18
Bloxstrap/Models/ClientVersion.cs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace Bloxstrap.Models
|
||||||
|
{
|
||||||
|
public class ClientVersion
|
||||||
|
{
|
||||||
|
[JsonPropertyName("version")]
|
||||||
|
public string Version { get; set; } = null!;
|
||||||
|
|
||||||
|
[JsonPropertyName("clientVersionUpload")]
|
||||||
|
public string VersionGuid { get; set; } = null!;
|
||||||
|
|
||||||
|
[JsonPropertyName("bootstrapperVersion")]
|
||||||
|
public string BootstrapperVersion { get; set; } = null!;
|
||||||
|
|
||||||
|
public DateTime? Timestamp { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -1,15 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Bloxstrap.Models
|
|
||||||
{
|
|
||||||
public class VersionDeploy
|
|
||||||
{
|
|
||||||
public string VersionGuid { get; set; } = null!;
|
|
||||||
public string FileVersion { get; set; } = null!;
|
|
||||||
public DateTime Timestamp { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user