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

ReadHeaderTimeout is setting a hard timeout on connections regardless of header sending #75

Closed vansante closed 3 years ago

vansante commented 3 years ago

I think this setting is supposed to timeout connections that are not sending the headers and terminate them after this amount of time. However, I set the setting to 5 seconds, and the result is that all connections are terminated after 5 seconds, even if they correctly sent the headers. The connection starts up, but is then abruptly ended after the 5 seconds are passed.

I think what is missing in #74 is a call to SetReadDeadline to reset the timeout after the proxy header was sent successfully.

pires commented 3 years ago

Hmmm, let me check.

pires commented 3 years ago

You are correct. Thanks a ton for reporting. Fixing it now!

pires commented 3 years ago

Can you, please, help test #75?

vansante commented 3 years ago

I tested #76 and I got the same results with version github.com/pires/go-proxyproto@v0.6.1-0.20210713120647-bab7dd263f97 in my go.mod .

jefferai commented 3 years ago

Additionally, #74 is lacking in picking a suitable default. Considering the reason for that change's existence, it really should include a default timeout. If people really want to have no timeout at all, a negative value could be defined as "no timeout".

pires commented 3 years ago

@jefferai what do you think a sane default should be? One second?

Also, can you please help review #76? I think I fixed it in that PR but the reporter can't seem to reproduce successfully so more eyes/minds would help.

pires commented 3 years ago

The fix was released as https://github.com/pires/go-proxyproto/releases/tag/v0.6.1