From 0073b985051dd45896cbc14d53691d76335b4e47 Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Wed, 16 Sep 2020 06:12:27 -0400 Subject: [PATCH] fix (*http.Server).Serve() exiting on ErrBadProxyLine anything other than a (net.Error) with Temporary() == true is treated as a fatal error that causes the http server to exit --- irc/utils/proxy.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/irc/utils/proxy.go b/irc/utils/proxy.go index 1214530d..9dbaa886 100644 --- a/irc/utils/proxy.go +++ b/irc/utils/proxy.go @@ -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") )