quic

package
v0.0.0-...-2c9eac5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 26, 2018 License: MIT Imports: 6 Imported by: 0

README

Build Status

gQUIC

QUIC(Quick UDP Internet Connection) implementation in go draft-hamilton-early-deployment-quic-00

Notice

This is test implementation of IETF QUIC, not google QUIC. I noticed the name gQUIC is too confusing, this would be changed in the future.

RUN example

Running example locally

If you notice procedure bellows are different from spec, I would be appreciate your suggestion.

  1. Server: run loop for waiting client connection
  2. Client: send packet with version (no frame)
  3. Server: check whether the version can be used from server (as of now)
  4. Client: send packet with Stream frame, data with "testData" (Server Ack)
  5. Client: send Ping (Server Ack as Pong)
  6. Client: send GoAway, reason with "This is GoAway reason" (Server Ack)
  7. Client: send ConnectionClose, reason with "This is Connection Close reason" (Server Ack)
  8. To be implemented
>> go run ./examples/main.go
TODO
  • Encryption
  • Connection negotiation
License

The MIT License (MIT) Copyright (c) 2015 ami-GS

Documentation

Index

Constants

View Source
const (
	// "01nullmm"
	// 'n'
	HasAckBlockLengths AckTypeFlag = 0x20
	// 'u'
	Unused = 0x10
	// 'll'
	LargestAckedLenMask = 0x0c
	LargestAckedLen1    = 0x00
	LargestAckedLen2    = 0x04
	LargestAckedLen4    = 0x08
	LargestAckedLen6    = 0x0c
	// 'mm'
	AckBlockLengthLenMask = 0x03
	AckBlockLengthLen1    = 0x00
	AckBlockLengthLen2    = 0x01
	AckBlockLengthLen4    = 0x02
	AckBlockLengthLen6    = 0x03
)
View Source
const (
	CONTAIN_QUIC_VERSION      PublicFlagType = 0x01
	PUBLIC_RESET                             = 0x02
	PRESENT_NONSE                            = 0x04
	CONNECTION_ID_LENGTH_8                   = 0x08
	OMIT_CONNECTION_ID                       = 0x00
	PACKET_NUMBER_LENGTH_MASK                = 0x30
	PACKET_NUMBER_LENGTH_6                   = 0x30
	PACKET_NUMBER_LENGTH_4                   = 0x20
	PACKET_NUMBER_LENGTH_2                   = 0x10
	PACKET_NUMBER_LENGTH_1                   = 0x00
	RESERVED_MULTIPATH                       = 0x40
	MUST_BE_ZERO                             = 0x80
)
View Source
const (
	MTU      = 1500 // temporally using
	MTU_IPv4 = 1370 // TODO: when to negotiate?
	MTU_IPv6 = 1350
)

Variables

View Source
var PacketParserMap = map[PacketType]PacketParser{
	VersionNegotiationPacketType: ParseVersionNegotiationPacket,
	FramePacketType:              ParseFramePacket,
	PublicResetPacketType:        ParsePublicResetPacket,
}
View Source
var QUIC_VERSION_LIST []uint32 = []uint32{
	uint32('Q'<<24 | '0'<<16 | '3'<<8 | '4'),
}

Functions

func ReadStreamLevelFrame

func ReadStreamLevelFrame(conn *Conn, f StreamLevelFrame) (bool, error)

Types

type AckFrame

type AckFrame struct {
	*FramePacket
	Type                  FrameType
	Settings              byte
	LargestAcked          uint64
	LargestAckedDeltaTime uint16
	NumberBlocks_1        byte
	FirstAckBlockLength   uint64

	GapToNextBlock []byte
	AckBlockLength []uint64 // repeats NumberBlocks_1 times ???

	NumTimestamp byte
	Timestamps   []Timestamp
}

func NewAckFrame

func NewAckFrame(largestAcked uint64, largestAckedDeltaTime uint16, blockLengths []uint64, timestamps []Timestamp) *AckFrame

func (*AckFrame) GetType

func (frame *AckFrame) GetType() FrameType

func (*AckFrame) GetWire

func (frame *AckFrame) GetWire() (wire []byte, err error)

func (*AckFrame) String

func (frame *AckFrame) String() (str string)

type AckTypeFlag

type AckTypeFlag byte

type BlockedFrame

type BlockedFrame struct {
	*FramePacket
	Type     FrameType
	StreamID uint32
}
0        1        2        3         4

+--------+--------+--------+--------+--------+ |Type(8) | Stream ID (32 bits) | +--------+--------+--------+--------+--------+

func NewBlockedFrame

func NewBlockedFrame(streamID uint32) *BlockedFrame

func (*BlockedFrame) GetStreamID

func (frame *BlockedFrame) GetStreamID() uint32

func (*BlockedFrame) GetType

func (frame *BlockedFrame) GetType() FrameType

func (*BlockedFrame) GetWire

func (frame *BlockedFrame) GetWire() (wire []byte, err error)

func (*BlockedFrame) String

func (frame *BlockedFrame) String() (str string)

type Client

type Client struct {
	Conn                   *Conn
	RecvChan               chan Packet
	LastSentVersion        uint32
	DecidedVersion         uint32 // if not zero, version negotiation was finished
	BufUntilVersionDecided []Packet
	IsServerObj            bool
	CurrentMaxStreamID     uint32
}

func NewClient

func NewClient(isServerObj bool) (*Client, error)

func (*Client) Connect

func (self *Client) Connect(addPair string) error

Func name should be same as that of http

func (*Client) Loop

func (self *Client) Loop()

func (*Client) Ping

func (self *Client) Ping() error

func (*Client) PublicResetPacket

func (self *Client) PublicResetPacket()

func (*Client) ReadLoop

func (self *Client) ReadLoop()

func (*Client) ReadPacketFromClient

func (self *Client) ReadPacketFromClient(p Packet) (bool, error)

func (*Client) ReadPacketFromServer

func (self *Client) ReadPacketFromServer(p Packet) (bool, error)

func (*Client) Request

func (self *Client) Request() error

func (*Client) Send

func (self *Client) Send(p Packet) error

func (*Client) SendFramePacket

func (self *Client) SendFramePacket(frames []Frame) error

type Conn

type Conn struct {
	*Transport
	Window           *Window
	Streams          map[uint32]*Stream
	LastGoodStreamID uint32
	ConnectionID     uint64
	RemoteAddr       *net.UDPAddr
	SentGoAway       bool
	RecvGoAway       bool
	TimeSpawn        time.Time
	PacketIdx        uint64
	UnackedPackets   map[uint64]Packet
}

func NewConnection

func NewConnection(rAddr *net.UDPAddr) (*Conn, error)

func (*Conn) ApplyAckFrame

func (conn *Conn) ApplyAckFrame(f *AckFrame) (bool, error)

func (*Conn) ApplyConnectionCloseFrame

func (conn *Conn) ApplyConnectionCloseFrame(f *ConnectionCloseFrame) (bool, error)

func (*Conn) ApplyGoAwayFrame

func (conn *Conn) ApplyGoAwayFrame(f *GoAwayFrame) (bool, error)

func (*Conn) ApplyPingFrame

func (conn *Conn) ApplyPingFrame(f *PingFrame) (bool, error)

func (*Conn) ApplyStopWaitingFrame

func (conn *Conn) ApplyStopWaitingFrame(f *StopWaitingFrame) (bool, error)

func (*Conn) Close

func (conn *Conn) Close() error

func (*Conn) Dial

func (conn *Conn) Dial() error

func (*Conn) GenStream

func (conn *Conn) GenStream(streamID uint32) *Stream

func (*Conn) IncrementPacketIdx

func (conn *Conn) IncrementPacketIdx()

func (*Conn) NewConnectionID

func (self *Conn) NewConnectionID() (uint64, error)

func (*Conn) ReadConnectionLevelFrame

func (conn *Conn) ReadConnectionLevelFrame(f Frame) (bool, error)

func (*Conn) WritePacket

func (conn *Conn) WritePacket(p Packet, fromServer bool) error

type ConnectionCloseFrame

type ConnectionCloseFrame struct {
	*FramePacket
	Type               FrameType
	ErrorCode          QUIC_OFFICIAL_ERROR
	ReasonPhraseLength uint16
	ReasonPhrase       string
}

func NewConnectionCloseFrame

func NewConnectionCloseFrame(errorCode QUIC_OFFICIAL_ERROR, reasonPhrase string) *ConnectionCloseFrame

func (*ConnectionCloseFrame) GetType

func (frame *ConnectionCloseFrame) GetType() FrameType

func (*ConnectionCloseFrame) GetWire

func (frame *ConnectionCloseFrame) GetWire() (wire []byte, err error)

func (*ConnectionCloseFrame) String

func (frame *ConnectionCloseFrame) String() (str string)

type Frame

type Frame interface {
	GetType() FrameType
	GetWire() ([]byte, error)
	String() string
}

func ParseAckFrame

func ParseAckFrame(fp *FramePacket, data []byte) (Frame, int)

func ParseBlockedFrame

func ParseBlockedFrame(fp *FramePacket, data []byte) (Frame, int)

func ParseCongestionFeedbackFrame

func ParseCongestionFeedbackFrame(fp *FramePacket, data []uint8) (Frame, int)

CongestionFeedback

func ParseConnectionCloseFrame

func ParseConnectionCloseFrame(fp *FramePacket, data []byte) (Frame, int)

func ParseGoAwayFrame

func ParseGoAwayFrame(fp *FramePacket, data []byte) (Frame, int)

func ParsePaddingFrame

func ParsePaddingFrame(fp *FramePacket, data []byte) (Frame, int)

func ParsePingFrame

func ParsePingFrame(fp *FramePacket, data []byte) (Frame, int)

func ParseRstStreamFrame

func ParseRstStreamFrame(fp *FramePacket, data []byte) (Frame, int)

func ParseStopWaitingFrame

func ParseStopWaitingFrame(fp *FramePacket, data []byte) (Frame, int)

func ParseStreamFrame

func ParseStreamFrame(fp *FramePacket, data []byte) (Frame, int)

func ParseWindowUpdateFrame

func ParseWindowUpdateFrame(fp *FramePacket, data []byte) (Frame, int)

type FramePacket

type FramePacket struct {
	*PacketHeader
	Frames   []Frame
	Wire     []byte
	DataSize uint16
	RestSize uint16
}

+--------+---...---+--------+---...---+ | Type | Payload | Type | Payload | +--------+---...---+--------+---...---+

func NewFramePacket

func NewFramePacket(connectionID, packetNumber uint64, frame []Frame) *FramePacket

func (*FramePacket) GetConnectionID

func (packet *FramePacket) GetConnectionID() uint64

func (*FramePacket) GetHeader

func (packet *FramePacket) GetHeader() *PacketHeader

func (*FramePacket) GetWire

func (packet *FramePacket) GetWire() ([]byte, error)

func (*FramePacket) PushBack

func (packet *FramePacket) PushBack(frame Frame) bool

func (*FramePacket) String

func (packet *FramePacket) String() (str string)

type FrameParser

type FrameParser func(fp *FramePacket, data []byte) (Frame, int)

type FrameType

type FrameType uint8
const (
	PaddingFrameType FrameType = iota
	RstStreamFrameType
	ConnectionCloseFrameType
	GoAwayFrameType
	WindowUpdateFrameType
	BlockedFrameType
	StopWaitingFrameType
	PingFrameType
	StreamFrameType             = 0x80
	AckFrameType                = 0x40
	CongestionFeedbackFrameType = 0x20
)

func (FrameType) String

func (frameType FrameType) String() string

type GoAwayFrame

type GoAwayFrame struct {
	*FramePacket
	Type               FrameType
	ErrorCode          QUIC_OFFICIAL_ERROR
	LastGoodStreamID   uint32
	ReasonPhraseLength uint16
	ReasonPhrase       string
}

func NewGoAwayFrame

func NewGoAwayFrame(errorCode QUIC_OFFICIAL_ERROR, lastGoodStreamID uint32, reasonPhrase string) *GoAwayFrame

func (*GoAwayFrame) GetType

func (frame *GoAwayFrame) GetType() FrameType

func (*GoAwayFrame) GetWire

func (frame *GoAwayFrame) GetWire() (wire []byte, err error)

func (*GoAwayFrame) String

func (frame *GoAwayFrame) String() (str string)

type MY_ERROR

type MY_ERROR uint16
const (
	CONNECTION_NOT_FOUND MY_ERROR = iota
	FAIL_TO_SET_CONNECTION_ID
)

func (MY_ERROR) Error

func (e MY_ERROR) Error() string

type Message

type Message struct {
	MsgTag QuicTag
	Tags   []QuicTag
	Values [][]byte
}

func NewMessage

func NewMessage(msgTag QuicTag) *Message

func (*Message) AppendTagValue

func (message *Message) AppendTagValue(tag QuicTag, value []byte) bool

func (*Message) GetWire

func (message *Message) GetWire() (wire []byte, err error)

func (*Message) Parse

func (message *Message) Parse(data []byte) (index int, err error)

func (*Message) SortTags

func (message *Message) SortTags()

func (*Message) String

func (message *Message) String() string

func (*Message) TagContain

func (message *Message) TagContain(tag QuicTag) bool

type Packet

type Packet interface {
	GetWire() ([]byte, error)
	GetConnectionID() uint64
	GetHeader() *PacketHeader
	String() string
}

func ParseFramePacket

func ParseFramePacket(ph *PacketHeader, data []byte) (Packet, int)

func ParsePublicResetPacket

func ParsePublicResetPacket(ph *PacketHeader, data []byte) (Packet, int)

func ParseVersionNegotiationPacket

func ParseVersionNegotiationPacket(ph *PacketHeader, data []byte) (Packet, int)

type PacketHeader

type PacketHeader struct {
	Type          PacketType
	PublicFlags   PublicFlagType
	ConnectionID  uint64
	Nonse         []uint8 // 0(nil) or 32
	Versions      []uint32
	PacketNumber  uint64
	RegularPacket bool
}

func NewPacketHeader

func NewPacketHeader(packetType PacketType, connectionID uint64, versions []uint32, packetNumber uint64, nonse []uint8) *PacketHeader

func ParsePacketHeader

func ParsePacketHeader(data []byte, fromServer bool) (ph *PacketHeader, length int, err error)

func (*PacketHeader) GetWire

func (ph *PacketHeader) GetWire() (wire []byte, err error)

func (*PacketHeader) String

func (ph *PacketHeader) String() string

type PacketParser

type PacketParser func(ph *PacketHeader, data []byte) (Packet, int)

type PacketType

type PacketType byte
const (
	VersionNegotiationPacketType PacketType = iota
	FramePacketType
	PublicResetPacketType
)

func (PacketType) String

func (pType PacketType) String() string

type PaddingFrame

type PaddingFrame struct {
	*FramePacket
	Type FrameType
}

func NewPaddingFrame

func NewPaddingFrame() *PaddingFrame

func (*PaddingFrame) GetType

func (frame *PaddingFrame) GetType() FrameType

func (*PaddingFrame) GetWire

func (frame *PaddingFrame) GetWire() (wire []byte, err error)

func (*PaddingFrame) String

func (frame *PaddingFrame) String() (str string)

type PingFrame

type PingFrame struct {
	*FramePacket
	Type FrameType
}

func NewPingFrame

func NewPingFrame() *PingFrame

func (*PingFrame) GetType

func (frame *PingFrame) GetType() FrameType

func (*PingFrame) GetWire

func (frame *PingFrame) GetWire() (wire []byte, err error)

func (*PingFrame) String

func (frame *PingFrame) String() (str string)

type PublicFlagType

type PublicFlagType byte

func (PublicFlagType) String

func (f PublicFlagType) String() string

type PublicResetPacket

type PublicResetPacket struct {
	*PacketHeader
	Msg *Message
}
0        1        2        3        4         8

+--------+--------+--------+--------+--------+-- --+ | Public | Connection ID (64) ... | -> |Flags(8)| | +--------+--------+--------+--------+--------+-- --+

9       10       11        12       13      14

+--------+--------+--------+--------+--------+--------+--- | Quic Tag (32) | Tag value map ... -> | (PRST) | (variable length) +--------+--------+--------+--------+--------+--------+---

func NewPublicResetPacket

func NewPublicResetPacket(connectionID uint64) *PublicResetPacket

func (*PublicResetPacket) AppendTagValue

func (packet *PublicResetPacket) AppendTagValue(tag QuicTag, value []byte) bool

func (*PublicResetPacket) GetConnectionID

func (packet *PublicResetPacket) GetConnectionID() uint64

func (*PublicResetPacket) GetHeader

func (packet *PublicResetPacket) GetHeader() *PacketHeader

func (*PublicResetPacket) GetWire

func (packet *PublicResetPacket) GetWire() ([]byte, error)

func (*PublicResetPacket) String

func (packet *PublicResetPacket) String() string

type QUIC_OFFICIAL_ERROR

type QUIC_OFFICIAL_ERROR uint16

TODO: The official errors shuold be in other file and package?

const (
	QUIC_NO_ERROR QUIC_OFFICIAL_ERROR = iota
	QUIC_STREAM_DATA_AFTER_TERMINATION
	QUIC_SERVER_ERROR_PROCESSING_STREAM
	QUIC_MULTIPLE_TERMINATION_OFFSETS
	QUIC_BAD_APPLICATION_PAYLOAD
	QUIC_INVALID_PACKET_HEADER
	QUIC_INVALID_FRAME_DATA
	QUIC_INVALID_RST_STREAM_DATA
	QUIC_INVALID_CONNECTION_CLOSE_DATA
	QUIC_INVALID_ACK_DATA
	QUIC_DECRYPTION_FAILURE
	QUIC_ENCRYPTION_FAILURE
	QUIC_PACKET_TOO_LARGE
	QUIC_PACKET_FOR_NONEXISTENT_STREAM
	QUIC_CLIENT_GOING_AWAY
	QUIC_SERVER_GOING_AWAY
	QUIC_INVALID_STREAM_ID
	QUIC_TOO_MANY_OPEN_STREAMS
	QUIC_CONNECTION_TIMED_OUT
	QUIC_CRYPTO_TAGS_OUT_OF_ORDER
	QUIC_CRYPTO_TOO_MANY_ENTRIES
	QUIC_CRYPTO_INVALID_VALUE_LENGTH
	QUIC_CRYPTO_MESSAGE_AFTER_HANDSHAKE_COMPLETE
	QUIC_INVALID_CRYPTO_MESSAGE_TYPE
	QUIC_SEQUENCE_NUMBER_LIMIT_REACHED
)

func (QUIC_OFFICIAL_ERROR) Error

func (e QUIC_OFFICIAL_ERROR) Error() string

type QuicTag

type QuicTag uint32
const (
	CHLO QuicTag = 'C' + ('H' << 8) + ('L' << 16) + ('O' << 24)
	SHLO QuicTag = 'S' + ('H' << 8) + ('L' << 16) + ('O' << 24)
	REJ  QuicTag = 'R' + ('E' << 8) + ('J' << 16) + (0 << 24)

	// Required Parameters
	// in CHLO/SHLO
	// Stream Flow Control Window
	SFCW QuicTag = 'S' + ('F' << 8) + ('C' << 16) + ('W' << 24)
	// Connection/Session Flow Control Window
	CFCW QuicTag = 'C' + ('F' << 8) + ('C' << 16) + ('W' << 24)

	// in CHLO
	// Version
	VER QuicTag = 'V' + ('E' << 8) + ('R' << 16) + (0 << 24)
	// Server Name Indication (optional)
	SNI QuicTag = 'S' + ('N' << 8) + ('I' << 16) + (0 << 24)
	// Source-address token (optional)
	STK QuicTag = 'S' + ('T' << 8) + ('K' << 16) + (0 << 24)
	// Proof demand (optional)
	PDMD QuicTag = 'P' + ('D' << 8) + ('M' << 16) + ('D' << 24)
	// Common certificate sets (optional)
	CCS QuicTag = 'C' + ('C' << 8) + ('S' << 16) + (0 << 24)
	// Cached certificate (optional)
	CCRT QuicTag = 'C' + ('C' << 8) + ('R' << 16) + ('T' << 24)

	// Optional Parameters
	// Socket receive buffer size in bytes
	SRBF QuicTag = 'S' + ('R' << 8) + ('B' << 16) + ('F' << 24)
	// Connection ID truncation
	TCID QuicTag = 'T' + ('C' << 8) + ('I' << 16) + ('D' << 24)
	// Connection Options are a repeated tag field
	COPT QuicTag = 'C' + ('O' << 8) + ('P' << 16) + ('T' << 24)

	// in REJ
	// Server config (optional)
	SCFG QuicTag = 'S' + ('C' << 8) + ('F' << 16) + ('G' << 24)
	// Server nonce (optional)
	SNO QuicTag = 'S' + ('N' << 8) + ('O' << 16) + (0 << 24)

	// Proof of authenticity (optional)
	PROF QuicTag = 'P' + ('R' << 8) + ('O' << 16) + ('F' << 24)

	// in SCFG
	// Server config ID
	SCID QuicTag = 'S' + ('C' << 8) + ('I' << 16) + ('D' << 24)
	// Key exchange algorithms
	KEXS QuicTag = 'K' + ('E' << 8) + ('X' << 16) + ('S' << 24)
	// Authenticated encryption algorithms
	AEAD QuicTag = 'A' + ('E' << 8) + ('A' << 16) + ('D' << 24)
	// A list of public values
	PUBS QuicTag = 'P' + ('U' << 8) + ('B' << 16) + ('S' << 24)
	// Orbit
	ORBT QuicTag = 'O' + ('R' << 8) + ('B' << 16) + ('T' << 24)
	// Expiry
	EXPY QuicTag = 'E' + ('X' << 8) + ('P' << 16) + ('Y' << 24)

	// in AEAD
	// AES-GCM with a 12-byte tag and IV
	AESG QuicTag = 'A' + ('E' << 8) + ('S' << 16) + ('G' << 24)
	// Salsa20 with Poly1305
	S20P QuicTag = 'S' + ('2' << 8) + ('0' << 16) + ('P' << 24)
	// in KEXS
	// Curve25519
	C255 QuicTag = 'C' + ('2' << 8) + ('5' << 16) + ('5' << 24)
	// P-256
	P256 QuicTag = 'P' + ('2' << 8) + ('5' << 16) + ('6' << 24)

	// in full CHLO
	// SCID, AEAD, KEXS, SNO, PUBS
	// Client nonce
	NONC QuicTag = 'N' + ('O' << 8) + ('N' << 16) + ('C' << 24)
	// Client encrypted tag-values (optional)
	CETV QuicTag = 'C' + ('E' << 8) + ('T' << 16) + ('V' << 24)

	// in CETV
	// ChannelID key (optional)
	CIDK QuicTag = 'C' + ('I' << 8) + ('D' << 16) + ('K' << 24)
	// ChnnelID signature (optional)
	CIDS QuicTag = 'C' + ('I' << 8) + ('D' << 16) + ('S' << 24)

	// in Public Reset Packet
	PRST QuicTag = 'P' + ('R' << 8) + ('S' << 16) + ('T' << 24)
	// public reset nonce proof
	RNON QuicTag = 'R' + ('N' << 8) + ('O' << 16) + ('N' << 24)
	// rejected sequence number
	RSEQ QuicTag = 'R' + ('S' << 8) + ('E' << 16) + ('Q' << 24)
	// client address
	CADR QuicTag = 'C' + ('A' << 8) + ('D' << 16) + ('R' << 24)
)

func (QuicTag) String

func (tag QuicTag) String() string

type RstStreamFrame

type RstStreamFrame struct {
	*FramePacket
	Type      FrameType
	StreamID  uint32
	Offset    uint64
	ErrorCode QUIC_OFFICIAL_ERROR
}

func NewRstStreamFrame

func NewRstStreamFrame(streamID uint32, offset uint64, errorCode QUIC_OFFICIAL_ERROR) *RstStreamFrame

func (*RstStreamFrame) GetStreamID

func (frame *RstStreamFrame) GetStreamID() uint32

func (*RstStreamFrame) GetType

func (frame *RstStreamFrame) GetType() FrameType

func (*RstStreamFrame) GetWire

func (frame *RstStreamFrame) GetWire() (wire []byte, err error)

func (*RstStreamFrame) String

func (frame *RstStreamFrame) String() (str string)

type Server

type Server struct {
	St              *Transport
	Clients         map[uint64]*Client
	SupportVersions []uint32
}

func NewServer

func NewServer() (*Server, error)

func (*Server) FramePacket

func (self *Server) FramePacket(frames []*Frame)

func (*Server) ListenAndServe

func (self *Server) ListenAndServe(addPair string) error

func (*Server) PublicResetPacket

func (self *Server) PublicResetPacket()

func (*Server) VersionNegotiationPacket

func (self *Server) VersionNegotiationPacket()

type State

type State byte
const (
	OPEN State = iota
	HALF_CLOSED
	CLOSED
)

func (State) String

func (s State) String() string

type StopWaitingFrame

type StopWaitingFrame struct {
	*FramePacket
	Type              FrameType
	LeastUnackedDelta uint64
}

func NewStopWaitingFrame

func NewStopWaitingFrame(leastUnackedDelta uint64) *StopWaitingFrame

func (*StopWaitingFrame) GetType

func (frame *StopWaitingFrame) GetType() FrameType

func (*StopWaitingFrame) GetWire

func (frame *StopWaitingFrame) GetWire() (wire []byte, err error)

func (*StopWaitingFrame) String

func (frame *StopWaitingFrame) String() (str string)

type Stream

type Stream struct {
	*Conn
	ID                  uint32
	State               State
	PeerState           State
	Window              *Window
	FlowControllBlocked bool
}

func NewStream

func NewStream(streamID uint32, conn *Conn) (stream *Stream)

func (*Stream) ApplyBlockedFrame

func (self *Stream) ApplyBlockedFrame(f *BlockedFrame) (bool, error)

func (*Stream) ApplyRstStreamFrame

func (self *Stream) ApplyRstStreamFrame(f *RstStreamFrame) (bool, error)

func (*Stream) ApplyStreamFrame

func (self *Stream) ApplyStreamFrame(f *StreamFrame) (bool, error)

func (*Stream) ApplyWindowUpdateFrame

func (self *Stream) ApplyWindowUpdateFrame(f *WindowUpdateFrame) (bool, error)

func (*Stream) SendFrame

func (self *Stream) SendFrame(f Frame)

func (*Stream) String

func (self *Stream) String() string

type StreamFrame

type StreamFrame struct {
	*FramePacket
	Type     FrameType
	Settings byte
	Fin      bool
	StreamID uint32
	Offset   uint64
	Data     []byte
}

func NewStreamFrame

func NewStreamFrame(fin bool, streamID uint32, offset uint64, data []byte) *StreamFrame

func (*StreamFrame) GetStreamID

func (frame *StreamFrame) GetStreamID() uint32

func (*StreamFrame) GetType

func (frame *StreamFrame) GetType() FrameType

func (*StreamFrame) GetWire

func (frame *StreamFrame) GetWire() (wire []byte, err error)

func (*StreamFrame) String

func (frame *StreamFrame) String() (str string)

type StreamLevelFrame

type StreamLevelFrame interface {
	GetType() FrameType
	GetWire() ([]byte, error)
	String() string
	GetStreamID() uint32
}

type Timestamp

type Timestamp struct {
	DeltaLargestAcked     byte
	TimeSinceLargestAcked uint32
}

type Transport

type Transport struct {
	//Conn     *tls.Conn
	UDPConn  *net.UDPConn
	CertPath string
	KeyPath  string
}

TODO: should be encrypt at proper timing

func NewTransport

func NewTransport(certPath, keyPath string) (*Transport, error)

func (*Transport) Close

func (self *Transport) Close() error

func (*Transport) Dial

func (self *Transport) Dial(rAddr *net.UDPAddr) error

func (*Transport) Listen

func (self *Transport) Listen(lAddr *net.UDPAddr) error

func (*Transport) Recv

func (self *Transport) Recv() (Packet, int, *net.UDPAddr, error)

func (*Transport) Send

func (self *Transport) Send(p Packet) (err error)

func (*Transport) SendTo

func (self *Transport) SendTo(p Packet, rAddr *net.UDPAddr) (err error)

type VersionNegotiationPacket

type VersionNegotiationPacket struct {
	*PacketHeader
}

func NewVersionNegotiationPacket

func NewVersionNegotiationPacket(connectionID uint64, versions []uint32) *VersionNegotiationPacket

func (*VersionNegotiationPacket) GetConnectionID

func (packet *VersionNegotiationPacket) GetConnectionID() uint64

func (*VersionNegotiationPacket) GetHeader

func (packet *VersionNegotiationPacket) GetHeader() *PacketHeader

func (*VersionNegotiationPacket) GetWire

func (packet *VersionNegotiationPacket) GetWire() (wire []byte, err error)

func (*VersionNegotiationPacket) String

func (packet *VersionNegotiationPacket) String() string

type Window

type Window struct {
	// contains filtered or unexported fields
}

func NewWindow

func NewWindow() (window *Window)

func (*Window) Consume

func (window *Window) Consume(consumeSize uint32)

func (*Window) Increase

func (window *Window) Increase(increaseSize uint32)

type WindowUpdateFrame

type WindowUpdateFrame struct {
	*FramePacket
	Type     FrameType
	StreamID uint32
	Offset   uint64
}

func NewWindowUpdateFrame

func NewWindowUpdateFrame(streamID uint32, offset uint64) *WindowUpdateFrame

func (*WindowUpdateFrame) GetStreamID

func (frame *WindowUpdateFrame) GetStreamID() uint32

func (*WindowUpdateFrame) GetType

func (frame *WindowUpdateFrame) GetType() FrameType

func (*WindowUpdateFrame) GetWire

func (frame *WindowUpdateFrame) GetWire() (wire []byte, err error)

func (*WindowUpdateFrame) String

func (frame *WindowUpdateFrame) String() (str string)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL