3
0
mirror of https://github.com/ergochat/ergo.git synced 2025-01-03 16:42:38 +01:00

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
commit 3ed047ccb8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -21,8 +21,24 @@ const (
maxProxyLineLen = 107 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 ( var (
ErrBadProxyLine = errors.New("invalid PROXY line") ErrBadProxyLine error = &proxyLineError{}
// TODO(golang/go#4373): replace this with the stdlib ErrNetClosing // TODO(golang/go#4373): replace this with the stdlib ErrNetClosing
ErrNetClosing = errors.New("use of closed network connection") ErrNetClosing = errors.New("use of closed network connection")
) )