socks

package
v0.22.4 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: ISC Imports: 7 Imported by: 0

Documentation

Overview

Package socks dials connections through a SOCKS5 proxy such as Tor.

It wraps golang.org/x/net/proxy and keeps the behavior bchd relied on from github.com/btcsuite/go-socks:

  • A connection reports the requested destination as its remote address, and the address the proxy bound for it as its local address, rather than the addresses of the connection to the proxy.
  • With Tor stream isolation, every connection authenticates with new random credentials, so Tor puts it on a circuit of its own.
  • Destinations are sent to the proxy unresolved, so the proxy resolves hostnames, including onion addresses.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ProxiedAddr

type ProxiedAddr struct {
	Net  string
	Host string
	Port int
}

ProxiedAddr is the address of a connection made through a proxy. Host may be a hostname, such as an onion address, since the proxy resolves it.

func (*ProxiedAddr) Network

func (a *ProxiedAddr) Network() string

Network returns the network of the address, such as "tcp".

func (*ProxiedAddr) String

func (a *ProxiedAddr) String() string

String returns the address in host:port form.

type Proxy

type Proxy struct {
	// Addr is the host:port address of the proxy.
	Addr string

	// Username and Password are the credentials for the proxy, if it
	// requires them.  They are ignored when TorIsolation is set.
	Username string
	Password string

	// TorIsolation makes every connection authenticate with new random
	// credentials, which Tor uses to isolate it on a circuit of its own.
	TorIsolation bool
}

Proxy dials connections through a SOCKS5 proxy.

func (*Proxy) Dial

func (p *Proxy) Dial(network, addr string) (net.Conn, error)

Dial connects to addr through the proxy.

func (*Proxy) DialContext

func (p *Proxy) DialContext(ctx context.Context, network,
	addr string) (net.Conn, error)

DialContext connects to addr through the proxy. The network is "tcp", "tcp4", "tcp6" or "onion", which bchd uses for onion addresses. The context covers both connecting to the proxy and the SOCKS handshake.

func (*Proxy) DialTimeout

func (p *Proxy) DialTimeout(network, addr string,
	timeout time.Duration) (net.Conn, error)

DialTimeout is like Dial, but gives up after timeout, which covers both connecting to the proxy and the SOCKS handshake. A zero timeout means no timeout.

Jump to

Keyboard shortcuts

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