proxy

package module
v0.0.0-...-5af7f74 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2021 License: MIT Imports: 18 Imported by: 1

README

proxy

A Go library based on golang.org/x/net/proxy.

Documentation

Overview

Package proxy is a library based on golang.org/x/net/proxy.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dial

func Dial(ctx context.Context, d Dialer, network, addr string) (net.Conn, error)

Dial works like DialContext on Dialer with a fallback in case provided Dialer is not a ContextDialer.

The passed ctx is only used for returning the Conn, not the lifetime of the Conn.

Custom dialers (registered via RegisterDialerType) that do not implement ContextDialer can leak a goroutine for as long as it takes the underlying Dialer implementation to timeout.

func RegisterDialerType

func RegisterDialerType(scheme string, f func(*url.URL, Dialer) (Dialer, error))

RegisterDialerType takes a URL scheme and a function to generate Dialers from a URL with that scheme and a forwarding Dialer. Registered schemes are used by FromURL.

Types

type ContextDialer

type ContextDialer interface {
	DialContext(ctx context.Context, network, addr string) (net.Conn, error)
}

A ContextDialer dials using a context.

type Dialer

type Dialer interface {
	Dial(network, addr string) (net.Conn, error)
}

A Dialer is a means to establish a connection. Custom dialers should also implement ContextDialer.

var Direct Dialer = proxy_Direct

Direct implements Dialer by making network connections directly using net.Dial or net.DialContext.

func FromEnvironment

func FromEnvironment() Dialer

FromEnvironment returns the dialer specified by the proxy-related variables in the environment and makes underlying connections directly.

func FromEnvironmentUsing

func FromEnvironmentUsing(forward Dialer) Dialer

FromEnvironmentUsing returns the dialer specify by the proxy-related variables in the environment and makes underlying connections using the provided forwarding Dialer (for instance, a *net.Dialer with desired configuration).

func FromURL

func FromURL(u *url.URL, forward Dialer) (Dialer, error)

FromURL returns a Dialer given a URL specification and an underlying Dialer for it to make network requests.

Directories

Path Synopsis
Package loadbalance provides load balancing over Dialers.
Package loadbalance provides load balancing over Dialers.
strategy/failover
Package failover provides a load balancing strategy that it tries to pick a reliable Dialer out of many.
Package failover provides a load balancing strategy that it tries to pick a reliable Dialer out of many.
strategy/random
Package random provides a load balancing strategy that randomly picks one Dialer out of many.
Package random provides a load balancing strategy that randomly picks one Dialer out of many.
strategy/roundrobin
Package roundrobin provides a load balancing strategy that cyclically picks one Dialer out of many.
Package roundrobin provides a load balancing strategy that cyclically picks one Dialer out of many.

Jump to

Keyboard shortcuts

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