TorProcess

TorProcess

Class that represents an individual Tor process.

Constructor

new TorProcess(tor_path, definitionopt, granax_optionsopt, loggeropt)

Source:
Creates an instance of `TorProcess`
Parameters:
Name Type Attributes Description
tor_path string Path to the Tor executable.
definition InstanceDefinition <optional>
Object containing various options for the instance. See InstanceDefinition for more info.
granax_options Object <optional>
Object containing options that will be passed to granax.
logger Logger <optional>
A winston logger. If not provided no logging will occur.

Extends

  • EventEmitter

Members

control_password :string

Source:
The password that will be set for the control protocol.
Type:
  • string

(readonly) control_port :number

Source:
Port Tor is bound to for API access.
Type:
  • number

control_port_connected :boolean

Source:
Is true when the connected via the control protcol
Type:
  • boolean

(readonly) controller :TorController

Source:
Instance of granax.TorController connected to the Tor process.
Type:
  • TorController

(readonly) definition :string

Source:
The definition used to create the instance.
Type:
  • string

(readonly) dns_port :number

Source:
Port Tor is bound to for DNS traffic.
Type:
  • number

granax_options :Object

Source:
Object containing options that will be passed to granax.
Type:
  • Object

(readonly) id :string

Source:
The unique identifier assigned to each instance.
Type:
  • string

(readonly) instance_group :Array.<string>

Source:
Groups the instance are currently in.
Type:

(readonly) instance_name :string

Source:
Either the "Name" property of the definition or the TorProcess#id property.
Type:
  • string

(readonly) ready :boolean

Source:
Property identifiyng whether Tor has started.
Type:
  • boolean

(readonly) socks_port :number

Source:
Port Tor is bound to for SOCKS5 traffic.
Type:
  • number

(readonly) tor_config :Object

Source:
The configuration passed to Tor. The same value as `definition.Config`.
Type:
  • Object

tor_path :string

Source:
Path to the Tor executable.
Type:
  • string

Methods

(async) create() → {Promise.<ChildProcess>}

Source:
Creates the Tor process based on the configuration provided. Promise is resolved when the process has been started.
Returns:
- The process that has been created.
Type
Promise.<ChildProcess>

(async) exit() → {Promise}

Source:
Kills the Tor process.
Returns:
Type
Promise

(async) get_config(keyword) → {Promise.<Array.<string>>}

Source:
Retrieves a configuration value from the instance via the control protocol.
Parameters:
Name Type Description
keyword string The name of the configuration property to retrieve.
Throws:
Will throw an error if not connected to the control protocol.
Returns:
Type
Promise.<Array.<string>>

(async) new_identity()

Source:
Requests a new identity via the control protocol.

(async) set_config(keyword, value) → {Promise}

Source:
Sets a configuration value for the instance via the control protocol.
Parameters:
Name Type Description
keyword string The name of the configuration property to retrieve.
value any Value to set the property to.
Throws:
Will throw an error if not connected to the control protocol.
Returns:
Type
Promise

(async) signal(signal) → {Promise}

Source:
Sends a signal via the control tnterface.
Parameters:
Name Type Description
signal string The signal to send.
Throws:
Will throw an error if not connected to the control protocol.
Returns:
Type
Promise

Events

control_listen

Source:
An event that fires when the Tor process has started listening for control interface traffic.

controller_ready

Source:
An event that fires when a connection has been established to the control protocol.

dns_listen

Source:
An event that fires when the Tor process has started listening for DNS traffic.

error

Source:
An event that fires when the Tor process has written an error to stdout, stderr or when an error occurs connecting via the control protocol.
Type:
  • Error
Returns:
Type
Error

process_exit

Source:
An event that fires when the process has closed.
Type:
  • number
Parameters:
Name Type Description
code number The exit code from the process.

ready

Source:
An event that fires when the Tor process is fully bootstrapped (and ready for traffic).

socks_listen

Source:
An event that fires when the Tor process has started listening for SOCKS5 traffic.