Documentation
¶
Index ¶
Constants ¶
const ( MIN_SPARE_H2_STREAMS = 20 ASSUMED_MAX_CONCURRENT_STREAMS = 100 MAX_RETRIES = 3 // Retry making a connection up to MAX_RETRIES times. LOW_LATENCY_MAX_CONCURRENT_STREAMS = 5 // Max concurrent streams on a low latency connection. )
Variables ¶
This section is empty.
Functions ¶
func StreamDataToDatagramChunk ¶
StreamDataToDatagramChunk converts UDP payload data to a CONNECT-UDP datagram chunk. This protocol is for tunneling a UDP stream via an HTTP proxy server. IETF draft: https://datatracker.ietf.org/doc/html/draft-ietf-masque-connect-udp-03 CONNECT-UDP datagram chunk is encoded in the format of T-L-V: T/Type: type; L/Length: data length; V/Value: data. |payload| is the UDP packet payload; |l| is the payload length. It returns the encoded chunk in a byte slice and its total length.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a MASQUE HTTP/2 client that supports HTTP CONNECT and CONNECT-UDP. All CONNECT requests are multiplexed using a HTTP/2 transport. Each CONNECT-UDP request is performed in HTTP/1.1 and sent individually via its own TLS connection. Any CONNECT or CONNECT-UDP requests that need HTTP/3 should not directly use this.
The tlsTimeout setting determines the duration the client waits when attempting to create a new TLS connection to the proxy. An error is returned if the connection is not ready to use within the specified tlsTimeout.
prot if not nil should be called before connect.
func NewClient ¶
func NewClient(config ClientConfig) *Client
NewClient creates a new Client instance with the provided parameters.
func (*Client) ConnectToProxy ¶
ConnectToProxy connects the Client to the proxy.
func (*Client) CreateTCPStream ¶
CreateTCPStream creates a TCP stream to the given address using the client. This function should ONLY be called after successfully calling ConnectToProxy.
If it succeeds, CreateTCPStream returns a Conn struct that provides a pair of I/O interfaces. Users can use the provided I/O interfaces to communicate with the target domain server in a way that is similar to a TCP socket's bytestream abstraction.
Otherwise, CreateTCPStream returns nil and indicates the error.
func (*Client) CreateUDPStream ¶
CreateUDPStream creates a UDP stream to the given address using the client.
This function should ONLY be called after calling |ConnectToProxy| successfully. If it succeeds, return a Conn struct that provides a pair of I/O interfaces. Users can then use the provided I/O interfaces to communicate with the target domain server in a way that is similar to an UDP datagram socket abstraction.
Otherwise, it returns nil and indicates the error. It refills the connection for the next call.
type ClientConfig ¶
type ClientConfig struct { ProxyAddr string AuthToken string Prot SocketProtector CertData []byte LowLatencyAddrs []string Logger *slog.Logger IgnoreCert bool }
ClientConfig is a configuration for a MASQUE client to be used to set the configuration of a new Client to be created.
type Conn ¶
type Conn struct { IoInc io.Writer IoOut io.ReadCloser // contains filtered or unexported fields }
Conn represents a HTTP CONNECT or CONNECT-UDP connection.
Each connection has a unique stream ID, specified by the |sid| field, and a pair of I/O handles, namely |IoInc| and |IoOut|, designed for sending and receiving data via the proxied TCP/UDP connection.
For CONNECT-UDP using HTTP/1.1, the |transport| field keeps track of the unique HTTP/1.1 TLS connection to the destination proxy server.
The |Alive| field indicates the liveness of the underlying CONNECT-UDP HTTP connection. Users should only send data through this proxied connection if |Alive| is true.
type SocketProtector ¶
SocketProtector is a type representing a function that overrides Android's VpnService.protect(). Android's VPN hooks are necessary to capture and redirect all of a phone's traffic through the MASQUE tunnel, but to avoid an infinite loop, the traffic sent to the MASQUE proxy needs to be exempted from that redirection. This function enables "protection" of the given file descriptor (the underlying system fd for the MASQUE tunnel) from Android's VPN.