proxy

package
v0.0.0-...-656f817 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2022 License: Apache-2.0 Imports: 19 Imported by: 2

Documentation

Overview

Package proxy provides support for a variety of protocols to proxy network data.

Index

Constants

This section is empty.

Variables

View Source
var (
	CRLF     = []byte{0x0d, 0x0a}
	CRLFCRLF = []byte{0x0d, 0x0a, 0x0d, 0x0a}
)
View Source
var Direct = direct{}

Direct is a direct proxy: one that makes network connections directly.

View Source
var DummyResolver = dummyResolver{}

Direct is a direct proxy: one that makes network connections directly.

Functions

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 Auth

type Auth struct {
	User, Password string
}

Auth contains authentication parameters that specific Dialers may require.

type Dialer

type Dialer interface {
	// Dial connects to the given address via the proxy.
	Dial(network, addr string) (c net.Conn, err error)
}

A Dialer is a means to establish a connection.

func FromEnvironment

func FromEnvironment() Dialer

FromEnvironment returns the dialer specified by the proxy related variables in the environment.

func FromURL

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

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

func HTTP1

func HTTP1(network, addr string, auth *Auth, forward Dialer, resolver Resolver) (Dialer, error)

func HTTP2

func HTTP2(network, addr string, auth *Auth, forward Dialer, resolver Resolver) (Dialer, error)

func HTTPS

func HTTPS(network, addr string, auth *Auth, forward Dialer, resolver Resolver) (Dialer, error)

func SOCKS4

func SOCKS4(network, addr string, is4a bool, forward Dialer, resolver Resolver) (Dialer, error)

SOCKS4 returns a Dialer that makes SOCKSv4 connections to the given address

func SOCKS5

func SOCKS5(network, addr string, auth *Auth, forward Dialer, resolver Resolver) (Dialer, error)

SOCKS5 returns a Dialer that makes SOCKSv5 connections to the given address with an optional username and password. See RFC 1928.

func SSH2

func SSH2(network, addr string, auth *Auth, forward Dialer, resolver Resolver, opts ...SSH2Option) (Dialer, error)

type PerHost

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

A PerHost directs connections to a default Dialer unless the hostname requested matches one of a number of exceptions.

func NewPerHost

func NewPerHost(defaultDialer, bypass Dialer) *PerHost

NewPerHost returns a PerHost Dialer that directs connections to either defaultDialer or bypass, depending on whether the connection matches one of the configured rules.

func (*PerHost) AddFromString

func (p *PerHost) AddFromString(s string)

AddFromString parses a string that contains comma-separated values specifying hosts that should use the bypass proxy. Each value is either an IP address, a CIDR range, a zone (*.example.com) or a hostname (localhost). A best effort is made to parse the string and errors are ignored.

func (*PerHost) AddHost

func (p *PerHost) AddHost(host string)

AddHost specifies a hostname that will use the bypass proxy.

func (*PerHost) AddIP

func (p *PerHost) AddIP(ip net.IP)

AddIP specifies an IP address that will use the bypass proxy. Note that this will only take effect if a literal IP address is dialed. A connection to a named host will never match an IP.

func (*PerHost) AddNetwork

func (p *PerHost) AddNetwork(net *net.IPNet)

AddNetwork specifies an IP range that will use the bypass proxy. Note that this will only take effect if a literal IP address is dialed. A connection to a named host will never match.

func (*PerHost) AddZone

func (p *PerHost) AddZone(zone string)

AddZone specifies a DNS suffix that will use the bypass proxy. A zone of "example.com" matches "example.com" and all of its subdomains.

func (*PerHost) Dial

func (p *PerHost) Dial(network, addr string) (c net.Conn, err error)

Dial connects to the address addr on the given network through either defaultDialer or bypass.

type Resolver

type Resolver interface {
	LookupHost(host string) (addrs []string, err error)
}

A Resolver is a means to transform hostname.

type SSH2Option

type SSH2Option func(*ssh2) error

func SSH2WithKnownHosts

func SSH2WithKnownHosts(hostFiles ...string) SSH2Option

func SSH2WithPublicKeys

func SSH2WithPublicKeys(keys ...string) SSH2Option

func SSH2WithSkipKnownHosts

func SSH2WithSkipKnownHosts() SSH2Option

Jump to

Keyboard shortcuts

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