-
-
Notifications
You must be signed in to change notification settings - Fork 110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Protocol: Keep listener listening if we don't trust the upstream address #110
Protocol: Keep listener listening if we don't trust the upstream address #110
Conversation
Can you, please, rebase? |
d96e12c
to
956f8fe
Compare
@pires done now, thanks. |
@pires any chance for merging this one? |
Sorry for the delay. Can we have some tests proving the changes work as expected? |
@pires no worries, I've added a test to show the listener stays open when experiencing the invalid upstream error but closes on others. |
@pires there doesn't seem to be any issues now other than linting which this PR didn't introduce. Would you consider merging it? 🙏🏼 |
Unfortunately, your PR history can't be rebase due to conflicts. I've fixed them but would like for you to re-author the commit so get proper recognition 🙏🏻 #117 |
d032c9c
to
d2dad29
Compare
Hi @pires thanks for the message, it's much appreciated. I've rebased everything from |
Superb! Thanks a ton. Closes #117 |
This PR is designed to prevent listeners being stopped when an error is returned, if the upstream connection address is not trusted (
ErrInvalidUpstream
). Instead, we continue to close the connection but now theAccept
method has afor
loop to continue looking for other connections to accept.In using this library we discovered that the listener
Accept
method returning an error caused the listener to be closed and never reopened when trying to serve HTTP endpoints.The change was based on github.com/armon/go-proxyproto/ which does something similar with the loop and checking for a particular type of error.
Notes:
See:
net/http/server.go => Serve(l net.Listener)
https://cs.opensource.google/go/go/+/master:src/net/http/server.go;l=3333-3351
Above we end up returning the
err
at the end, which stops theServe
method (so prevents us listening).