Class: TorController

TorController

Represents a Tor controller for issuing commands

new TorController(socket [, options])

Parameters:
Name Type Argument Description
socket Socket net.Socket connected to Tor's control port
options object <optional>
Properties
Name Type Argument Default Description
authOnConnect boolean <optional>
true Automatically authenticate
Source:

Methods


<static> createChallengeResponse(cookie, clientNonce, serverNonce)

Creates the challenge response from a SAFECOOKIE challenge
Parameters:
Name Type Description
cookie string The secret cookie string
clientNonce string Client nonce sent with auth challenge
serverNonce string Server nonce reply from auth challenge
Source:
Returns:
Type
string

<static> createReplySplitter()

Creates a message splitter from incoming socket data
Source:

addEventListeners(events, callback)

Instructs Tor to send asynchronous events for the given types - these events will be emitted from the controller. Calling this method resets previously set event listeners
Parameters:
Name Type Description
events Array.<string> List of event types to listen for
callback TorController~addEventListenersCallback
Source:
See:

attachStream(streamId [, circuitId] [, hopNumber], callback)

Attaches the specified stream to the given circuit
Parameters:
Name Type Argument Default Description
streamId string ID for the stream to attach
circuitId string <optional>
0 Circuit to attach stream
hopNumber number <optional>
Which hop to exit circuit
callback TorController~attachStreamCallback
Source:

authenticate(token, callback)

Authenticates with the control port given the supplied param
Parameters:
Name Type Description
token string
callback TorController~authenticateCallback
Source:

cleanCircuits(callback)

Clears DNS cache and establishes new clean circuits
Parameters:
Name Type Description
callback TorController~cleanCircuitsCallback
Source:

clearDnsCache(callback)

Forget client side hostname->ip cache
Parameters:
Name Type Description
callback TorController~clearDnsCacheCallback
Source:

closeCicuit(circuitId [, options], callback)

Closes the given circuit
Parameters:
Name Type Argument Description
circuitId string ID for the circuit to close
options object <optional>
Properties
Name Type Argument Default Description
ifUnused boolean <optional>
false Only close if not in use
callback TorController~closeCircuitCallback
Source:

closeStream(streamId [, reason], callback)

Closes the exit for the given stream
Parameters:
Name Type Argument Default Description
streamId string ID for the stream to close
reason number <optional>
1 Reason code for closing stream
callback TorController~closeStreamCallback
Source:
See:

createAddressMapping(target, replacement, callback)

Instruct Tor to route requests to the target to the replacement
Parameters:
Name Type Description
target string Original address to map
replacement string New address to route request to target
callback TorController~createAddressMappingCallback
Source:

createCircuit( [purpose], callback)

Creates a new circuit, returning the newly created circuit ID
Parameters:
Name Type Argument Default Description
purpose string <optional>
"general" The circuit purpose, either general|controller
callback TorController~createCircuitCallback
Source:

createHiddenService(ports [, options], callback)

Establishes a hidden service on the given target
Parameters:
Name Type Argument Description
ports array Array containing optional virtualPort (defaults to 80) and target ip:port string
options object <optional>
module:commands#ADD_ONION
callback TorController~createHiddenServiceCallback
Source:

destroyHiddenService(serviceId, callback)

Takes down a running hidden service owned by this controller
Parameters:
Name Type Description
serviceId string Tor hidden service ID
callback TorController~destroyHiddenServiceCallback
Source:

dropGuards(callback)

Tells the server to drop all guard nodes. Do not invoke this command lightly; it can increase vulnerability to tracking attacks over time.
Parameters:
Name Type Description
callback TorController~dropGuardsCallback
Source:

dumpHeartbeat(callback)

Dumps a heartbeat message to the logs
Parameters:
Name Type Description
callback TorController~dumpHeartbeatCallback
Source:

dumpStats(callback)

Dump stats to tor log file
Parameters:
Name Type Description
callback TorController~dumpStatsCallback
Source:

enableDebug(callback)

Set open logs to debug level
Parameters:
Name Type Description
callback TorController~enableDebugCallback
Source:

extendCircuit(circuitId, callback)

Extends the existing circuit
Parameters:
Name Type Description
circuitId string The circuit ID to extend
callback TorController~extendCircuitCallback
Source:

fetchHiddenServiceDescriptor(serviceId [, serverLongName], callback)

Fetches descriptors for the given hidden service
Parameters:
Name Type Argument Description
serviceId string ID for the hidden service
serverLongName string <optional>
Long name for specific server to use
callback TorController~fetchHiddenServiceDescriptorCallback
Source:

getAuthChallenge(nonce, callback)

Requests an authentication challenge from tor
Parameters:
Name Type Description
nonce string Client nonce for authenticating
callback TorController~getAuthChallengeCallback
Source:

getConfig(keyword, callback)

Return the values for the given configuration key
Parameters:
Name Type Description
keyword string Configuration key
callback TorController~getConfigCallback
Source:

getInfo(keyword, callback)

Get information from Tor not stored in configuration
Parameters:
Name Type Description
keyword string Keyword for info to fetch
callback TorController~getInfoCallback
Source:
See:

getProtocolInfo(callback)

Ask tor for general information
Parameters:
Name Type Description
callback TorController~getProtocolInfoCallback
Source:

halt(callback)

Shutdown tor immediately
Parameters:
Name Type Description
callback TorController~haltCallback
Source:

loadConfig(configText, callback)

Instruct Tor to load the configuration file from the given text
Parameters:
Name Type Description
configText string Complete torrc config text to load
callback TorController~loadConfigCallback
Source:

postDescriptor(descriptor [, options], callback)

Inform the server about a new descriptor
Parameters:
Name Type Argument Description
descriptor object Key-value pairs for server descriptor
options object <optional>
Properties
Name Type Argument Default Description
purpose string <optional>
"general" general|controller|bridge
cache boolean <optional>
true Flag for caching descriptor
callback TorController~postDescriptorCallback
Source:

postHiddenServiceDescriptor(descriptor [, serverLongName], callback)

Launch a hidden service descriptor upload
Parameters:
Name Type Argument Description
descriptor string
serverLongName string <optional>
Long name for specific server to use
callback TorController~postHiddenServiceDescriptorCallback
Source:
See:

quit(callback)

Tells Tor to hang up on the controller
Parameters:
Name Type Description
callback TorController~quitCallback
Source:

redirectStream(streamId, address [, port], callback)

Change the exit address on a given stream
Parameters:
Name Type Argument Description
streamId string ID for stream to redirect
address string Exit address for the given stream
port number <optional>
Exit port for the given stream
callback TorController~redirectStreamCallback
Source:

reloadConfig(callback)

Reloads the config values set
Parameters:
Name Type Description
callback TorController~reloadConfigCallback
Source:

removeEventListeners(callback)

Instructs Tor to stop listening for events
Parameters:
Name Type Description
callback TorController~removeEventListenersCallback
Source:

resetConfig(keyword, callback)

Change the value for a configuration variable to it's default
Parameters:
Name Type Description
keyword string Configuration key
callback TorController~resetConfigCallback
Source:

resolve(address [, options], callback)

Launch remote hostname lookup - answer returnd as async ADDRMAP event
Parameters:
Name Type Argument Description
address string Address to lookup
options object <optional>
Properties
Name Type Argument Default Description
reverse boolean <optional>
false Perform reverse lookup
callback TorController~resolveCallback
Source:

saveConfig(callback)

Tell Tor to write out it's config value to it's torrc
Parameters:
Name Type Description
callback TorController~saveConfigCallback
Source:

setCircuitPurpose(circuitId, purpose, callback)

Sets the purpose of the given circuit
Parameters:
Name Type Description
circuitId string The identifier for the circuit
purpose string One of general|controller
callback TorController~setCircuitPurposeCallback
Source:

setConfig(keyword, value, callback)

Change the value for a configuration variable
Parameters:
Name Type Description
keyword string Configuration key
value string New value to set
callback TorController~setConfigCallback
Source:

shutdown(callback)

Controlled shutdown signal
Parameters:
Name Type Description
callback TorController~shutdownCallback
Source:

signal(signal, callback)

Sends a signal to the control port
Parameters:
Name Type Description
signal string
callback TorController~signalCallback
Source:

takeOwnership(callback)

Take ownership of the tor process - will close tor when the connection closes
Parameters:
Name Type Description
callback TorController~takeOwnershipCallback
Source:

Type Definitions


addEventListenersCallback(error)

Parameters:
Name Type Description
error object | null
Source:

attachStreamCallback(error)

Parameters:
Name Type Description
error object | null
Source:

cleanCircuitsCallback(error)

Parameters:
Name Type Description
error object | null
Source:

clearDnsCacheCallback(error)

Parameters:
Name Type Description
error object | null
Source:

closeCircuitCallback(error)

Parameters:
Name Type Description
error object | null
Source:

closeStreamCallback(error)

Parameters:
Name Type Description
error object | null
Source:

createAddressMappingCallback(error)

Parameters:
Name Type Description
error object | null
Source:

createCircuitCallback(error, result)

Parameters:
Name Type Description
error object | null
result Array.<string>
Source:

createHiddenServiceCallback(error, result)

Parameters:
Name Type Description
error object | null
result AddOnionResult
Source:

destroyHiddenServiceCallback(error)

Parameters:
Name Type Description
error object | null
Source:

dropGuardsCallback(error)

Parameters:
Name Type Description
error object | null
Source:

dumpHeartbeatCallback(error)

Parameters:
Name Type Description
error object | null
Source:

dumpStatsCallback(error)

Parameters:
Name Type Description
error object | null
Source:

enableDebugCallback(error)

Parameters:
Name Type Description
error object | null
Source:

extendCircuitCallback(error, result)

Parameters:
Name Type Description
error object | null
result Array.<string>
Source:

fetchHiddenServiceDescriptorCallback(error)

Parameters:
Name Type Description
error object | null
Source:

getAuthChallengeCallback(error, result)

Parameters:
Name Type Description
error object | null
result AuthChallengeResult
Source:

getConfigCallback(error, result)

Parameters:
Name Type Description
error object | null
result GetConfigResult
Source:

getInfoCallback(error, result)

Parameters:
Name Type Description
error object | null
result string
Source:

getProtocolInfoCallback(error, result)

Parameters:
Name Type Description
error object | null
result ProtocolInfoResult
Source:

haltCallback(error)

Parameters:
Name Type Description
error object | null
Source:

loadConfigCallback(error)

Parameters:
Name Type Description
error object | null
Source:

postDescriptorCallback(error)

Parameters:
Name Type Description
error object | null
Source:

postHiddenServiceDescriptorCallback(error)

Parameters:
Name Type Description
error object | null
Source:

quitCallback(error)

Parameters:
Name Type Description
error object | null
Source:

redirectStreamCallback(error)

Parameters:
Name Type Description
error object | null
Source:

reloadConfigCallback(error)

Parameters:
Name Type Description
error object | null
Source:

resetConfigCallback(error)

Parameters:
Name Type Description
error object | null
Source:

resolveCallback(error)

Parameters:
Name Type Description
error object | null
Source:

saveConfigCallback(error)

Parameters:
Name Type Description
error object | null
Source:

setCircuitPurposeCallback(error)

Parameters:
Name Type Description
error object | null
Source:

setConfigCallback(error)

Parameters:
Name Type Description
error object | null
Source:

shutdownCallback(error)

Parameters:
Name Type Description
error object | null
Source:

signalCallback(error)

Parameters:
Name Type Description
error object | null
Source:

takeOwnershipCallback(error)

Parameters:
Name Type Description
error object | null
Source:

Events


close

Fires when the underlying socket closes
Source:

error

Fired when the underlying socket encounters an error
Type: error
Source:

ready

Fires when the controller is authenticated and ready to send commands
Source: