mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-21 10:01:27 -07:00
Add check for working deployment domain (#134)
this is gonna suck to merge into 2.2.0 lmao
This commit is contained in:
parent
1f40efd10d
commit
c87eff997a
@ -258,7 +258,7 @@ namespace Bloxstrap
|
|||||||
if (!IsFirstRun)
|
if (!IsFirstRun)
|
||||||
ShouldSaveConfigs = true;
|
ShouldSaveConfigs = true;
|
||||||
|
|
||||||
DeployManager.SetChannel(Settings.Prop.Channel);
|
DeployManager.Channel = Settings.Prop.Channel;
|
||||||
|
|
||||||
// start bootstrapper and show the bootstrapper modal if we're not running silently
|
// start bootstrapper and show the bootstrapper modal if we're not running silently
|
||||||
Logger.WriteLine($"[App::OnStartup] Initializing bootstrapper");
|
Logger.WriteLine($"[App::OnStartup] Initializing bootstrapper");
|
||||||
|
@ -13,11 +13,68 @@ namespace Bloxstrap.Helpers
|
|||||||
public class DeployManager
|
public class DeployManager
|
||||||
{
|
{
|
||||||
#region Properties
|
#region Properties
|
||||||
public const string DefaultBaseUrl = "https://setup.rbxcdn.com";
|
|
||||||
public const string DefaultChannel = "LIVE";
|
public const string DefaultChannel = "LIVE";
|
||||||
|
|
||||||
public string BaseUrl { get; private set; } = DefaultBaseUrl;
|
private string _channel = DefaultChannel;
|
||||||
public string Channel { get; private set; } = DefaultChannel;
|
|
||||||
|
public string Channel
|
||||||
|
{
|
||||||
|
get => _channel;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_channel != value)
|
||||||
|
App.Logger.WriteLine($"[DeployManager::SetChannel] Changed channel to {value}");
|
||||||
|
|
||||||
|
_channel = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// a list of roblox delpoyment locations that we check for, in case one of them don't work
|
||||||
|
private List<string> BaseUrls = new()
|
||||||
|
{
|
||||||
|
"https://setup.rbxcdn.com",
|
||||||
|
"https://setup-ak.rbxcdn.com",
|
||||||
|
"https://s3.amazonaws.com/setup.roblox.com"
|
||||||
|
};
|
||||||
|
|
||||||
|
private string? _baseUrl = null;
|
||||||
|
|
||||||
|
public string BaseUrl
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (String.IsNullOrEmpty(_baseUrl))
|
||||||
|
{
|
||||||
|
// check for a working accessible deployment domain
|
||||||
|
foreach (string attemptedUrl in BaseUrls)
|
||||||
|
{
|
||||||
|
App.Logger.WriteLine($"[DeployManager::DefaultBaseUrl.Set] Testing connection to '{attemptedUrl}'...");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
App.HttpClient.GetAsync($"{attemptedUrl}/version").Wait();
|
||||||
|
App.Logger.WriteLine($"[DeployManager::DefaultBaseUrl.Set] Connection successful!");
|
||||||
|
_baseUrl = attemptedUrl;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
App.Logger.WriteLine($"[DeployManager::DefaultBaseUrl.Set] Connection failed!");
|
||||||
|
App.Logger.WriteLine($"[DeployManager::DefaultBaseUrl.Set] {ex}");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (String.IsNullOrEmpty(_baseUrl))
|
||||||
|
throw new Exception("Unable to find an accessible Roblox deploy mirror!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Channel == DefaultChannel)
|
||||||
|
return _baseUrl;
|
||||||
|
else
|
||||||
|
return $"{_baseUrl}/channel/{Channel.ToLower()}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// most commonly used/interesting channels
|
// most commonly used/interesting channels
|
||||||
public static readonly List<string> SelectableChannels = new()
|
public static readonly List<string> SelectableChannels = new()
|
||||||
@ -32,17 +89,6 @@ namespace Bloxstrap.Helpers
|
|||||||
};
|
};
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public void SetChannel(string channel)
|
|
||||||
{
|
|
||||||
if (Channel == channel)
|
|
||||||
return;
|
|
||||||
|
|
||||||
App.Logger.WriteLine($"[DeployManager::SetChannel] Set channel to {Channel}");
|
|
||||||
|
|
||||||
Channel = channel;
|
|
||||||
BaseUrl = channel == DefaultChannel ? DefaultBaseUrl : $"{DefaultBaseUrl}/channel/{channel.ToLower()}";
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<ClientVersion> GetLastDeploy(bool timestamp = false)
|
public async Task<ClientVersion> GetLastDeploy(bool timestamp = false)
|
||||||
{
|
{
|
||||||
App.Logger.WriteLine($"[DeployManager::GetLastDeploy] Getting deploy info for channel {Channel} (timestamp={timestamp})");
|
App.Logger.WriteLine($"[DeployManager::GetLastDeploy] Getting deploy info for channel {Channel} (timestamp={timestamp})");
|
||||||
|
@ -39,7 +39,7 @@ namespace Bloxstrap.ViewModels
|
|||||||
ChannelDeployInfo = null;
|
ChannelDeployInfo = null;
|
||||||
OnPropertyChanged(nameof(ChannelDeployInfo));
|
OnPropertyChanged(nameof(ChannelDeployInfo));
|
||||||
|
|
||||||
App.DeployManager.SetChannel(channel);
|
App.DeployManager.Channel = channel;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user