Open peteski22 opened 2 months ago
Can you, please, rebase?
Can you, please, rebase?
@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.
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).