http3

package
v0.0.0-...-d8d7169 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2024 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDatagramStreamClosed = fmt.Errorf("stream has been closed")

ErrDatagramStreamClosed is an error representing a failure where the DatagramStream is closed

Functions

This section is empty.

Types

type Client

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

Client is an object that should not be initialized manually. Please call NewClient() to get a correctly initialized client.

func NewClient

func NewClient(config ClientConfig) (*Client, error)

NewClient provides a method that returns a new Client object, creating a new http3.RoundTripper object dedicated to be used with the provided proxy address.

Note that proxyAddr is in ip:port format, where 'ip' may be a DNS address if desired. TODO: Find a way to disable congestion control on the QUIC connection (but not streams)

func (*Client) Close

func (c *Client) Close() error

Close closes a Client object. This will kill the datagram receiver loop, and any active stream objects.

func (*Client) CreateTCPStream

func (c *Client) CreateTCPStream(destAddr string) (quich3.Stream, error)

CreateTCPStream creates a TCP Stream through the proxy to the designated destination. Note that destAddr is in ip:port format, where ip CANNOT be a DNS address. This TCP stream is the responsibility of the caller to Close() properly.

func (*Client) CreateUDPStream

func (c *Client) CreateUDPStream(destAddr string) (*DatagramStream, error)

CreateUDPStream creates a UDP Stream through the proxy Also starts the receiver loop for datagrams if it hasn't already been started. Returns a DatagramStream object that becomes the responsibility of the caller to Close(). destAddr should be in ip:port format, where ip CANNOT be a DNS address.

type ClientConfig

type ClientConfig struct {
	// The proxy to connect to in host:port format.
	ProxyAddr string

	// Maximium number of incoming streams. Typically not an issue, as
	// the Client will not need to handle incoming connections.
	MaxIncomingStreams int64

	// Maximum time to keep a proxy stream idle. Defaults to 10 minutes.
	MaxIdleTimeout time.Duration

	// Timeout for the HTTP client to initally connect to the server.
	// If a response is not received by the time this occurs, the connection will break.
	// Defaults to 10 seconds.
	ConnectTimeout time.Duration

	// Authorization token string to pass in a Proxy-Authorization header when
	// connecting to a proxy server. Note that the token is formatted into the header
	// automatically; it is not necessary to provide the full value-string that
	// would appear in an HTTP header.
	AuthToken string

	// Pinned cert bytes
	CertData []byte

	// Set to true to ignore invalid/unverifiable certs provided by the proxy server.
	// Note that if UseCertSideLoader is true, this value is irrelevant after a
	// cert file has been loaded with LoadNewCert().
	Insecure bool

	Logger *slog.Logger
}

ClientConfig is options to give when creating a new Client with NewClient(). Note that sane defaults are used when value is not provided/initialized.

type DatagramStream

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

DatagramStream is an object for Proxied UDP Streams that implements I/O functionality. This object contains information necessary to communicate with the Client message receiver loop.

Read/Write on a DatagramStream works as expected, though note it will use Datagram framing semantics (each block is an individual UDP packet).

It is important that the caller DO NOT close the quic.Stream OR the quic.Connection object that is given inside of the struct.

func (*DatagramStream) Close

func (s *DatagramStream) Close() error

Close closes a DatagramStream, returning its flow ID to the pool by calling its closeTrigger().

func (*DatagramStream) Read

func (s *DatagramStream) Read(b []byte) (int, error)

Read reads from a datagram stream. Blocks if no data is available. If the provided []byte slice is not large enough for the message, it will be truncated and the remainder dropped.

func (*DatagramStream) Write

func (s *DatagramStream) Write(b []byte) (int, error)

Write writes to a datagram stream. May block if the stream buffer is full. Note that this function requires prepending 1 to 9 bytes to send the datagram: this means that the MTU size of the connection will be below what the caller may expect.

Jump to

Keyboard shortcuts

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