h1. Overview

A lobber storage node is essentially a standard BitTorrent client with a very thin layer used to receive notification about new and modified torrents. A lobber storage node is provided as a twisted plugin and is installed from the python package index.

There is no dependency on any one BitTorrent client but development and testing is done using transmission, a BitTorrent client designed to run as a headless standalone server.

h1. Installing

The examples below assume a debian/ubuntu environment. If you're running another unix-like or windows OS your milage may vary. Our goal is for lobber to run on a multitude of environments and operating systems. Please provide us with patches\!

h2. Transmission

{code}
# apt-get install transmission-cli transmission-daemon
{code}

At this point you should have a transmission daemon running after each reboot. Use the {{/etc/init.d/transmission-daemon}} tool to stop/start the service in the normal way.

h2. lobberstoragenode

The lobberstoragenode is available from [http://pypi.python.org/] and can be installed using the easy_install tool from python-setuptools:

{warn}Errata: You may have to download the tarball and install it using the provided setup.py instead of using easy_install.{warn}

{code}
# apt-get install python-setuptools python-twisted python-feedparser bittorent
# easy_install stompservice lobberstoragenode
{code}

At this point {{twistd}} should have a new plugin registered. Verify this by running {{twistd \--help}} and look for {{lobberstoragenode}} in the list of commands. If you see this then you're installation should be ok.

{code}
# twistd --help
...
Commands:
    ftp                    An FTP server.
    telnet                 A simple, telnet-based remote debugging service.
    socks                  A SOCKSv4 proxy service.
    manhole-old            An interactive remote debugger service.
    portforward            A simple port-forwarder.
    lobberstoragenode      A Storage Node for Lobber
    web                    A general-purpose web server which can serve from a
                           filesystem or application resource.
    inetd                  An inetd(8) replacement.
    news                   A news server.
    xmpp-router            An XMPP Router server
    words                  A modern words server
    toc                    An AIM TOC service.
    dns                    A domain name server.
    mail                   An email service
    manhole                An interactive remote debugger service accessible via
                           telnet and ssh and providing syntax coloring and
                           basic line editing functionality.
    conch                  A Conch SSH service.
{code}

Running {{twistd lobberstoragenode \--help}} gives you an overview of the options:

{code}
# twistd lobberstoragenode --help
Usage: twistd [options] lobberstoragenode [options]
Options:
  -S, --stompUrl=    The STOMP protocol URL to use for notifications [default:
                     stomp://localhost:61613]
  -k, --lobberKey=   The Lobber application key to use
  -d, --torrentDir=  The directory where to store torrents [default: torrents]
  -u, --lobberUrl=   The Lobber URL prefix [default:
                     http://localhost:8000/torrents]
  -s, --script=      The script to run on all received torrents [default: ls -l]
      --version
      --help         Display this help and exit.
{code}

When running a storage-node for development purposes you will typically run it with both the {{\-\-stompUrl}} and {{\-\-lobberUrl}} parameters pointing to endpoints on your local development sandbox. When running a storage-node off of {{beta.lobber.se}} you will typically want to start it this way:

{code}
# twistd -n lobberstoragenode -k <appkey> -h beta.lobber.se -d /var/torrents [<destination|rss>]*
{code}

The final arguments is a set of STOMP destinations and/or RSS feeds. Each RSS feed is pulled regularly and each link is downloaded. If the downloaded data is a BitTorrent file it is stored in the {{\-\-torrentDir}} directory ({{/var/torrents}} in the example above). Optionally if a {{\-\-script}} option was given it will be run as a command with the path to the torrent-file as an argument. 

If you want to notify transmission of new torrents you might do something like this
{code}
# twistd -n lobberstoragenode ... --script="transmission-remote -n transmission:transmission -a"
{code}

A more complete example. This would regularly pull all torrents linked from {{https://beta.lobber.se/torrent/tag/foo.rss}} and ask transmission to add the new ones.

{code}
# twistd -n lobberstoragenode -k <key> -h beta.lobber.se -d /tmp \\
         --script="transmission-remote -n transmission:transmission -a" \\
         https://beta.lobber.se/torrent/tag/foo.rss /torrent/tag/foo
{code}

h1. Useful stuff to listen to for a storagenode

h2. STOMP destinations

||Location||What it gets you||
|/torrent/new|Each newly created torrent|
|/torrent/tag/add|Each time a torrent is tagged|
|/torrent/tag/add/foo|Each time a torrent is tagged with 'foo'|
|/torrent/tag/remove/foo|Each time the 'foo' tag is removed from a torrrent|

h2. RSS URLs

||Location||What it gets you||
|https://lobber.example.org/torrents/all.rss|All torrents readable by the current user (or key)|
|https://lobber.example.org/torrents/tag/foo.rss|All torrents tagged with 'foo'|