From c3192aa8f552650cd2eb4e1e68fad7a3bd52562c Mon Sep 17 00:00:00 2001 From: hoelee Date: Thu, 16 Jul 2026 12:53:00 +0800 Subject: [PATCH] feat(botfilter): add TestTrustedProxyHeaderSeparatesClients --- botfilter_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/botfilter_test.go b/botfilter_test.go index 110f78bc..edcabe7b 100644 --- a/botfilter_test.go +++ b/botfilter_test.go @@ -136,3 +136,17 @@ func Test404ScoreBansOnSubsequentRequest(t *testing.T) { } } +func TestTrustedProxyHeaderSeparatesClients(t *testing.T) { + cfg := CreateConfig() + cfg.RequireUserAgent = true + cfg.ClientIPHeader = "X-Forwarded-For" + cfg.TrustedProxyCIDRs = []string{"127.0.0.0/8"} + nextCalls := 0 + handler, err := New(context.Background(), http.HandlerFunc(func(rw http.ResponseWriter, _ *http.Request) { + nextCalls++ + rw.WriteHeader(http.StatusNoContent) + }), cfg, "test") + if err != nil { + t.Fatalf("New() error = %v", err) + } +