dialer

package
v1.62.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: MPL-2.0 Imports: 3 Imported by: 1

Documentation

Index

Examples

Constants

This section is empty.

Variables

View Source
var Default = &net.Dialer{}

Used by wrappers of standard library network types.

Functions

This section is empty.

Types

type Socks5 added in v1.62.0

type Socks5 struct {
	// Address of the SOCKS5 proxy, such as "127.0.0.1:1080".
	Addr string
	// Optional username/password credentials for the proxy.
	Auth *proxy.Auth
	// The dialer used to connect to the proxy itself. Defaults to
	// connecting directly.
	Forward T
}

Socks5 dials through a SOCKS5 proxy server (RFC 1928/1929).

func NewSocks5 added in v1.62.0

func NewSocks5(proxyAddr string, auth *proxy.Auth) *Socks5

NewSocks5 returns a dialer that routes connections through the SOCKS5 proxy at proxyAddr. An auth of nil connects without credentials.

Example
d := NewSocks5("localhost:1080", nil)
// The dialer can be added to a client for outgoing peer connections:
// cl.AddDialer(d)
_ = d

func (*Socks5) Dial added in v1.62.0

func (me *Socks5) Dial(ctx context.Context, addr string) (net.Conn, error)

func (*Socks5) DialerNetwork added in v1.62.0

func (me *Socks5) DialerNetwork() string

type T

type T interface {
	Dial(_ context.Context, addr string) (net.Conn, error)
	DialerNetwork() string
}

Dialers have the network locked in.

type WithContext

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

An interface to ease wrapping dialers that explicitly include a network parameter.

type WithNetwork

type WithNetwork struct {
	Network string
	Dialer  WithContext
}

Adapts a WithContext to the Dial interface in this package.

func (WithNetwork) Dial

func (me WithNetwork) Dial(ctx context.Context, addr string) (_ net.Conn, err error)

func (WithNetwork) DialerNetwork

func (me WithNetwork) DialerNetwork() string

Jump to

Keyboard shortcuts

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