Add Flypaper solution skeleton with HTTP tarpit, SQLite event log and tests

This commit is contained in:
Tom committed 2026-11-14 13:15:57 +01:00
1 parent 20314268c6
commit f9161f48e7
55 files changed
+1331

No files matched your search

@@ -0,0 +1,24 @@
using Microsoft.Extensions.Options;
namespace Flypaper.Core.Strategies;
public sealed class DripStrategy(IOptions<DripOptions> options, TimeProvider timeProvider) : ITarpitStrategy
{
private static readonly byte[] Alphabet = "abcdefghijklmnopqrstuvwxyz0123456789"u8.ToArray();
public string Name => "drip";
public bool Supports(TrapProtocol protocol) => protocol == TrapProtocol.Http;
public async Task RunAsync(ITrapChannel channel, CancellationToken ct)
{
var buffer = new byte[1];
while (true)
{
ct.ThrowIfCancellationRequested();
buffer[0] = Alphabet[Random.Shared.Next(Alphabet.Length)];
await channel.WriteAsync(buffer, ct);
await Task.Delay(options.Value.Interval, timeProvider, ct);
}
}
}