- add: Content manipulation think
This commit is contained in:
15
Nebula.Launcher/Models/DownloadStreamHeaderFlags.cs
Normal file
15
Nebula.Launcher/Models/DownloadStreamHeaderFlags.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
|
||||
namespace Nebula.Launcher.Models;
|
||||
|
||||
[Flags]
|
||||
public enum DownloadStreamHeaderFlags
|
||||
{
|
||||
None = 0,
|
||||
|
||||
/// <summary>
|
||||
/// If this flag is set on the download stream, individual files have been pre-compressed by the server.
|
||||
/// This means each file has a compression header, and the launcher should not attempt to compress files itself.
|
||||
/// </summary>
|
||||
PreCompressed = 1 << 0
|
||||
}
|
||||
8
Nebula.Launcher/Models/RobustBuildInfo.cs
Normal file
8
Nebula.Launcher/Models/RobustBuildInfo.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace Nebula.Launcher.Models;
|
||||
|
||||
public class RobustBuildInfo
|
||||
{
|
||||
public ServerInfo BuildInfo;
|
||||
public RobustManifestInfo RobustManifestInfo;
|
||||
public RobustUrl Url;
|
||||
}
|
||||
@@ -4,26 +4,37 @@ using System.Text.Json.Serialization;
|
||||
|
||||
namespace Nebula.Launcher.Models;
|
||||
|
||||
public sealed record AuthInfo(string Mode, string PublicKey);
|
||||
public sealed record AuthInfo(
|
||||
[property: JsonPropertyName("mode")] string Mode,
|
||||
[property: JsonPropertyName("public_key")] string PublicKey);
|
||||
|
||||
public sealed record BuildInfo(
|
||||
string EngineVersion,
|
||||
string ForkId,
|
||||
string Version,
|
||||
string DownloadUrl,
|
||||
string ManifestUrl,
|
||||
bool Acz,
|
||||
string Hash,
|
||||
string ManifestHash);
|
||||
[property: JsonPropertyName("engine_version")] string EngineVersion,
|
||||
[property: JsonPropertyName("fork_id")] string ForkId,
|
||||
[property: JsonPropertyName("version")] string Version,
|
||||
[property: JsonPropertyName("download_url")] string DownloadUrl,
|
||||
[property: JsonPropertyName("manifest_download_url")] string ManifestDownloadUrl,
|
||||
[property: JsonPropertyName("manifest_url")] string ManifestUrl,
|
||||
[property: JsonPropertyName("acz")] bool Acz,
|
||||
[property: JsonPropertyName("hash")] string Hash,
|
||||
[property: JsonPropertyName("manifest_hash")] string ManifestHash);
|
||||
|
||||
public sealed record ServerLink(string Name, string Icon, string Url);
|
||||
public sealed record ServerInfo(string ConnectAddress, AuthInfo Auth, BuildInfo Build, string Desc, List<ServerLink> Links);
|
||||
public sealed record ServerLink(
|
||||
[property: JsonPropertyName("name")] string Name,
|
||||
[property: JsonPropertyName("icon")] string Icon,
|
||||
[property: JsonPropertyName("url")] string Url);
|
||||
|
||||
public sealed record ServerInfo(
|
||||
[property: JsonPropertyName("connect_address")] string ConnectAddress,
|
||||
[property: JsonPropertyName("auth")] AuthInfo Auth,
|
||||
[property: JsonPropertyName("build")] BuildInfo Build,
|
||||
[property: JsonPropertyName("desc")] string Desc,
|
||||
[property: JsonPropertyName("links")] List<ServerLink> Links);
|
||||
|
||||
public sealed record EngineVersionInfo(
|
||||
bool Insecure,
|
||||
[property: JsonPropertyName("redirect")]
|
||||
string? RedirectVersion,
|
||||
Dictionary<string, EngineBuildInfo> Platforms);
|
||||
[property: JsonPropertyName("insecure")] bool Insecure,
|
||||
[property: JsonPropertyName("redirect")] string? RedirectVersion,
|
||||
[property: JsonPropertyName("platforms")] Dictionary<string, EngineBuildInfo> Platforms);
|
||||
|
||||
public sealed class EngineBuildInfo
|
||||
{
|
||||
@@ -37,27 +48,28 @@ public sealed class EngineBuildInfo
|
||||
public string Url = default!;
|
||||
}
|
||||
|
||||
public sealed record ServerHubInfo(string Address, ServerStatus StatusData, List<string> InferredTags);
|
||||
public sealed record ServerHubInfo(
|
||||
[property: JsonPropertyName("address")] string Address,
|
||||
[property: JsonPropertyName("statusData")] ServerStatus StatusData,
|
||||
[property: JsonPropertyName("inferredTags")] List<string> InferredTags);
|
||||
|
||||
public sealed record ServerStatus(
|
||||
string Map,
|
||||
string Name,
|
||||
List<string> Tags,
|
||||
string Preset,
|
||||
int Players,
|
||||
[property: JsonPropertyName("round_id")]
|
||||
int RoundId,
|
||||
[property: JsonPropertyName("run_level")]
|
||||
int RunLevel,
|
||||
[property: JsonPropertyName("panic_bunker")]
|
||||
bool PanicBunker,
|
||||
[property: JsonPropertyName("round_start_time")]
|
||||
DateTime? RoundStartTime,
|
||||
[property: JsonPropertyName("soft_max_players")]
|
||||
int SoftMaxPlayers);
|
||||
[property: JsonPropertyName("map")] string Map,
|
||||
[property: JsonPropertyName("name")] string Name,
|
||||
[property: JsonPropertyName("tags")] List<string> Tags,
|
||||
[property: JsonPropertyName("preset")] string Preset,
|
||||
[property: JsonPropertyName("players")] int Players,
|
||||
[property: JsonPropertyName("round_id")] int RoundId,
|
||||
[property: JsonPropertyName("run_level")] int RunLevel,
|
||||
[property: JsonPropertyName("panic_bunker")] bool PanicBunker,
|
||||
[property: JsonPropertyName("round_start_time")] DateTime? RoundStartTime,
|
||||
[property: JsonPropertyName("soft_max_players")] int SoftMaxPlayers);
|
||||
|
||||
public sealed record ModulesInfo(Dictionary<string, Module> Modules);
|
||||
public sealed record ModulesInfo(
|
||||
[property: JsonPropertyName("modules")] Dictionary<string, Module> Modules);
|
||||
|
||||
public sealed record Module(Dictionary<string, ModuleVersionInfo> Versions);
|
||||
public sealed record Module(
|
||||
[property: JsonPropertyName("versions")] Dictionary<string, ModuleVersionInfo> Versions);
|
||||
|
||||
public sealed record ModuleVersionInfo(Dictionary<string, EngineBuildInfo> Platforms);
|
||||
public sealed record ModuleVersionInfo(
|
||||
[property: JsonPropertyName("platforms")] Dictionary<string, EngineBuildInfo> Platforms);
|
||||
|
||||
64
Nebula.Launcher/Models/RobustUrl.cs
Normal file
64
Nebula.Launcher/Models/RobustUrl.cs
Normal file
@@ -0,0 +1,64 @@
|
||||
using System;
|
||||
using Nebula.Launcher.Utils;
|
||||
|
||||
namespace Nebula.Launcher.Models;
|
||||
|
||||
public class RobustUrl
|
||||
{
|
||||
public RobustUrl(string url)
|
||||
{
|
||||
if (!UriHelper.TryParseSs14Uri(url, out var uri))
|
||||
throw new Exception("Invalid scheme");
|
||||
|
||||
Uri = uri;
|
||||
|
||||
HttpUri = UriHelper.GetServerApiAddress(Uri);
|
||||
}
|
||||
|
||||
public Uri Uri { get; }
|
||||
public Uri HttpUri { get; }
|
||||
public RobustPath InfoUri => new(this, "info");
|
||||
public RobustPath StatusUri => new(this, "status");
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return HttpUri.ToString();
|
||||
}
|
||||
|
||||
public static implicit operator Uri(RobustUrl url)
|
||||
{
|
||||
return url.HttpUri;
|
||||
}
|
||||
|
||||
public static explicit operator RobustUrl(string url)
|
||||
{
|
||||
return new RobustUrl(url);
|
||||
}
|
||||
|
||||
public static explicit operator RobustUrl(Uri uri)
|
||||
{
|
||||
return new RobustUrl(uri.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public class RobustPath
|
||||
{
|
||||
public string Path;
|
||||
public RobustUrl Url;
|
||||
|
||||
public RobustPath(RobustUrl url, string path)
|
||||
{
|
||||
Url = url;
|
||||
Path = path;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return ((Uri)this).ToString();
|
||||
}
|
||||
|
||||
public static implicit operator Uri(RobustPath path)
|
||||
{
|
||||
return new Uri(path.Url, path.Url.HttpUri.PathAndQuery + path.Path);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user