npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-rtorrent-client

v0.2.0

Published

Versatile rTorrent client for Node applications

Downloads

21

Readme

node-rtorrent-client

A versatile NodeJS rTorrent client which can utilise SCGI and XMLRPC via HTTP and HTTPS.

Description

A brand new, easy to use rTorrent client for NodeJS applications, written using ECMAScript for asynchronous communication with a rTorrent server via direct SCGI (socket or TCP), or XMLRPC (HTTP or HTTPS), supporting authentication.

Installation

npm install node-rtorrent-client

Usage

For ECMAScript applications:

import { Client } from 'node-rtorrent-client'

const options = {
  mode        : scgi,                          /* Either xmlrpc or scgi (default) */
  socket      : "/path/to/rtorrent.sock",      /* If utilising socket */
  host        : "hostname",                    /* IP address or hostname for SCGI(TCP) or XMLRPC */
  port        : 1234,                          /* TCP port number for either SCGI(TCP) or XMLRPC */
  ssl         : true,                          /* Enable or disable SSL for XMLRPC */
  username    : "username",                    /* Username and password if require for XMLRPC */
  password    : "password"
};

/* Get a new client */
const client = new Client( options );

/* Test the connection */
await client.testConnection();

/* Send returns a promise, so either await or resolve else ways */
let methods = await client.system.listMethods()
    .send();

/* Stop all active torrents through chaining commands */
await client.torrent.multicall( 'active' )
    .torrent.stop()
    .send();

/* Get the name, hash and label for all torrents */
let result = await client.torrent.multiCall()
    .torrent.name()
    .torrent.hash()
    .torrent.getLabel()
    .send();

/* 
  Responses make sense. Eg:
  result = [
    [ 'name1', 'hash1', 'label1' ],
    [ 'name2', 'hash2', 'label2' ],
    ...
  ];
*/

/* Set a label */
await client.torrent.setLabel( 'foobar', 'hashoftorrent' )
    .send();

/* Start one torrent */
await client.torrent.start( 'hashoftorrent' )
    .send();

More to come

CLI

The included cli.js script can be used for direct CLI access to rTorrent without being restricted to the interface.

For usage information, execute:

node cli.js --help

That should yield something like this:

rTorrent client

  Runs remote procedure commands on the rTorrent server

Execution

  $ node cli.js [options] -- command param1 param2...

Options

  -m, --mode string       Connection mode, either scgi or xmlrpc
  -h, --host string       Host name or IP address for SCGI or XMLRPC
  -p, --port number       Port number for SCGI or XMLRPC
  -a, --path string       XMLRPC path
  -u, --username string   XMLRPC username (auth basic only)
  -w, --password string   XMLRPC password
  -s, --socket file       Socket path for SCGI
  -?, --help              Display this usage information

Examples:

# To list all methods available via XMLRPC:
node cli.js -m xmlrpc -h 10.1.2.3 -p 8080 -u username -w password -a /RPC2 -- system.listMethods

# To list all methods available via SCGI socket:
node cli.js -m scgi -w /tmp/rtorrent.sock -- system.listMethods

# To fetch the hash and label for each active torrent:
node cli.js -m xmlrpc -h 10.1.2.3 -p 8080 -u username -w password -a /RPC2 -- d.multicall2 '' active d.hash= d.custom1=

Refer to rTorrent XMLRPC manual for more information about commands.

Support

This software is likely full of bugs. Parts of it are completely untested, and much of the connection handling code has no test cases. Please feel free to contribute with pull requests.

Acknowledgments

XML encoding / decoding inspired by @kinabcd (node-rtorrent-scgi)

License

ISC, refer to LICENSE.txt