Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

include the maximum payload size in the DatagramTooLargeError #4470

Merged
merged 2 commits into from
Apr 27, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix SendDatagram
  • Loading branch information
nekohasekai committed Apr 15, 2024
commit b4420fda2accfd3e3eded7cbbfd05df1947b8b98
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
Loading