Skip to content

Commit

Permalink
handler.go: cookie: Allocate enough bytes to be able to hash an ipv6 …
Browse files Browse the repository at this point in the history
…address without addition allocs.
  • Loading branch information
Sandertv committed May 4, 2024
1 parent 7a99b42 commit e251d9b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (h listenerConnectionHandler) close(conn *Conn) {
// hash of the random cookie salt and the address.
func (h listenerConnectionHandler) cookie(addr net.Addr) uint32 {
udp, _ := addr.(*net.UDPAddr)
b := make([]byte, 6, 10)
b := make([]byte, 6, 22)
binary.LittleEndian.PutUint32(b, h.cookieSalt)
binary.LittleEndian.PutUint16(b, uint16(udp.Port))
b = append(b, udp.IP...)
Expand Down

0 comments on commit e251d9b

Please sign in to comment.