Skip to content

Commit 562e4b9

Browse files
authored
Merge branch 'main' into feat/keep_listening_when_upstream_not_trusted
2 parents 255c95e + 9814f02 commit 562e4b9

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

header.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,11 @@ func (header *Header) EqualsTo(otherHeader *Header) bool {
155155
if otherHeader == nil {
156156
return false
157157
}
158-
// TLVs only exist for version 2
159-
if header.Version == 2 && !bytes.Equal(header.rawTLVs, otherHeader.rawTLVs) {
158+
if header.Version != otherHeader.Version || header.Command != otherHeader.Command || header.TransportProtocol != otherHeader.TransportProtocol {
160159
return false
161160
}
162-
if header.Version != otherHeader.Version || header.Command != otherHeader.Command || header.TransportProtocol != otherHeader.TransportProtocol {
161+
// TLVs only exist for version 2
162+
if header.Version == 2 && !bytes.Equal(header.rawTLVs, otherHeader.rawTLVs) {
163163
return false
164164
}
165165
// Return early for header with LOCAL command, which contains no address information

protocol.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,15 @@ func ValidateHeader(v Validator) func(*Conn) {
7171
}
7272
}
7373

74+
// SetReadHeaderTimeout sets the readHeaderTimeout for a connection when passed as option to NewConn()
75+
func SetReadHeaderTimeout(t time.Duration) func(*Conn) {
76+
return func(c *Conn) {
77+
if t >= 0 {
78+
c.readHeaderTimeout = t
79+
}
80+
}
81+
}
82+
7483
// Accept waits for and returns the next valid connection to the listener.
7584
func (p *Listener) Accept() (net.Conn, error) {
7685
for {

0 commit comments

Comments
 (0)