Merge pull request #1269 from slingamn/websocket_proxy

fix websocket listeners with proxy-before-TLS closing on bad PROXY lines
This commit is contained in:
Shivaram Lingamneni
2020-09-16 03:16:17 -07:00
committed by GitHub

View File

@@ -21,8 +21,24 @@ const (
maxProxyLineLen = 107
)
// XXX implement net.Error with a Temporary() method that returns true;
// otherwise, ErrBadProxyLine will cause (*http.Server).Serve() to exit
type proxyLineError struct{}
func (p *proxyLineError) Error() string {
return "invalid PROXY line"
}
func (p *proxyLineError) Timeout() bool {
return false
}
func (p *proxyLineError) Temporary() bool {
return true
}
var (
ErrBadProxyLine = errors.New("invalid PROXY line")
ErrBadProxyLine error = &proxyLineError{}
// TODO(golang/go#4373): replace this with the stdlib ErrNetClosing
ErrNetClosing = errors.New("use of closed network connection")
)