Skip to content

Commit 880d578

Browse files
committed
protocol: DEFAULT_TIMEOUT is now DefaultReadHeaderTimeout
Signed-off-by: Pires <pjpires@gmail.com>
1 parent 0c5719a commit 880d578

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

protocol.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ import (
88
"time"
99
)
1010

11-
var DEFAULT_TIMEOUT = 200 * time.Millisecond
11+
// DefaultReadHeaderTimeout is how long header processing waits for header to
12+
// be read from the wire, if Listener.ReaderHeaderTimeout is not set.
13+
// It's kept as a global variable so to make it easier to find and override,
14+
// e.g. go build -ldflags -X "github.com/pires/go-proxyproto.DefaultReadHeaderTimeout=1s"
15+
var DefaultReadHeaderTimeout = 200 * time.Millisecond
1216

1317
// Listener is used to wrap an underlying listener,
1418
// whose connections may be using the HAProxy Proxy Protocol.
@@ -77,9 +81,9 @@ func (p *Listener) Accept() (net.Conn, error) {
7781
ValidateHeader(p.ValidateHeader),
7882
)
7983

80-
// If the ReadHeaderTimeout for the listener is 0, set a default of 200ms
84+
// If the ReadHeaderTimeout for the listener is unset, use the default timeout.
8185
if p.ReadHeaderTimeout == 0 {
82-
p.ReadHeaderTimeout = DEFAULT_TIMEOUT
86+
p.ReadHeaderTimeout = DefaultReadHeaderTimeout
8387
}
8488

8589
// Set the readHeaderTimeout of the new conn to the value of the listener

0 commit comments

Comments
 (0)