2017 © Pedro Peláez
 

library bencode-torrent

PHP Library for decoding and encoding BitTorrent BEncoded data, built for Gazelle

image

apollorip/bencode-torrent

PHP Library for decoding and encoding BitTorrent BEncoded data, built for Gazelle

  • Monday, July 2, 2018
  • by itismadness
  • Repository
  • 0 Watchers
  • 1 Stars
  • 84 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 6 Versions
  • 68 % Grown

The README.md

BEncode Torrent

Test Packagist Packagist PHP Version Support, (*1)

PHP library for encoding and decoding BitTorrent BEncode data, focused around usage within Gazelle., (*2)

Usage

composer require orpheusnet/bencode-torrent, (*3)

require('vendor/autoload.php');
$bencode = new \OrpheusNET\BencodeTorrent\BencodeTorrent();
$bencode->decodeFile('path/to/file.torrent');
var_dump($bencode->getName());
var_dump($bencode->getHexInfoHash());
var_dump($bencode->getFileList());

See the BencodeTorrent class for more information on the available methods. Additionally, see Bencode for the underlying library to encode/decode BEncode data., (*4)

Description

BEncode is the encoding used by BitTorrent to store and transmitting loosely structured data. It supports:, (*5)

  • byte strings
  • integers
  • lists
  • dictionaries (associative arrays, where keys are sorted alphabetically)

You can see more information about how these types are supported at BitTorrentSpecification#Bencoding., (*6)

In addition to the above, torrent files are expected to be BEncoded dictionaries that contain minimally the keys announce__ (byte string) and __info__ (dictionary). Within the __info dictionary, we then expect piece length (integer) and __pieces__ (byte string). If the torrent has only a single file, we then expect __name__ (byte string) and __length__ (integer), whereas for a multi-file torrent, we'll have __name__ (byte string) and __files__ (list) where each element is a dictionary that has the keys __length__ (integer) and __path__ (list of strings)., (*7)

As such, this library will make some checks when loading data that these mandatory fields exist or else an Exception is raised. More information on these fields can be found at BitTorrentSpecification#Metainfo_File_Structure., (*8)

Finally, this library is primarily aimed at being used within the Gazelle so we have some utility functions within the library that make sense there to accomplish the following things:, (*9)

  • Ensuring torrent files are marked as 'private'
  • Setting a 'source' on torrents (to ensure unique info hash)
  • Cleaning out unnecessary fields that also reveal stuff about a user (like announce list and created by)
  • Generate string file lists as expected by Gazelle for display

This is based (loosely) off the code in the two separate BEncode libraries within WCD's Gazelle (bencodetorrent.class.php and torrent.class.php), but without the now unnecessary 32bit shims as well as making it a unified library used for both uploading and downloading the torrent files., (*10)

The Versions

02/07 2018

dev-master

9999999-dev

PHP Library for decoding and encoding BitTorrent BEncoded data, built for Gazelle

  Sources   Download

Unlicense

The Development Requires

by Avatar itismadness

02/07 2018

v0.10.0

0.10.0.0

PHP Library for decoding and encoding BitTorrent BEncoded data, built for Gazelle

  Sources   Download

Unlicense

The Development Requires

by Avatar itismadness

12/04 2018

v0.9.2

0.9.2.0

PHP Library for decoding and encoding BitTorrent BEncoded data, built for Gazelle

  Sources   Download

Unlicense

The Development Requires

by Avatar itismadness

11/04 2018

v0.9.1

0.9.1.0

PHP Library for decoding and encoding BitTorrent BEncoded data, built for Gazelle

  Sources   Download

Unlicense

The Development Requires

by Avatar itismadness

10/04 2018

v0.9.0

0.9.0.0

PHP Library for decoding and encoding BitTorrent BEncoded data, built for Gazelle

  Sources   Download

Unlicense

The Development Requires

by Avatar itismadness

03/04 2018

v0.8.0

0.8.0.0

PHP Library for decoding and encoding BitTorrent BEncoded data, built for Gazelle

  Sources   Download

Unlicense

The Development Requires

by Avatar itismadness