quic

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2023 License: BSD-3-Clause Imports: 24 Imported by: 0

Documentation

Overview

Package quic is an experimental, incomplete implementation of the QUIC protocol. This package is a work in progress, and is not ready for use at this time.

This package implements (or will implement) RFC 9000, RFC 9001, and RFC 9002.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApplicationError

type ApplicationError struct {
	Code   uint64
	Reason string
}

An ApplicationError is an application protocol error code (RFC 9000, Section 20.2). Application protocol errors may be sent when terminating a stream or connection.

func (ApplicationError) Error

func (e ApplicationError) Error() string

type Config

type Config struct {
	// TLSConfig is the endpoint's TLS configuration.
	// It must be non-nil and include at least one certificate or else set GetCertificate.
	TLSConfig *tls.Config

	// StreamReadBufferSize is the maximum amount of data sent by the peer that a
	// stream will buffer for reading.
	// If zero, the default value of 1MiB is used.
	// If negative, the limit is zero.
	StreamReadBufferSize int64

	// StreamWriteBufferSize is the maximum amount of data a stream will buffer for
	// sending to the peer.
	// If zero, the default value of 1MiB is used.
	// If negative, the limit is zero.
	StreamWriteBufferSize int64
}

A Config structure configures a QUIC endpoint. A Config must not be modified after it has been passed to a QUIC function. A Config may be reused; the quic package will also not modify it.

type Conn

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

A Conn is a QUIC connection.

Multiple goroutines may invoke methods on a Conn simultaneously.

func (*Conn) AcceptStream added in v0.14.0

func (c *Conn) AcceptStream(ctx context.Context) (*Stream, error)

AcceptStream waits for and returns the next stream created by the peer.

func (*Conn) NewSendOnlyStream added in v0.14.0

func (c *Conn) NewSendOnlyStream(ctx context.Context) (*Stream, error)

NewSendOnlyStream creates a unidirectional, send-only stream.

If the peer's maximum stream limit for the connection has been reached, NewSendOnlyStream blocks until the limit is increased or the context expires.

func (*Conn) NewStream added in v0.14.0

func (c *Conn) NewStream(ctx context.Context) (*Stream, error)

NewStream creates a stream.

If the peer's maximum stream limit for the connection has been reached, NewStream blocks until the limit is increased or the context expires.

func (*Conn) String

func (c *Conn) String() string

type Stream added in v0.14.0

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

func (*Stream) Close added in v0.15.0

func (s *Stream) Close() error

Close closes the stream. See CloseContext for more details.

func (*Stream) CloseContext added in v0.15.0

func (s *Stream) CloseContext(ctx context.Context) error

CloseContext closes the stream. Any blocked stream operations will be unblocked and return errors.

CloseContext flushes any data in the stream write buffer and waits for the peer to acknowledge receipt of the data. If the stream has been reset, it waits for the peer to acknowledge the reset. If the context expires before the peer receives the stream's data, CloseContext discards the buffer and returns the context error.

func (*Stream) CloseRead added in v0.15.0

func (s *Stream) CloseRead()

CloseRead aborts reads on the stream. Any blocked reads will be unblocked and return errors.

CloseRead notifies the peer that the stream has been closed for reading. It does not wait for the peer to acknowledge the closure. Use CloseContext to wait for the peer's acknowledgement.

func (*Stream) CloseWrite added in v0.15.0

func (s *Stream) CloseWrite()

CloseWrite aborts writes on the stream. Any blocked writes will be unblocked and return errors.

CloseWrite sends any data in the stream write buffer to the peer. It does not wait for the peer to acknowledge receipt of the data. Use CloseContext to wait for the peer's acknowledgement.

func (*Stream) IsReadOnly added in v0.14.0

func (s *Stream) IsReadOnly() bool

IsReadOnly reports whether the stream is read-only (a unidirectional stream created by the peer).

func (*Stream) IsWriteOnly added in v0.14.0

func (s *Stream) IsWriteOnly() bool

IsWriteOnly reports whether the stream is write-only (a unidirectional stream created locally).

func (*Stream) Read added in v0.14.0

func (s *Stream) Read(b []byte) (n int, err error)

Read reads data from the stream. See ReadContext for more details.

func (*Stream) ReadContext added in v0.14.0

func (s *Stream) ReadContext(ctx context.Context, b []byte) (n int, err error)

ReadContext reads data from the stream.

ReadContext returns as soon as at least one byte of data is available.

If the peer closes the stream cleanly, ReadContext returns io.EOF after returning all data sent by the peer. If the peer aborts reads on the stream, ReadContext returns an error wrapping StreamResetCode.

func (*Stream) Reset added in v0.15.0

func (s *Stream) Reset(code uint64)

Reset aborts writes on the stream and notifies the peer that the stream was terminated abruptly. Any blocked writes will be unblocked and return errors.

Reset sends the application protocol error code, which must be less than 2^62, to the peer. It does not wait for the peer to acknowledge receipt of the error. Use CloseContext to wait for the peer's acknowledgement.

Reset does not affect reads. Use CloseRead to abort reads on the stream.

func (*Stream) Write added in v0.14.0

func (s *Stream) Write(b []byte) (n int, err error)

Write writes data to the stream. See WriteContext for more details.

func (*Stream) WriteContext added in v0.14.0

func (s *Stream) WriteContext(ctx context.Context, b []byte) (n int, err error)

WriteContext writes data to the stream.

WriteContext writes data to the stream write buffer. Buffered data is only sent when the buffer is sufficiently full. Call the Flush method to ensure buffered data is sent.

TODO: Implement Flush.

type StreamErrorCode added in v0.15.0

type StreamErrorCode uint64

A StreamErrorCode is an application protocol error code (RFC 9000, Section 20.2) indicating whay a stream is being closed.

func (StreamErrorCode) Error added in v0.15.0

func (e StreamErrorCode) Error() string

Jump to

Keyboard shortcuts

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