README
¶
Documentation
¶
Overview ¶
Package torgo provides a Golang controller interface for Tor.
Index ¶
- func NewClient(addr string) (*http.Client, error)
- func ServiceIDFromEd25519(pub ed25519.PublicKey) (string, error)
- func ServiceIDFromRSA(pub *rsa.PublicKey) (string, error)
- type Controller
- func (c *Controller) AddOnion(onion *Onion) error
- func (c *Controller) AuthenticateCookie() error
- func (c *Controller) AuthenticateNone() error
- func (c *Controller) AuthenticatePassword(password string) error
- func (c *Controller) DeleteOnion(serviceID string) error
- func (c *Controller) GetAddress() (string, error)
- func (c *Controller) GetBytesRead() (int, error)
- func (c *Controller) GetBytesWritten() (int, error)
- func (c *Controller) GetConfigFile() (string, error)
- func (c *Controller) GetTorPid() (int, error)
- func (c *Controller) GetVersion() (string, error)
- func (c *Controller) SetConf(param, value string) error
- func (c *Controller) Signal(signal string) error
- type Onion
Examples ¶
- Controller.AddOnion
- Controller.AddOnion (Ed25519)
- Controller.AuthenticateCookie
- Controller.AuthenticateNone
- Controller.AuthenticatePassword
- Controller.DeleteOnion
- Controller.GetAddress
- Controller.GetBytesRead
- Controller.GetBytesWritten
- Controller.GetConfigFile
- Controller.GetTorPid
- Controller.GetVersion
- Controller.Signal (Newnym)
- Controller.Signal (Reload)
- NewClient (Httpget)
- NewController
- OnionFromEd25519
- OnionFromRSA
- ServiceIDFromEd25519
- ServiceIDFromRSA
Constants ¶
Variables ¶
Functions ¶
func NewClient ¶
NewClient return new HTTP client that uses a Tor SOCKS proxy. `addr` is the host:port address of SOCKS proxy (usually "127.0.0.1:9050")
Example (Httpget) ¶
Create a new Tor SOCKS HTTP client and request current IP from httpbin.org.
Output:
func ServiceIDFromEd25519 ¶
ServiceIDFromEd25519 calculates a Tor service ID from an ed25519.PublicKey.
Types ¶
type Controller ¶
type Controller struct { // Array of available authentication methods. AuthMethods []string // Cookie file path (empty if not available). CookieFile string // Text is a textproto.Conn to the control port. Text *textproto.Conn }
A Controller instance is a control port connection that provides methods for communicating with Tor.
func NewController ¶
func NewController(addr string) (*Controller, error)
NewController returns a new Controller instance connecting to the control port at addr.
func (*Controller) AddOnion ¶
func (c *Controller) AddOnion(onion *Onion) error
AddOnion adds Onion hidden service. If no private key is supplied one will be generated and the PrivateKeyType and PrivateKey properties will be set with the newly generated one. The hidden service will use port mapping contained in Ports map supplied. ServiceID will be assigned based on the private key and will be the address of this hidden service (without the ".onion" ending).
func (*Controller) AuthenticateCookie ¶
func (c *Controller) AuthenticateCookie() error
AuthenticateCookie authenticate to controller with cookie from current CookieFile path.
func (*Controller) AuthenticateNone ¶
func (c *Controller) AuthenticateNone() error
AuthenticateNone authenticate to controller without password or cookie.
func (*Controller) AuthenticatePassword ¶
func (c *Controller) AuthenticatePassword(password string) error
AuthenticatePassword authenticate to controller with password.
func (*Controller) DeleteOnion ¶
func (c *Controller) DeleteOnion(serviceID string) error
DeleteOnion deletes an onion by its serviceID (stop hidden service created by this controller).
func (*Controller) GetAddress ¶
func (c *Controller) GetAddress() (string, error)
GetAddress returns the current external IP address.
func (*Controller) GetBytesRead ¶
func (c *Controller) GetBytesRead() (int, error)
GetBytesRead returns total bytes downloaded.
func (*Controller) GetBytesWritten ¶
func (c *Controller) GetBytesWritten() (int, error)
GetBytesWritten returns total bytes uploaded.
func (*Controller) GetConfigFile ¶
func (c *Controller) GetConfigFile() (string, error)
GetConfigFile return path to Tor config file.
func (*Controller) GetTorPid ¶
func (c *Controller) GetTorPid() (int, error)
GetTorPid returns PID for current Tor process.
func (*Controller) GetVersion ¶
func (c *Controller) GetVersion() (string, error)
GetVersion returns version of Tor server.
func (*Controller) SetConf ¶
func (c *Controller) SetConf(param, value string) error
func (*Controller) Signal ¶
func (c *Controller) Signal(signal string) error
Signal sends a signal to the server. Tor documentations defines the following signals :
* RELOAD * SHUTDOWN * DUMP * DEBUG * HALT * CLEARDNSCACHE * NEWNYM * HEARTBEAT * DORMANT * ACTIVE
type Onion ¶
type Onion struct { // Ports maps virtual ports for the hidden service to local addresses. Ports map[int]string // ServiceID is the unique hidden service address (without ".onion" ending). ServiceID string // Base64 encoded private key for the hidden service. PrivateKey string // Type of private key (RSA1024 or ED25519-V3). PrivateKeyType string }
Onion represents a hidden service.
func OnionFromEd25519 ¶
func OnionFromEd25519(pri ed25519.PrivateKey) (*Onion, error)
OnionFromEd25519 returns an Onion instance from an ED25519 private key which can be used to start a hidden service with controller.AddOnion.
func OnionFromRSA ¶
func OnionFromRSA(pri *rsa.PrivateKey) (*Onion, error)
OnionFromRSA returns an Onion instance from a 1024 bit RSA private key which can be used to start a hidden service with controller.AddOnion.
Directories
¶
Path | Synopsis |
---|---|
examples
|
|