tor

package
v1.2.28 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: AGPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrOnionAlreadyRunning = errors.New("onion already running")
	ErrOnionNotRunning     = errors.New("onion not running")
	ErrOnionInvalidKey     = errors.New("invalid onion key")
	ErrOnionInvalidKeyType = errors.New("invalid onion key type")
	ErrOnionKeyInvalidSize = errors.New("invalid onion key size")
	ErrOnionKeyExists      = errors.New("onion private key already exists")
	ErrOnionMissingKey     = errors.New("missing private key for onion")
	ErrOnionInvalidKeySpec = errors.New("invalid private key specification")
	ErrOnionAddFailed      = errors.New("failed to add hidden service")
	ErrOnionServiceID      = errors.New("serviceID mismatch")
)

Error codes

View Source
var (
	ErrTorNoSocksPort = errors.New("no SocksPort found")
	ErrTorNotLocal    = errors.New("tor service not local")
)

Error codes

View Source
var (
	ErrTorInvalidProto = fmt.Errorf("only TCP protocol allowed")
)

Error codes

Functions

func IsTorExit

func IsTorExit(src net.IP) bool

IsTorExit checks if source is a TOR exit node

func ServiceID

func ServiceID(key interface{}) (id string, err error)

ServiceID returns the "onion name" of the hidden service (without the trailing ".onion") based on a public key

Types

type Onion

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

Onion is a hidden service implementation on a Tor service

func NewOnion

func NewOnion(key interface{}) (o *Onion, err error)

NewOnion instantiates a new hidden service

func (*Onion) AddFlag

func (o *Onion) AddFlag(flags ...string)

AddFlag adds service flags

func (*Onion) AddPort

func (o *Onion) AddPort(listen int, spec string)

AddPort adds a port mapping for the hidden service

func (*Onion) ServiceID

func (o *Onion) ServiceID() (id string, err error)

ServiceID returns the "onion name" of the hidden service (without the trailing ".onion")

func (*Onion) SetCredentials

func (o *Onion) SetCredentials(name, passwd string)

SetCredentials sets username and password for basic authentication

func (*Onion) Start

func (o *Onion) Start(srv *Service) (err error)

Start a new hidden service via a Tor service.

func (*Onion) Stop

func (o *Onion) Stop(srv *Service) error

Stop removes a hidden service from the Tor service

type Service

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

Service instance to communicate commands (and responses) with a running Tor process.

func NewService

func NewService(schema, endp string) (srv *Service, err error)

NewService instantiates a new Tor controller

func (*Service) Authenticate

func (s *Service) Authenticate(auth string) error

Authenticate client by password defined in torrc as "HashedControlPassword 16:..."

func (*Service) Close

func (s *Service) Close() error

Close connection to Tor process

func (*Service) Dial

func (s *Service) Dial(netw, address string, flags ...string) (net.Conn, error)

Dial a Tor-based connection

func (*Service) DialTimeout

func (s *Service) DialTimeout(netw, address string, timeout time.Duration, flags ...string) (net.Conn, error)

DialTimeout to establish a Tor-based connection with timeout

func (*Service) GetConf

func (s *Service) GetConf(cfg string) (map[string][]string, error)

GetConf returns the configuration settings associated with a config string. Key/value pairs are returned in a map.

func (*Service) GetInfo

func (s *Service) GetInfo(keys []string) (map[string][]string, error)

GetInfo from Tor service for non-torrc values

func (*Service) GetSocksPort

func (s *Service) GetSocksPort(flags ...string) (string, error)

GetSocksPort returns the best-matching SocksPort definition for a given set of flags (only works for local Tor services)

func (*Service) MapAddress

func (s *Service) MapAddress(addrs map[string]string) (map[string][]string, error)

MapAddress tells the Tor servce that future SOCKS requests for connections to the original address should be replaced with connections to the specified replacement address.

func (*Service) ResetConf

func (s *Service) ResetConf(cfg string) error

ResetConf resets a configuration to its default value

func (*Service) SaveConf

func (s *Service) SaveConf(force bool) error

SaveConf instructs the server to write out its config options into its torrc.

func (*Service) SetConf

func (s *Service) SetConf(key, value string) error

SetConf sets a configration from a key/value pair.

func (*Service) SetConfList

func (s *Service) SetConfList(cfg map[string]string) error

SetConfList sets all settings from a list of key/value pairs

func (*Service) SetEvents

func (s *Service) SetEvents(evs []string, extended bool) error

SetEvents requests the server to inform the client about interesting events.

func (*Service) Signal

func (s *Service) Signal(sig string) error

Signal the server for action.

Directories

Path Synopsis
tools

Jump to

Keyboard shortcuts

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