Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions ctx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2713,8 +2713,16 @@ func Benchmark_Ctx_IPs_v6_With_IP_Validation(b *testing.B) {
}

func Benchmark_Ctx_IP_With_ProxyHeader(b *testing.B) {
app := New(Config{ProxyHeader: HeaderXForwardedFor})
c := app.AcquireCtx(&fasthttp.RequestCtx{})
app := New(Config{
ProxyHeader: HeaderXForwardedFor,
TrustProxy: true,
TrustProxyConfig: TrustProxyConfig{
Loopback: true,
},
})
fastCtx := &fasthttp.RequestCtx{}
fastCtx.SetRemoteAddr(net.Addr(&net.TCPAddr{IP: net.ParseIP("127.0.0.1")}))
c := app.AcquireCtx(fastCtx)
c.Request().Header.Set(HeaderXForwardedFor, "127.0.0.1")
var res string
b.ReportAllocs()
Expand All @@ -2725,8 +2733,17 @@ func Benchmark_Ctx_IP_With_ProxyHeader(b *testing.B) {
}

func Benchmark_Ctx_IP_With_ProxyHeader_and_IP_Validation(b *testing.B) {
app := New(Config{ProxyHeader: HeaderXForwardedFor, EnableIPValidation: true})
c := app.AcquireCtx(&fasthttp.RequestCtx{})
app := New(Config{
ProxyHeader: HeaderXForwardedFor,
TrustProxy: true,
TrustProxyConfig: TrustProxyConfig{
Loopback: true,
},
EnableIPValidation: true,
})
fastCtx := &fasthttp.RequestCtx{}
fastCtx.SetRemoteAddr(net.Addr(&net.TCPAddr{IP: net.ParseIP("127.0.0.1")}))
c := app.AcquireCtx(fastCtx)
c.Request().Header.Set(HeaderXForwardedFor, "127.0.0.1")
var res string
b.ReportAllocs()
Expand Down
Loading
Loading