A simple library to connect to a Tor control port and send commands to it.
npm install tor-ctrl
In below example, we are requesting for a new identity from Tor.
import { TorControl } from 'tor-ctrl';
const tc = new TorControl({
host: 'localhost',
port: 9051,
password: 'secure-password'
});
tc.connect().then(async () => {
const { data } = await tc.getNewIdentity();
console.log(data); // { code: 250, message: 'OK' }
await tc.disconnect();
});
Check out the examples directory for more examples.
Send a Custom Command
If you don't know the available commands, please first check out the official Tor Control Protocol documentation.
const { data, error } = await tc.sendCommand(['GETINFO', 'version', 'config-file']);
console.log(data); // [ { code: NUM, message: STRING }, ... ]
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
This project is licensed under the GPL-3.0 License - see the LICENSE file for details.