Documentation ¶
Overview ¶
Package minq is a minimal implementation of QUIC, as documented at https://quicwg.github.io/. Minq partly implements draft-04.
Package minq is a minimal implementation of QUIC, as documented at https://quicwg.github.io/. Minq partly implements draft-04.
Internal structure indicating packets we have received
Index ¶
- Constants
- Variables
- func SetLogOutput(f func(string, ...interface{}))
- type CongestionController
- type CongestionControllerDummy
- type CongestionControllerIetf
- type Connection
- func (c *Connection) CheckTimer() (int, error)
- func (c *Connection) ClientId() ConnectionId
- func (c *Connection) Close() error
- func (c *Connection) CreateSendStream() SendStream
- func (c *Connection) CreateStream() Stream
- func (c *Connection) Error(appError uint16, reason string) error
- func (c *Connection) GetRecvStream(id uint64) RecvStream
- func (c *Connection) GetSendStream(id uint64) SendStream
- func (c *Connection) GetState() State
- func (c *Connection) GetStream(id uint64) Stream
- func (c *Connection) Input(p []byte) error
- func (c *Connection) Role() Role
- func (c *Connection) ServerId() ConnectionId
- func (c *Connection) SetHandler(h ConnectionHandler)
- func (c *Connection) String() string
- func (c *Connection) Writable() bool
- type ConnectionHandler
- type ConnectionId
- type ErrorCode
- type RecordLayerFactoryImpl
- type RecordLayerImpl
- func (r *RecordLayerImpl) DiscardReadKey(epoch mint.Epoch)
- func (r *RecordLayerImpl) Epoch() mint.Epoch
- func (r *RecordLayerImpl) PeekRecordType(block bool) (mint.RecordType, error)
- func (r *RecordLayerImpl) ReadRecord() (*mint.TLSPlaintext, error)
- func (r *RecordLayerImpl) Rekey(epoch mint.Epoch, factory mint.AeadFactory, keys *mint.KeySet) error
- func (r *RecordLayerImpl) ResetClear(seq uint64)
- func (r *RecordLayerImpl) SetLabel(s string)
- func (r *RecordLayerImpl) SetVersion(v uint16)
- func (r *RecordLayerImpl) WriteRecord(pt *mint.TLSPlaintext) error
- type RecvStream
- type RecvStreamState
- type Role
- type SendStream
- type SendStreamState
- type Server
- type ServerHandler
- type State
- type Stream
- type TlsConfig
- type Transport
- type TransportFactory
- type TransportParameterId
- type TransportParameterList
- type UdpTransport
- type UdpTransportFactory
- type VersionNumber
Constants ¶
const ( RoleClient = Role(1) RoleServer = Role(2) )
These are roles.
const ( StateInit = State(1) StateWaitClientInitial = State(2) StateWaitServerInitial = State(3) StateWaitServerFirstFlight = State(4) StateWaitClientSecondFlight = State(5) StateEstablished = State(6) StateClosing = State(7) StateClosed = State(8) StateError = State(9) )
These are connection states.
const ( SendStreamStateOpen = SendStreamState(0) SendStreamStateSend = SendStreamState(1) SendStreamStateCloseQueued = SendStreamState(2) // Not in the spec SendStreamStateDataSent = SendStreamState(3) SendStreamStateResetSent = SendStreamState(4) SendStreamStateDataRecvd = SendStreamState(5) // Not tracked SendStreamStateResetRecvd = SendStreamState(6) // Not tracked )
SendStreamState values. Not all of these are tracked
const ( RecvStreamStateRecv = RecvStreamState(0) RecvStreamStateSizeKnown = RecvStreamState(1) RecvStreamStateDataRecvd = RecvStreamState(2) // Not tracked RecvStreamStateResetRecvd = RecvStreamState(3) RecvStreamStateDataRead = RecvStreamState(4) RecvStreamStateResetRead = RecvStreamState(5) )
RecvStreamState values. Not all of these are tracked.
Variables ¶
var ErrorConnIsClosed = fatalError("Connection is closed")
var ErrorConnIsClosing = nonFatalError("Connection is closing")
var ErrorConnectionTimedOut = fatalError("Connection timed out")
var ErrorDestroyConnection = fatalError("Terminate connection")
var ErrorFlowControlError = fatalError("Flow control error")
var ErrorFrameFormatError = fatalError("Frame format error")
var ErrorInvalidEncoding = fatalError("Invalid encoding")
var ErrorInvalidPacket = nonFatalError("Invalid packet")
var ErrorMissingValue = fatalError("Expected value is missing")
var ErrorProtocolViolation = fatalError("Protocol violation")
var ErrorReceivedVersionNegotiation = fatalError("Received a version negotiation packet advertising a different version than ours")
var ErrorStreamIsClosed = fatalError("Stream is closed")
var ErrorStreamReset = fatalError("Stream was reset")
var ErrorWouldBlock = nonFatalError("Would have blocked (QUIC)")
Return codes.
var HsEpochs = []mint.Epoch{mint.EpochClear, mint.EpochHandshakeData}
Functions ¶
func SetLogOutput ¶
func SetLogOutput(f func(string, ...interface{}))
Types ¶
type CongestionController ¶
type CongestionController interface {
// contains filtered or unexported methods
}
type CongestionControllerDummy ¶
type CongestionControllerDummy struct { }
type CongestionControllerIetf ¶
type CongestionControllerIetf struct {
// contains filtered or unexported fields
}
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
func NewConnection ¶
func NewConnection(trans Transport, role Role, tls *TlsConfig, handler ConnectionHandler) *Connection
Create a new QUIC connection. Should only be used with role=RoleClient, though we use it with RoleServer internally.
func (*Connection) CheckTimer ¶
func (c *Connection) CheckTimer() (int, error)
Check the connection's timer and process any events whose time has expired in the meantime. This includes sending retransmits, etc.
func (*Connection) ClientId ¶
func (c *Connection) ClientId() ConnectionId
ClientId returns the current identity, as dictated by the client.
func (*Connection) CreateSendStream ¶
func (c *Connection) CreateSendStream() SendStream
CreateSendStream creates a stream that can send only.
func (*Connection) CreateStream ¶
func (c *Connection) CreateStream() Stream
CreateStream creates a stream that can send and receive.
func (*Connection) GetRecvStream ¶
func (c *Connection) GetRecvStream(id uint64) RecvStream
GetRecvStream retrieves a stream with the given id. Returns nil if no such stream exists.
func (*Connection) GetSendStream ¶
func (c *Connection) GetSendStream(id uint64) SendStream
GetSendStream retrieves a stream with the given id. Returns nil if no such stream exists.
func (*Connection) GetState ¶
func (c *Connection) GetState() State
Get the current state of a connection.
func (*Connection) GetStream ¶
func (c *Connection) GetStream(id uint64) Stream
GetStream retrieves a stream with the given id. Returns nil if no such stream exists.
func (*Connection) Input ¶
func (c *Connection) Input(p []byte) error
Input provides a packet to the connection.
TODO(ekr@rtfm.com): when is error returned?
func (*Connection) Role ¶
func (c *Connection) Role() Role
func (*Connection) ServerId ¶
func (c *Connection) ServerId() ConnectionId
ServerId returns the current identity, as dictated by the server.
func (*Connection) SetHandler ¶
func (c *Connection) SetHandler(h ConnectionHandler)
Set the handler class for a given connection.
func (*Connection) String ¶
func (c *Connection) String() string
func (*Connection) Writable ¶
func (c *Connection) Writable() bool
type ConnectionHandler ¶
type ConnectionHandler interface { // The connection has changed state to state |s| StateChanged(s State) // NewRecvStream indicates that a new unidirectional stream has been // created by the remote peer. |s| contains the stream. NewRecvStream(s RecvStream) // NewStream indicates that a new bidirectional stream has been // created by the remote peer. |s| contains the stream. NewStream(s Stream) // StreamReadable indicates that |s| is now readable. StreamReadable(s RecvStream) }
Interface for the handler object which the Connection will call to notify of events on the connection.
type ConnectionId ¶
type ConnectionId []byte
ConnectionId identifies the connection that a packet belongs to.
func (ConnectionId) EncodeLength ¶
func (c ConnectionId) EncodeLength() byte
EncodeLength produces the length encoding used in the long packet header.
func (ConnectionId) String ¶
func (c ConnectionId) String() string
String stringifies a connection ID in the natural way.
type RecordLayerFactoryImpl ¶
type RecordLayerFactoryImpl struct {
// contains filtered or unexported fields
}
func (*RecordLayerFactoryImpl) NewLayer ¶
func (f *RecordLayerFactoryImpl) NewLayer(conn io.ReadWriter, dir mint.Direction) mint.RecordLayer
type RecordLayerImpl ¶
func (*RecordLayerImpl) DiscardReadKey ¶
func (r *RecordLayerImpl) DiscardReadKey(epoch mint.Epoch)
func (*RecordLayerImpl) Epoch ¶
func (r *RecordLayerImpl) Epoch() mint.Epoch
func (*RecordLayerImpl) PeekRecordType ¶
func (r *RecordLayerImpl) PeekRecordType(block bool) (mint.RecordType, error)
func (*RecordLayerImpl) ReadRecord ¶
func (r *RecordLayerImpl) ReadRecord() (*mint.TLSPlaintext, error)
func (*RecordLayerImpl) Rekey ¶
func (r *RecordLayerImpl) Rekey(epoch mint.Epoch, factory mint.AeadFactory, keys *mint.KeySet) error
func (*RecordLayerImpl) ResetClear ¶
func (r *RecordLayerImpl) ResetClear(seq uint64)
func (*RecordLayerImpl) SetLabel ¶
func (r *RecordLayerImpl) SetLabel(s string)
func (*RecordLayerImpl) SetVersion ¶
func (r *RecordLayerImpl) SetVersion(v uint16)
func (*RecordLayerImpl) WriteRecord ¶
func (r *RecordLayerImpl) WriteRecord(pt *mint.TLSPlaintext) error
type RecvStream ¶
type RecvStream interface {
// contains filtered or unexported methods
}
RecvStream can receive.
type RecvStreamState ¶
type RecvStreamState uint8
RecvStreamState is the state of a RecvStream
func (RecvStreamState) String ¶
func (s RecvStreamState) String() string
String produces a nice string from a RecvStreamState.
type SendStream ¶
type SendStream interface {
// contains filtered or unexported methods
}
SendStream can send.
type SendStreamState ¶
type SendStreamState uint8
SendStreamState is the state of a SendStream
func (SendStreamState) String ¶
func (s SendStreamState) String() string
String produces a nice string from a SendStreamState.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server represents a QUIC server. A server can be fed an arbitrary number of packets and will create Connections as needed, passing each packet to the right connection.
func NewServer ¶
func NewServer(factory TransportFactory, tls *TlsConfig, handler ServerHandler) *Server
Create a new QUIC server with the provide TLS config.
func (*Server) ConnectionCount ¶
How many connections do we have?
func (*Server) SetHandler ¶
func (s *Server) SetHandler(h ServerHandler)
SetHandler sets a handler function.
type ServerHandler ¶
type ServerHandler interface { // A new connection has been created and can be found in |c|. NewConnection(c *Connection) }
Interface for the handler object which the Server will call to notify of events.
type Stream ¶
type Stream interface {
// contains filtered or unexported methods
}
Stream is both a send and receive stream.
type TlsConfig ¶
type TlsConfig struct { ServerName string CertificateChain []*x509.Certificate Key crypto.Signer ForceHrr bool // contains filtered or unexported fields }
func NewTlsConfig ¶
type Transport ¶
Interface for an object to send packets. Each Transport is bound to some particular remote address (or in testing we just use a mock which sends the packet into a queue).
type TransportFactory ¶
type TransportFactory interface { // Make a transport object bound to |remote|. MakeTransport(remote *net.UDPAddr) (Transport, error) }
TransportFactory makes transports bound to a specific remote address.
type TransportParameterId ¶
type TransportParameterId uint16
type TransportParameterList ¶
type TransportParameterList []transportParameter
type UdpTransport ¶
type UdpTransport struct {
// contains filtered or unexported fields
}
func NewUdpTransport ¶
func NewUdpTransport(u *net.UDPConn, r *net.UDPAddr) *UdpTransport
func (*UdpTransport) Send ¶
func (t *UdpTransport) Send(p []byte) error
type UdpTransportFactory ¶
type UdpTransportFactory struct {
// contains filtered or unexported fields
}
func NewUdpTransportFactory ¶
func NewUdpTransportFactory(sock *net.UDPConn) *UdpTransportFactory
func (*UdpTransportFactory) MakeTransport ¶
func (f *UdpTransportFactory) MakeTransport(remote *net.UDPAddr) (Transport, error)