Download LauncherConfig.cs from nttl050611/LauncherPC: direct link, hf CLI and curl.
- Browser
- Download file 5.65 kB
-
https://huggingface.co/datasets/nttl050611/LauncherPC/resolve/main/LauncherConfig.cs
- Command line
-
hf download hf://datasets/nttl050611/LauncherPC/LauncherConfig.cs
-
curl -L -o LauncherConfig.cs https://huggingface.co/datasets/nttl050611/LauncherPC/resolve/main/LauncherConfig.cs
5.65 kB
| using System; | |
| using System.Net.Http; | |
| using System.Threading.Tasks; | |
| using Newtonsoft.Json; | |
| namespace ZerionLauncher.Services | |
| { | |
| /// <summary> | |
| /// Giá trị mặc định khi không tải được config từ host (offline / host chết). | |
| /// Giữ nguyên giá trị production hiện tại để launcher vẫn chạy được. | |
| /// </summary> | |
| public class RemoteConfigData | |
| { | |
| [] | |
| public string ApiBaseUrl { get; set; } = "https://api-production-20fe.up.railway.app/api/v1"; | |
| [] | |
| public string NewsUrl { get; set; } = "https://huggingface.co/datasets/nttl050611/LauncherPC/raw/main/news.json"; | |
| [] | |
| public string ManifestUrl { get; set; } = "https://huggingface.co/datasets/nttl050611/LauncherPC/resolve/main/manifest.json"; | |
| [] | |
| public string PlayersUrl { get; set; } = "http://15.235.149.123/players.json"; | |
| [] | |
| public string AutoUpdaterXmlUrl { get; set; } = "https://raw.githubusercontent.com/ntl050611/gta/refs/heads/main/autoupdater.xml"; | |
| [] | |
| public string LauncherReleaseApiUrl { get; set; } = "https://api.github.com/repos/ntl050611/gta/releases/latest"; | |
| [] | |
| public string PayloadEndpoint { get; set; } = "http://127.0.0.1:3000/api/v1/security/payload"; | |
| [] | |
| public string PayloadEncryptionKeyHex { get; set; } = "0000000000000000000000000000000000000000000000000000000000000000"; | |
| [] | |
| public string DiscordInviteUrl { get; set; } = "https://discord.gg/X63Zbz99j8"; | |
| [] | |
| public string WebsiteUrl { get; set; } = "https://dinhcaotdm.net"; | |
| [] | |
| public string FanpageUrl { get; set; } = "https://fb.dinhcaotdm.net"; | |
| [] | |
| public string RegisterUrl { get; set; } = "https://zerion.vn/register"; | |
| [] | |
| public string AccountUrl { get; set; } = "https://zerion.vn/account"; | |
| } | |
| /// <summary> | |
| /// Tải cấu hình từ host ngay khi launcher khởi động. Mọi URL / key / IP / port | |
| /// được lấy từ đây — muốn đổi server chỉ cần sửa file launcher-config.json trên | |
| /// host, không cần build lại launcher. Nếu fetch thất bại thì dùng giá trị | |
| /// mặc định trong RemoteConfigData. | |
| /// </summary> | |
| public static class RemoteConfig | |
| { | |
| // ⚠️ Đây là URL duy nhất còn hardcode — bỏ file launcher-config.json cạnh nó. | |
| 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 | |
| { | |
| // Mạng lỗi / host lỗi — giữ nguyên mặc định, launcher vẫn chạy. | |
| } | |
| } | |
| /// <summary>Trường nào host để trống thì giữ giá trị mặc định.</summary> | |
| 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; | |
| } | |
| } | |
| } | |