Files
DorkNet/launcher/Backend/SingleOriginServiceMap.cs
Alexa f5ad4b59ef Localtunnel hosting + admin panel + AppData db
- Default hosting mode is now Localtunnel — public *.loca.lt URL,
  no account, auto-fetched on first run. Replaces the prototyped
  Tailscale mode.
- Tailscale code purged from launcher + CLI; docs swapped to
  Localtunnel throughout (easy-setup, joining-a-server, server-cli,
  troubleshooting, faq, READMEs).
- Launcher sidebar gains an Open admin panel button — opens
  https://admin.<apex> in the browser once the server is live.
- SQLite db moves to %APPDATA%\DorkNet\dorknet.db (server reads
  Database__SqlitePath env var, launcher passes it). Existing dbs
  under <serverDir>\data\ are migrated on first run.
- CLI Program.cs: --mode default flips from tailscale to localtunnel;
  csproj links in LocaltunnelTunnel + LocaltunnelInstaller.
- New Backend files: LauncherNameServer, LocaltunnelInstaller,
  LocaltunnelTunnel, SingleOriginServiceMap.
- .gitignore: exclude installer/out/.
2026-05-28 01:39:38 +03:00

70 lines
2.2 KiB
C#

using System.Text.Json;
namespace DorkNet.Launcher.Backend;
public static class SingleOriginServiceMap
{
private static readonly (string Service, string Prefix)[] Services =
[
("WWW", "www"),
("API", "api"),
("Accounts", "accounts"),
("Auth", "auth"),
("BugReporting", "bugreporting"),
("Cards", "cards"),
("CDN", "cdn"),
("Chat", "chat"),
("Clubs", "clubs"),
("CMS", "cms"),
("Commerce", "commerce"),
("Data", "data"),
("DataCollection", "datacollection"),
("Discovery", "discovery"),
("Econ", "econ"),
("GameLogs", "gamelogs"),
("Geo", "geo"),
("Images", "img"),
("Leaderboard", "leaderboard"),
("Link", "link"),
("Lists", "lists"),
("Matchmaking", "match"),
("Moderation", "moderation"),
("NameServer", "ns"),
("Notifications", "notify"),
("PlatformNotifications", "platformnotifications"),
("PlayerSettings", "playersettings"),
("RoomComments", "roomcomments"),
("RoomieIntegrations", "roomieintegrations"),
("Rooms", "rooms"),
("Storage", "storage"),
("Strings", "strings"),
("StringsCDN", "strings-cdn"),
("Studio", "studio"),
("Thorn", "thorn"),
("Videos", "videos"),
];
public static Dictionary<string, string> Build(string publicBaseUrl)
{
var baseUrl = NormalizeBaseUrl(publicBaseUrl);
return Services.ToDictionary(
x => x.Service,
x => $"{baseUrl}/__dn/{x.Prefix}",
StringComparer.OrdinalIgnoreCase);
}
public static string ToJson(string publicBaseUrl)
=> JsonSerializer.Serialize(Build(publicBaseUrl));
public static string NormalizeBaseUrl(string value)
{
var trimmed = (value ?? "").Trim();
if (string.IsNullOrWhiteSpace(trimmed))
throw new ArgumentException("Public tunnel URL is empty.", nameof(value));
if (!trimmed.StartsWith("http://", StringComparison.OrdinalIgnoreCase) &&
!trimmed.StartsWith("https://", StringComparison.OrdinalIgnoreCase))
trimmed = "https://" + trimmed;
return trimmed.TrimEnd('/');
}
}