• Stars
    star
    233
  • Rank 172,230 (Top 4 %)
  • Language
    Haskell
  • License
    BSD 2-Clause "Sim...
  • Created almost 15 years ago
  • Updated almost 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A bittorrent client written in Haskell

Combinatorrent - a bittorrent client.

Build Status

Introduction

This is a bittorrent client. I am the introduction document and I need to be written by some generous soul!

Installation

Here is what I do to install haskell torrrent locally on my machine:

cabal install --prefix=$HOME --user

Since we are using the magnificient cabal, this is enough to install haskell torrent in our $HOME/bin directory.

Usage

Combinatorrent can currently only do one very simple thing. If you call it with

Combinatorrent foo.torrent

then it will begin downloading the file in foo.torrent to the current directory via the Bittorrent protocol.

Protocol support

Currently haskell-torrent supports the following BEPs (See the BEP Process document for an explanation of these)

  • 0003, 0004, 0006, 0010, 0020,

Combinatorrent implicitly supports these extensions

  • 0027: Support by the virtue of only supporting a single tracker and no DHT.

Partially supported extensions:

  • 0007: Combinatorrent understands and uses the "peers6" response from the tracker to connect clients. On the other hand, it does nothing to provide the "ipv4=" and "ipv6=" keys on tracker requests. As such, it can be claimed that 0007 support is available, as everything we left out is only qualified as MAY.

  • 0023: Combinatorrent supports the "compact" response only, although it is explicitly stated that the client must support both. In practice it has little impact as all modern trackers will only return compact responses anyway.

Combinatorrent is not supporting these BEPs, but strives to do so one day:

  • 0005, 0009, 0012, 0015, 0016, 0017, 0018, 0019, 0021, 0022, 0024, 0026, 0028, 0029, 0030, 0031, 0032

Debugging

For debugging, jlouis tends to use the following:

make conf build test

This builds Combinatorrent with the Debug flag set and also builds the software with profiling by default so it is easy to hunt down performance regressions. It also runs the internal test-suite for various values. There are a couple of interesting targets in the top-level Makefile

Reading material for hacking Combinatorrent:

  • Protocol specification - BEP0003: This is the original protocol specification, tracked into the BEP process. It is worth reading because it explains the general overview and the precision with which the original protocol was written down.

  • Bittorrent Enhancement Process - BEP0000 The BEP process is an official process for adding extensions on top of the BitTorrent protocol. It allows implementors to mix and match the extensions making sense for their client and it allows people to discuss extensions publicly in a forum. It also provisions for the deprecation of certain features in the long run as they prove to be of less value.

  • wiki.theory.org An alternative description of the protocol. This description is in general much more detailed than the BEP structure. It is worth a read because it acts somewhat as a historic remark and a side channel. Note that there are some commentary on these pages which can be disputed quite a lot.

  • "Supervisor Behaviour" From the Erlang documentation. How the Erlang Supervisor behaviour works. The Supervisor and process structure of Combinatorrent is somewhat inspired by the Erlang ditto.

Source code Hierarchy

  • Data: Data structures.

    • Queue: Functional queues. Standard variant with two lists.
    • PendingSet: A wrapper around Data.PSQueue for tracking how common a piece is.
    • PieceSet: BitArrays of pieces and their operations.
  • Process: Process definitions for the different processes comprising Combinatorrent

    • ChokeMgr: Manages choking and unchoking of peers, based upon the current speed of the peer and its current state. Global for multiple torrents.
    • Console: Simple console process. Only responds to 'quit' at the moment.
    • DirWatcher: Watches a directory and adds any torrent present in it.
    • FS: Process managing the file system.
    • Listen: Not used at the moment. Step towards listening sockets.
    • Peer: Several process definitions for handling peers. Two for sending, one for receiving and one for controlling the peer and handle the state.
    • PeerMgr: Management of a set of peers for a single torrent.
    • PieceMgr: Keeps track of what pieces have been downloaded and what are missing. Also hands out blocks for downloading to the peers.
    • Status: Keeps track of uploaded/downloaded/left bytes for a single torrent. Could be globalized.
    • Timer: Timer events.
    • TorrentManager: Manages torrents at the top-level.
    • Tracker: Communication with the tracker.
  • Protocol: Modules for interacting with the various bittorrent protocols.

    • BCode: The bittorrent BCode coding. Used by several protocols.
    • Wire: The protocol used for communication between peers.
  • Top Level:

    • Channels: Various Channel definitions.
    • Combinatorrent: Main entry point to the code. Sets up processes.
    • Digest: SHA1 digests as used in the bittorrent protocol.
    • FS: Low level Filesystem code. Interacts with files.
    • Process: Code for Erlang-inspired processes.
    • RateCalc: Rate calculations for a network socket. We use this to keep track of the current speed of a peer in one direction.
    • Supervisor: Erlang-inspired Supervisor processes.
    • Test.hs: Code for test-framework
    • TestInstance.hs: Various helper instances not present in the test framework by default
    • Torrent: Various helpers and types for Torrents.
    • Tracer: Code for simple "ring"-like tracing.
    • Version.hs.in: Generates Version.hs via the configure script.

More Repositories

1

fuse

A Circuit Breaker for Erlang
Erlang
501
star
2

graphql-erlang

GraphQL implementation in Erlang.
Erlang
312
star
3

etorrent

Erlang Bittorrent Client
Erlang
295
star
4

safetyvalve

A safety valve for your erlang node
Erlang
257
star
5

enacl

Erlang bindings for NaCl / libsodium
Erlang
189
star
6

dht

DHT implementation in Erlang
Erlang
123
star
7

eministat

Port of Poul-Henning Kamp's ministat to the Erlang world
Erlang
99
star
8

plan9-setup

My Plan9 Files for configuration of plan 9 from user space
Shell
94
star
9

turtle

A wrapper on the RabbitMQ Erlang Client (Erlang)
Erlang
71
star
10

erl-lenses

Lens implementation in Erlang
Erlang
67
star
11

graphql-erlang-tutorial

A tutorial for the graphql-erlang system
JavaScript
58
star
12

erlangnode

Run an OCaml program as an erlang node
OCaml
29
star
13

rlimit

Magnus Klaar's rate limiter code from etorrent
Erlang
26
star
14

erlang-utp

uTP implementation in Erlang
Erlang
23
star
15

etorrent_core

Core application in the etorrent subsystem.
Erlang
23
star
16

curve_tun

TCP tunnels secured by Curve25519
Erlang
19
star
17

forge

Melt unstructured data and cast it with structure
Erlang
18
star
18

maps_eqc

EQC tests for maps
Erlang
14
star
19

transit-ocaml

The Transit format in OCaml
OCaml
13
star
20

erl-glicko2

Glicko 2 ranking for Erlang
Erlang
13
star
21

positive

Check if a term is positive
Erlang
13
star
22

go-challenge-1

The 1st Golang challenge in Erlang
Erlang
11
star
23

jlouis-emacs-conf

My Emacs Configuration.
Emacs Lisp
10
star
24

eqc_lib

Erlang QuickCheck common library functions
Erlang
9
star
25

erlfmt

Formatting of Erlang terms from the command line
Erlang
6
star
26

glicko2

Glicko 2 computations in Go
Go
6
star
27

glocko2

Go implementation of the glicko2 calculations
Go
5
star
28

erl-webstuff

Various Utilities for web processing
Erlang
5
star
29

eventi

A (experimental) venti implementation in Erlang.
Erlang
5
star
30

av-prog

Advanced programming course hacking on ICFP 2006
Haskell
4
star
31

nmoptim

Nelder-Mead optimization heuristic in Go
Go
4
star
32

ident

Go ident client library
Go
3
star
33

bench-map

Benchmarks of Erlang maps
Erlang
3
star
34

mylittlepony

Pony is an experimental ircd in Erlang.
Shell
3
star
35

meganalysis-erlang

An Erlang implementation of the meganalysis project
Erlang
3
star
36

dotfiles

My dotfiles
2
star
37

o-glicko2

Ocaml Glicko2 implementation
OCaml
2
star
38

janus-formalization

My (planned) graduate project on invertible computation.
Verilog
2
star
39

disque_eqc

QuickCheck model for discque
Erlang
2
star
40

corona

Various tools for processing COVID-19 data sets
R
2
star
41

jlouis-vimrc

Vim configuration files
Vim Script
2
star
42

jlouis-tvm

Formalization of virtual machines. Master project.
C
1
star
43

covid-19-stats-dk

Covid-19 statistics for Denmark
R
1
star
44

rank

Rank Quake Live games in Go
Go
1
star