bittorrent-0.0.0.3: Bittorrent protocol implementation.

Portabilityportable
Stabilityexperimental
Maintainerpxqr.sta@gmail.com
Safe HaskellNone

Data.Torrent

Contents

Description

Torrent file contains metadata about files and folders but not content itself. The files are bencoded dictionaries. There is also other info which is used to help join the swarm.

This module provides torrent metainfo serialization and info hash extraction.

For more info see: http://www.bittorrent.org/beps/bep_0003.html#metainfo-files, https://wiki.theory.org/BitTorrentSpecification#Metainfo_File_Structure

Synopsis

Info dictionary

data InfoDict Source

Info part of the .torrent file contain info about each content file.

Constructors

InfoDict 

Fields

idInfoHash :: !InfoHash

SHA1 hash of the (other) DictInfo fields.

idLayoutInfo :: !LayoutInfo
 
idPieceInfo :: !PieceInfo
 
idPrivate :: !Bool

If set the client MUST publish its presence to get other peers ONLY via the trackers explicity described in the metainfo file.

BEP 27: http://www.bittorrent.org/beps/bep_0027.html

infoDictionary :: LayoutInfo -> PieceInfo -> Bool -> InfoDictSource

Smart constructor: add a info hash to info dictionary.

Lenses

Torrent file

data Torrent Source

Metainfo about particular torrent.

Constructors

Torrent 

Fields

tAnnounce :: !URI

The URL of the tracker.

tAnnounceList :: !(Maybe [[URI]])

Announce list add multiple tracker support.

BEP 12: http://www.bittorrent.org/beps/bep_0012.html

tComment :: !(Maybe Text)

Free-form comments of the author.

tCreatedBy :: !(Maybe Text)

Name and version of the program used to create the .torrent.

tCreationDate :: !(Maybe POSIXTime)

Creation time of the torrent, in standard UNIX epoch.

tEncoding :: !(Maybe Text)

String encoding format used to generate the pieces part of the info dictionary in the .torrent metafile.

tInfoDict :: !InfoDict

Info about each content file.

tPublisher :: !(Maybe URI)

Containing the RSA public key of the publisher of the torrent. Private counterpart of this key that has the authority to allow new peers onto the swarm.

tPublisherURL :: !(Maybe URI)
 
tSignature :: !(Maybe BS.ByteString)

The RSA signature of the info dictionary (specifically, the encrypted SHA-1 hash of the info dictionary).

Lenses

Construction

nullTorrent :: URI -> InfoDict -> TorrentSource

A simple torrent contains only required fields.

Mime types

typeTorrent :: BS.ByteStringSource

Mime type of torrent files.

File paths

torrentExt :: StringSource

Extension usually used for torrent files.

isTorrentPath :: FilePath -> BoolSource

Test if this path has proper extension.

IO

fromFile :: FilePath -> IO TorrentSource

Read and decode a .torrent file.

toFile :: FilePath -> Torrent -> IO ()Source

Encode and write a .torrent file.