Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/XIVLauncher.Common/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ public static class Constants
public const uint STEAM_APP_ID = 39210;
public const uint STEAM_FT_APP_ID = 312060;

public const string LAUNCHER_CONFIG_URL = "https://kamori.goats.dev/Launcher/GetLauncherClientConfig";
public const string FRONTIER_FALLBACK = "https://launcher.finalfantasyxiv.com/v650/index.html?rc_lang={0}&time={1}";
public static string PatcherUserAgent => GetPatcherUserAgent(PlatformHelpers.GetPlatform());

private static string GetPatcherUserAgent(Platform platform)
Expand All @@ -29,4 +31,4 @@ private static string GetPatcherUserAgent(Platform platform)
}
}
}
}
}
34 changes: 34 additions & 0 deletions src/XIVLauncher.Common/Util/ApiHelpers.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
using Serilog;
using System;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Json;
using System.Net.Http.Headers;
using System.Threading.Tasks;

namespace XIVLauncher.Common.Util;

Expand Down Expand Up @@ -95,4 +99,34 @@ public static void AddWithoutValidation(this HttpHeaders headers, string key, st
var attributes = memInfo[0].GetCustomAttributes(typeof(TAttribute), false);
return (attributes.Length > 0) ? (TAttribute)attributes[0] : null;
}

/// <summary>
/// Represents a response from Kamori's GetLauncherClientConfig endpoint.
/// </summary>
public struct LauncherClientConfig
{
public string frontierUrl { get; set; }
public string? cutOffBootver { get; set; }
public uint flags { get; set; }

public static async Task<LauncherClientConfig> GetAsync()
{
try
{
HttpClient HttpClient = new()
{
Timeout = TimeSpan.FromSeconds(5)
};
return await HttpClient.GetFromJsonAsync<LauncherClientConfig>(Constants.LAUNCHER_CONFIG_URL).ConfigureAwait(false);
}
catch (Exception ex)
{
Log.Error(ex, "Could not obtain LauncherClientConfig");
return new LauncherClientConfig()
{
frontierUrl = Constants.FRONTIER_FALLBACK,
};
}
}
}
}
3 changes: 2 additions & 1 deletion src/XIVLauncher.Common/XIVLauncher.Common.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Product>XIVLauncher.Common</Product>
<AssemblyTitle>XIVLauncher.Common</AssemblyTitle>
Expand Down Expand Up @@ -52,6 +52,7 @@
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="SharedMemory" Version="2.3.2" />
<PackageReference Include="System.Memory" Version="4.5.4" />
<PackageReference Include="System.Net.Http.Json" Version="6.0.0" />
<PackageReference Include="System.Security.Principal.Windows" Version="5.0.0" />
<PackageReference Include="System.Text.Json" Version="6.0.6" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private IndexUpdateCommand(ParseResult parseResult)

private async Task<int> Handle(CancellationToken cancellationToken)
{
var la = new Launcher((ISteam?)null, new CommonUniqueIdCache(null), this.settings, "https://launcher.finalfantasyxiv.com/v650/index.html?rc_lang={0}&time={1}");
var la = new Launcher((ISteam?)null, new CommonUniqueIdCache(null), this.settings, XIVLauncher.Common.Util.ApiHelpers.LauncherClientConfig.GetAsync().GetAwaiter().GetResult().frontierUrl);

var bootPatchListFile = new FileInfo(Path.Combine(this.settings.GamePath.FullName, "bootlist.json"));

Expand Down
2 changes: 1 addition & 1 deletion src/XIVLauncher/Windows/ViewModel/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public MainWindowViewModel(Window window)
var frontierUrl = Updates.UpdateLease?.FrontierUrl;
#if DEBUG || RELEASENOUPDATE
// FALLBACK
frontierUrl ??= "https://launcher.finalfantasyxiv.com/v650/index.html?rc_lang={0}&time={1}";
frontierUrl ??= XIVLauncher.Common.Util.ApiHelpers.LauncherClientConfig.GetAsync().GetAwaiter().GetResult().frontierUrl;
#endif

Launcher = App.GlobalSteamTicket == null
Expand Down