.env, JSON, YAML, SQL and Git config carry URLs marked with the serving catch, so a later request shows where the address came from. MCP exposes the marker. Switch: Flypaper__Drip__Signposts. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
29 lines
939 B
C#
29 lines
939 B
C#
using System.Text.RegularExpressions;
|
|
using Flypaper.Core.Abstractions;
|
|
|
|
namespace Flypaper.Core.Strategies;
|
|
|
|
public sealed partial record SignpostLinks(string BaseUrl, string Marker)
|
|
{
|
|
public const int MarkerLength = 12;
|
|
|
|
public string Backup => $"{BaseUrl}/backup/db-{Marker}.sql";
|
|
|
|
public string Admin => $"{BaseUrl}/admin-{Marker}/";
|
|
|
|
public string Settings => $"{BaseUrl}/storage/settings-{Marker}.json";
|
|
|
|
public string Repository => $"{BaseUrl}/git-{Marker}/portal.git";
|
|
|
|
public static string MarkerOf(Guid sessionId) => sessionId.ToString("N")[..MarkerLength];
|
|
|
|
public static SignpostLinks For(ITrapChannel channel)
|
|
{
|
|
var baseUrl = channel.Host is { } host && HostPattern().IsMatch(host) ? $"http://{host}" : "";
|
|
return new SignpostLinks(baseUrl, MarkerOf(channel.Session.Id));
|
|
}
|
|
|
|
[GeneratedRegex(@"^[A-Za-z0-9.-]{1,253}\z")]
|
|
private static partial Regex HostPattern();
|
|
}
|