0.1.0 • Published 2 months ago

tor-ctrl v0.1.0

Weekly downloads
-
License
GPL-3.0
Repository
github
Last release
2 months ago

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.

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.

0.1.0

2 months ago