Skip to content

Commit cdc20e9

Browse files
committed
protocol: swallow header parsing error
Signed-off-by: Pires <[email protected]>
1 parent e25c3dc commit cdc20e9

File tree

2 files changed

+1
-29
lines changed

2 files changed

+1
-29
lines changed

protocol.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,7 @@ func (p *Conn) SetWriteDeadline(t time.Time) error {
117117
}
118118

119119
func (p *Conn) readHeader() error {
120-
hdr, err := Read(p.bufReader)
121-
if err != nil {
122-
return err
123-
}
124-
p.header = hdr
120+
p.header, _ = Read(p.bufReader)
125121
return nil
126122

127123
}

protocol_test.go

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,6 @@ func TestPassthrough(t *testing.T) {
2626
}
2727
defer conn.Close()
2828

29-
// Write out the header!
30-
header := &Header{
31-
Version: 2,
32-
Command: PROXY,
33-
TransportProtocol: TCPv4,
34-
SourceAddress: net.ParseIP("10.1.1.1"),
35-
SourcePort: 1000,
36-
DestinationAddress: net.ParseIP("20.2.2.2"),
37-
DestinationPort: 2000,
38-
}
39-
header.WriteTo(conn)
40-
4129
conn.Write([]byte("ping"))
4230
recv := make([]byte, 4)
4331
_, err = conn.Read(recv)
@@ -89,18 +77,6 @@ func TestTimeout(t *testing.T) {
8977
// Do not send data for a while
9078
time.Sleep(clientWriteDelay)
9179

92-
// Write out the header!
93-
header := &Header{
94-
Version: 1,
95-
//Command: PROXY, // not needed in v1
96-
TransportProtocol: TCPv4,
97-
SourceAddress: net.ParseIP("127.0.0.1"),
98-
SourcePort: 1000,
99-
DestinationAddress: net.ParseIP("20.2.2.2"),
100-
DestinationPort: 2000,
101-
}
102-
header.WriteTo(conn)
103-
10480
conn.Write([]byte("ping"))
10581
recv := make([]byte, 4)
10682
_, err = conn.Read(recv)

0 commit comments

Comments
 (0)