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
32 lines
1.1 KiB
C#
32 lines
1.1 KiB
C#
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;
|
|
}
|
|
}
|
|
}
|