pires / go-proxyproto

A Go library implementation of the PROXY protocol, versions 1 and 2.
Apache License 2.0
478 stars 107 forks source link

DefaultReadHeaderTimeout is too strict #83

Closed emersion closed 2 years ago

emersion commented 2 years ago

200ms is too strict and is causing breakage downstream, especially when TLS is involved. Having a timeout is good, but should not penalize slow connections.

The stdlib is using a 10s timeout for the TLS handshake for instance.

Ref https://github.com/emersion/soju/pull/33

pires commented 2 years ago

We didn't have any data to justify more or less and we made it possible to replace it. Actually, one of my requests was to export the default so it could be overridden at compile time too, eg go build -ldflags -X "github.com/pires/go-proxyproto.DefaultReadHeaderTimeout=10s", so you don't need to set it per listener.

I'm fine increasing the default for less experienced consumers of the API to not run into problems early on.

csmith commented 2 years ago

eg go build -ldflags -X "github.com/pires/go-proxyproto.DefaultReadHeaderTimeout=10s"

As an aside, this doesn't work. -X only works with string vars:

 -X importpath.name=value
    Set the value of the string variable in importpath named name to value.
    This is only effective if the variable is declared in the source code either uninitialized
    or initialized to a constant string expression.

-- https://pkg.go.dev/cmd/link

pires commented 2 years ago

TIL thanks a lot @csmith.