Constructor
new TorController(socket, optionsopt)
Parameters:Name | Type | Attributes | Description |
---|
socket | Socket | | net.Socket connected to Tor's control port |
options | object | <optional>
| PropertiesName | Type | Attributes | Default | Description |
---|
authOnConnect | boolean | <optional>
| true | Automatically authenticate |
|
Methods
(static) createChallengeResponse(cookie, clientNonce, serverNonce) → {string}
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 |
(static) createReplySplitter()
Creates a message splitter from incoming socket data
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
attachStream(streamId, circuitIdopt, hopNumberopt, callback)
Attaches the specified stream to the given circuit
Parameters:Name | Type | Attributes | 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 | | | |
authenticate(token, callback)
Authenticates with the control port given the supplied param
Parameters:Name | Type | Description |
---|
token | string | |
callback | TorController~authenticateCallback | |
cleanCircuits(callback)
Clears DNS cache and establishes new clean circuits
clearDnsCache(callback)
Forget client side hostname->ip cache
closeCicuit(circuitId, optionsopt, callback)
Parameters:Name | Type | Attributes | Description |
---|
circuitId | string | | ID for the circuit to close |
options | object | <optional>
| PropertiesName | Type | Attributes | Default | Description |
---|
ifUnused | boolean | <optional>
| false | Only close if not in use |
|
callback | TorController~closeCircuitCallback | | |
closeStream(streamId, reasonopt, callback)
Closes the exit for the given stream
Parameters:Name | Type | Attributes | Default | Description |
---|
streamId | string | | | ID for the stream to close |
reason | number | <optional>
| 1 | Reason code for closing stream |
callback | TorController~closeStreamCallback | | | |
createAddressMapping(target, replacement, callback)
Instruct Tor to route requests to the target to the replacement
createCircuit(purposeopt, callback)
Creates a new circuit, returning the newly created circuit ID
createHiddenService(ports, optionsopt, callback)
Establishes a hidden service on the given target
Parameters:Name | Type | Attributes | 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 | | |
destroyHiddenService(serviceId, callback)
Takes down a running hidden service owned by this controller
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.
dumpHeartbeat(callback)
Dumps a heartbeat message to the logs
dumpStats(callback)
Dump stats to tor log file
enableDebug(callback)
Set open logs to debug level
extendCircuit(circuitId, callback)
Extends the existing circuit
fetchHiddenServiceDescriptor(serviceId, serverLongNameopt, callback)
Fetches descriptors for the given hidden service
getAuthChallenge(nonce, callback)
Requests an authentication challenge from tor
getConfig(keyword, callback)
Return the values for the given configuration key
getInfo(keyword, callback)
Get information from Tor not stored in configuration
getProtocolInfo(callback)
Ask tor for general information
halt(callback)
loadConfig(configText, callback)
Instruct Tor to load the configuration file from the given text
postDescriptor(descriptor, optionsopt, callback)
Inform the server about a new descriptor
Parameters:Name | Type | Attributes | Description |
---|
descriptor | object | | Key-value pairs for server descriptor |
options | object | <optional>
| PropertiesName | Type | Attributes | Default | Description |
---|
purpose | string | <optional>
| "general" | general|controller|bridge | cache | boolean | <optional>
| true | Flag for caching descriptor |
|
callback | TorController~postDescriptorCallback | | |
postHiddenServiceDescriptor(descriptor, serverLongNameopt, callback)
Launch a hidden service descriptor upload
quit(callback)
Tells Tor to hang up on the controller
redirectStream(streamId, address, portopt, callback)
Change the exit address on a given stream
Parameters:Name | Type | Attributes | 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 | | |
reloadConfig(callback)
Reloads the config values set
removeEventListeners(callback)
Instructs Tor to stop listening for events
Parameters:Name | Type | Description |
---|
callback | TorController~removeEventListenersCallback | |
resetConfig(keyword, callback)
Change the value for a configuration variable to it's default
resolve(address, optionsopt, callback)
Launch remote hostname lookup - answer returnd as async ADDRMAP event
Parameters:Name | Type | Attributes | Description |
---|
address | string | | Address to lookup |
options | object | <optional>
| PropertiesName | Type | Attributes | Default | Description |
---|
reverse | boolean | <optional>
| false | Perform reverse lookup |
|
callback | TorController~resolveCallback | | |
saveConfig(callback)
Tell Tor to write out it's config value to it's torrc
setCircuitPurpose(circuitId, purpose, callback)
Sets the purpose of the given circuit
setConfig(keyword, value, callback)
Change the value for a configuration variable
shutdown(callback)
Controlled shutdown signal
signal(signal, callback)
Sends a signal to the control port
takeOwnership(callback)
Take ownership of the tor process - will close tor when the connection closes
Type Definitions
addEventListenersCallback(error)
Parameters:Name | Type | Description |
---|
error | object | null | |
attachStreamCallback(error)
Parameters:Name | Type | Description |
---|
error | object | null | |
cleanCircuitsCallback(error)
Parameters:Name | Type | Description |
---|
error | object | null | |
clearDnsCacheCallback(error)
Parameters:Name | Type | Description |
---|
error | object | null | |
closeCircuitCallback(error)
Parameters:Name | Type | Description |
---|
error | object | null | |
closeStreamCallback(error)
Parameters:Name | Type | Description |
---|
error | object | null | |
createAddressMappingCallback(error)
Parameters:Name | Type | Description |
---|
error | object | null | |
createCircuitCallback(error, result)
Parameters:Name | Type | Description |
---|
error | object | null | |
result | Array.<string> | |
createHiddenServiceCallback(error, result)
Parameters:Name | Type | Description |
---|
error | object | null | |
result | AddOnionResult | |
destroyHiddenServiceCallback(error)
Parameters:Name | Type | Description |
---|
error | object | null | |
dropGuardsCallback(error)
Parameters:Name | Type | Description |
---|
error | object | null | |
dumpHeartbeatCallback(error)
Parameters:Name | Type | Description |
---|
error | object | null | |
dumpStatsCallback(error)
Parameters:Name | Type | Description |
---|
error | object | null | |
enableDebugCallback(error)
Parameters:Name | Type | Description |
---|
error | object | null | |
extendCircuitCallback(error, result)
Parameters:Name | Type | Description |
---|
error | object | null | |
result | Array.<string> | |
fetchHiddenServiceDescriptorCallback(error)
Parameters:Name | Type | Description |
---|
error | object | null | |
getAuthChallengeCallback(error, result)
Parameters:Name | Type | Description |
---|
error | object | null | |
result | AuthChallengeResult | |
getConfigCallback(error, result)
Parameters:Name | Type | Description |
---|
error | object | null | |
result | GetConfigResult | |
getInfoCallback(error, result)
Parameters:Name | Type | Description |
---|
error | object | null | |
result | string | |
getProtocolInfoCallback(error, result)
Parameters:Name | Type | Description |
---|
error | object | null | |
result | ProtocolInfoResult | |
haltCallback(error)
Parameters:Name | Type | Description |
---|
error | object | null | |
loadConfigCallback(error)
Parameters:Name | Type | Description |
---|
error | object | null | |
postDescriptorCallback(error)
Parameters:Name | Type | Description |
---|
error | object | null | |
postHiddenServiceDescriptorCallback(error)
Parameters:Name | Type | Description |
---|
error | object | null | |
quitCallback(error)
Parameters:Name | Type | Description |
---|
error | object | null | |
redirectStreamCallback(error)
Parameters:Name | Type | Description |
---|
error | object | null | |
reloadConfigCallback(error)
Parameters:Name | Type | Description |
---|
error | object | null | |
resetConfigCallback(error)
Parameters:Name | Type | Description |
---|
error | object | null | |
resolveCallback(error)
Parameters:Name | Type | Description |
---|
error | object | null | |
saveConfigCallback(error)
Parameters:Name | Type | Description |
---|
error | object | null | |
setCircuitPurposeCallback(error)
Parameters:Name | Type | Description |
---|
error | object | null | |
setConfigCallback(error)
Parameters:Name | Type | Description |
---|
error | object | null | |
shutdownCallback(error)
Parameters:Name | Type | Description |
---|
error | object | null | |
signalCallback(error)
Parameters:Name | Type | Description |
---|
error | object | null | |
takeOwnershipCallback(error)
Parameters:Name | Type | Description |
---|
error | object | null | |
Events
close
Fires when the underlying socket closes
error
Fired when the underlying socket encounters an error
ready
Fires when the controller is authenticated and ready to send commands