Skip to content

Commit

Permalink
Fix SendDatagram
Browse files Browse the repository at this point in the history
  • Loading branch information
nekohasekai committed Apr 15, 2024
1 parent afd0b06 commit b4420fd
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -2358,9 +2358,10 @@ func (s *connection) SendDatagram(p []byte) error {
}

f := &wire.DatagramFrame{DataLenPresent: true}
if protocol.ByteCount(len(p)) > f.MaxDataLen(s.peerParams.MaxDatagramFrameSize, s.version) {
maxDataLen := f.MaxDataLen(s.peerParams.MaxDatagramFrameSize, s.version)
if protocol.ByteCount(len(p)) > maxDataLen {
return &DatagramTooLargeError{
PeerMaxDatagramFrameSize: int64(s.peerParams.MaxDatagramFrameSize),
PeerMaxDatagramFrameSize: int64(maxDataLen),
}
}
f.Data = make([]byte, len(p))
Expand Down

0 comments on commit b4420fd

Please sign in to comment.