mirror of
https://github.com/DorkSquadRR/DorkNet.git
synced 2026-10-26 07:28:45 -07:00
46e2bb15e4
- ClientMod: add SingleOriginBaseUrl config + URI rewrite path so the client can talk to one https://<apex>/__dn/<service>/... base instead of demanding wildcard subdomains. ServerHost rewrite still the fallback when SingleOriginBaseUrl is empty. - ClientMod config: InjectAuthValues now defaults to false. The server's PhotonCustomAuthController already fail-opens (Photon:RequireCustomAuth=false), so anonymous bootstrap is the cleaner default and avoids Photon's CustomAuthFailed loop when a WAF returns 403 to Photon's probe. - Server: SQLite path now reads Database:SqlitePath config (Database__SqlitePath env). Falls back to <bin>/data/dorknet.db so existing Docker / standalone deploys are unchanged. Lets the Windows launcher put the db under %APPDATA%\DorkNet. - Server: DomainConfig + ConfigService updates for the single-origin apex. - .gitignore: exclude local-releases.zip.
35 lines
1.6 KiB
C#
35 lines
1.6 KiB
C#
namespace DorkNet.Server.Services;
|
|
|
|
/// <summary>Single source of truth for the deployment apex domain.
|
|
/// Read from <c>DORKNET_DOMAIN</c> env var (or config key
|
|
/// <c>Domain:Apex</c>) at startup. Defaults to <c>localhost</c>. Replaces
|
|
/// per-controller <c>[Host("api.rec.net","api.localhost")]</c> filters —
|
|
/// allowed hosts are derived as <c>{apex}</c> + <c>*.{apex}</c>, fed
|
|
/// into HostFilteringMiddleware. Subdomain-discriminating handlers
|
|
/// (Cdn vs Img on path "/{*path}") branch on
|
|
/// <c>Request.Host.Host.Split('.')[0]</c>.</summary>
|
|
public sealed class DomainConfig
|
|
{
|
|
public string Apex { get; }
|
|
public string Scheme { get; }
|
|
public string? Port { get; }
|
|
public string? SingleOriginBaseUrl { get; }
|
|
public bool SingleOriginEnabled => !string.IsNullOrWhiteSpace(SingleOriginBaseUrl);
|
|
|
|
public DomainConfig(string apex, string scheme = "https", string? port = null, string? singleOriginBaseUrl = null)
|
|
{
|
|
Apex = apex;
|
|
Scheme = string.IsNullOrWhiteSpace(scheme) ? "https" : scheme.TrimEnd(':', '/', '\\');
|
|
Port = string.IsNullOrWhiteSpace(port) ? null : port.Trim().TrimStart(':');
|
|
SingleOriginBaseUrl = string.IsNullOrWhiteSpace(singleOriginBaseUrl)
|
|
? null
|
|
: singleOriginBaseUrl.Trim().TrimEnd('/');
|
|
}
|
|
|
|
public string Sub(string prefix) => $"{prefix}.{Apex}";
|
|
public string Url(string host) => Port is null ? $"{Scheme}://{host}" : $"{Scheme}://{host}:{Port}";
|
|
public string SubUrl(string prefix) => Url(Sub(prefix));
|
|
public static bool MatchesSubdomain(string host, string prefix)
|
|
=> host.StartsWith(prefix + ".", StringComparison.OrdinalIgnoreCase);
|
|
}
|