Add optional timeout to get PROXY header

The library user can define a maximum time to wait
for the PROXY protocol header, before failing out to
normal connection.

We can assume that a proxy in front of the service will
send the PROXY header immediatelly.

This solves the issue of clients getting block when
getting the RemoteAddr() for an incoming connection that
does not send any data. That is the case of http.Serve on
go < 1.6 as described in https://github.com/armon/go-proxyproto/issues/1
This commit is contained in:
Hector Rivas Gandara
2016-07-12 18:19:20 +01:00
parent 609d6338d3
commit 49fdb5cfab
3 changed files with 98 additions and 16 deletions

View File

@@ -28,7 +28,7 @@ Using the library is very simple:
list, err := net.Listen("tcp", "...")
// Wrap listener in a proxyproto listener
proxyList := &proxyproto.Listener{list}
proxyList := &proxyproto.Listener{Listener: list}
conn, err :=proxyList.Accept()
...