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) + } +