2018-11-20 17:51:25 -05:00
|
|
|
package wire
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
|
2019-01-17 09:33:18 -05:00
|
|
|
"v2ray.com/core/external/github.com/lucas-clemente/quic-go/internal/protocol"
|
2018-11-20 17:51:25 -05:00
|
|
|
)
|
|
|
|
|
2018-11-23 11:04:53 -05:00
|
|
|
// A PingFrame is a PING frame
|
2018-11-20 17:51:25 -05:00
|
|
|
type PingFrame struct{}
|
|
|
|
|
|
|
|
func parsePingFrame(r *bytes.Reader, version protocol.VersionNumber) (*PingFrame, error) {
|
2018-11-23 11:04:53 -05:00
|
|
|
if _, err := r.ReadByte(); err != nil {
|
2018-11-20 17:51:25 -05:00
|
|
|
return nil, err
|
|
|
|
}
|
2018-11-23 11:04:53 -05:00
|
|
|
return &PingFrame{}, nil
|
2018-11-20 17:51:25 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
func (f *PingFrame) Write(b *bytes.Buffer, version protocol.VersionNumber) error {
|
2018-11-23 11:04:53 -05:00
|
|
|
b.WriteByte(0x1)
|
2018-11-20 17:51:25 -05:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// Length of a written frame
|
|
|
|
func (f *PingFrame) Length(version protocol.VersionNumber) protocol.ByteCount {
|
|
|
|
return 1
|
|
|
|
}
|