webt

package
v0.0.0-...-efdb145 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2025 License: Apache-2.0 Imports: 22 Imported by: 1

README

This is a quic-based transport that establishes a WebTransport session over HTTP/3.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListenAddr

func ListenAddr(options *ListenOptions) (net.Listener, error)

ListenAddr creates an HTTP/3 server listening on a given address. The net.Conn instances returned by the net.Listener may be multiplexed connections.

func NewClient

func NewClient(config *ClientOptions) *client

NewClient returns a client that creates multiplexed WebTransport based sessions

func NewConn

func NewConn(stream webtransport.Stream, session *webtransport.Session, res *http.Response, onClose streamClosedFn) net.Conn

NewConn creates a new net.Conn from a webtransport.Stream, session, and http.Response

Types

type ClientOptions

type ClientOptions struct {
	Addr       string
	Path       string
	TLSConfig  *tls.Config
	QUICConfig *quic.Config
	PinnedCert *x509.Certificate
}

type DatagramChunker

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

DatagramChunker handles chunking and reassemly of datagram payloads

func NewDatagramChunker

func NewDatagramChunker() *DatagramChunker

NewDatagramChunker creates a new ChunkedDatagramHandler that handles chunking and reassembly of datagram payloads

func (*DatagramChunker) Chunk

func (dc *DatagramChunker) Chunk(p []byte) [][]byte

Chunk splits a message into datagram chunks to be sent over the wire

func (*DatagramChunker) Close

func (dc *DatagramChunker) Close()

Close disposes of the instance. After calling Close() the instance can not be used anymore

func (*DatagramChunker) Read

func (dc *DatagramChunker) Read() ([]byte, error)

Read returns the complete/assembled message

func (*DatagramChunker) Receive

func (dc *DatagramChunker) Receive(data []byte)

Receive processes a datagram chunk, assembles them, and queues complete messages that will be returned from Read()

type ListenOptions

type ListenOptions struct {
	Addr       string
	Path       string
	TLSConfig  *tls.Config
	QUICConfig *quic.Config
	Handler    *http.ServeMux
	// DatagramHandler is an optional datagram handler that will be called when a new WebTransport session is created
	// It will be called with a net.PacketConn that wraps the WebTransport session, and with the remote address
	DatagramHandler func(pconn net.PacketConn, remoteAddr net.Addr)
}

Jump to

Keyboard shortcuts

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