new TorControl(socket, optionsopt)
Name | Type | Attributes | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
socket | Socket | net.Socket connected to Tor's control port | |||||||||||
options | object | <optional> | Properties
|
- Source
Methods
addEventListeners(events)
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
Name | Type | Description |
---|---|---|
events | Array.<string> | List of event types to listen for |
- Source
attachStream(streamId, circuitIdopt, hopNumberopt)
Attaches the specified stream to the given circuit
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 |
- Source
authenticate(token)
Authenticates with the control port given the supplied param
Name | Type | Description |
---|---|---|
token | string |
- Source
cleanCircuits()
Clears DNS cache and establishes new clean circuits
- Source
clearDnsCache()
Forget client side hostname->ip cache
- Source
closeCicuit(circuitId, optionsopt)
Closes the given circuit
Name | Type | Attributes | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
circuitId | string | ID for the circuit to close | |||||||||||
options | object | <optional> | Properties
|
- Source
closeStream(streamId, reasonopt)
Closes the exit for the given stream
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
streamId | string | ID for the stream to close | ||
reason | number | <optional> | 1 | Reason code for closing stream |
- Source
createAddressMapping(target, replacement)
Instruct Tor to route requests to the target to the replacement
Name | Type | Description |
---|---|---|
target | string | Original address to map |
replacement | string | New address to route request to target |
- Source
createCircuit(purposeopt)
Creates a new circuit, returning the newly created circuit ID
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
purpose | string | <optional> | "general" | The circuit purpose, either general|controller |
- Source
createHiddenService(ports, optionsopt)
Establishes a hidden service on the given target
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 |
- Source
destroyHiddenService(serviceId)
Takes down a running hidden service owned by this controller
Name | Type | Description |
---|---|---|
serviceId | string | Tor hidden service ID |
- Source
dropGuards()
Tells the server to drop all guard nodes. Do not invoke this command lightly; it can increase vulnerability to tracking attacks over time.
- Source
dumpHeartbeat()
Dumps a heartbeat message to the logs
- Source
dumpStats()
Dump stats to tor log file
- Source
enableDebug()
Set open logs to debug level
- Source
extendCircuit(circuitId)
Extends the existing circuit
Name | Type | Description |
---|---|---|
circuitId | string | The circuit ID to extend |
- Source
fetchHiddenServiceDescriptor(serviceId, serverLongNameopt)
Fetches descriptors for the given hidden service
Name | Type | Attributes | Description |
---|---|---|---|
serviceId | string | ID for the hidden service | |
serverLongName | string | <optional> | Long name for specific server to use |
- Source
getAuthChallenge(nonce)
Requests an authentication challenge from tor
Name | Type | Description |
---|---|---|
nonce | string | Client nonce for authenticating |
- Source
getConfig(keyword)
Return the values for the given configuration key
Name | Type | Description |
---|---|---|
keyword | string | Configuration key |
- Source
getInfo(keyword)
Get information from Tor not stored in configuration
Name | Type | Description |
---|---|---|
keyword | string | Keyword for info to fetch |
- Source
getProtocolInfo()
Ask tor for general information
- Source
halt()
Shutdown tor immediately
- Source
loadConfig(configText)
Instruct Tor to load the configuration file from the given text
Name | Type | Description |
---|---|---|
configText | string | Complete torrc config text to load |
- Source
postDescriptor(descriptor, optionsopt)
Inform the server about a new descriptor
Name | Type | Attributes | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
descriptor | object | Key-value pairs for server descriptor | ||||||||||||||||
options | object | <optional> | Properties
|
- Source
postHiddenServiceDescriptor(descriptor, serverLongNameopt)
Launch a hidden service descriptor upload
Name | Type | Attributes | Description |
---|---|---|---|
descriptor | string | ||
serverLongName | string | <optional> | Long name for specific server to use |
- Source
quit()
Tells Tor to hang up on the controller
- Source
redirectStream(streamId, address, portopt)
Change the exit address on a given stream
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 |
- Source
reloadConfig()
Reloads the config values set
- Source
removeEventListeners()
Instructs Tor to stop listening for events
- Source
resetConfig(keyword)
Change the value for a configuration variable to it's default
Name | Type | Description |
---|---|---|
keyword | string | Configuration key |
- Source
resolve(address, optionsopt)
Launch remote hostname lookup - answer returnd as async ADDRMAP event
Name | Type | Attributes | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
address | string | Address to lookup | |||||||||||
options | object | <optional> | Properties
|
- Source
saveConfig()
Tell Tor to write out it's config value to it's torrc
- Source
setCircuitPurpose(circuitId, purpose)
Sets the purpose of the given circuit
Name | Type | Description |
---|---|---|
circuitId | string | The identifier for the circuit |
purpose | string | One of general|controller |
- Source
setConfig(keyword, value)
Change the value for a configuration variable
Name | Type | Description |
---|---|---|
keyword | string | Configuration key |
value | string | New value to set |
- Source
shutdown()
Controlled shutdown signal
- Source
signal(signal)
Sends a signal to the control port
Name | Type | Description |
---|---|---|
signal | string |
- Source
takeOwnership()
Take ownership of the tor process - will close tor when the connection closes
- Source
(static) createChallengeResponse(cookie, clientNonce, serverNonce) → {string}
Creates the challenge response from a SAFECOOKIE challenge
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
- Type:
- string
(static) createReplySplitter()
Creates a message splitter from incoming socket data
- Source
Events
close
Fires when the underlying socket closes
- Source
error
Fired when the underlying socket encounters an error
- Error
- Source
ready
Fires when the controller is authenticated and ready to send commands
- Source