torsvc

package
v0.4.2-beta Latest Latest
Warning

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

Go to latest
Published: May 29, 2018 License: MIT Imports: 7 Imported by: 0

README

torsvc

The torsvc package contains utility functions that allow for interacting with the Tor daemon. So far, supported functions include routing all traffic over Tor's exposed socks5 proxy and routing DNS queries over Tor (A, AAAA, SRV). In the future more features will be added: automatic setup of v2 hidden service functionality, control port functionality, and handling manually setup v3 hidden services.

Installation and Updating

$ go get -u github.com/lightningnetwork/lnd/torsvc

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TorDial

func TorDial(address, socksPort string, streamIsolation bool) (net.Conn, error)

TorDial returns a connection to a remote peer via Tor's socks proxy. Only TCP is supported over Tor. The final argument determines if we should force stream isolation for this new connection. If we do, then this means this new connection will use a fresh circuit, rather than possibly re-using an existing circuit.

func TorLookupHost

func TorLookupHost(host, socksPort string) ([]string, error)

TorLookupHost performs DNS resolution on a given hostname via Tor's native resolver. Only IPv4 addresses are returned.

func TorLookupSRV

func TorLookupSRV(service, proto, name, socksPort, dnsServer string) (string,
	[]*net.SRV, error)

TorLookupSRV uses Tor's socks proxy to route DNS SRV queries. Tor does not natively support SRV queries so we must route all SRV queries THROUGH the Tor proxy and connect directly to a DNS server and query it. NOTE: TorLookupSRV uses golang's proxy package since go-socks will cause the SRV request to hang.

func TorResolveTCP

func TorResolveTCP(address, socksPort string) (*net.TCPAddr, error)

TorResolveTCP uses Tor's proxy to resolve TCP addresses instead of the system resolver that ResolveTCPAddr and related functions use. Only TCP resolution is supported.

Types

type Net

type Net interface {
	// Dial accepts a network and address and returns a connection to a remote
	// peer.
	Dial(string, string) (net.Conn, error)

	// LookupHost performs DNS resolution on a given hostname and returns
	// addresses of that hostname
	LookupHost(string) ([]string, error)

	// LookupSRV allows a service and network to be specified and makes queries
	// to a given DNS server for SRV queries.
	LookupSRV(string, string, string) (string, []*net.SRV, error)

	// ResolveTCPAddr is a used to resolve publicly advertised TCP addresses.
	ResolveTCPAddr(string, string) (*net.TCPAddr, error)
}

Net is an interface housing a Dial function and several DNS functions, to abstract the implementation of these functions over both Regular and Tor

type RegularNet

type RegularNet struct{}

RegularNet is an implementation of the Net interface that defines behaviour for Regular network connections

func (*RegularNet) Dial

func (r *RegularNet) Dial(network, address string) (net.Conn, error)

Dial on the regular network uses net.Dial

func (*RegularNet) LookupHost

func (r *RegularNet) LookupHost(host string) ([]string, error)

LookupHost for regular network uses the net.LookupHost function

func (*RegularNet) LookupSRV

func (r *RegularNet) LookupSRV(service, proto, name string) (string, []*net.SRV, error)

LookupSRV for regular network uses net.LookupSRV function

func (*RegularNet) ResolveTCPAddr

func (r *RegularNet) ResolveTCPAddr(network, address string) (*net.TCPAddr, error)

ResolveTCPAddr for regular network uses net.ResolveTCPAddr function

type TorProxyNet

type TorProxyNet struct {
	// TorDNS is the IP:PORT of the DNS server for Tor to use for SRV queries
	TorDNS string

	// TorSocks is the port which Tor's exposed SOCKS5 proxy is listening on.
	// This is used for an outbound-only mode, so the node will not listen for
	// incoming connections
	TorSocks string

	// StreamIsolation is a bool that determines if we should force the
	// creation of a new circuit for this connection. If true, then this
	// means that our traffic may be harder to correlate as each connection
	// will now use a distinct circuit.
	StreamIsolation bool
}

TorProxyNet is an implementation of the Net interface that defines behaviour for Tor network connections

func (*TorProxyNet) Dial

func (t *TorProxyNet) Dial(network, address string) (net.Conn, error)

Dial on the Tor network uses the torsvc TorDial() function, and requires that network specified be tcp because only that is supported

func (*TorProxyNet) LookupHost

func (t *TorProxyNet) LookupHost(host string) ([]string, error)

LookupHost on Tor network uses the torsvc TorLookupHost function.

func (*TorProxyNet) LookupSRV

func (t *TorProxyNet) LookupSRV(service, proto, name string) (string, []*net.SRV, error)

LookupSRV on Tor network uses the torsvc TorLookupHost function.

func (*TorProxyNet) ResolveTCPAddr

func (t *TorProxyNet) ResolveTCPAddr(network, address string) (*net.TCPAddr, error)

ResolveTCPAddr on Tor network uses the towsvc TorResolveTCP function, and requires network to be "tcp" because only "tcp" is supported

Jump to

Keyboard shortcuts

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