# README
tor
The tor 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.
- Routing DNS queries over Tor (A, AAAA, SRV).
- Limited Tor Control functionality (synchronous messages only). So far, this
includes:
- Support for SAFECOOKIE, HASHEDPASSWORD, and NULL authentication methods.
- Creating v2 and v3 onion services.
In the future, the Tor Control functionality will be extended to support v3 onion services, asynchronous messages, etc.
Installation and Updating
$ go get -u github.com/lightningnetwork/lnd/tor
# Functions
Dial is a wrapper over the non-exported dial function that returns a wrapper around net.Conn in order to expose the actual remote address we're dialing, rather than the proxy's address.
DisableLog disables all library log output.
FakeIPToOnionHost turns a fake IPv6 address that encodes an Onion v2 address back into its onion host address representation.
IsOnionFakeIP checks whether a given net.Addr is a fake IPv6 address that encodes an Onion v2 address.
IsOnionHost determines whether a host is part of an onion address.
LookupHost performs DNS resolution on a given host via Tor's native resolver.
LookupSRV uses Tor's SOCKS proxy to route DNS SRV queries.
NewController returns a new Tor controller that will be able to interact with a Tor server.
NewOnionFile creates a file-based implementation of the OnionStore interface to store an onion service's private key.
OnionHostToFakeIP encodes an Onion v2 address into a fake IPv6 address that encodes the same information but can be used for libraries that operate on an IP address base only, like btcd's address manager.
ParseAddr parses an address from its string format to a net.Addr.
ResolveTCPAddr uses Tor's proxy to resolve TCP addresses instead of the standard system resolver provided in the `net` package.
UseLogger uses a specified Logger to output package logging info.
# Constants
DefaultConnTimeout is the maximum amount of time a dial will wait for a connect to complete.
MinTorVersion is the minimum supported version that the Tor server must be running on.
OnionSuffix is the ".onion" suffix for v2 and v3 onion addresses.
OnionSuffixLen is the length of the ".onion" suffix.
ProtocolInfoVersion is the `protocolinfo` version currently supported by the Tor server.
TORC as in Tor Controller.
V2 denotes that the onion service is V2.
V2DecodedLen is the length of a decoded v2 onion service.
V2KeyParam is a parameter that Tor accepts for a new V2 service.
V2Len is the length of a v2 onion service including the ".onion" suffix.
V3 denotes that the onion service is V3.
V3DecodedLen is the length of a decoded v3 onion service.
V3KeyParam is a parameter that Tor accepts for a new V3 service.
V3Len is the length of a v3 onion service including the ".onion" suffix.
# Variables
Base32Encoding represents the Tor's base32-encoding scheme for v2 and v3 onion addresses.
ErrEncryptedTorPrivateKey is thrown when a tor private key is encrypted, but the user requested an unencrypted key.
ErrNoPrivateKey is an error returned by the OnionStore.PrivateKey method when a private key hasn't yet been stored.
ErrNoServiceFound is used when the Tor daemon replies no active onion services found for the current control connection while we expect one.
ErrServiceIDMismatch is used when the serviceID the controller has doesn't match the serviceID the Tor daemon has.
ErrServiceNotCreated is used when we want to query info on an onion service while it's not been created yet.
# Structs
AddOnionConfig houses all of the required parameters in order to successfully create a new onion service or restore an existing one.
ClearNet is an implementation of the Net interface that defines behaviour for regular network connections.
Controller is an implementation of the Tor Control protocol.
OnionAddr represents a Tor network end point onion address.
OnionFile is a file-based implementation of the OnionStore interface that stores an onion service's private key.
ProxyNet is an implementation of the Net interface that defines behavior for Tor network connections.
# Interfaces
EncrypterDecrypter is used for encrypting and decrypting the onion service private key.
Net is an interface housing a Dial function and several DNS functions that allows us to abstract the implementations of these functions over different networks, e.g.
OnionStore is a store containing information about a particular onion service.