Answer first visits to / and favicon with an instant WordPress lure
Build and deploy / build (push) Successful in 1m33s
Build and deploy / deploy (push) Successful in 20s

Unknown IPs get a small WordPress-looking page or icon and are not held;
later requests are trapped as before. Switch: Flypaper__Drip__Lure.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
TomandClaude Sonnet 5.5 committed 2026-11-21 12:57:29 +01:00
1 parent 2437880013
commit 4b946453fb
18 files changed
+360 -2

No files matched your search

@@ -3,6 +3,7 @@ using Flypaper.Core.Abstractions;
using Flypaper.Core.Models;
using Flypaper.Core.Networking;
using Flypaper.Core.Runtime;
using Flypaper.Core.Strategies;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Server.Kestrel.Core.Features;
@@ -14,6 +15,8 @@ internal sealed class FlypaperMiddleware(
RequestDelegate next,
TrapRunner runner,
IOptions<PortOptions> ports,
IKnownIpLookup knownIps,
IOptionsMonitor<DripOptions> drip,
TimeProvider timeProvider)
{
public async Task InvokeAsync(HttpContext context)
@@ -32,11 +35,17 @@ internal sealed class FlypaperMiddleware(
context.Connection.RemoteIpAddress ?? IPAddress.None,
timeProvider.GetUtcNow());
var isNewIp = drip.CurrentValue.Lure
&& HttpMethods.IsGet(request.Method)
&& LureContent.Handles(request.Path.Value)
&& !await knownIps.HasSeenAsync(session.RemoteIp, context.RequestAborted);
var trapContext = new TrapContext(
session,
$"{request.Method} {StoredHost(request.Host)}{request.Path}{request.QueryString}",
request.Headers.UserAgent.ToString(),
request.Path.Value);
request.Path.Value,
isNewIp);
var outcome = await runner.RunAsync(
trapContext,
@@ -77,6 +86,14 @@ internal sealed class FlypaperMiddleware(
response.Headers.Server = "nginx";
response.Headers.CacheControl = "no-store";
response.Headers["X-Accel-Buffering"] = "no";
if (strategy is IResponseHeaders extra)
{
foreach (var (name, value) in extra.Headers)
{
response.Headers[name] = value;
}
}
await response.StartAsync(ct);
return new HttpTrapChannel(session, response);