feat(protocol): API v1 contract and typed client
DTOs for auth, users, sequences, frames, manifests, uploads, jobs, render nodes, events and LAN discovery; TitanoClient with TOFU certificate pinning, bearer auth, resumable SHA-256-verified chunked uploads with retry/backoff, shared bandwidth limiter and the event WebSocket stream. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
12 files changed
+751
-11
No files matched your search
@@ -0,0 +1,31 @@
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Titano.Protocol;
|
||||
|
||||
/// <summary>
|
||||
/// LAN discovery (TITANO_DISCOVERY): the server broadcasts a small UDP beacon on port 48300 every few seconds;
|
||||
/// clients listen and offer "Studio NAS found on this network" on first run.
|
||||
/// </summary>
|
||||
public sealed record DiscoveryBeacon(string Name, string Version, int HttpPort, int HttpsPort, string? TlsFingerprint)
|
||||
{
|
||||
public const int Port = 48300;
|
||||
private const string Magic = "TITANO1 ";
|
||||
|
||||
public byte[] ToBytes() => Encoding.UTF8.GetBytes(Magic + JsonSerializer.Serialize(this, ProtocolJson.Default.DiscoveryBeacon));
|
||||
|
||||
public static DiscoveryBeacon? TryParse(ReadOnlySpan<byte> datagram)
|
||||
{
|
||||
if (datagram.Length > 2048) return null;
|
||||
var text = Encoding.UTF8.GetString(datagram);
|
||||
if (!text.StartsWith(Magic, StringComparison.Ordinal)) return null;
|
||||
try
|
||||
{
|
||||
return JsonSerializer.Deserialize(text[Magic.Length..], ProtocolJson.Default.DiscoveryBeacon);
|
||||
}
|
||||
catch (JsonException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user