STorrent is a BitTorrent client written almost entirely in Akka.
STorrent heavily leverages Akka's reactive IO features to provide a (hopefully) simple set of abstractions around establishing connections with peers, reading/write bytestreams and parsing those bytestreams into BitTorrent's message model.
STorrent was heavily inspired by Ttorrent which I initially attempted to port to Akka but then decided to start entirely from scratch after taking the Coursera Reactive Programming course.
STorrent has been tested throughout, leveraging akka-testkit and scalatest to test the expected inputs/outputs, parent/child communication and actor termination, as well as regular specs for non actor classes.
If you contribute please be sure to add plenty of tests.
Examples are placed in the io.github.oxlade39.storrent.example
package
Distilled:
val sys = ActorSystem("Example")
// this will create and start an actor heirarchy to download the given torrent using default values
val download = sys.actorOf(StorrentDownload.props("examples" / "ubuntu-13.10-desktop-amd64.iso.torrent"), "ubuntu")
io.github.oxlade39.storrent.example.Example
demonstrates one example usage of STorrent and can be used to successfully
download Ubuntu
STorrent is not finished! For example serving pieces to connected peers is not implemented at all, in other words only downloads are currently supported.
I'm working on fixing that, you can help too.
This is my first attempt at developing anything significant in Akka, following on from the Coursera Reactive Programming course. I'm keen to improve my Akka and Scala so constructive criticism is welcomed.
The remaining work will be tracked in the issues section, the focus on working toward a 1.0 release which will aim to be a minimum feature working BitTorrent client.
Notable implementation areas:
Torrent
The torrent file modelBencodeParser
implementation of Bencode parsingBValue
case classes representing the different Bencoded types
Example
An example of using STorrent to download Ubuntu
There is currently no notification of final completion but this shouldn't be hard to add...
Folder and single File persistence, using java.nio
Downloader2
Actor currently responsible for managing and co-ordinating child actors which request and download the individual pieces and blocks. It currently uses a work pulling pattern to queue the available work (pieces from peers) and allow workers to request the next download task (piece from peer) to work on.
Copyright 2014 Dan Oxlade
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.