Compare commits
2
Commits
v0.5.0
...
d2cbab5d4b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d2cbab5d4b | ||
|
|
0655af2699 |
No files matched your search
+12
-1
@@ -6,6 +6,16 @@ All notable changes to Flypaper are documented in this file. The format follows
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
## [0.5.1] - 2026-11-17
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Dashboard: strategies are shown with a plain German name (e.g. „Link-Labyrinth“, „Gefälschte Zugangsdaten
|
||||||
|
(.env)“) instead of the technical abbreviation. Tooltip and expanded row (also on touch devices) explain what
|
||||||
|
the bot gets, spell out the suffixes (`50-500ms 1-1024B`, `head`, `link`, `repeat`) and show the technical name.
|
||||||
|
Used in the catch list, the Top 10 „Strategien“ tab, filter chips and the page „Erkenntnisse“. The search also
|
||||||
|
finds the German names. Unknown names are shown unchanged. Stored values and MCP results stay technical.
|
||||||
|
|
||||||
## [0.5.0] - 2026-11-17
|
## [0.5.0] - 2026-11-17
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
@@ -174,7 +184,8 @@ First release.
|
|||||||
- Unraid Docker template; when started as root, the container hands `/data` to its app user
|
- Unraid Docker template; when started as root, the container hands `/data` to its app user
|
||||||
and drops privileges.
|
and drops privileges.
|
||||||
|
|
||||||
[Unreleased]: https://gitea.anticarnist.de/Tom/Flypaper/compare/v0.5.0...main
|
[Unreleased]: https://gitea.anticarnist.de/Tom/Flypaper/compare/v0.5.1...main
|
||||||
|
[0.5.1]: https://gitea.anticarnist.de/Tom/Flypaper/releases/tag/v0.5.1
|
||||||
[0.5.0]: https://gitea.anticarnist.de/Tom/Flypaper/releases/tag/v0.5.0
|
[0.5.0]: https://gitea.anticarnist.de/Tom/Flypaper/releases/tag/v0.5.0
|
||||||
[0.4.0]: https://gitea.anticarnist.de/Tom/Flypaper/releases/tag/v0.4.0
|
[0.4.0]: https://gitea.anticarnist.de/Tom/Flypaper/releases/tag/v0.4.0
|
||||||
[0.3.1]: https://gitea.anticarnist.de/Tom/Flypaper/releases/tag/v0.3.1
|
[0.3.1]: https://gitea.anticarnist.de/Tom/Flypaper/releases/tag/v0.3.1
|
||||||
|
|||||||
@@ -113,8 +113,10 @@ public sealed class DashboardQueries(IDbContextFactory<FlypaperDbContext> dbCont
|
|||||||
if (!string.IsNullOrWhiteSpace(filter.Search))
|
if (!string.IsNullOrWhiteSpace(filter.Search))
|
||||||
{
|
{
|
||||||
var pattern = $"%{filter.Search.Trim().Replace("\\", "\\\\").Replace("%", "\\%").Replace("_", "\\_")}%";
|
var pattern = $"%{filter.Search.Trim().Replace("\\", "\\\\").Replace("%", "\\%").Replace("_", "\\_")}%";
|
||||||
|
var strategyNames = filter.SearchStrategies ?? [];
|
||||||
events = events.Where(e =>
|
events = events.Where(e =>
|
||||||
EF.Functions.Like(e.RemoteIp, pattern, "\\")
|
EF.Functions.Like(e.RemoteIp, pattern, "\\")
|
||||||
|
|| strategyNames.Any(name => e.Strategy == name || EF.Functions.Like(e.Strategy, name + " %", "\\"))
|
||||||
|| EF.Functions.Like(e.Provider!, pattern, "\\")
|
|| EF.Functions.Like(e.Provider!, pattern, "\\")
|
||||||
|| EF.Functions.Like(e.Target!, pattern, "\\")
|
|| EF.Functions.Like(e.Target!, pattern, "\\")
|
||||||
|| EF.Functions.Like(e.Strategy, pattern, "\\")
|
|| EF.Functions.Like(e.Strategy, pattern, "\\")
|
||||||
|
|||||||
@@ -12,7 +12,8 @@ public sealed record RecentFilter(
|
|||||||
string? Target = null,
|
string? Target = null,
|
||||||
string? Strategy = null,
|
string? Strategy = null,
|
||||||
string? Search = null,
|
string? Search = null,
|
||||||
int Limit = RecentFilter.DefaultLimit)
|
int Limit = RecentFilter.DefaultLimit,
|
||||||
|
IReadOnlyList<string>? SearchStrategies = null)
|
||||||
{
|
{
|
||||||
public const int DefaultLimit = 50;
|
public const int DefaultLimit = 50;
|
||||||
public const int MaxLimit = 500;
|
public const int MaxLimit = 500;
|
||||||
|
|||||||
@@ -81,7 +81,7 @@
|
|||||||
@foreach (var tab in tabs)
|
@foreach (var tab in tabs)
|
||||||
{
|
{
|
||||||
<div role="tabpanel" id="panel-@tab.Id" aria-labelledby="tab-@tab.Id" tabindex="0" hidden="@(tab != tabs[0])">
|
<div role="tabpanel" id="panel-@tab.Id" aria-labelledby="tab-@tab.Id" tabindex="0" hidden="@(tab != tabs[0])">
|
||||||
<TopTable KeyLabel="@tab.KeyLabel" Entries="tab.Entries" ShowFlags="tab.ShowFlags" KeyFormatter="tab.KeyFormatter" LabelFormatter="tab.LabelFormatter"
|
<TopTable KeyLabel="@tab.KeyLabel" Entries="tab.Entries" ShowFlags="tab.ShowFlags" KeyFormatter="tab.KeyFormatter" LabelFormatter="tab.LabelFormatter" TitleFormatter="tab.TitleFormatter"
|
||||||
Href="entry => TopFilter(tab, entry).Href()" IsActive="entry => tab.Current(_filter) == entry.Key" />
|
Href="entry => TopFilter(tab, entry).Href()" IsActive="entry => tab.Current(_filter) == entry.Key" />
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
@@ -178,6 +178,7 @@
|
|||||||
var target = Formatting.Target(trapEvent.Target);
|
var target = Formatting.Target(trapEvent.Target);
|
||||||
var duration = Formatting.Duration(TimeSpan.FromMilliseconds(trapEvent.DurationMs));
|
var duration = Formatting.Duration(TimeSpan.FromMilliseconds(trapEvent.DurationMs));
|
||||||
var bytes = Formatting.Number(trapEvent.BytesSent);
|
var bytes = Formatting.Number(trapEvent.BytesSent);
|
||||||
|
var strategy = StrategyNames.Describe(trapEvent.Strategy);
|
||||||
<tr id="f@(index)" data-expand="event:@trapEvent.Id" tabindex="0" aria-expanded="false" class="@(trapEvent.Outcome == TrapOutcome.Rejected ? "rejected" : null)">
|
<tr id="f@(index)" data-expand="event:@trapEvent.Id" tabindex="0" aria-expanded="false" class="@(trapEvent.Outcome == TrapOutcome.Rejected ? "rejected" : null)">
|
||||||
<td class="c-time"><span class="c-date">@started.ToString("dd.MM.") </span>@started.ToString("HH:mm:ss")</td>
|
<td class="c-time"><span class="c-date">@started.ToString("dd.MM.") </span>@started.ToString("HH:mm:ss")</td>
|
||||||
<td class="c-ip mono" title="@trapEvent.RemoteIp">@trapEvent.RemoteIp</td>
|
<td class="c-ip mono" title="@trapEvent.RemoteIp">@trapEvent.RemoteIp</td>
|
||||||
@@ -195,13 +196,24 @@
|
|||||||
<td class="c-target mono" title="@target">
|
<td class="c-target mono" title="@target">
|
||||||
@target
|
@target
|
||||||
<div class="extra extra-md">Provider: @(provider ?? "–")</div>
|
<div class="extra extra-md">Provider: @(provider ?? "–")</div>
|
||||||
<div class="extra extra-md">Strategie: @trapEvent.Strategy</div>
|
|
||||||
<div class="extra extra-md">User-Agent: @(trapEvent.ClientInfo ?? "–")</div>
|
<div class="extra extra-md">User-Agent: @(trapEvent.ClientInfo ?? "–")</div>
|
||||||
|
<div class="extra extra-all strategy-info">
|
||||||
|
<strong>@strategy.DisplayName</strong>
|
||||||
|
@if (strategy.Explanation is not null)
|
||||||
|
{
|
||||||
|
<div>@strategy.Explanation</div>
|
||||||
|
}
|
||||||
|
@foreach (var detail in strategy.Details)
|
||||||
|
{
|
||||||
|
<div>@detail</div>
|
||||||
|
}
|
||||||
|
<div class="mono">@strategy.Raw</div>
|
||||||
|
</div>
|
||||||
<div class="extra extra-all">Herkunft: @(trapEvent.CountryCode is { } code ? $"{Formatting.Flag(code)} {code} · {Origin(trapEvent)}" : "–")</div>
|
<div class="extra extra-all">Herkunft: @(trapEvent.CountryCode is { } code ? $"{Formatting.Flag(code)} {code} · {Origin(trapEvent)}" : "–")</div>
|
||||||
<div class="extra extra-sm">Dauer: @duration · Bytes: @bytes</div>
|
<div class="extra extra-sm">Dauer: @duration · Bytes: @bytes</div>
|
||||||
<div class="extra extra-xs">Datum: @started.ToString("dd.MM.yyyy") · Ausgang: @OutcomeLabel(trapEvent.Outcome)</div>
|
<div class="extra extra-xs">Datum: @started.ToString("dd.MM.yyyy") · Ausgang: @OutcomeLabel(trapEvent.Outcome)</div>
|
||||||
</td>
|
</td>
|
||||||
<td class="c-strategy mono" title="@trapEvent.Strategy">@trapEvent.Strategy</td>
|
<td class="c-strategy" title="@strategy.Tooltip">@strategy.DisplayName</td>
|
||||||
<td class="c-agent" title="@trapEvent.ClientInfo">@trapEvent.ClientInfo</td>
|
<td class="c-agent" title="@trapEvent.ClientInfo">@trapEvent.ClientInfo</td>
|
||||||
<td class="c-duration num">@duration</td>
|
<td class="c-duration num">@duration</td>
|
||||||
<td class="c-bytes num">@bytes</td>
|
<td class="c-bytes num">@bytes</td>
|
||||||
@@ -260,7 +272,7 @@
|
|||||||
{
|
{
|
||||||
_filter = DashboardFilter.Parse(Zeit, Ausgang, Land, Provider, Ip, Ziel, Strategie, Q, Limit);
|
_filter = DashboardFilter.Parse(Zeit, Ausgang, Land, Provider, Ip, Ziel, Strategie, Q, Limit);
|
||||||
_data = await Queries.GetAsync();
|
_data = await Queries.GetAsync();
|
||||||
_recent = await Queries.GetRecentAsync(_filter.ToRecentFilter());
|
_recent = await Queries.GetRecentAsync(_filter.ToRecentFilter() with { SearchStrategies = StrategyNames.Matching(_filter.Q) });
|
||||||
_loadedAt = DateTime.Now;
|
_loadedAt = DateTime.Now;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -270,7 +282,7 @@
|
|||||||
new("providers", "Provider", "Provider", data.TopProviders, f => f.Provider, (f, key) => f with { Provider = key }),
|
new("providers", "Provider", "Provider", data.TopProviders, f => f.Provider, (f, key) => f with { Provider = key }),
|
||||||
new("ips", "IPs", "IP", data.TopIps, f => f.Ip, (f, key) => f with { Ip = key }),
|
new("ips", "IPs", "IP", data.TopIps, f => f.Ip, (f, key) => f with { Ip = key }),
|
||||||
new("targets", "Ziele", "Ziel", data.TopTargets, f => f.Ziel, (f, key) => f with { Ziel = key }, KeyFormatter: Formatting.Target),
|
new("targets", "Ziele", "Ziel", data.TopTargets, f => f.Ziel, (f, key) => f with { Ziel = key }, KeyFormatter: Formatting.Target),
|
||||||
new("strategies", "Strategien", "Strategie", data.TopStrategies, f => f.Strategie, (f, key) => f with { Strategie = key })
|
new("strategies", "Strategien", "Strategie", data.TopStrategies, f => f.Strategie, (f, key) => f with { Strategie = key }, KeyFormatter: StrategyNames.Summary, LabelFormatter: (key, _) => StrategyNames.Display(key), TitleFormatter: key => StrategyNames.Describe(key).Tooltip)
|
||||||
];
|
];
|
||||||
|
|
||||||
private DashboardFilter TopFilter(TopTab tab, TopEntry entry) =>
|
private DashboardFilter TopFilter(TopTab tab, TopEntry entry) =>
|
||||||
@@ -314,7 +326,7 @@
|
|||||||
|
|
||||||
if (_filter.Strategie is { } strategie)
|
if (_filter.Strategie is { } strategie)
|
||||||
{
|
{
|
||||||
yield return ($"Strategie: {strategie}", reset with { Strategie = null });
|
yield return ($"Strategie: {StrategyNames.Display(strategie)}", reset with { Strategie = null });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_filter.Q is { } q)
|
if (_filter.Q is { } q)
|
||||||
@@ -344,5 +356,6 @@
|
|||||||
Func<DashboardFilter, string?, DashboardFilter> Set,
|
Func<DashboardFilter, string?, DashboardFilter> Set,
|
||||||
bool ShowFlags = false,
|
bool ShowFlags = false,
|
||||||
Func<string?, string?>? KeyFormatter = null,
|
Func<string?, string?>? KeyFormatter = null,
|
||||||
Func<string?, string?, string?>? LabelFormatter = null);
|
Func<string?, string?, string?>? LabelFormatter = null,
|
||||||
|
Func<string?, string?>? TitleFormatter = null);
|
||||||
}
|
}
|
||||||
@@ -29,7 +29,7 @@ else
|
|||||||
var label = LabelFormatter is null ? entry.Label : LabelFormatter(entry.Key, entry.Label);
|
var label = LabelFormatter is null ? entry.Label : LabelFormatter(entry.Key, entry.Label);
|
||||||
var share = (entry.Count * 100.0 / Entries[0].Count).ToString("0.#", CultureInfo.InvariantCulture);
|
var share = (entry.Count * 100.0 / Entries[0].Count).ToString("0.#", CultureInfo.InvariantCulture);
|
||||||
var active = IsActive(entry);
|
var active = IsActive(entry);
|
||||||
var title = label is null ? key : $"{label} · {key}";
|
var title = TitleFormatter?.Invoke(entry.Key) ?? (label is null ? key : $"{label} · {key}");
|
||||||
<tr data-href="@Href(entry)" class="@(active ? "active" : null)">
|
<tr data-href="@Href(entry)" class="@(active ? "active" : null)">
|
||||||
<td class="clip" title="@title">
|
<td class="clip" title="@title">
|
||||||
<a href="@Href(entry)" aria-current="@(active ? "true" : null)" title="@(active ? $"Filter {title} entfernen" : $"Fänge filtern: {title}")">
|
<a href="@Href(entry)" aria-current="@(active ? "true" : null)" title="@(active ? $"Filter {title} entfernen" : $"Fänge filtern: {title}")">
|
||||||
@@ -40,8 +40,11 @@ else
|
|||||||
@if (label is not null)
|
@if (label is not null)
|
||||||
{
|
{
|
||||||
<span class="top-label">@label</span>
|
<span class="top-label">@label</span>
|
||||||
|
@if (key.Length > 0)
|
||||||
|
{
|
||||||
<span class="top-key mono">@key</span>
|
<span class="top-key mono">@key</span>
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<span class="mono">@key</span>
|
<span class="mono">@key</span>
|
||||||
@@ -68,6 +71,8 @@ else
|
|||||||
|
|
||||||
[Parameter] public Func<string?, string?, string?>? LabelFormatter { get; set; }
|
[Parameter] public Func<string?, string?, string?>? LabelFormatter { get; set; }
|
||||||
|
|
||||||
|
[Parameter] public Func<string?, string?>? TitleFormatter { get; set; }
|
||||||
|
|
||||||
[Parameter, EditorRequired] public required Func<TopEntry, string> Href { get; set; }
|
[Parameter, EditorRequired] public required Func<TopEntry, string> Href { get; set; }
|
||||||
|
|
||||||
[Parameter, EditorRequired] public required Func<TopEntry, bool> IsActive { get; set; }
|
[Parameter, EditorRequired] public required Func<TopEntry, bool> IsActive { get; set; }
|
||||||
|
|||||||
@@ -44,7 +44,7 @@
|
|||||||
<p class="lab-meta">
|
<p class="lab-meta">
|
||||||
@foreach (var strategy in entry.StrategyList)
|
@foreach (var strategy in entry.StrategyList)
|
||||||
{
|
{
|
||||||
<code>@strategy</code>
|
<code title="@StrategyNames.Describe(strategy).Tooltip">@StrategyNames.Display(strategy)</code>
|
||||||
}
|
}
|
||||||
@if (entry.Commit is { } commit)
|
@if (entry.Commit is { } commit)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -68,7 +68,7 @@
|
|||||||
<SettingsField Label="Wiederholer erkennen" For="repeat-window" Unit="Tage" Hint="0 bis 365, 0 = aus. IPs mit einem Timeout in diesem Zeitraum gelten als Wiederholer" Errors="_errors" Key="@nameof(HoldMethodModel.RepeatWindowDays)">
|
<SettingsField Label="Wiederholer erkennen" For="repeat-window" Unit="Tage" Hint="0 bis 365, 0 = aus. IPs mit einem Timeout in diesem Zeitraum gelten als Wiederholer" Errors="_errors" Key="@nameof(HoldMethodModel.RepeatWindowDays)">
|
||||||
<InputText id="repeat-window" @bind-Value="Model!.RepeatWindowDays" inputmode="numeric" />
|
<InputText id="repeat-window" @bind-Value="Model!.RepeatWindowDays" inputmode="numeric" />
|
||||||
</SettingsField>
|
</SettingsField>
|
||||||
<SettingsField Label="Haltedauer für Wiederholer" For="repeat-hold" Hint="d.hh:mm:ss, höchstens 7 Tage. Strategie bekommt den Zusatz repeat" Errors="_errors" Key="@nameof(HoldMethodModel.RepeatHoldDuration)">
|
<SettingsField Label="Haltedauer für Wiederholer" For="repeat-hold" Hint="d.hh:mm:ss, höchstens 7 Tage. Strategie bekommt den Zusatz repeat („Wiederholer“)" Errors="_errors" Key="@nameof(HoldMethodModel.RepeatHoldDuration)">
|
||||||
<InputText id="repeat-hold" @bind-Value="Model!.RepeatHoldDuration" />
|
<InputText id="repeat-hold" @bind-Value="Model!.RepeatHoldDuration" />
|
||||||
</SettingsField>
|
</SettingsField>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -0,0 +1,114 @@
|
|||||||
|
using System.Globalization;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
|
namespace Flypaper.Web.Components.Shared;
|
||||||
|
|
||||||
|
public sealed record StrategyInfo(string Raw, string BaseName, string DisplayName, string? Explanation, IReadOnlyList<string> Details)
|
||||||
|
{
|
||||||
|
public string Tooltip
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
var lines = new List<string> { DisplayName };
|
||||||
|
if (Explanation is not null)
|
||||||
|
{
|
||||||
|
lines.Add(Explanation);
|
||||||
|
}
|
||||||
|
|
||||||
|
lines.AddRange(Details);
|
||||||
|
lines.Add($"Technisch: {Raw}");
|
||||||
|
return string.Join("\n", lines);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static partial class StrategyNames
|
||||||
|
{
|
||||||
|
private static readonly Dictionary<string, (string Name, string Explanation)> Known = new(StringComparer.Ordinal)
|
||||||
|
{
|
||||||
|
["maze-drip"] = ("Link-Labyrinth", "Eine Webseite voller Links, die immer zu neuen, erfundenen Seiten führen. Der Bot folgt ihnen und verirrt sich, während alles nur tröpfchenweise ankommt."),
|
||||||
|
["index-drip"] = ("Gefälschtes Ordner-Listing", "Eine Dateiliste im Stil von „Index of /…“ mit erfundenen Ordnern und Dateien. Wer weiterklickt, landet im Link-Labyrinth."),
|
||||||
|
["html-drip"] = ("Endlose Webseite", "Eine gewöhnlich aussehende Webseite, die nie aufhört und nur Stück für Stück geliefert wird. Der Bot wartet auf das Ende, das nie kommt."),
|
||||||
|
["text-drip"] = ("Endloser Text", "Unendlicher Fließtext ohne Formatierung, der nur tröpfchenweise ankommt. Der Bot wartet auf das Ende, das nie kommt."),
|
||||||
|
["env-drip"] = ("Gefälschte Zugangsdaten (.env)", "Eine erfundene .env-Datei mit Passwörtern und Schlüsseln, die nie endet. Bots, die nach geleakten Zugangsdaten suchen, lesen sie bis zum Ende."),
|
||||||
|
["git-drip"] = ("Gefälschtes Git-Projekt", "Eine erfundene Git-Konfiguration, die wie die echte beginnt und nie endet. Bots, die Quellcode abgreifen wollen, bleiben daran hängen."),
|
||||||
|
["svn-drip"] = ("Gefälschtes Subversion-Projekt", "Erfundene Dateien aus einem .svn-Ordner, die wie die echten beginnen und nie enden. Bots, die Quellcode abgreifen wollen, bleiben daran hängen."),
|
||||||
|
["hg-drip"] = ("Gefälschtes Mercurial-Projekt", "Erfundene Dateien aus einem .hg-Ordner, die wie die echten beginnen und nie enden. Bots, die Quellcode abgreifen wollen, bleiben daran hängen."),
|
||||||
|
["json-drip"] = ("Gefälschte JSON-Datei", "Eine erfundene JSON-Datei, die nie endet. Bots, die Konfigurationen und Daten einsammeln, warten auf das Dateiende."),
|
||||||
|
["xml-drip"] = ("Gefälschte XML-Datei", "Eine erfundene XML-Datei, die nie endet. Bots, die Konfigurationen und Daten einsammeln, warten auf das Dateiende."),
|
||||||
|
["yaml-drip"] = ("Gefälschte YAML-Datei", "Eine erfundene YAML-Konfiguration, die nie endet. Bots, die Konfigurationen einsammeln, warten auf das Dateiende."),
|
||||||
|
["sql-drip"] = ("Gefälschter Datenbank-Export (SQL)", "Ein erfundener SQL-Dump mit endlos vielen Einträgen. Bots, die nach Datenbank-Backups suchen, laden ihn herunter, solange es geht."),
|
||||||
|
["hikvision-drip"] = ("Gefälschte Überwachungskamera (Hikvision)", "Die Antwort einer erfundenen Hikvision-Kamera, die nie endet. Bots, die nach angreifbaren Kameras suchen, warten auf die komplette Antwort."),
|
||||||
|
["wordpress-drip"] = ("Gefälschte WordPress-Anmeldung", "Eine erfundene WordPress-Anmeldeseite, die nie fertig geladen wird. Bots, die Passwörter durchprobieren, kommen nie zum Formular."),
|
||||||
|
["robots-static"] = ("robots.txt (Hinweis an brave Crawler)", "Die robots.txt wird sofort und vollständig geliefert. Sie verbietet alles, brave Crawler bleiben draußen. Es wird bewusst niemand festgehalten."),
|
||||||
|
["robots-bait"] = ("Köder aus der robots.txt", "Ein Pfad, der in der robots.txt als verboten steht, aber ins Link-Labyrinth führt. Wer dort landet, hat das Verbot gelesen und ignoriert. Er wird mindestens 24 Stunden festgehalten.")
|
||||||
|
};
|
||||||
|
|
||||||
|
public static StrategyInfo Describe(string? strategy)
|
||||||
|
{
|
||||||
|
var raw = strategy?.Trim() ?? "";
|
||||||
|
var tokens = raw.Split(' ', StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
if (tokens.Length == 0)
|
||||||
|
{
|
||||||
|
return new StrategyInfo(raw, raw, raw, null, []);
|
||||||
|
}
|
||||||
|
|
||||||
|
var details = new List<string>();
|
||||||
|
for (var i = 1; i < tokens.Length; i++)
|
||||||
|
{
|
||||||
|
var token = tokens[i];
|
||||||
|
if (DelayPattern().Match(token) is { Success: true } delay
|
||||||
|
&& i + 1 < tokens.Length && SizePattern().Match(tokens[i + 1]) is { Success: true } chunk)
|
||||||
|
{
|
||||||
|
details.Add($"tröpfelt {Range(chunk.Groups[1].Value, chunk.Groups[2].Value)} Byte alle {Range(delay.Groups[1].Value, delay.Groups[2].Value)} ms");
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
else if (token is "head" or "link" && i + 1 < tokens.Length && SingleSizePattern().Match(tokens[i + 1]) is { Success: true } size)
|
||||||
|
{
|
||||||
|
var bytes = Number(size.Groups[1].Value);
|
||||||
|
details.Add(token == "head"
|
||||||
|
? $"schneller Start: die ersten {bytes} Byte sofort"
|
||||||
|
: $"alle {bytes} Byte ein Link");
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
else if (token == "repeat")
|
||||||
|
{
|
||||||
|
details.Add("Wiederholer: darf länger festgehalten werden");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
details.Add(token);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Known.TryGetValue(tokens[0], out var known)
|
||||||
|
? new StrategyInfo(raw, tokens[0], known.Name, known.Explanation, details)
|
||||||
|
: new StrategyInfo(raw, tokens[0], tokens[0], null, details);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string Display(string? strategy) => Describe(strategy).DisplayName;
|
||||||
|
|
||||||
|
public static string Summary(string? strategy) =>
|
||||||
|
string.Join(" · ", Describe(strategy).Details.Where(detail => detail.StartsWith("tröpfelt", StringComparison.Ordinal) || detail.StartsWith("Wiederholer", StringComparison.Ordinal)).Select(detail => detail.Split(':')[0]));
|
||||||
|
|
||||||
|
public static IReadOnlyList<string> Matching(string? search)
|
||||||
|
{
|
||||||
|
var term = search?.Trim();
|
||||||
|
return string.IsNullOrEmpty(term)
|
||||||
|
? []
|
||||||
|
: Known.Where(pair => pair.Value.Name.Contains(term, StringComparison.CurrentCultureIgnoreCase)).Select(pair => pair.Key).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string Range(string min, string max) => min == max ? Number(min) : $"{Number(min)}–{Number(max)}";
|
||||||
|
|
||||||
|
private static string Number(string digits) => long.Parse(digits, CultureInfo.InvariantCulture).ToString("N0", Formatting.German);
|
||||||
|
|
||||||
|
[GeneratedRegex(@"^(\d+)-(\d+)ms$")]
|
||||||
|
private static partial Regex DelayPattern();
|
||||||
|
|
||||||
|
[GeneratedRegex(@"^(\d+)-(\d+)B$")]
|
||||||
|
private static partial Regex SizePattern();
|
||||||
|
|
||||||
|
[GeneratedRegex(@"^(\d+)B$")]
|
||||||
|
private static partial Regex SingleSizePattern();
|
||||||
|
}
|
||||||
@@ -468,6 +468,10 @@ a.button:hover {
|
|||||||
width: 190px;
|
width: 190px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.recent-table .strategy-info div {
|
||||||
|
margin-top: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
.recent-table .extra {
|
.recent-table .extra {
|
||||||
display: none;
|
display: none;
|
||||||
margin-top: 4px;
|
margin-top: 4px;
|
||||||
|
|||||||
@@ -76,6 +76,15 @@ public sealed class RecentCatchesTests : IDisposable
|
|||||||
recent.Total.ShouldBe(expected);
|
recent.Total.ShouldBe(expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task Search_also_matches_strategy_base_names_from_display_names()
|
||||||
|
{
|
||||||
|
var recent = await _queries.GetRecentAsync(new RecentFilter(Search: "Zugangsdaten", SearchStrategies: ["env-drip"]));
|
||||||
|
|
||||||
|
recent.Total.ShouldBe(2);
|
||||||
|
recent.Items.ShouldAllBe(e => e.Strategy == "env-drip");
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Returns_an_empty_result_when_nothing_matches()
|
public async Task Returns_an_empty_result_when_nothing_matches()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,66 @@
|
|||||||
|
using Flypaper.Core.Strategies;
|
||||||
|
using Flypaper.Web.Components.Shared;
|
||||||
|
using Shouldly;
|
||||||
|
|
||||||
|
namespace Flypaper.Tests.Web;
|
||||||
|
|
||||||
|
public sealed class StrategyNamesTests
|
||||||
|
{
|
||||||
|
[Fact]
|
||||||
|
public void Describes_the_maze_with_all_suffixes()
|
||||||
|
{
|
||||||
|
var info = StrategyNames.Describe("maze-drip 50-500ms 1-1024B head 1024B link 160B repeat");
|
||||||
|
|
||||||
|
info.DisplayName.ShouldBe("Link-Labyrinth");
|
||||||
|
info.Explanation.ShouldNotBeNull();
|
||||||
|
info.Details.ShouldBe([
|
||||||
|
"tröpfelt 1–1.024 Byte alle 50–500 ms",
|
||||||
|
"schneller Start: die ersten 1.024 Byte sofort",
|
||||||
|
"alle 160 Byte ein Link",
|
||||||
|
"Wiederholer: darf länger festgehalten werden"
|
||||||
|
]);
|
||||||
|
info.Raw.ShouldBe("maze-drip 50-500ms 1-1024B head 1024B link 160B repeat");
|
||||||
|
info.Tooltip.ShouldContain("Technisch: maze-drip 50-500ms");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void Shows_unknown_names_and_tokens_unchanged()
|
||||||
|
{
|
||||||
|
var info = StrategyNames.Describe("ufo-drip 5-9ms 1-2B odd");
|
||||||
|
|
||||||
|
info.DisplayName.ShouldBe("ufo-drip");
|
||||||
|
info.Explanation.ShouldBeNull();
|
||||||
|
info.Details.ShouldBe(["tröpfelt 1–2 Byte alle 5–9 ms", "odd"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Theory]
|
||||||
|
[InlineData("robots-static")]
|
||||||
|
[InlineData("robots-bait 10-20ms 1-8B link 160B")]
|
||||||
|
public void Covers_robots_strategies(string strategy) =>
|
||||||
|
StrategyNames.Describe(strategy).Explanation.ShouldNotBeNull();
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void Covers_every_strategy_name_of_the_core()
|
||||||
|
{
|
||||||
|
string[] names =
|
||||||
|
[
|
||||||
|
MazeDripStrategy.PageName, MazeDripStrategy.ListingName, MazeDripStrategy.BaitName,
|
||||||
|
HtmlDripStrategy.StrategyName, TextDripStrategy.StrategyName, RobotsStaticStrategy.StrategyName,
|
||||||
|
.. FileContent.Profiles.Select(profile => profile.Name)
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach (var name in names)
|
||||||
|
{
|
||||||
|
StrategyNames.Describe(name).Explanation.ShouldNotBeNull(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void Finds_base_names_by_display_name()
|
||||||
|
{
|
||||||
|
StrategyNames.Matching(" gefälschtes git ").ShouldBe(["git-drip"]);
|
||||||
|
StrategyNames.Matching("zugangsdaten").ShouldBe(["env-drip"]);
|
||||||
|
StrategyNames.Matching("").ShouldBeEmpty();
|
||||||
|
StrategyNames.Matching("nichts").ShouldBeEmpty();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user