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

0.1.0 • Public • Published

tor-ctrl

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,
  password: 'secure-password'
});

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

Examples

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 }, ... ]

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

License

This project is licensed under the GPL-3.0 License - see the LICENSE file for details.

Readme

Keywords

Package Sidebar

Install

npm i tor-ctrl

Weekly Downloads

5

Version

0.1.0

License

GPL-3.0

Unpacked Size

118 kB

Total Files

9

Last publish

Collaborators

  • shahradelahi