Documentation
¶
Overview ¶
Package minq is a minimal implementation of QUIC, as documented at https://quicwg.github.io/. Minq partly implements draft-04.
Index ¶
- Constants
- Variables
- type Connection
- func (c *Connection) CheckTimer() (int, error)
- func (c *Connection) Close()
- func (c *Connection) CreateStream() *Stream
- func (c *Connection) GetState() State
- func (c *Connection) GetStream(id uint32) *Stream
- func (c *Connection) Id() ConnectionId
- func (c *Connection) Input(p []byte) error
- func (c *Connection) SetHandler(h ConnectionHandler)
- type ConnectionHandler
- type ConnectionId
- type ErrorCode
- type Server
- type ServerHandler
- type State
- type Stream
- type TlsConfig
- type Transport
- type TransportFactory
- type UdpTransport
- type UdpTransportFactory
- type VersionNumber
Constants ¶
const ( RoleClient = 1 RoleServer = 2 )
Variables ¶
var ErrorDestroyConnection = fmt.Errorf("Terminate connection")
var ErrorReceivedVersionNegotiation = fmt.Errorf("Received a version negotiation packet advertising a different version than ours")
var ErrorWouldBlock = fmt.Errorf("Would have blocked")
Return codes.
Functions ¶
This section is empty.
Types ¶
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
Connection represents a QUIC connection. Clients can make connections directly but servers should create a minq.Server object which creates Connections as a side effect.
The control discipline is entirely operated by the consuming application. It has two major responsibilities:
- Deliver any incoming datagrams using Input()
- Periodically call CheckTimer(). In future there will be some way to know how often to call it, but right now it treats every call to CheckTimer() as timer expiry.
The application provides a handler object which the Connection calls to notify it of various events.
func NewConnection ¶
func NewConnection(trans Transport, role uint8, 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) CreateStream ¶
func (c *Connection) CreateStream() *Stream
Create a stream on a given connection. Returns the created stream.
func (*Connection) GetState ¶
func (c *Connection) GetState() State
Get the current state of a connection.
func (*Connection) GetStream ¶
func (c *Connection) GetStream(id uint32) *Stream
Get the stream with stream id |id|. Returns nil if no such stream exists.
func (*Connection) Id ¶
func (c *Connection) Id() ConnectionId
Get the connection ID for a connection. Returns 0 if you are a client and the first server packet hasn't been received.
func (*Connection) Input ¶
func (c *Connection) Input(p []byte) error
Provide a packet to the connection.
TODO(ekr@rtfm.com): when is error returned?
func (*Connection) SetHandler ¶
func (c *Connection) SetHandler(h ConnectionHandler)
Set the handler class for a given connection.
type ConnectionHandler ¶
type ConnectionHandler interface {
// The connection has changed state to state |s|
StateChanged(s State)
// A new stream has been created (by receiving a frame
// from the other side. |s| contains the stream.
NewStream(s *Stream)
// Stream |s| is now readable.
StreamReadable(s *Stream)
}
Interface for the handler object which the Connection will call to notify of events on the connection.
type ConnectionId ¶
type ConnectionId uint64
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.
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 struct {
// contains filtered or unexported fields
}
A single QUIC stream.
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 {
// contains filtered or unexported methods
}
TransportFactory makes transports bound to a specific remote address.
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
