proxier

package module
v0.0.0-...-b55fe15 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2023 License: MIT Imports: 11 Imported by: 2

Documentation

Overview

Package proxier provides a implementation of an HTTP client and proxy server using the net/http package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewUTLSRoundTripper

func NewUTLSRoundTripper(opts ...UTLSOption) (http.RoundTripper, error)

NewUTLSRoundTripper creates a new round tripper that can be used in an HTTP client to handle secure connections using the UTLS protocol.

It takes an optional list of `UTLSOption` arguments that can be used to customize the behavior of the round tripper. It returns an `http.RoundTripper` and an error.

func ProxyHTTP

func ProxyHTTP(network, addr string, auth *proxy.Auth, forward proxy.Dialer) (*httpProxy, error)

func ProxyHTTPS

func ProxyHTTPS(network, addr string, auth *proxy.Auth, forward proxy.Dialer, cfg *utls.Config, clientHelloID *utls.ClientHelloID) (*httpProxy, error)

Types

type Client

type Client struct {
	*http.Client
}

The Client struct wraps an http.Client and provides a higher-level interface for making HTTP requests. It can be used to customize the behavior of the client, such as specify timeouts.

func NewClient

func NewClient(client *http.Client) *Client

NewClient returns a new instance of the Client struct with the specified HTTP client. If no client is provided as an argument, a default client with a default timeout value is created. This function is a constructor method and returns a pointer to the new Client instance.

type Server

type Server struct {
}

func (*Server) Serve

func (s *Server) Serve()

type UTLS

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

UTLS represents a uTLS struct.

func UTLSOptions

func UTLSOptions(options ...UTLSOption) UTLS

Options takes one or more UTLSOptions and returns a UTLS struct has been configured according to those options.

type UTLSDialer

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

func (*UTLSDialer) Dial

func (dialer *UTLSDialer) Dial(network, addr string) (net.Conn, error)

type UTLSOption

type UTLSOption func(*UTLS)

UTLSOption is a function type that modifies a UTLS struct by setting one of its fields.

func ClientHello

func ClientHello(ch *utls.ClientHelloID) UTLSOption

ClientHello sets the clientHello field of a UTLS struct to the given clientHello.

func Config

func Config(c *utls.Config) UTLSOption

Config sets the utls config field of a UTLS struct to the given config.

func Proxy

func Proxy(p interface{}) UTLSOption

Proxy sets the proxy field of a UTLS struct to the given proxy.

type UTLSRoundTripper

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

A http.RoundTripper that uses uTLS (with a specified Client Hello ID) to make TLS connections.

Can only be reused among servers which negotiate the same ALPN.

func (*UTLSRoundTripper) Dialer

func (u *UTLSRoundTripper) Dialer() proxy.Dialer

Dialer returns the underlying *net.Dialer used by the UTLSRoundTripper's proxyDialer. This method is useful for accessing additional properties of the dialer, such as its proxy settings.

func main() {
	dialer := UTLSRoundTripper.Dialer()
	conn, err := dialer.Dial("tcp", "example.com:443")
	if err != nil {
		panic(err)
	}
	// Optional to wraps conn to a tls client for tls transport.
	conn = tls.Client(conn, &tls.Config{ServerName: "example.com"})

	// ...
}

func (*UTLSRoundTripper) RoundTrip

func (u *UTLSRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip executes a single HTTP transaction, using the UTLS protocol for secure connections. It takes an `http.Request` and returns an `http.Response` and an error. This method is used in an HTTP client to send a request and receive a response.

Jump to

Keyboard shortcuts

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