Skip to content

Commit

Permalink
Merge branch 'main' into feat/keep_listening_when_upstream_not_trusted
Browse files Browse the repository at this point in the history
  • Loading branch information
pires authored Oct 8, 2024
2 parents 255c95e + 9814f02 commit 562e4b9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 3 additions & 3 deletions header.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,11 @@ func (header *Header) EqualsTo(otherHeader *Header) bool {
if otherHeader == nil {
return false
}
// TLVs only exist for version 2
if header.Version == 2 && !bytes.Equal(header.rawTLVs, otherHeader.rawTLVs) {
if header.Version != otherHeader.Version || header.Command != otherHeader.Command || header.TransportProtocol != otherHeader.TransportProtocol {
return false
}
if header.Version != otherHeader.Version || header.Command != otherHeader.Command || header.TransportProtocol != otherHeader.TransportProtocol {
// TLVs only exist for version 2
if header.Version == 2 && !bytes.Equal(header.rawTLVs, otherHeader.rawTLVs) {
return false
}
// Return early for header with LOCAL command, which contains no address information
Expand Down
9 changes: 9 additions & 0 deletions protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ func ValidateHeader(v Validator) func(*Conn) {
}
}

// SetReadHeaderTimeout sets the readHeaderTimeout for a connection when passed as option to NewConn()
func SetReadHeaderTimeout(t time.Duration) func(*Conn) {
return func(c *Conn) {
if t >= 0 {
c.readHeaderTimeout = t
}
}
}

// Accept waits for and returns the next valid connection to the listener.
func (p *Listener) Accept() (net.Conn, error) {
for {
Expand Down

0 comments on commit 562e4b9

Please sign in to comment.