Manage Tor over the control port. Defer a series of write()
operations, then be execute()
them to get a Promise that resolves when the connection is closed and all operations have been written to the control port with a positive completion reply.
import { commander, commands } from 'tor-commander'
const controlPort = commander(9055)
controlPort
.write(commands.AUTHENTICATE())
.write(commands.ADD_ONION({ Port: 80 }))
.write(commands.QUIT)
.execute()
.then(data)
.catch(error)
Expects a number or an object with the property port
.
Defer a command to be written to the control port once connected.
Returns a Promise. Opens a connection to the Tor control port and writes from the write queue. Resolves on positive completion reply, rejects for all other types of replies or if the connection fails in any way.
To simplify command construction there are a few helpers available on the exported commands
object.
Returns the correct authentication string depending on whether token
is supplied or not. Where token is the plaintext password.
Available options:
{
keyType, // default: NEW
keyBlob, // default: BEST
flags, // default: [ 'Detach' ]
port, // Required
clientName,
clientBlob
}
Takes a ServiceID (the onion address excluding .onion), note that this does not disconnect currently connected clients.
Reload config.
Controlled shutdown.
Dump statistics.
Switches all open logs to the debug log level.
Immediate shutdown.
Clear cached IPs for all hostnames.
Switch to clean circuits.
Unscheduled heartbeat message.
Close the control port connection.