shahradelahi / node-tor-control

A NodeJs library to communicate with Tor-Control

Home Page:https://www.npmjs.com/package/tor-ctrl

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

About

A NodeJs library to communicate with Tor-Control

https://www.npmjs.com/package/tor-ctrl

License:GNU General Public License v3.0


Languages

Language:TypeScript 100.0%