diff --git a/docs/configuration.md b/docs/configuration.md index 58f694f..ef4cd2f 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -20,7 +20,6 @@ All optional. Read at startup; list entries need an index (`__0`, `__1`, ...). | `ConnectionStrings__Flypaper` | SQLite database | `Data Source=/data/flypaper.db` | | `Flypaper__DataProtection__KeysPath` | Keys for login cookies and forms | `/data/keys` | | `Flypaper__GeoIp__Directory` | Folder for the DB-IP databases; empty disables GeoIP | `/data/geoip` | -| `Flypaper__Drip__Content` | Hold method: `Html`, `Text` or `Alternating` | `Html` | | `Flypaper__Drip__MinDelay` / `MaxDelay` | Pause between chunks | `00:00:00.05` / `00:00:01` | | `Flypaper__Drip__MinChunkSize` / `MaxChunkSize` | Bytes per chunk | `1` / `64` | | `Flypaper__Drip__HeadStartSize` | Bytes sent immediately before dripping starts (`0` = off) | `1024` | @@ -40,7 +39,6 @@ general reset button removes all saved values; the hold method section has its o | Setting | Default | |---|---| -| Hold method: content (HTML filler text, random plain text, or alternating per catch) | HTML filler text | | Hold method: pause between chunks, min and max (10 ms to 30 s) | 50 ms / 1000 ms | | Hold method: chunk size, min and max (1 to 4096 bytes) | 1 / 64 bytes | | Hold method: head start, sent without delay before the drip (0 to 65536 bytes) | 1024 bytes | diff --git a/docs/overview.md b/docs/overview.md index 252f068..f89f6e2 100644 --- a/docs/overview.md +++ b/docs/overview.md @@ -31,7 +31,7 @@ flowchart LR ## Features - **Trap** for everything that reaches the trap port: whatever host or path a bot asks for -- **Slow delivery** of endless generated HTML or plain text (or both, alternating per catch) +- **Slow delivery** of endless generated HTML (link labyrinth) with irregular timing; content, pauses, chunk sizes and hold time are set in the dashboard - **Limits**: maximum connections overall and per IP, maximum hold time per catch - **Dashboard**: totals, a world map, top countries, providers, IPs and paths, the latest diff --git a/src/Flypaper.Core/FlypaperCoreExtensions.cs b/src/Flypaper.Core/FlypaperCoreExtensions.cs index 6dc52c2..7f8a7f5 100644 --- a/src/Flypaper.Core/FlypaperCoreExtensions.cs +++ b/src/Flypaper.Core/FlypaperCoreExtensions.cs @@ -20,7 +20,6 @@ public static class FlypaperCoreExtensions services.TryAddSingleton(); services.TryAddSingleton(); services.TryAddEnumerable(ServiceDescriptor.Singleton()); - services.TryAddEnumerable(ServiceDescriptor.Singleton()); services.TryAddEnumerable(ServiceDescriptor.Singleton()); services.AddSingleton(_ => LureStrategy.Page()); services.AddSingleton(_ => LureStrategy.Icon()); diff --git a/src/Flypaper.Core/Runtime/ConfiguredStrategySelector.cs b/src/Flypaper.Core/Runtime/ConfiguredStrategySelector.cs index 04dc430..a9866b5 100644 --- a/src/Flypaper.Core/Runtime/ConfiguredStrategySelector.cs +++ b/src/Flypaper.Core/Runtime/ConfiguredStrategySelector.cs @@ -40,14 +40,7 @@ public sealed class ConfiguredStrategySelector( var maze = options.CurrentValue.LinkSpacing > 0 && candidates.Any(strategy => strategy.Name == MazeDripStrategy.PageName); var page = maze ? MazeDripStrategy.PageName : HtmlDripStrategy.StrategyName; - string[] wanted = options.CurrentValue.Content switch - { - DripContent.Text => [TextDripStrategy.StrategyName], - DripContent.Alternating => [page, TextDripStrategy.StrategyName], - _ => [page] - }; - - var matching = candidates.Where(strategy => wanted.Contains(strategy.Name)).ToList(); + var matching = candidates.Where(strategy => strategy.Name == page).ToList(); var chosen = matching.Count == 0 ? candidates.FirstOrDefault() : matching[random.Next(0, matching.Count)]; diff --git a/src/Flypaper.Core/Settings/HoldMethodSettings.cs b/src/Flypaper.Core/Settings/HoldMethodSettings.cs index 822f431..51a45e1 100644 --- a/src/Flypaper.Core/Settings/HoldMethodSettings.cs +++ b/src/Flypaper.Core/Settings/HoldMethodSettings.cs @@ -4,7 +4,6 @@ using Flypaper.Core.Strategies; namespace Flypaper.Core.Settings; public sealed record HoldMethodSettings( - DripContent Content, TimeSpan MinDelay, TimeSpan MaxDelay, int MinChunkSize, @@ -21,7 +20,6 @@ public sealed record HoldMethodSettings( public IReadOnlyDictionary ToConfiguration() => new Dictionary { - [SettingKeys.DripContent] = Content.ToString(), [SettingKeys.DripMinDelay] = MinDelay.ToString("c", CultureInfo.InvariantCulture), [SettingKeys.DripMaxDelay] = MaxDelay.ToString("c", CultureInfo.InvariantCulture), [SettingKeys.DripMinChunkSize] = MinChunkSize.ToString(CultureInfo.InvariantCulture), @@ -43,7 +41,6 @@ public sealed record HoldMethodSettings( } public sealed record HoldMethodInput( - string? Content, string? MinDelayMs, string? MaxDelayMs, string? MinChunkSize, diff --git a/src/Flypaper.Core/Settings/RuntimeSettingsParser.cs b/src/Flypaper.Core/Settings/RuntimeSettingsParser.cs index 40358f6..7b2f232 100644 --- a/src/Flypaper.Core/Settings/RuntimeSettingsParser.cs +++ b/src/Flypaper.Core/Settings/RuntimeSettingsParser.cs @@ -48,14 +48,6 @@ public static class RuntimeSettingsParser { var errors = new Dictionary(); - DripContent? content = Enum.TryParse(input.Content, ignoreCase: true, out var parsed) && Enum.IsDefined(parsed) - ? parsed - : null; - if (content is null) - { - errors[nameof(input.Content)] = "Bitte eine Methode wählen."; - } - var minDelay = ParseInt(input.MinDelayMs, nameof(input.MinDelayMs), MinDelayMs, MaxDelayMs, errors); var maxDelay = ParseInt(input.MaxDelayMs, nameof(input.MaxDelayMs), MinDelayMs, MaxDelayMs, errors); var minChunk = ParseInt(input.MinChunkSize, nameof(input.MinChunkSize), 1, MaxChunkSize, errors); @@ -84,7 +76,6 @@ public static class RuntimeSettingsParser return new HoldMethodParseResult( new HoldMethodSettings( - content!.Value, TimeSpan.FromMilliseconds(minDelay!.Value), TimeSpan.FromMilliseconds(maxDelay!.Value), minChunk!.Value, diff --git a/src/Flypaper.Core/Settings/SettingKeys.cs b/src/Flypaper.Core/Settings/SettingKeys.cs index bd67ac0..bbf1a16 100644 --- a/src/Flypaper.Core/Settings/SettingKeys.cs +++ b/src/Flypaper.Core/Settings/SettingKeys.cs @@ -9,7 +9,6 @@ public static class SettingKeys public const string RepeatHoldDuration = "Flypaper:RepeatHoldDuration"; public const string IgnorePrivateNetworks = "Flypaper:IgnorePrivateNetworks"; public const string RetentionDays = "Flypaper:Retention:Days"; - public const string DripContent = "Flypaper:Drip:Content"; public const string DripMinDelay = "Flypaper:Drip:MinDelay"; public const string DripMaxDelay = "Flypaper:Drip:MaxDelay"; public const string DripMinChunkSize = "Flypaper:Drip:MinChunkSize"; @@ -23,7 +22,7 @@ public static class SettingKeys [MaxConnections, MaxConnectionsPerIp, IgnorePrivateNetworks, RetentionDays]; public static readonly IReadOnlyList HoldMethod = - [DripContent, DripMinDelay, DripMaxDelay, DripMinChunkSize, DripMaxChunkSize, DripHeadStartSize, DripMatchPath, DripLinkSpacing, DripBaitPaths, MaxHoldDuration, RepeatWindowDays, RepeatHoldDuration]; + [DripMinDelay, DripMaxDelay, DripMinChunkSize, DripMaxChunkSize, DripHeadStartSize, DripMatchPath, DripLinkSpacing, DripBaitPaths, MaxHoldDuration, RepeatWindowDays, RepeatHoldDuration]; public static readonly IReadOnlySet All = new HashSet(General.Concat(HoldMethod), StringComparer.OrdinalIgnoreCase); diff --git a/src/Flypaper.Core/Strategies/DripContent.cs b/src/Flypaper.Core/Strategies/DripContent.cs deleted file mode 100644 index bbcf16e..0000000 --- a/src/Flypaper.Core/Strategies/DripContent.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Flypaper.Core.Strategies; - -public enum DripContent -{ - Html, - Text, - Alternating -} diff --git a/src/Flypaper.Core/Strategies/DripOptions.cs b/src/Flypaper.Core/Strategies/DripOptions.cs index 59675cd..a450563 100644 --- a/src/Flypaper.Core/Strategies/DripOptions.cs +++ b/src/Flypaper.Core/Strategies/DripOptions.cs @@ -4,8 +4,6 @@ public sealed class DripOptions { public const string SectionName = "Flypaper:Drip"; - public DripContent Content { get; set; } = DripContent.Html; - public TimeSpan MinDelay { get; set; } = TimeSpan.FromMilliseconds(50); public TimeSpan MaxDelay { get; set; } = TimeSpan.FromSeconds(1); diff --git a/src/Flypaper.Core/Strategies/TextContent.cs b/src/Flypaper.Core/Strategies/TextContent.cs deleted file mode 100644 index 51ba9a2..0000000 --- a/src/Flypaper.Core/Strategies/TextContent.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System.Text; -using Flypaper.Core.Abstractions; - -namespace Flypaper.Core.Strategies; - -public static class TextContent -{ - public static IEnumerable Generate(IRandomSource random) - { - while (true) - { - var builder = new StringBuilder(); - var sentences = random.Next(1, 7); - for (var i = 0; i < sentences; i++) - { - if (i > 0) - { - builder.Append(' '); - } - - builder.Append(LoremText.Sentence(random)); - } - - yield return builder.Append(random.Next(0, 4) == 0 ? "\n\n" : "\n").ToString(); - } - } -} diff --git a/src/Flypaper.Core/Strategies/TextDripStrategy.cs b/src/Flypaper.Core/Strategies/TextDripStrategy.cs deleted file mode 100644 index 23209ab..0000000 --- a/src/Flypaper.Core/Strategies/TextDripStrategy.cs +++ /dev/null @@ -1,18 +0,0 @@ -using Flypaper.Core.Abstractions; -using Microsoft.Extensions.Options; - -namespace Flypaper.Core.Strategies; - -public sealed class TextDripStrategy( - IOptionsMonitor options, - IRandomSource random, - TimeProvider timeProvider) : DripStrategy(options, random, timeProvider) -{ - public const string StrategyName = "text-drip"; - - public override string Name => StrategyName; - - public override string MediaType => "text/plain; charset=utf-8"; - - protected override IEnumerable Content(IRandomSource random, ITrapChannel channel, DripOptions options) => TextContent.Generate(random); -} diff --git a/src/Flypaper.Http/FlypaperHttpExtensions.cs b/src/Flypaper.Http/FlypaperHttpExtensions.cs index a43b608..1d6761c 100644 --- a/src/Flypaper.Http/FlypaperHttpExtensions.cs +++ b/src/Flypaper.Http/FlypaperHttpExtensions.cs @@ -19,7 +19,8 @@ public static class FlypaperHttpExtensions "Flypaper:Http:KnownHosts", "Flypaper:Http:TrapPaths", "Flypaper:Http:ExtraKnownHosts", - "Flypaper:Http:TrapPathsOverride" + "Flypaper:Http:TrapPathsOverride", + "Flypaper:Drip:Content" ]; public static IServiceCollection AddFlypaperHttp(this IServiceCollection services, IConfiguration configuration) diff --git a/src/Flypaper.Web/Components/Pages/Settings/HoldMethodModel.cs b/src/Flypaper.Web/Components/Pages/Settings/HoldMethodModel.cs index 5ad5571..1b4490e 100644 --- a/src/Flypaper.Web/Components/Pages/Settings/HoldMethodModel.cs +++ b/src/Flypaper.Web/Components/Pages/Settings/HoldMethodModel.cs @@ -2,8 +2,6 @@ namespace Flypaper.Web.Components.Pages.Settings; public sealed class HoldMethodModel { - public string? Content { get; set; } - public string? MinDelayMs { get; set; } public string? MaxDelayMs { get; set; } diff --git a/src/Flypaper.Web/Components/Pages/Settings/HoldMethodSection.razor b/src/Flypaper.Web/Components/Pages/Settings/HoldMethodSection.razor index 08f623f..c93a1c6 100644 --- a/src/Flypaper.Web/Components/Pages/Settings/HoldMethodSection.razor +++ b/src/Flypaper.Web/Components/Pages/Settings/HoldMethodSection.razor @@ -21,28 +21,6 @@
-
- Inhalt - -
- @foreach (var choice in Choices) - { - - } -
-
- @if (_errors.TryGetValue(nameof(HoldMethodModel.Content), out var contentError)) - { -

@contentError

- } -
-
@@ -105,13 +83,6 @@ @code { - private static readonly (string Value, string Title, string Text)[] Choices = - [ - (nameof(DripContent.Html), "HTML-Fülltext", "Eine endlose Webseite mit Überschriften, Absätzen und vielen Links, die wieder in die Falle führen (Link-Labyrinth). Wirkt auf Crawler am echtesten."), - (nameof(DripContent.Text), "Zufallstext", "Schlichter Text ohne Markup, ausgeliefert als text/plain."), - (nameof(DripContent.Alternating), "Wechselnd", "Pro Fang zufällig eine der beiden. Gut, um zu vergleichen, was Bots länger hält.") - ]; - private readonly object _resetModel = new(); private IReadOnlyDictionary _errors = new Dictionary(); private bool _hasOverrides; @@ -146,8 +117,7 @@ private async Task SaveAsync() { var result = RuntimeSettingsParser.ParseHoldMethod(new HoldMethodInput( - Model!.Content, - Model.MinDelayMs, + Model!.MinDelayMs, Model.MaxDelayMs, Model.MinChunkSize, Model.MaxChunkSize, @@ -180,7 +150,6 @@ var drip = Drip.CurrentValue; return new HoldMethodModel { - Content = drip.Content.ToString(), MinDelayMs = ((int)drip.MinDelay.TotalMilliseconds).ToString(CultureInfo.InvariantCulture), MaxDelayMs = ((int)drip.MaxDelay.TotalMilliseconds).ToString(CultureInfo.InvariantCulture), MinChunkSize = drip.MinChunkSize.ToString(CultureInfo.InvariantCulture), diff --git a/src/Flypaper.Web/Components/Shared/StrategyNames.cs b/src/Flypaper.Web/Components/Shared/StrategyNames.cs index bfbb6ce..f065062 100644 --- a/src/Flypaper.Web/Components/Shared/StrategyNames.cs +++ b/src/Flypaper.Web/Components/Shared/StrategyNames.cs @@ -34,7 +34,6 @@ public static partial class StrategyNames ["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."), diff --git a/test/Flypaper.Tests/Core/FileContentTests.cs b/test/Flypaper.Tests/Core/FileContentTests.cs index 46295a8..6cb5108 100644 --- a/test/Flypaper.Tests/Core/FileContentTests.cs +++ b/test/Flypaper.Tests/Core/FileContentTests.cs @@ -126,7 +126,6 @@ public sealed class FileContentTests new HtmlDripStrategy(options, random, TimeProvider.System), new MazeDripStrategy(MazeKind.Page, options, random, TimeProvider.System), new MazeDripStrategy(MazeKind.Listing, options, random, TimeProvider.System), - new TextDripStrategy(options, random, TimeProvider.System), new RobotsStaticStrategy(options), new MazeDripStrategy(MazeKind.Bait, options, random, TimeProvider.System), .. FileContent.Profiles.Select(profile => new FileDripStrategy(profile, options, random, TimeProvider.System)) diff --git a/test/Flypaper.Tests/Core/HoldMethodParserTests.cs b/test/Flypaper.Tests/Core/HoldMethodParserTests.cs index f08b646..4162f19 100644 --- a/test/Flypaper.Tests/Core/HoldMethodParserTests.cs +++ b/test/Flypaper.Tests/Core/HoldMethodParserTests.cs @@ -6,14 +6,13 @@ namespace Flypaper.Tests.Core; public sealed class HoldMethodParserTests { - private static readonly HoldMethodInput Valid = new("Alternating", "50", "1000", "1", "64", "2048", true, "80", "/Backup-2024, /admin-old/x", "01:00:00", "7", "1.00:00:00"); + private static readonly HoldMethodInput Valid = new("50", "1000", "1", "64", "2048", true, "80", "/Backup-2024, /admin-old/x", "01:00:00", "7", "1.00:00:00"); [Fact] public void Parses_valid_input() { var settings = RuntimeSettingsParser.ParseHoldMethod(Valid).Settings.ShouldNotBeNull(); - settings.Content.ShouldBe(DripContent.Alternating); settings.MinDelay.ShouldBe(TimeSpan.FromMilliseconds(50)); settings.MaxDelay.ShouldBe(TimeSpan.FromSeconds(1)); settings.MinChunkSize.ShouldBe(1); @@ -26,19 +25,6 @@ public sealed class HoldMethodParserTests settings.ToConfiguration().Keys.ShouldBe(SettingKeys.HoldMethod, ignoreOrder: true); } - [Theory] - [InlineData("html", DripContent.Html)] - [InlineData("Text", DripContent.Text)] - public void Accepts_content_case_insensitively(string value, DripContent expected) => - RuntimeSettingsParser.ParseHoldMethod(Valid with { Content = value }).Settings.ShouldNotBeNull().Content.ShouldBe(expected); - - [Theory] - [InlineData("")] - [InlineData("fake-env")] - [InlineData("7")] - public void Rejects_unknown_content(string value) => - RuntimeSettingsParser.ParseHoldMethod(Valid with { Content = value }).Errors.Keys.ShouldBe([nameof(HoldMethodInput.Content)]); - [Theory] [InlineData("9", "1000")] [InlineData("50", "30001")] diff --git a/test/Flypaper.Tests/Core/StrategySelectionTests.cs b/test/Flypaper.Tests/Core/StrategySelectionTests.cs index a1e6bcb..91cdf61 100644 --- a/test/Flypaper.Tests/Core/StrategySelectionTests.cs +++ b/test/Flypaper.Tests/Core/StrategySelectionTests.cs @@ -14,65 +14,34 @@ public sealed class StrategySelectionTests private static readonly TrapContext Http = new(new TrapSession(Guid.NewGuid(), TrapProtocol.Http, IPAddress.Parse("203.0.113.9"), DateTimeOffset.UtcNow)); - [Theory] - [InlineData(DripContent.Html, "html-drip")] - [InlineData(DripContent.Text, "text-drip")] - public void Selects_the_configured_content(DripContent content, string expected) => - Selector(content).Select(Http).ShouldNotBeNull().Name.ShouldBe(expected); - [Fact] - public void Alternating_picks_both_strategies() - { - var selector = Selector(DripContent.Alternating); - - var names = Enumerable.Range(0, 50).Select(_ => selector.Select(Http)!.Name).Distinct().ToList(); - - names.ShouldBe(["html-drip", "text-drip"], ignoreOrder: true); - } + public void Selects_the_html_page() => + Selector().Select(Http).ShouldNotBeNull().Name.ShouldBe("html-drip"); [Fact] public void Returns_nothing_for_unsupported_protocols() { var ssh = Http with { Session = Http.Session with { Protocol = TrapProtocol.Ssh } }; - Selector(DripContent.Html).Select(ssh).ShouldBeNull(); + Selector().Select(ssh).ShouldBeNull(); } [Fact] public void Strategies_describe_themselves_with_their_parameters() { var options = TestOptions.Monitor(new DripOptions { MinDelay = TimeSpan.FromMilliseconds(100), MaxDelay = TimeSpan.FromMilliseconds(250), MinChunkSize = 2, MaxChunkSize = 8 }); - var text = new TextDripStrategy(options, new SeededRandomSource(1), TimeProvider.System); + var html = new HtmlDripStrategy(options, new SeededRandomSource(1), TimeProvider.System); - text.Describe().ShouldBe("text-drip 100-250ms 2-8B head 1024B"); - text.MediaType.ShouldStartWith("text/plain"); - new HtmlDripStrategy(options, new SeededRandomSource(1), TimeProvider.System).MediaType.ShouldStartWith("text/html"); + html.Describe().ShouldBe("html-drip 100-250ms 2-8B head 1024B"); + html.MediaType.ShouldStartWith("text/html"); } - [Fact] - public async Task Text_strategy_drips_plain_text() + private static ConfiguredStrategySelector Selector() { - var strategy = new TextDripStrategy( - TestOptions.Monitor(new DripOptions { MinDelay = TimeSpan.FromMilliseconds(1), MaxDelay = TimeSpan.FromMilliseconds(2), MinChunkSize = 32, MaxChunkSize = 64 }), - new SeededRandomSource(3), - TimeProvider.System); - var channel = new FakeTrapChannel(); - using var cts = new CancellationTokenSource(TimeSpan.FromMilliseconds(200)); - - await Should.ThrowAsync(() => strategy.RunAsync(channel, cts.Token)); - - var text = Encoding.UTF8.GetString(channel.Writes.SelectMany(w => w).ToArray()); - text.Length.ShouldBeGreaterThan(200); - text.ShouldNotContain("<"); - text.ShouldContain("\n"); - } - - private static ConfiguredStrategySelector Selector(DripContent content) - { - var options = TestOptions.Monitor(new DripOptions { Content = content }); + var options = TestOptions.Monitor(new DripOptions()); var random = new SeededRandomSource(11); return new ConfiguredStrategySelector( - [new HtmlDripStrategy(options, random, TimeProvider.System), new TextDripStrategy(options, random, TimeProvider.System)], + [new HtmlDripStrategy(options, random, TimeProvider.System)], options, random); } diff --git a/test/Flypaper.Tests/Http/ContentTypeTests.cs b/test/Flypaper.Tests/Http/ContentTypeTests.cs index 1363823..b19edba 100644 --- a/test/Flypaper.Tests/Http/ContentTypeTests.cs +++ b/test/Flypaper.Tests/Http/ContentTypeTests.cs @@ -14,20 +14,18 @@ namespace Flypaper.Tests.Http; public sealed class ContentTypeTests { [Theory] - [InlineData("Html", "/", "text/html; charset=utf-8")] - [InlineData("Text", "/", "text/plain; charset=utf-8")] - [InlineData("Html", "/config.json", "application/json")] - [InlineData("Html", "/.env", "text/plain; charset=utf-8")] - [InlineData("Html", "/sitemap.xml", "application/xml")] - [InlineData("Html", "/SDK/webLanguage", "application/xml")] - [InlineData("Html", "/wp-login.php", "text/html; charset=UTF-8")] - public async Task Trap_answers_with_the_media_type_of_the_selected_strategy(string content, string path, string expected) + [InlineData("/", "text/html; charset=utf-8")] + [InlineData("/config.json", "application/json")] + [InlineData("/.env", "text/plain; charset=utf-8")] + [InlineData("/sitemap.xml", "application/xml")] + [InlineData("/SDK/webLanguage", "application/xml")] + [InlineData("/wp-login.php", "text/html; charset=UTF-8")] + public async Task Trap_answers_with_the_media_type_of_the_selected_strategy(string path, string expected) { var configuration = new ConfigurationBuilder() .AddInMemoryCollection(new Dictionary { ["Flypaper:MaxHoldDuration"] = "00:00:00.100", - ["Flypaper:Drip:Content"] = content, ["Flypaper:Drip:MinDelay"] = "00:00:00.005", ["Flypaper:Drip:MaxDelay"] = "00:00:00.010" }) diff --git a/test/Flypaper.Tests/Storage/SettingsOverrideTests.cs b/test/Flypaper.Tests/Storage/SettingsOverrideTests.cs index 6d23468..282c63e 100644 --- a/test/Flypaper.Tests/Storage/SettingsOverrideTests.cs +++ b/test/Flypaper.Tests/Storage/SettingsOverrideTests.cs @@ -89,10 +89,9 @@ public sealed class SettingsOverrideTests : IDisposable var store = host.Services.GetRequiredService(); string[] holdKeys = [.. SettingKeys.HoldMethod]; - await store.SaveAsync(new HoldMethodSettings(DripContent.Text, TimeSpan.FromMilliseconds(200), TimeSpan.FromSeconds(2), 8, 16, 256, false, 0, "/trap-a/", TimeSpan.FromMinutes(5), 7, TimeSpan.FromHours(24))); + await store.SaveAsync(new HoldMethodSettings(TimeSpan.FromMilliseconds(200), TimeSpan.FromSeconds(2), 8, 16, 256, false, 0, "/trap-a/", TimeSpan.FromMinutes(5), 7, TimeSpan.FromHours(24))); await store.SaveAsync(new RuntimeSettings(50, 4, 90, true)); - drip.CurrentValue.Content.ShouldBe(DripContent.Text); drip.CurrentValue.MinDelay.ShouldBe(TimeSpan.FromMilliseconds(200)); drip.CurrentValue.MaxChunkSize.ShouldBe(16); drip.CurrentValue.HeadStartSize.ShouldBe(256); @@ -103,13 +102,12 @@ public sealed class SettingsOverrideTests : IDisposable core.CurrentValue.MaxConnections.ShouldBe(50); (await store.HasOverridesAsync(holdKeys)).ShouldBeTrue(); - await store.SaveAsync(new HoldMethodSettings(DripContent.Text, TimeSpan.FromMilliseconds(200), TimeSpan.FromSeconds(2), 8, 16, 256, false, 0, "", TimeSpan.FromMinutes(5), 0, TimeSpan.FromHours(2))); + await store.SaveAsync(new HoldMethodSettings(TimeSpan.FromMilliseconds(200), TimeSpan.FromSeconds(2), 8, 16, 256, false, 0, "", TimeSpan.FromMinutes(5), 0, TimeSpan.FromHours(2))); drip.CurrentValue.BaitPaths.ShouldBe(""); await store.ResetAsync(holdKeys); drip.CurrentValue.BaitPaths.ShouldBe(BaitPaths.Default); - drip.CurrentValue.Content.ShouldBe(DripContent.Html); drip.CurrentValue.MinDelay.ShouldBe(TimeSpan.FromMilliseconds(50)); core.CurrentValue.MaxHoldDuration.ShouldBe(TimeSpan.FromHours(1)); core.CurrentValue.MaxConnections.ShouldBe(50); diff --git a/test/Flypaper.Tests/Web/StrategyNamesTests.cs b/test/Flypaper.Tests/Web/StrategyNamesTests.cs index 2487d0f..318c7aa 100644 --- a/test/Flypaper.Tests/Web/StrategyNamesTests.cs +++ b/test/Flypaper.Tests/Web/StrategyNamesTests.cs @@ -46,7 +46,7 @@ public sealed class StrategyNamesTests string[] names = [ MazeDripStrategy.PageName, MazeDripStrategy.ListingName, MazeDripStrategy.BaitName, - HtmlDripStrategy.StrategyName, TextDripStrategy.StrategyName, RobotsStaticStrategy.StrategyName, + HtmlDripStrategy.StrategyName, RobotsStaticStrategy.StrategyName, LureStrategy.PageName, LureStrategy.IconName, .. FileContent.Profiles.Select(profile => profile.Name) ];