Skip to content

Commit

Permalink
protocol: use smaller read buffer size
Browse files Browse the repository at this point in the history
  • Loading branch information
mmatczuk authored and pires committed Oct 8, 2024
1 parent 424fc80 commit 9171270
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,13 @@ func (p *Listener) Addr() net.Addr {
// NewConn is used to wrap a net.Conn that may be speaking
// the proxy protocol into a proxyproto.Conn
func NewConn(conn net.Conn, opts ...func(*Conn)) *Conn {
// For v1 the header length is at most 108 bytes.
// For v2 the header length is at most 52 bytes plus the length of the TLVs.
// We use 256 bytes to be safe.
const bufSize = 256

pConn := &Conn{
bufReader: bufio.NewReader(conn),
bufReader: bufio.NewReaderSize(conn, bufSize),
conn: conn,
}

Expand Down

0 comments on commit 9171270

Please sign in to comment.