Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

We’re showing branches in this repository, but you can also compare across forks.

base fork: sanko/net-bittorrent-protocol
base: 5506598358
...
head fork: sanko/net-bittorrent-protocol
compare: ae8d93c824
  • 4 commits
  • 11 files changed
  • 0 commit comments
  • 1 contributor
68 Build.PL
View
@@ -9,46 +9,46 @@ my $is_developer = ((-d '.git') ? 1 : 0) or ($ENV{'RELEASE_TESTING'} ? 1 : 0);
my @tests;
find \&find_cb, qw[t/];
my $mb = Module::Build->new(
- module_name => 'Net::BitTorrent::Protocol',
- license => 'artistic_2',
- dist_author => 'Sanko Robinson <sanko@cpan.org>',
- dist_abstract => 'Basic, Protocol-level BitTorrent Utilities',
- requires => {
- Carp => 0,
- Exporter => 0,
- 'Module::Build' => 0.38,
- perl => '5.10.0'
- },
- build_requires => {Carp => 0,
- Exporter => 0,
- 'Module::Build' => 0.38,
- perl => '5.10.0',
- 'Test::More' => 0
- },
- configure_requires => {'File::Find' => 0,
- 'Module::Build' => 0.38
- },
- auto_features => {
- packet_dump_support => {
- description => 'Dumps unhanded packets for easy bug reporting',
- requires => {'Data::Dump' => 0}
- }
- },
- test_files => \@tests,
- test_file_exts => ['.t'],
- meta_merge => {
- keywords =>
- [qw[BitTorrent Protocol Packet Utility Bencode Compact Peers]],
- resources => {
+ module_name => 'Net::BitTorrent::Protocol',
+ license => 'artistic_2',
+ dist_author => 'Sanko Robinson <sanko@cpan.org>',
+ dist_abstract => 'Basic, Protocol-level BitTorrent Utilities',
+ requires => {
+ Carp => 0,
+ 'Digest::SHA' => 1,
+ Exporter => 0,
+ perl => '5.10.0'
+ },
+ build_requires => {Carp => 0,
+ Exporter => 0,
+ 'Module::Build' => 0.38,
+ perl => '5.10.0',
+ 'Test::More' => 0
+ },
+ configure_requires => {'File::Find' => 0,
+ 'Module::Build' => 0.38
+ },
+ auto_features => {
+ packet_dump_support => {
+ description => 'Dumps unhanded packets for easy bug reporting',
+ requires => {'Data::Dump' => 0}
+ }
+ },
+ test_files => \@tests,
+ test_file_exts => ['.t'],
+ meta_merge => {
+ keywords => [
+ qw[BitTorrent Protocol Packet Utility Bencode Compact Peers BEP]],
+ resources => {
bugtracker => 'http://github.com/sanko/net-bittorrent/issues',
repository =>
'git://github.com/sanko/net-bittorrent-protocol.git',
ChangeLog =>
'http://github.com/sanko/net-bittorrent-protocol/commits/',
homepage => 'http://sankorobinson.com/net-bittorrent/'
- }
- },
- create_readme => 1
+ }
+ },
+ create_readme => 1
);
$mb->notes(automated_testing => $automated_testing ? 1 : 0);
$mb->notes(release_testing => $is_developer);
12 Changes
View
@@ -1,4 +1,14 @@
-Version 0.9.1 | The wee hours of December 19th, 2011 | xxxxxxxxxx
+Version 1.0.0 | Soon | xxxxxxxxxx
+
+ API Changes/Compatibility Information:
+ * New utility function ::BEP06::generate_fast_set( ... )
+
+ Documentation/Sample Code/Test Suite:
+ * Example script is now a standalone module: AnyEvent::BitTorrent
+ * BEP06 functions are now documented
+ * BEP07 functions now have tests
+
+Version 0.9.1 | The wee hours of December 19th, 2011 | 5506598358
API Changes/Compatibility Information:
* ::BEP03::build_piece(...) wants the actual data rather than a reference
1  MANIFEST
View
@@ -16,5 +16,6 @@ t/0000_net_bittorrent_protocol.t
t/0003_net_bittorrent_protocol_bep03.t
t/0003_net_bittorrent_protocol_bep03_bencode.t
t/0006_net_bittorrent_protocol_bep06.t
+t/0007_net_bittorrent_protocol_bep07.t
t/0010_net_bittorrent_protocol_bep10.t
TODO
46 README
View
@@ -54,40 +54,44 @@ Importing from Net::BitTorrent::Protocol
`types'
Imports the packet type values from BEP03, BEP06, and BEP10.
+ `utils'
+ Imports the utility functions from BEP06. =back
+
See Also
- AnyEvent::BitTorrent - Simple client which uses
- Net::BitTorrent::Protocol
+ AnyEvent::BitTorrent - Simple client which uses
+ Net::BitTorrent::Protocol
- http://bittorrent.org/beps/bep_0003.html - The BitTorrent Protocol
- Specification
+ http://bittorrent.org/beps/bep_0003.html - The BitTorrent Protocol
+ Specification
- http://bittorrent.org/beps/bep_0006.html - Fast Extension
+ http://bittorrent.org/beps/bep_0006.html - Fast Extension
- http://bittorrent.org/beps/bep_0010.html - Extension Protocol
+ http://bittorrent.org/beps/bep_0010.html - Extension Protocol
- http://wiki.theory.org/BitTorrentSpecification - An annotated guide to
- the BitTorrent protocol
+ http://wiki.theory.org/BitTorrentSpecification - An annotated guide
+ to the BitTorrent protocol
- Net::BitTorrent::PeerPacket - by Joshua McAdams
+ Net::BitTorrent::PeerPacket - by Joshua McAdams
- Protocol::BitTorrent - by Tom Molesworth
+ Protocol::BitTorrent - by Tom Molesworth
Author
- Sanko Robinson <sanko@cpan.org> - http://sankorobinson.com/
+ Sanko Robinson <sanko@cpan.org> - http://sankorobinson.com/
- CPAN ID: SANKO
+ CPAN ID: SANKO
License and Legal
- Copyright (C) 2008-2012 by Sanko Robinson <sanko@cpan.org>
+ Copyright (C) 2008-2012 by Sanko Robinson <sanko@cpan.org>
- This program is free software; you can redistribute it and/or modify it
- under the terms of The Artistic License 2.0. See the LICENSE file
- included with this distribution or notes on the Artistic License 2.0 for
- clarification.
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of The Artistic License 2.0. See the LICENSE file
+ included with this distribution or notes on the Artistic License 2.0
+ for clarification.
- When separated from the distribution, all original POD documentation is
- covered by the Creative Commons Attribution-Share Alike 3.0 License. See
- the clarification of the CCA-SA3.0.
+ When separated from the distribution, all original POD documentation
+ is covered by the Creative Commons Attribution-Share Alike 3.0
+ License. See the clarification of the CCA-SA3.0.
- Neither this module nor the Author is affiliated with BitTorrent, Inc.
+ Neither this module nor the Author is affiliated with BitTorrent,
+ Inc.
10 lib/Net/BitTorrent/Protocol.pm
View
@@ -35,8 +35,11 @@ use Exporter qw[];
types => [@{$Net::BitTorrent::Protocol::BEP03::EXPORT_TAGS{types}},
@{$Net::BitTorrent::Protocol::BEP06::EXPORT_TAGS{types}},
@{$Net::BitTorrent::Protocol::BEP10::EXPORT_TAGS{types}}
- ]
-);
+ ],
+
+ utils => [@{ $Net::BitTorrent::Protocol::BEP06::EXPORT_TAGS{utils}
+ },
+ ] );
@EXPORT_OK = sort map { @$_ = sort @$_; @$_ } values %EXPORT_TAGS;
$EXPORT_TAGS{'all'} = \@EXPORT_OK;
my $parse_packet_dispatch;
@@ -198,6 +201,9 @@ Imports the packet type values from L<BEP03|Net::BitTorrent::Protocol::BEP03>,
L<BEP06|Net::BitTorrent::Protocol::BEP06>, and
L<BEP10|Net::BitTorrent::Protocol::BEP10>.
+=item C<utils>
+
+Imports the utility functions from L<BEP06|Net::BitTorrent::Protocol::BEP06>.
=back
=head1 See Also
17 lib/Net/BitTorrent/Protocol/BEP03.pm
View
@@ -527,23 +527,23 @@ and C<$peerid]>.
=item C<parse_keepalive( $data )>
-Returns an empty list. Keepalive packets to not contain a playload.
+Returns an empty list. Keepalive packets do not contain a playload.
=item C<parse_choke( $data )>
-Returns an empty list. Choke packets to not contain a playload.
+Returns an empty list. Choke packets do not contain a playload.
=item C<parse_unchoke( $data )>
-Returns an empty list. Unchoke packets to not contain a playload.
+Returns an empty list. Unchoke packets do not contain a playload.
=item C<parse_interested( $data )>
-Returns an empty list. Interested packets to not contain a playload.
+Returns an empty list. Interested packets do not contain a playload.
=item C<parse_not_interested( $data )>
-Returns an empty list. Not interested packets to not contain a playload.
+Returns an empty list. Not interested packets do not contain a playload.
=item C<parse_have( $data )>
@@ -557,16 +557,17 @@ working with C<vec(...)>.
=item C<parse_request( $data )>
Returns an array reference containing the C<$index>, C<$offset>, and
-C<length>.
+C<$length>.
=item C<parse_piece( $data )>
-Returns an array reference containing teh C<$index>, C<$offset>, and C<$data>.
+Returns an array reference containing teh C<$index>, C<$offset>, and
+C<$block>.
=item C<parse_cancel( $data )>
Returns an array reference containing the C<$index>, C<$offset>, and
-C<length>.
+C<$length>.
=item C<parse_port( $data )>
247 lib/Net/BitTorrent/Protocol/BEP06.pm
View
@@ -1,25 +1,20 @@
package Net::BitTorrent::Protocol::BEP06;
-our $MAJOR = 0; our $MINOR = 9; our $PATCH = 1; our $DEV = ''; our $VERSION = sprintf('%0d.%0d.%0d' . ($DEV =~ m[S] ? '-%s' : ''), $MAJOR, $MINOR, $PATCH, $DEV);
+our $MAJOR = 1; our $MINOR = 0; our $PATCH = 0; our $DEV = ''; our $VERSION = sprintf('%0d.%0d.%0d' . ($DEV =~ m[S] ? '-%s' : ''), $MAJOR, $MINOR, $PATCH, $DEV);
use Carp qw[carp];
use vars qw[@EXPORT_OK %EXPORT_TAGS];
use Exporter qw[];
*import = *import = *Exporter::import;
%EXPORT_TAGS = (
build => [
- qw[
- build_suggest build_allowed_fast build_reject
+ qw[ build_suggest build_allowed_fast build_reject
build_have_all build_have_none ]
],
parse => [
- qw[
- parse_suggest parse_have_all parse_have_none
+ qw[ parse_suggest parse_have_all parse_have_none
parse_reject parse_allowed_fast ]
],
- types => [
- qw[
- $SUGGEST $HAVE_ALL $HAVE_NONE $REJECT $ALLOWED_FAST
- ]
- ]
+ types => [qw[ $SUGGEST $HAVE_ALL $HAVE_NONE $REJECT $ALLOWED_FAST ]],
+ utils => [qw[generate_fast_set]]
);
@EXPORT_OK = sort map { @$_ = sort @$_; @$_ } values %EXPORT_TAGS;
$EXPORT_TAGS{'all'} = \@EXPORT_OK;
@@ -28,9 +23,8 @@ our $HAVE_ALL = 14;
our $HAVE_NONE = 15;
our $REJECT = 16;
our $ALLOWED_FAST = 17;
-our $EXTPROTOCOL = 20;
-sub build_suggest ($) {
+sub build_suggest {
my ($index) = @_;
if ((!defined $index) || ($index !~ m[^\d+$])) {
carp sprintf '%s::build_suggest() requires an index parameter',
@@ -39,10 +33,10 @@ sub build_suggest ($) {
}
return pack('NcN', 5, 13, $index);
}
-sub build_have_all () { return pack('Nc', 1, 14); }
-sub build_have_none () { return pack('Nc', 1, 15); }
+sub build_have_all { pack('Nc', 1, 14); }
+sub build_have_none { pack('Nc', 1, 15); }
-sub build_reject ($$$) {
+sub build_reject {
my ($index, $offset, $length) = @_;
if ((!defined $index) || ($index !~ m[^\d+$])) {
carp sprintf '%s::build_reject() requires an index parameter',
@@ -63,7 +57,7 @@ sub build_reject ($$$) {
return pack('Nca*', length($packed) + 1, 16, $packed);
}
-sub build_allowed_fast ($) {
+sub build_allowed_fast {
my ($index) = @_;
if ((!defined $index) || ($index !~ m[^\d+$])) {
carp sprintf
@@ -75,17 +69,17 @@ sub build_allowed_fast ($) {
}
# Parsing functions
-sub parse_suggest ($) {
+sub parse_suggest {
my ($packet) = @_;
if ((!$packet) || (length($packet) < 1)) {
return {error => 'Incorrect packet length for SUGGEST'};
}
return unpack('N', $packet);
}
-sub parse_have_all ($) { return; }
-sub parse_have_none ($) { return; }
+sub parse_have_all { return; }
+sub parse_have_none { return; }
-sub parse_reject ($) {
+sub parse_reject {
my ($packet) = @_;
if ((!$packet) || (length($packet) < 9)) {
return {error =>
@@ -97,47 +91,224 @@ sub parse_reject ($) {
return ([unpack('N3', $packet)]);
}
-sub parse_allowed_fast ($) {
+sub parse_allowed_fast {
my ($packet) = @_;
if ((!$packet) || (length($packet) < 1)) {
return {error => 'Incorrect packet length for FASTSET'};
}
return unpack('N', $packet);
}
+
+#
+sub generate_fast_set {
+ my ($k, $sz, $infohash, $ip) = @_;
+ my @a;
+ my $x = pack('C3', (split(/\./, $ip))) . "\0" . $infohash;
+ while (1) {
+ require Digest::SHA;
+ $x = Digest::SHA::sha1($x);
+ for my $i (0 .. 4) {
+ return @a if scalar @a == $k;
+ my $index = hex(unpack('H*', substr($x, $i * 4, 4))) % $sz;
+ push @a, $index if !grep { $_ == $index } @a;
+ }
+ }
+ @a;
+}
+
+#
1;
=pod
-=item C<build_allowed_fast ( INDEX )>
+=head1 NAME
+
+Net::BitTorrent::Protocol::BEP06 - Packet Utilities for BEP06: Fast Extension
+
+=head1 Synopsis
+
+ use Net::BitTorrent::Protocol::BEP06 qw[all];
+ my $index = parse_allowed_fast($data);
+
+=head1 Description
+
+The Fast Extension modifies the semantics of the
+L<Request|Net::BitTorrent::Protocol::BEP03/"build_request ( $index, $offset, $length )">,
+L<Choke|Net::BitTorrent::Protocol::BEP03/"build_choke ( )">,
+L<Unchoke|Net::BitTorrent::Protocol::BEP03/"build_unchoke ( )">, and
+L<Cancel|Net::BitTorrent::Protocol::BEP03/"build_cancel ( $index, $offset, $length )">,
+and adds a L<Reject|/"build_reject ( $index, $offset, $length )"> Request.
+Now, every request is guaranteed to result in I<exactly one> response which is
+either the corresponding reject or corresponding piece message. Even when a
+request is cancelled, the peer receiving the cancel should respond with either
+the corresponding reject or the corresponding piece: requests that are being
+processed are allowed to complete.
+
+Choke no longer implicitly rejects all pending requests, thus eliminating some
+race conditions which could cause pieces to be needlessly requested multiple
+times.
+
+=head1 Importing from Net::BitTorrent::Protocol::BEP06
+
+There are four tags available for import. To get them all in one go, use the
+C<:all> tag.
+
+=over
+
+=item C<:types>
+
+Packet types
+
+For more on what these packets actually mean, see the Fast Extension spec.
+This is a list of the currently supported packet types.
+
+=over
+
+=item C<$SUGGEST>
+
+=item C<$HAVE_ALL>
+
+=item C<$HAVE_NONE>
+
+=item C<$REJECT>
+
+=item C<$ALLOWED_FAST>
+
+=back
+
+=item C<:build>
+
+These create packets ready-to-send to remote peers. See
+L<Building Functions|/"Building Functions">.
+
+=item C<:parse>
+
+These are used to parse unknown data into sensible packets. The same packet
+types we can build, we can also parse. See
+L<Parsing Functions|/"Parsing Functions">.
+
+=item C<:utils>
+
+Helpful functions listed in the section entitled
+L<Utility Functions|/"Utility Functions">.
+
+=back
+
+=head1 Building Functions
+
+=over
+
+=item C<build_have_all( )>
+
+Creates an advisory packet which claims you have all pieces and can seed.
+
+You should send this rather than a bitfield of all true values.
+
+=item C<build_have_none( )>
+
+Creates an advisory packet which claims you have no data related to the
+torrent.
+
+=item C<build_suggest( $index )>
+
+Creates an advisory message meaning "you might like to download this piece."
+The intended usage is for 'super-seeding' without throughput reduction, to
+avoid redundant downloads, and so that a seed which is disk I/O bound can
+upload contiguous or identical pieces to avoid excessive disk seeks.
+
+You should send this instead of a bitfield of nothing but null values.
+
+=item C<build_reject ( $index, $offset, $length )>
+
+Creates a packet which is used to notify a requesting peer that its request
+will not be satisfied.
+
+=item C<build_allowed_fast ( $index )>
+
+Creates an advisory message which means "if you ask for this piece, I'll give
+it to you even if you're choked."
+
+=back
+
+=head1 Parsing Functions
+
+These are the parsing counterparts for the C<build_> functions.
+
+When the packet is invalid, a hash reference is returned with a single key:
+C<error>. The value is a string describing what went wrong.
+
+Return values for valid packets are explained below.
+
+=over
+
+=item C<parse_have_all( $data )>
+
+Returns an empty list. HAVE ALL packets do not contain a payload.
+
+=item C<parse_have_none( $data )>
+
+Returns an empty list. HAVE NONE packets do not contain a payload.
+
+=item C<parse_suggest( $data )>
+
+Returns an integer.
+
+=item C<parse_reject( $data )>
+
+Returns an array reference containing the C<$index>, C<$offset>, and
+C<$length>.
+
+=item C<parse_allowed_fast( $data )>
+
+Returns an integer.
+
+=back
+
+=head1 Utility Functions
-Creates an Allowed Fast packet.
+=over
-uTorrent never advertises a fast set... why should we?
+=item C<generate_fast_set( $k, $sz, $infohash, $ip )>
-See also: http://bittorrent.org/beps/bep_0006.html - Fast Extension
+Returns a list of integers. C<$k> is the number of pieces in the set, C<$sz>
+is the number of pieces in the torrent, C<$infohash> is the packed infohash,
+C<$ip> is the IPv4 (dotted quad) address of the peer this set will be
+generated for.
-=item C<build_suggest ( INDEX )>
+ my $data = join '',
+ map { build_allowed_fast($_) }
+ generate_fast_set(7, 1313, "\xAA" x 20, '80.4.4.200');
-Creates a Suggest Piece packet.
+=back
-Super seeding is not supported by Net::BitTorrent. Yet.
+=head1 See Also
-See also: http://bittorrent.org/beps/bep_0006.html - Fast Extension
+http://bittorrent.org/beps/bep_0006.html - Fast Extension
-=item C<build_reject ( INDEX, OFFSET, LENGTH )>
+=head1 Author
-Creates a Reject Request packet.
+Sanko Robinson <sanko@cpan.org> - http://sankorobinson.com/
-See also: http://bittorrent.org/beps/bep_0006.html - Fast Extension
+CPAN ID: SANKO
-=item C<build_have_all ( )>
+=head1 License and Legal
-Creates a Have All packet.
+Copyright (C) 2008-2012 by Sanko Robinson <sanko@cpan.org>
-See also: http://bittorrent.org/beps/bep_0006.html - Fast Extension
+This program is free software; you can redistribute it and/or modify it under
+the terms of
+L<The Artistic License 2.0|http://www.perlfoundation.org/artistic_license_2_0>.
+See the F<LICENSE> file included with this distribution or
+L<notes on the Artistic License 2.0|http://www.perlfoundation.org/artistic_2_0_notes>
+for clarification.
-=item C<build_have_none ( )>
+When separated from the distribution, all original POD documentation is
+covered by the
+L<Creative Commons Attribution-Share Alike 3.0 License|http://creativecommons.org/licenses/by-sa/3.0/us/legalcode>.
+See the
+L<clarification of the CCA-SA3.0|http://creativecommons.org/licenses/by-sa/3.0/us/>.
-Creates a Have None packet.
+Neither this module nor the L<Author|/Author> is affiliated with BitTorrent,
+Inc.
-See also: http://bittorrent.org/beps/bep_0006.html - Fast Extension
+=cut
24 lib/Net/BitTorrent/Protocol/BEP07.pm
View
@@ -2,7 +2,7 @@ package Net::BitTorrent::Protocol::BEP07;
use strict;
use warnings;
use Carp qw[carp];
-our $MAJOR = 0; our $MINOR = 9; our $PATCH = 0; our $DEV = 'rc5'; our $VERSION = sprintf('%0d.%0d.%0d' . ($DEV =~ m[S] ? '-%s' : ''), $MAJOR, $MINOR, $PATCH, $DEV);
+our $MAJOR = 1; our $MINOR = 0; our $PATCH = 0; our $DEV = 'rc5'; our $VERSION = sprintf('%0d.%0d.%0d' . ($DEV =~ m[S] ? '-%s' : ''), $MAJOR, $MINOR, $PATCH, $DEV);
use vars qw[@EXPORT_OK %EXPORT_TAGS];
use Exporter qw[];
*import = *import = *Exporter::import;
@@ -10,20 +10,20 @@ use Exporter qw[];
%EXPORT_TAGS = (all => [@EXPORT_OK], bencode => [@EXPORT_OK]);
sub uncompact_ipv6 {
- my %peers;
- $peers{sprintf("%X:%X:%X:%X:%X:%X:%X:%X:%s", unpack('n9', $1))}++
- while ($_[0] =~ s[^(.{18})][]g);
- return keys %peers;
+ return $_[0] ?
+ map {
+ my (@h) = unpack 'n*', $_;
+ [sprintf('%X:%X:%X:%X:%X:%X:%X:%X', @h), $h[-1]]
+ } $_[0] =~ m[(.{20})]g
+ : ();
}
sub compact_ipv6 {
- my (@peers) = @_;
- @peers || return;
my $return;
my %seen;
-PEER: for my $peer (grep(defined && !$seen{$_}++, @peers)) {
- next if not $peer;
- my ($ip, $port) = ($peer =~ m[^([\da-f:]+):(\d+)$]i);
+PEER: for my $peer (grep(defined && !$seen{$_}++, @_)) {
+ my ($ip, $port) = @$peer;
+ $ip // next;
if ($port > 2**16) {
carp 'Port number beyond ephemeral range: ' . $peer;
}
@@ -49,9 +49,7 @@ PEER: for my $peer (grep(defined && !$seen{$_}++, @peers)) {
}
$ip =~ s/::/:::/ while $c++ < 7; # expand compressed fields
$ip .= 0 if $ip =~ /:$/;
- my @hex = split(/:/, $ip);
- $hex[$_] = hex($hex[$_] || 0) foreach (0 .. $#hex);
- $return .= uc pack('n9', @hex, $port);
+ $return .= pack('H36', join '', split /:/, $ip) . pack 'n', $port;
}
}
return $return;
2  t/0000_net_bittorrent_protocol.t
View
@@ -32,7 +32,7 @@ can_ok 'Net::BitTorrent::Protocol', $_ for
# BEP06
qw[build_suggest build_allowed_fast build_reject build_have_all
build_have_none parse_suggest parse_have_all parse_have_none parse_reject
- parse_allowed_fast],
+ parse_allowed_fast generate_fast_set],
# BEP07
qw[compact_ipv6 uncompact_ipv6],
8 t/0006_net_bittorrent_protocol_bep06.t
View
@@ -87,6 +87,14 @@ is parse_allowed_fast("\xf0\xf0\xf0\xf0"),
is parse_allowed_fast("\xff\xff\xff\xff"),
4294967295, 'parse_allowed_fast("\xff\xff\xff\xff") == 4294967295';
+#
+is_deeply [generate_fast_set(7, 1313, "\xAA" x 20, '80.4.4.200')],
+ [1059, 431, 808, 1217, 287, 376, 1188],
+ 'generate_fast_set( ... ) Spec vector A';
+is_deeply [generate_fast_set(9, 1313, "\xAA" x 20, '80.4.4.200')],
+ [1059, 431, 808, 1217, 287, 376, 1188, 353, 508],
+ 'generate_fast_set( ... ) Spec vector B';
+
# We're finished!
done_testing;
__END__
34 t/0007_net_bittorrent_protocol_bep07.t
View
@@ -0,0 +1,34 @@
+use Test::More;
+use lib './lib', '../lib';
+$|++;
+
+# Does it return 1?
+use_ok 'Net::BitTorrent::Protocol::BEP07', ':all';
+
+#
+is compact_ipv6(['2001:0db8:85a3:0000:0000:8a2e:0370:7334', 2223]),
+ pack('H*', '20010db885a3000000008a2e03707334000008af'),
+ 'compact_ipv6( ... )';
+
+#
+is_deeply uncompact_ipv6(
+ pack('H*', '20010db885a3000000008a2e03707334000008af')
+ ),
+ ['2001:DB8:85A3:0:0:8A2E:370:7334', 2223],
+ 'uncompact_ipv6( ... )';
+
+# We're finished!
+done_testing;
+__END__
+Copyright (C) 2008-2012 by Sanko Robinson <sanko@cpan.org>
+
+This program is free software; you can redistribute it and/or modify it
+under the terms of The Artistic License 2.0. See the LICENSE file
+included with this distribution or
+http://www.perlfoundation.org/artistic_license_2_0. For
+clarification, see http://www.perlfoundation.org/artistic_2_0_notes.
+
+When separated from the distribution, all POD documentation is covered by
+the Creative Commons Attribution-Share Alike 3.0 License. See
+http://creativecommons.org/licenses/by-sa/3.0/us/legalcode. For
+clarification, see http://creativecommons.org/licenses/by-sa/3.0/us/.

No commit comments for this range

Something went wrong with that request. Please try again.