/xorro

A Bit-Torrent-Like P2P File Transfer System using Ruby

Primary LanguageRuby

Xorro P2P

Xorro P2P is a Ruby implementation of a Bit-Torrent-Like Peer to Peer file transfer system. Xorro is experimental, proof of concept software, and not intended as a replacement for existing P2P solutions.

Features

  • A Full implementation of a Kademlia Distributed Hash Table.

  • File sharing by drag/drop into browser - shards and manifest are autogenerated and broadcasted onto network.

  • Files are retreived by requesting the file ID -- manifest file is automatically downloaded, shards are retreived and reassembled.

  • Contents of local routing table and DHT segment can be inspected via web UI.

Getting Started

Dependencies

Ruby 2.3.1
Networking

While anyone can download Xorro, launch a node, and retreive files from the Xorro network, contributing to the network (hosting files available to others) requires one of the following:

  1. Node is directly on the public internet with a public IP, no NAT or Firewall blocking public access.
  2. Node is behind a NAT/Firewall but port forwarding is set up so that the node's port is publicly accessible.
  3. Node is behind a NAT/Firewall with no port forwarding, but a 3rd party tunneling tool is installed.

Ngrok is a tool that allows you to expose a local webserver behind a NAT firewall to the internet via secure tunnel. Xorro supports Ngrok to enable NAT translated communications.

Download Ngrok, unzip the executable, and copy it to somewhere in your $PATH ie: /usr/local/bin/ngrok

Get ngrok here.

Once ngrok is installed, you can optionally create a free account at ngrok.com and install your authtoken. The free account raises Ngrok's request/minute limit, allowing you to contribute to the network.

Installation

  1. Download the repository: git clone https://github.com/xorro-p2p/xorro.git
  2. cd into the xorro directory and run bundle install.

Configuration

  1. Change your username and password in config.yml
  2. Upon first launch, Xorro will create the xorro_homes folder at the location specified in config.yml. The default is ~/Desktop/xorro_homes. Feel free to change this.

Usage

Launching the Application

Xorro ships with a number of launch/kill scripts located in bin.

To launch a Xorro Node from behind a NAT/Firewall and retreive files from the global P2P network, run:

bin/launch_leech.sh

To launch a public Xorro Node on a host directly on the internet, or behind a firewall with port forwarding run:

bin/launch_pf_public.sh 9999   ### or other tcp port number

To launch a Xorro Node on a host behind a firewall, using Ngrok for tunneling:

bin/launch_nat_public.sh 9999   ### or other tcp port number

Your admin control panel is now accessible at http://localhost/9999. Authenticate with the credentials you set in config.yml.

Adding a file

Add a file to the network by navigating to 'Upload File' in the sidebar, then drag an image, pdf, or mp3 into the browser window. Your file will be sharded in the background, after which the shards and manifest will be broadcast to peer nodes. Your file is visible on the 'My Files' page, and the shards/manifests are visible on the Debug/Data page.

Retreiving a file

To retreive a file from the network, navigate to the 'Get File' page and enter the ID of the file you would like.

Don't know the ID of any files on the Xorro network? Try this one: 1376592690108572977913416942036588071274772272329

After successful retreival, the file will appear on the 'My Files' page and can be viewed or downloaded

Shutting Down

To shut down your Xorro node -- run bin/kill_nodes.sh.

Other scripts and environment variables

Development of Xorro required the flexibility to rapidly launch fleets of nodes in a local environment, each with specific environment variables set at launch. The rest of the scripts beneath /bin are written to standardize and streamline this process.

Some relevant environment variables for node launch:

  1. PORT: http port that Sinatra Web UI will run on.
  2. SUPERIP: IPV4 address or fully qualified domain name of supernode to be contacted at boot.
  3. SUPERPORT: TCP Port used to contact supernode at boot.
  4. SUPER: true or false -- is the node a supernode?
  5. NAT: true or false -- is this node behind NAT firewall?
  6. FQDN: Fully Qualified Domain Name or public IP at which the node is reachable.
  7. LEECH: true or false -- this disables the broadcast of location info about any hosted files.