orpheusnet/bencode-torrent 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

orpheusnet/bencode-torrent

最新稳定版本:v1.3.0

Composer 安装命令:

composer require orpheusnet/bencode-torrent

包简介

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

README 文档

README

Test Packagist Packagist PHP Version Support

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

Usage

composer require orpheusnet/bencode-torrent

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.

Description

BEncode is the encoding used by BitTorrent to store and transmitting loosely structured data. It supports:

  • 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.

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).

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.

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:

  • 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.

统计信息

  • 总下载量: 8.48k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 11
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 11
  • Watchers: 2
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: Unlicense
  • 更新时间: 2018-11-10