瀏覽代碼

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
tags/v2.4.0-rc1
Shivaram Lingamneni 3 年之前
父節點
當前提交
0073b98505
共有 1 個檔案被更改,包括 17 行新增1 行删除
  1. 17
    1
      irc/utils/proxy.go

+ 17
- 1
irc/utils/proxy.go 查看文件

@@ -21,8 +21,24 @@ const (
21 21
 	maxProxyLineLen = 107
22 22
 )
23 23
 
24
+// XXX implement net.Error with a Temporary() method that returns true;
25
+// otherwise, ErrBadProxyLine will cause (*http.Server).Serve() to exit
26
+type proxyLineError struct{}
27
+
28
+func (p *proxyLineError) Error() string {
29
+	return "invalid PROXY line"
30
+}
31
+
32
+func (p *proxyLineError) Timeout() bool {
33
+	return false
34
+}
35
+
36
+func (p *proxyLineError) Temporary() bool {
37
+	return true
38
+}
39
+
24 40
 var (
25
-	ErrBadProxyLine = errors.New("invalid PROXY line")
41
+	ErrBadProxyLine error = &proxyLineError{}
26 42
 	// TODO(golang/go#4373): replace this with the stdlib ErrNetClosing
27 43
 	ErrNetClosing = errors.New("use of closed network connection")
28 44
 )

Loading…
取消
儲存