masque

package
v0.28.2 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: MIT Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// WellKnownPath is the well-known path prefix for MASQUE UDP proxying
	WellKnownPath = "/.well-known/masque/udp/"
)

Variables

View Source
var (
	ErrInvalidPath = errors.New("masque: invalid path template")
	ErrInvalidPort = errors.New("masque: invalid port number")
)

Functions

func BuildMasquePath

func BuildMasquePath(host string, port int) string

BuildMasquePath constructs a MASQUE UDP proxy path from host and port.

func ParseMasquePath

func ParseMasquePath(path string) (host string, port int, err error)

ParseMasquePath parses a MASQUE UDP proxy path template. The expected format is: /.well-known/masque/udp/{host}/{port}/ Returns the host and port extracted from the path.

Types

type DatagramConn

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

DatagramConn wraps an HTTP/3 stream's datagram methods as net.PacketConn. This allows UDP packets to be tunneled over HTTP/3 datagrams per RFC 9297/9298.

func NewDatagramConn

func NewDatagramConn(stream *http3.Stream, laddr, raddr net.Addr) *DatagramConn

NewDatagramConn creates a new DatagramConn wrapping an HTTP/3 stream.

func NewDatagramConnFromRequestStream

func NewDatagramConnFromRequestStream(stream *http3.RequestStream, laddr, raddr net.Addr) *DatagramConn

NewDatagramConnFromRequestStream creates a new DatagramConn wrapping an HTTP/3 request stream. This is used by the client-side connector. The stream will be closed when Close() is called.

func (*DatagramConn) Close

func (c *DatagramConn) Close() error

Close closes the datagram connection and the underlying stream. It also cancels the read context so a goroutine blocked in ReadFrom is released.

func (*DatagramConn) LocalAddr

func (c *DatagramConn) LocalAddr() net.Addr

LocalAddr returns the local network address.

func (*DatagramConn) Read

func (c *DatagramConn) Read(b []byte) (n int, err error)

Read reads data from the connection (net.Conn interface).

func (*DatagramConn) ReadFrom

func (c *DatagramConn) ReadFrom(b []byte) (n int, addr net.Addr, err error)

ReadFrom reads a UDP datagram from the HTTP/3 stream. Per RFC 9297, HTTP datagrams have a context ID prefix. For CONNECT-UDP (RFC 9298), the context ID is 0.

func (*DatagramConn) RemoteAddr

func (c *DatagramConn) RemoteAddr() net.Addr

RemoteAddr returns the remote network address.

func (*DatagramConn) SetDeadline

func (c *DatagramConn) SetDeadline(t time.Time) error

SetDeadline sets the read and write deadlines.

func (*DatagramConn) SetReadDeadline

func (c *DatagramConn) SetReadDeadline(t time.Time) error

SetReadDeadline sets the read deadline.

func (*DatagramConn) SetWriteDeadline

func (c *DatagramConn) SetWriteDeadline(t time.Time) error

SetWriteDeadline sets the write deadline. Note: Write deadlines are not used for HTTP/3 datagrams as SendDatagram is non-blocking.

func (*DatagramConn) Write

func (c *DatagramConn) Write(b []byte) (n int, err error)

Write writes data to the connection (net.Conn interface).

func (*DatagramConn) WriteTo

func (c *DatagramConn) WriteTo(b []byte, addr net.Addr) (n int, err error)

WriteTo sends a UDP datagram via the HTTP/3 stream. Per RFC 9297, we prepend the context ID (0x00 for CONNECT-UDP).

type DatagramStreamer

type DatagramStreamer interface {
	SendDatagram(b []byte) error
	ReceiveDatagram(ctx context.Context) ([]byte, error)
}

DatagramStreamer is an interface for sending and receiving HTTP/3 datagrams. Both http3.Stream and http3.RequestStream implement this interface.

type StreamConn

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

StreamConn wraps an HTTP/3 stream as net.Conn for TCP tunneling (RFC 9114). Unlike DatagramConn which uses HTTP/3 datagrams, StreamConn reads/writes directly to the HTTP/3 stream body for reliable, ordered byte streams.

func NewStreamConn

func NewStreamConn(stream *http3.Stream, laddr, raddr net.Addr) *StreamConn

NewStreamConn creates a new StreamConn wrapping an HTTP/3 stream (server-side). This is used for TCP CONNECT tunneling where data flows through the stream body.

func NewStreamConnFromRequestStream

func NewStreamConnFromRequestStream(stream *http3.RequestStream, laddr, raddr net.Addr) *StreamConn

NewStreamConnFromRequestStream creates a new StreamConn wrapping an HTTP/3 request stream (client-side). This is used for TCP CONNECT tunneling where data flows through the stream body.

func (*StreamConn) Close

func (c *StreamConn) Close() error

Close closes the stream connection.

func (*StreamConn) LocalAddr

func (c *StreamConn) LocalAddr() net.Addr

LocalAddr returns the local network address.

func (*StreamConn) Read

func (c *StreamConn) Read(b []byte) (n int, err error)

Read reads data from the HTTP/3 stream body.

func (*StreamConn) RemoteAddr

func (c *StreamConn) RemoteAddr() net.Addr

RemoteAddr returns the remote network address.

func (*StreamConn) SetDeadline

func (c *StreamConn) SetDeadline(t time.Time) error

SetDeadline sets the read and write deadlines.

func (*StreamConn) SetReadDeadline

func (c *StreamConn) SetReadDeadline(t time.Time) error

SetReadDeadline sets the read deadline.

func (*StreamConn) SetWriteDeadline

func (c *StreamConn) SetWriteDeadline(t time.Time) error

SetWriteDeadline sets the write deadline.

func (*StreamConn) Write

func (c *StreamConn) Write(b []byte) (n int, err error)

Write writes data to the HTTP/3 stream body.

type StreamReadWriter

type StreamReadWriter interface {
	io.Reader
	io.Writer
	io.Closer
	SetDeadline(t time.Time) error
	SetReadDeadline(t time.Time) error
	SetWriteDeadline(t time.Time) error
}

StreamReadWriter is an interface for reading and writing to HTTP/3 streams. Both http3.Stream and http3.RequestStream implement this interface.

Jump to

Keyboard shortcuts

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