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

Add support for ReadHeaderTimeout #74

Closed unmarshal closed 3 years ago

unmarshal commented 3 years ago

Set a read deadline when waiting for the PROXY protocol header.

coveralls commented 3 years ago

Coverage Status

Coverage increased (+0.9%) to 94.353% when pulling cdc63867da24fc609b727231f682670d0d1cd346 on unmarshal:read_header_timeout into 7f48261db810703d173f27f3309a808cc2b49b8b on pires:main.

pires commented 3 years ago

I'm under the impression I'm about to learn something here but how can the coverage increase if no tests were implemented? Are the examples added here considered example tests?

unmarshal commented 3 years ago

I was scratching my head about the test coverage too. I ended up just removing the examples and moving the https server to the README. I didn't want to restructure your project.

pires commented 3 years ago

No, no, no, please, keep the code in the examples folder or let's make sure they are testable examples which is so much better than keeping examples in README.md. I am just curious how the hell goveralls reports a 0.7% increment in code coverage 😂

unmarshal commented 3 years ago

Sounds good. Will do.

unmarshal commented 3 years ago

code coverage didn't increase because of the examples. guessing it has to do with the new lines added when the deadline is set.

unmarshal commented 3 years ago

Whoops. Yes, that was a mistake. I will fix that and also add a test. Cheers.

unmarshal commented 3 years ago

Sorry about the premature squashing and force pushes. Didn't realize it messed with github's review system.

jefferai commented 3 years ago

@pires I strongly urge you to pick a suitable default for when no read timeout is set. Otherwise you put the onus on library users to know that they have to do this in order to be safe.

pires commented 3 years ago

Agreed.