dnscrypt-proxy/vendor/github.com/quic-go/quic-go/internal/wire/path_challenge_frame.go

36 lines
772 B
Go
Raw Normal View History

2022-07-21 18:50:10 +02:00
package wire
import (
"bytes"
"io"
"github.com/quic-go/quic-go/internal/protocol"
2022-07-21 18:50:10 +02:00
)
// A PathChallengeFrame is a PATH_CHALLENGE frame
type PathChallengeFrame struct {
Data [8]byte
}
2024-03-26 19:56:06 +01:00
func parsePathChallengeFrame(r *bytes.Reader, _ protocol.Version) (*PathChallengeFrame, error) {
2022-07-21 18:50:10 +02:00
frame := &PathChallengeFrame{}
if _, err := io.ReadFull(r, frame.Data[:]); err != nil {
if err == io.ErrUnexpectedEOF {
return nil, io.EOF
}
return nil, err
}
return frame, nil
}
2024-03-26 19:56:06 +01:00
func (f *PathChallengeFrame) Append(b []byte, _ protocol.Version) ([]byte, error) {
2023-05-01 16:05:02 +02:00
b = append(b, pathChallengeFrameType)
2022-10-24 10:20:25 +02:00
b = append(b, f.Data[:]...)
return b, nil
2022-07-21 18:50:10 +02:00
}
// Length of a written frame
2024-03-26 19:56:06 +01:00
func (f *PathChallengeFrame) Length(_ protocol.Version) protocol.ByteCount {
2022-07-21 18:50:10 +02:00
return 1 + 8
}