Documentation
¶
Index ¶
- type ClientConn
- type Conn
- func (c *Conn) Close() error
- func (c *Conn) LocalAddr() net.Addr
- func (c *Conn) ReadFrom(b []byte) (n int, addr net.Addr, err error)
- func (c *Conn) RemoteAddr() net.Addr
- func (c *Conn) SetDeadline(t time.Time) error
- func (c *Conn) SetReadDeadline(t time.Time) error
- func (c *Conn) SetWriteDeadline(time.Time) error
- func (c *Conn) WriteTo(p []byte, _ net.Addr) (n int, err error)
- type Proxy
- type ProxyRequest
- type ProxyRequestParseError
- type Request
- type Transport
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClientConn ¶ added in v0.4.0
type ClientConn struct {
// contains filtered or unexported fields
}
A ClientConn represents a connection to a single proxy server. Multiple proxied connections can be established over a single ClientConn.
func NewClientConn ¶ added in v0.6.0
func NewClientConn(conn *http3.ClientConn) *ClientConn
NewClientConn creates a client connection using an existing HTTP/3 connection. The HTTP/3 connection and its underlying QUIC connection must have datagrams enabled. The caller owns the HTTP/3 connection and can also use it for ordinary HTTP requests. Closing a Conn returned by ClientConn.Dial does not close the HTTP/3 connection.
type Conn ¶ added in v0.4.0
type Conn struct {
// contains filtered or unexported fields
}
func (*Conn) RemoteAddr ¶ added in v0.4.0
type Proxy ¶
type Proxy struct {
// contains filtered or unexported fields
}
A Proxy is an RFC 9298 CONNECT-UDP proxy.
func (*Proxy) Proxy ¶
func (s *Proxy) Proxy(w http.ResponseWriter, r *ProxyRequest) error
Proxy proxies a request on a newly created connected UDP socket. For more control over the UDP socket, use ProxyConnectedSocket. Applications may add custom header fields to the response header, but MUST NOT call WriteHeader on the http.ResponseWriter.
func (*Proxy) ProxyConnectedSocket ¶
func (s *Proxy) ProxyConnectedSocket(w http.ResponseWriter, _ *ProxyRequest, conn *net.UDPConn) error
ProxyConnectedSocket proxies a request on a connected UDP socket. Applications may add custom header fields such as Proxy-Status to the response header, but MUST NOT call WriteHeader on the http.ResponseWriter. It closes the connection before returning.
type ProxyRequest ¶ added in v0.4.0
ProxyRequest is the parsed CONNECT-UDP request returned from ParseProxyRequest. Target is the target server that the client requests to connect to. It can either be DNS name:port or an IP:port.
func ParseProxyRequest ¶ added in v0.4.0
func ParseProxyRequest(r *http.Request, template *uritemplate.Template) (*ProxyRequest, error)
ParseProxyRequest parses a CONNECT-UDP request. The template is the URI template that clients will use to configure this UDP proxy.
type ProxyRequestParseError ¶ added in v0.4.0
ProxyRequestParseError is returned from ParseProxyRequest if parsing the CONNECT-UDP request fails. It is recommended that the request is rejected with the corresponding HTTP status code.
func (*ProxyRequestParseError) Error ¶ added in v0.4.0
func (e *ProxyRequestParseError) Error() string
func (*ProxyRequestParseError) Unwrap ¶ added in v0.4.0
func (e *ProxyRequestParseError) Unwrap() error
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
Request is a CONNECT-UDP request created by NewRequest. The zero value is not valid.
func NewRequest ¶ added in v0.4.0
func NewRequest(ctx context.Context, proxyTemplate *uritemplate.Template, target string) (*Request, error)
NewRequest creates a CONNECT-UDP request for the given target. The target must be given as a host:port.
type Transport ¶ added in v0.4.0
type Transport struct {
// TLSClientConfig is the TLS client config used when dialing the QUIC connection to the proxy.
// It must set the "h3" ALPN.
TLSClientConfig *tls.Config
// QUICConfig is the QUIC config used when dialing the QUIC connection.
QUICConfig *quic.Config
// DialAddr dials the QUIC connection to the proxy.
// If unset, quic.DialAddr is used.
DialAddr func(ctx context.Context, addr string, tlsConf *tls.Config, quicConf *quic.Config) (*quic.Conn, error)
}
A Transport establishes proxied connections to multiple remote hosts.
func (*Transport) Dial ¶ added in v0.4.0
Dial is a shortcut that opens a QUIC connection to the proxy and then dials a proxied connection. Closing the returned Conn also closes the QUIC connection to the proxy. More advanced use cases, including multiple proxied connections via one proxy connection, should dial a new QUIC connection and use Transport.NewClientConn.
func (*Transport) NewClientConn ¶ added in v0.4.0
func (t *Transport) NewClientConn(conn *quic.Conn) (*ClientConn, error)
NewClientConn creates a client connection for an already established QUIC connection. It returns an error if the QUIC connection didn't negotiate datagram support. The caller owns the QUIC connection and closes it when done. To reuse an existing HTTP/3 connection, use NewClientConn.