| using System; |
| using System.Net.Http; |
| using System.Threading.Tasks; |
| using Newtonsoft.Json; |
|
|
| namespace ZerionLauncher.Services |
| { |
| |
| |
| |
| |
| public class RemoteConfigData |
| { |
| [JsonProperty("apiBaseUrl")] |
| public string ApiBaseUrl { get; set; } = "https://api-production-20fe.up.railway.app/api/v1"; |
|
|
| [JsonProperty("newsUrl")] |
| public string NewsUrl { get; set; } = "https://huggingface.co/datasets/nttl050611/LauncherPC/raw/main/news.json"; |
|
|
| [JsonProperty("manifestUrl")] |
| public string ManifestUrl { get; set; } = "https://huggingface.co/datasets/nttl050611/LauncherPC/resolve/main/manifest.json"; |
|
|
| [JsonProperty("playersUrl")] |
| public string PlayersUrl { get; set; } = "http://15.235.149.123/players.json"; |
|
|
| [JsonProperty("autoUpdaterXmlUrl")] |
| public string AutoUpdaterXmlUrl { get; set; } = "https://raw.githubusercontent.com/ntl050611/gta/refs/heads/main/autoupdater.xml"; |
|
|
| [JsonProperty("launcherReleaseApiUrl")] |
| public string LauncherReleaseApiUrl { get; set; } = "https://api.github.com/repos/ntl050611/gta/releases/latest"; |
|
|
| [JsonProperty("payloadEndpoint")] |
| public string PayloadEndpoint { get; set; } = "http://127.0.0.1:3000/api/v1/security/payload"; |
|
|
| [JsonProperty("payloadEncryptionKeyHex")] |
| public string PayloadEncryptionKeyHex { get; set; } = "0000000000000000000000000000000000000000000000000000000000000000"; |
|
|
| [JsonProperty("discordInviteUrl")] |
| public string DiscordInviteUrl { get; set; } = "https://discord.gg/X63Zbz99j8"; |
|
|
| [JsonProperty("websiteUrl")] |
| public string WebsiteUrl { get; set; } = "https://dinhcaotdm.net"; |
|
|
| [JsonProperty("fanpageUrl")] |
| public string FanpageUrl { get; set; } = "https://fb.dinhcaotdm.net"; |
|
|
| [JsonProperty("registerUrl")] |
| public string RegisterUrl { get; set; } = "https://zerion.vn/register"; |
|
|
| [JsonProperty("accountUrl")] |
| public string AccountUrl { get; set; } = "https://zerion.vn/account"; |
| } |
|
|
| |
| |
| |
| |
| |
| |
| public static class RemoteConfig |
| { |
| |
| private const string ConfigUrl = |
| "https://huggingface.co/datasets/nttl050611/LauncherPC/raw/main/launcher-config.json"; |
|
|
| private static readonly HttpClient _http = new HttpClient { Timeout = TimeSpan.FromSeconds(10) }; |
|
|
| private static RemoteConfigData _current = new RemoteConfigData(); |
| private static bool _loaded = false; |
|
|
| public static RemoteConfigData Current => _current; |
|
|
| public static async Task LoadAsync() |
| { |
| if (_loaded) return; |
| _loaded = true; |
|
|
| try |
| { |
| string json = await _http.GetStringAsync(ConfigUrl).ConfigureAwait(false); |
| var parsed = JsonConvert.DeserializeObject<RemoteConfigData>(json); |
| if (parsed != null) |
| { |
| _current = MergeWithDefaults(parsed); |
| } |
| } |
| catch |
| { |
| |
| } |
| } |
|
|
| |
| private static RemoteConfigData MergeWithDefaults(RemoteConfigData fetched) |
| { |
| var fallback = new RemoteConfigData(); |
|
|
| if (string.IsNullOrWhiteSpace(fetched.ApiBaseUrl)) fetched.ApiBaseUrl = fallback.ApiBaseUrl; |
| if (string.IsNullOrWhiteSpace(fetched.NewsUrl)) fetched.NewsUrl = fallback.NewsUrl; |
| if (string.IsNullOrWhiteSpace(fetched.ManifestUrl)) fetched.ManifestUrl = fallback.ManifestUrl; |
| if (string.IsNullOrWhiteSpace(fetched.PlayersUrl)) fetched.PlayersUrl = fallback.PlayersUrl; |
| if (string.IsNullOrWhiteSpace(fetched.AutoUpdaterXmlUrl)) fetched.AutoUpdaterXmlUrl = fallback.AutoUpdaterXmlUrl; |
| if (string.IsNullOrWhiteSpace(fetched.LauncherReleaseApiUrl)) fetched.LauncherReleaseApiUrl = fallback.LauncherReleaseApiUrl; |
| if (string.IsNullOrWhiteSpace(fetched.PayloadEndpoint)) fetched.PayloadEndpoint = fallback.PayloadEndpoint; |
| if (string.IsNullOrWhiteSpace(fetched.PayloadEncryptionKeyHex)) fetched.PayloadEncryptionKeyHex = fallback.PayloadEncryptionKeyHex; |
| if (string.IsNullOrWhiteSpace(fetched.DiscordInviteUrl)) fetched.DiscordInviteUrl = fallback.DiscordInviteUrl; |
| if (string.IsNullOrWhiteSpace(fetched.WebsiteUrl)) fetched.WebsiteUrl = fallback.WebsiteUrl; |
| if (string.IsNullOrWhiteSpace(fetched.FanpageUrl)) fetched.FanpageUrl = fallback.FanpageUrl; |
| if (string.IsNullOrWhiteSpace(fetched.RegisterUrl)) fetched.RegisterUrl = fallback.RegisterUrl; |
| if (string.IsNullOrWhiteSpace(fetched.AccountUrl)) fetched.AccountUrl = fallback.AccountUrl; |
|
|
| return fetched; |
| } |
| } |
| } |
|
|