quicutil

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2022 License: Apache-2.0 Imports: 16 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// SingleStreamProto is a quic application layer protocol that transports
	// an opaque, bi-directional data stream using quic. This is intended as a
	// drop-in replacement for TCP.
	//
	// This is more fiddly than perhaps expected because quic-go does not _currently_
	// have any API that allows to wait until the send buffer is drained and save
	// shutdown (of the UDP socket, or the application) is possible.
	// See https://github.com/lucas-clemente/quic-go/issues/3291.
	// TODO: simplify this once possible (as a protocol breaking change)
	//
	// The "protocol" is:
	//  - each peer opens a unidirectional stream for sending data
	//  - once the data was read in full (i.e. the FIN frame was received, EOF
	//    condition on the stream), we explicitly signal this to the peer.
	//    The signal is opening and directly closing a second unidirectional
	//    stream.
	SingleStreamProto = "qs"
)

Functions

func GenerateSelfSignedCert

func GenerateSelfSignedCert() (*tls.Certificate, error)

GenerateSelfSignedCert generates a private key and a self-signed dummy certificate usable for TLS with InsecureSkipVerify: true

func MustGenerateSelfSignedCert

func MustGenerateSelfSignedCert() []tls.Certificate

MustGenerateSelfSignedCert generates private key and a self-signed dummy certificate usable for TLS with InsecureSkipVerify: true. Like GenerateSelfSignedCert but panics on error and returns a slice with a single entry, for convenience when initializing a tls.Config structure.

Types

type SingleStream

type SingleStream struct {
	Session quic.Session
	// contains filtered or unexported fields
}

SingleStream implements an opaque, bi-directional data stream using QUIC, intending to be a drop-in replacement for TCP. A SingleStream is either created by

  • on the client side: quic.Dial and then immediately NewSingleStream(sess) with the obtained session
  • on the listener side: quic.Listener wrapped in SingleStreamListener, which returns SingleStream from Accept.

func NewSingleStream

func NewSingleStream(session quic.Session) (*SingleStream, error)

func (*SingleStream) Close

func (s *SingleStream) Close() error

func (*SingleStream) CloseRead

func (s *SingleStream) CloseRead() error

CloseRead aborts receiving on this stream. It will ask the peer to stop transmitting stream data. This is analogous e.g. to net.TCPConn.CloseRead.

func (*SingleStream) CloseSync

func (s *SingleStream) CloseSync(ctx context.Context) error

func (*SingleStream) CloseWrite

func (s *SingleStream) CloseWrite() error

CloseWrite closes the stream for writing. This is analogous e.g. to net.TCPConn.CloseWrite

func (*SingleStream) LocalAddr

func (s *SingleStream) LocalAddr() net.Addr

func (*SingleStream) Read

func (s *SingleStream) Read(p []byte) (int, error)

func (*SingleStream) RemoteAddr

func (s *SingleStream) RemoteAddr() net.Addr

func (*SingleStream) SetDeadline

func (s *SingleStream) SetDeadline(t time.Time) error

func (*SingleStream) SetReadDeadline

func (s *SingleStream) SetReadDeadline(t time.Time) error

func (*SingleStream) SetWriteDeadline

func (s *SingleStream) SetWriteDeadline(t time.Time) error

func (*SingleStream) Write

func (s *SingleStream) Write(p []byte) (int, error)

type SingleStreamListener

type SingleStreamListener struct {
	quic.Listener
}

SingleStreamListener is a wrapper for a quic.Listener, returning SingleStream connections from Accept. This allows to use quic in contexts where a (TCP-)net.Listener is expected.

func (SingleStreamListener) Accept

func (l SingleStreamListener) Accept() (net.Conn, error)

Jump to

Keyboard shortcuts

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