ServerPack: open pages in the engine's web panel #3

Open
AwfulWaffle wants to merge 22 commits from AwfulWaffle/RynthServers:serverpack-web-panel-engine into main
3 changed files with 48 additions and 1 deletions
Showing only changes of commit 5e732cecb7 - Show all commits

RynthDreamWeave: link ChatSource into the plugin, strict alphabet tests, harden the launch stem

The plugin project did not compile (ChatSource not linked). LaunchWire now treats any line starting with the success stem as success-shaped: malformed, it is dropped, never returned as refusal text.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Daniel Wallace 2026-11-07 14:44:41 -08:00

View file

@ -13,6 +13,8 @@ internal static class LaunchWire
public const string RequestCommand = "/weblogin"; public const string RequestCommand = "/weblogin";
public const string ReplyLead = "[WEB] "; public const string ReplyLead = "[WEB] ";
public const string SuccessLead = "[WEB] Launch code: "; public const string SuccessLead = "[WEB] Launch code: ";
/// <summary>Any line starting like this has the success shape: malformed, it is dropped, never shown as a refusal.</summary>
private const string SuccessStem = "[WEB] Launch code";
public const int CodeLength = 43; public const int CodeLength = 43;
public const long ReplyTimeoutMs = 10_000, MinIntervalMs = 3_000; public const long ReplyTimeoutMs = 10_000, MinIntervalMs = 3_000;
@ -37,8 +39,9 @@ internal static class LaunchWire
int start = ChatSource.ContentStart(text); int start = ChatSource.ContentStart(text);
ReadOnlySpan<char> line = text.AsSpan(start); ReadOnlySpan<char> line = text.AsSpan(start);
if (line.StartsWith(SuccessLead.AsSpan(), StringComparison.Ordinal)) if (line.StartsWith(SuccessStem.AsSpan(), StringComparison.Ordinal))
{ {
if (!line.StartsWith(SuccessLead.AsSpan(), StringComparison.Ordinal)) return false;
ReadOnlySpan<char> rest = line.Slice(SuccessLead.Length); ReadOnlySpan<char> rest = line.Slice(SuccessLead.Length);
if (rest.Length <= CodeLength || rest[CodeLength] != ' ') return false; if (rest.Length <= CodeLength || rest[CodeLength] != ' ') return false;
for (int i = 0; i < CodeLength; i++) for (int i = 0; i < CodeLength; i++)

View file

@ -13,6 +13,11 @@
<RynthPluginDescription>DreamWeave only: the server card (rules, server features, player commands, links, account setup) in its own window on the RynthCore bar, the retail Character panel whose XP for next level keeps reading past level 275, and the bank check every minute that gives Lum/hr its luminance.</RynthPluginDescription> <RynthPluginDescription>DreamWeave only: the server card (rules, server features, player commands, links, account setup) in its own window on the RynthCore bar, the retail Character panel whose XP for next level keeps reading past level 275, and the bank check every minute that gives Lum/hr its luminance.</RynthPluginDescription>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<!-- LaunchWire tells a server line from a player's copy of it. -->
<Compile Include="$(RynthSuiteRoot)Plugins\Shared\ChatSource.cs" Link="Shared\ChatSource.cs" />
</ItemGroup>
<Import Project="..\Shared\ServerPack\ServerPlugin.props" /> <Import Project="..\Shared\ServerPack\ServerPlugin.props" />
</Project> </Project>

View file

@ -17,6 +17,7 @@ internal static class DreamWeaveWebTests
r.Add("dreamweave web: a player's copy of the launch line is never taken", PlayerCopy); r.Add("dreamweave web: a player's copy of the launch line is never taken", PlayerCopy);
r.Add("dreamweave web: the launch URL is built from constants and a clean code", UrlFromConstants); r.Add("dreamweave web: the launch URL is built from constants and a clean code", UrlFromConstants);
r.Add("dreamweave web: destination ids are verbs no one else uses", IdsAreFree); r.Add("dreamweave web: destination ids are verbs no one else uses", IdsAreFree);
r.Add("dreamweave web: LaunchWire: code alphabet is strict", Alphabet);
r.Add("dreamweave web: ACE's refusals parse as refusals, other lines are ignored", Refusals); r.Add("dreamweave web: ACE's refusals parse as refusals, other lines are ignored", Refusals);
} }
@ -92,6 +93,44 @@ internal static class DreamWeaveWebTests
} }
} }
private static void Alphabet()
{
const string b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
Check.Eq(b64.Length, 64, "64 base64url chars");
foreach (char c in b64)
Check.True(LaunchWire.IsCodeChar(c), "accepted: " + c);
char[] bad = { '+', '/', '=', '&', '?', '#', '%', '.', ' ', '\t', '!', '~', '\u00e9', '\u0000' };
foreach (char c in bad)
{
string name = "U+" + ((int)c).ToString("X4");
Check.True(!LaunchWire.IsCodeChar(c), "IsCodeChar rejects " + name);
foreach (int idx in new[] { 0, 21, 42 })
{
char[] chars = Code.ToCharArray();
chars[idx] = c;
string line = "[WEB] Launch code: " + new string(chars) + " (single use, expires in 60 seconds)";
Check.True(!Parse(line, 0x05, out string code, out string refusal), "refused: " + name + " at " + idx);
Check.Eq(code, "", "no code: " + name + " at " + idx);
Check.Eq(refusal, "", "no refusal: " + name + " at " + idx);
}
}
// Round trip of a code holding both '-' and '_'.
string dashed = "-_" + Code.Substring(2);
Check.True(Parse("[WEB] Launch code: " + dashed + " (single use, expires in 60 seconds)", 0x05, out string got, out _), "dash/underscore code parses");
Check.Eq(got, dashed, "dash/underscore code intact");
Check.True(DreamWeaveWeb.LaunchUrl(got, DreamWeaveWeb.ById("market")!).Contains("code=" + dashed + "&to=", StringComparison.Ordinal), "url carries the code verbatim");
// The stem alone marks the success shape: malformed, it is dropped, never a refusal.
foreach (string l in new[] { "[WEB] Launch code:" + Code, "[WEB] Launch code " + Code, "[WEB] Launch code", "[WEB] Launch codes " + Code })
{
Check.True(!Parse(l, 0x05, out string c2, out string r2), "malformed success-shaped line dropped: " + l);
Check.Eq(c2, "", "no code: " + l);
Check.Eq(r2, "", "no refusal text: " + l);
}
}
private static void Refusals() private static void Refusals()
{ {
string[] lines = string[] lines =