Skip to content

Commit

Permalink
Fixed HAProxy's PROXY protocol v1 Human-readable header format in Dia…
Browse files Browse the repository at this point in the history
…lProxy

original code sent the header in the format: PROXY <family> <srcIP>
<srcPort> <dstIP> <dstPort>
according to docs header format should be:
PROXY <family> <srcIP> <dstIP> <srcPort> <dstPort>

this is according
to:
https://www.haproxy.org/download/1.8/doc/proxy-protocol.txt
section
2.1. Human-readable header format (Version 1).
  • Loading branch information
AdamEr8 authored and danderson committed Aug 24, 2021
1 parent 2825d76 commit 0f9bced
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tcpproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ func (dp *DialProxy) sendProxyHeader(w io.Writer, src net.Conn) error {
if srcAddr.IP.To4() == nil {
family = "TCP6"
}
_, err := fmt.Fprintf(w, "PROXY %s %s %d %s %d\r\n", family, srcAddr.IP, srcAddr.Port, dstAddr.IP, dstAddr.Port)
_, err := fmt.Fprintf(w, "PROXY %s %s %s %d %d\r\n", family, srcAddr.IP, dstAddr.IP, srcAddr.Port, dstAddr.Port)
return err
default:
return fmt.Errorf("PROXY protocol version %d not supported", dp.ProxyProtocolVersion)
Expand Down

0 comments on commit 0f9bced

Please sign in to comment.