NAME
Net::BitTorrent::Tracker::HTTP - HTTP/HTTPS BitTorrent Tracker Protocol
SYNOPSIS
use Net::BitTorrent::Tracker::HTTP;
my $tracker = Net::BitTorrent::Tracker::HTTP->new(
url => 'https://tracker.example.com/announce'
);
# Perform announce
$tracker->perform_announce({
infohash => $ih,
peer_id => $id,
port => 6881,
downloaded => 0,
uploaded => 0,
left => 1024
}, sub ($res) {
say 'Interval: ' . $res->{interval};
});
DESCRIPTION
Net::BitTorrent::Tracker::HTTP implements the original BitTorrent tracker protocol over HTTP and HTTPS. It handles URL encoding of binary infohashes and parsing of bencoded responses.
METHODS
new( %params )
Creates a new HTTP tracker object.
my $tracker = Net::BitTorrent::Tracker::HTTP->new( url => $url );
Expected parameters:
url-
The tracker announce URL.
perform_announce( \%params, [$callback] )
Sends an announce request to the HTTP tracker.
$tracker->perform_announce( \%params, sub ($res) { ... } );
Expected parameters:
\%params-
Standard announce parameters. Automatically handles compact peer lists (IPv4 and IPv6) and supports asynchronous mode if
$params-{ua}> is provided (e.g., an instance of Mojo::UserAgent). $callback- optional-
Called with the parsed response hash.
perform_scrape( \@infohashes, [$callback] )
Sends a scrape request to the HTTP tracker.
$tracker->perform_scrape( \@ihs, sub ($res) { ... } );
Executes a tracker scrape (BEP 48) by converting the announce URL to a scrape URL and requesting statistics for the provided hashes.
Expected parameters:
build_announce_url( $params )
Generates the full announce URL with query parameters.
my $url = $tracker->build_announce_url( \%params );
Correctly percent-encodes the binary info_hash and peer_id fields.
Expected parameters:
build_scrape_url( $infohashes )
Generates the scrape URL for the given infohashes.
my $url = $tracker->build_scrape_url( \@ihs );
Expected parameters:
parse_response( $data )
Decodes and parses a tracker response.
my $dict = $tracker->parse_response( $raw_data );
Automatically expands compact peer lists into user-friendly hashrefs.
Expected parameters:
SPECIFICATIONS
BEP 03: The BitTorrent Protocol (HTTP Tracker)
BEP 23: Tracker Returns Compact Peer Lists
BEP 07: IPv6 Support (
peers6field)BEP 48: Tracker Scrape Convention
AUTHOR
Sanko Robinson <sanko@cpan.org>
COPYRIGHT
Copyright (C) 2008-2026 by Sanko Robinson.
This library is free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0.