Documentation
¶
Index ¶
- Constants
- Variables
- func BuildMasquePath(host string, port int) string
- func ParseMasquePath(path string) (host string, port int, err error)
- type DatagramConn
- func (c *DatagramConn) Close() error
- func (c *DatagramConn) LocalAddr() net.Addr
- func (c *DatagramConn) Read(b []byte) (n int, err error)
- func (c *DatagramConn) ReadFrom(b []byte) (n int, addr net.Addr, err error)
- func (c *DatagramConn) RemoteAddr() net.Addr
- func (c *DatagramConn) SetDeadline(t time.Time) error
- func (c *DatagramConn) SetReadDeadline(t time.Time) error
- func (c *DatagramConn) SetWriteDeadline(t time.Time) error
- func (c *DatagramConn) Write(b []byte) (n int, err error)
- func (c *DatagramConn) WriteTo(b []byte, addr net.Addr) (n int, err error)
- type DatagramStreamer
- type StreamConn
- func (c *StreamConn) Close() error
- func (c *StreamConn) LocalAddr() net.Addr
- func (c *StreamConn) Read(b []byte) (n int, err error)
- func (c *StreamConn) RemoteAddr() net.Addr
- func (c *StreamConn) SetDeadline(t time.Time) error
- func (c *StreamConn) SetReadDeadline(t time.Time) error
- func (c *StreamConn) SetWriteDeadline(t time.Time) error
- func (c *StreamConn) Write(b []byte) (n int, err error)
- type StreamReadWriter
Constants ¶
const (
// WellKnownPath is the well-known path prefix for MASQUE UDP proxying
WellKnownPath = "/.well-known/masque/udp/"
)
Variables ¶
var ( ErrInvalidPath = errors.New("masque: invalid path template") ErrInvalidPort = errors.New("masque: invalid port number") )
Functions ¶
func BuildMasquePath ¶
BuildMasquePath constructs a MASQUE UDP proxy path from host and port.
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 ¶
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.
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) 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.
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.