tor-ctrl
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

tor-ctrl

CI NPM Version Install Size License

tor-ctrl is a simple library to connect to a Tor control port and send commands to it.

📦 Installation

npm install tor-ctrl

📖 Usage

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,
  // Or, if you want to control via Tor Unix socket:
  // socketPath: '/var/run/tor/control',
  password: 'secure-password'
});

await tc.connect();

const { data } = await tc.getNewIdentity();
console.log(data); // { code: 250, message: 'OK' }

await tc.disconnect();
Send a Custom Command

If you don't know the available commands, please first check out the official the Tor Control Protocol specifications.

const { data, error } = await tc.sendCommand(['GETINFO', 'version', 'config-file']);
console.log(data); // [ { code: NUM, message: STRING }, ... ]

For more examples, check out the examples directory.

🤝 Contributing

Want to contribute? Awesome! To show your support is to star the project, or to raise issues on GitHub.

Thanks again for your support, it is much appreciated! 🙏

License

GPL-3.0 © Shahrad Elahi and contributors.

Package Sidebar

Install

npm i tor-ctrl

Weekly Downloads

5

Version

0.2.0

License

GPL-3.0

Unpacked Size

68.6 kB

Total Files

6

Last publish

Collaborators

  • shahradelahi