Skip to content

Commit

Permalink
...I really should keep better track of what I'm doing with this bran…
Browse files Browse the repository at this point in the history
…ch...

 - New ::Version.pm to hold all sorts of version and identification stuff
 - Many tests skipped based on user categories and system capabilities thanks Module::Build trickery
 - use Scalar::Util::refaddr in all classes (...I'm toying with the object system for kicks)
 - UDP-talk-to-ourself.pl tests if UDP loopback will cause test failures
 - .:shrugs:. More?
  • Loading branch information
sanko committed Oct 11, 2008
1 parent 9d45cf6 commit d79b72b
Show file tree
Hide file tree
Showing 32 changed files with 8,915 additions and 8,362 deletions.
104 changes: 59 additions & 45 deletions Build.PL
Original file line number Diff line number Diff line change
Expand Up @@ -5,55 +5,49 @@ use File::Find;
use Module::Build;
use 5.008001;

#
my $GIVE_THEM_A_CHOICE = 0;
my @search = qw[t/000_miniswarm/ t/700_classes/];
my $can_talk_to_ourself = 0;
# ...
$|++;

# http://cpantest.grango.org/wiki/CPANAuthorNotes
my $automated_testing = $ENV{q[AUTOMATED_TESTING]}
|| $ENV{q[PERL_MM_USE_DEFAULT]};
my $is_developer = ((-d q[.svn]) ? 1 : 0) or ($ENV{RELEASE_TESTING} ? 1 : 0);
my $okay_tcp = okay_tcp();
my $okay_udp = okay_udp();
my $verbose = grep {m[^-v$]i} @ARGV; # see M:B::API's args()
my @tests;
find \&find_cb, sort qw[t/000_miniswarm/ t/700_classes/];

#
if ( # http://cpantest.grango.org/wiki/CPANAuthorNotes
($GIVE_THEM_A_CHOICE
? 1 # and (not $ENV{q[AUTOMATED_TESTING]} and not $ENV{q[PERL_MM_USE_DEFAULT]})
: 1
)
and can_talk_to_ourself()
and local $| = 1
and print(
<<'END'
print $okay_tcp || $okay_udp ? <<'FTW': <<'FAIL';
****************************************************************************
During the test phase, we will be opening ports, contacting a tiny local
tracker, and trading data to simulate actual swarms. By design, the
tests transfer only to the local system.
NOTE: These tests can be painfully slow, redundant, and may fail due to
restrictive firewalling, solar flare activity, or other connectivity
problems.
NOTE: These tests may fail due to restrictive firewalling, solar flare
activity, or other connectivity problems.
****************************************************************************
END
)
and (
$GIVE_THEM_A_CHOICE
? (print(
q[
Do you want to perform these tests in addition to core tests? [no] ]
)
and readline(*STDIN) =~ m[^y]i
)
: 1
)
)
{ $can_talk_to_ourself = 1;
}
my @tests;
find \&find_cb, sort @search;
FTW
****************************************************************************
Hrm... Your system seems to be misconfigured; an attempt to create a
loopback has failed. We'll work around the by skipping most of the
socket-related tests.
NOTE: Skipping these tests greatly reduces the usefullness of the
Net::BitTorrent test suite and makes life difficult.
****************************************************************************
FAIL
#
my $mb = Module::Build->new(
module_name => q[Net::BitTorrent],
license => q[artistic_2], # requires MB 0.2808_01 or better
dist_author => q[Sanko Robinson <sanko@cpan.org>],
dist_abstract => q[BitTorrent peer-to-peer protocol],
dist_version_from => q[lib/Net/BitTorrent.pm],
dist_version_from => q[lib/Net/BitTorrent/Version.pm],
build_requires => {
q[Module::Build] => 0.30, # dev on 0.30|core in 5.009004
q[Module::Build] => 0.30, # dev on 0.30
# min 0.2808_01 for artistic_2
q[Test::More] => 0.8, # dev on 0.8
},
Expand All @@ -64,13 +58,13 @@ my $mb = Module::Build->new(
q[Fcntl] => 0, # dev on 1.06
q[File::Path] => 0, # dev on 2.04
q[File::Spec] => 0, # dev on 3.2701
q[Module::Build] => 0.30, # dev on 0.30|CORE in 5.10
q[Module::Build] => 0.30, # dev on 0.30
q[perl] => q[5.8.1], # dev on 5.11
q[Scalar::Util] => 1.19, # dev on 1.19
q[Socket] => 1.77, # dev on 1.80
q[Time::HiRes] => 0, # dev on 1.9712
q[Test::More] => 0.8, # dev on 0.8
q[version] => 0.76 # dev on 0.76|CORE in 5.10
q[version] => 0.74 # dev on 0.76|CORE in 5.10
},
recommends => {
q[Data::Dumper] => 0, # core...
Expand Down Expand Up @@ -100,24 +94,44 @@ my $mb = Module::Build->new(
},
);
#
$mb->notes(can_talk_to_ourself => $can_talk_to_ourself);
# Set some random state data for the .t files to get
$mb->notes(okay_tcp => $okay_tcp);
$mb->notes(okay_udp => $okay_udp);
$mb->notes(automated_testing => $automated_testing);
$mb->notes(release_testing => $is_developer);
$mb->notes(verbose => $verbose);
$mb->notes(test_suite => \@tests);
$mb->notes(gmtime => gmtime);
#
#warn join q[, ], @tests;
# M::B is lazy and leaves this file behind on Win32 but it needs that to wrap
# things up...
# $mb->add_to_cleanup(qw[./Build.bat]);
# I'm lazy and... well... yeah...
$mb->fix_shebang_line(@tests);
$mb->fix_shebang_line(@{($mb->rscan_dir(q[./lib], qr/\.pm$/))[0]});

# Break it off, let's go.
$mb->create_build_script;

sub can_talk_to_ourself { # taken from LWP
return 0 if not -f q[t/900_data/910_scripts/talk-to-ourself.pl];
system(qq["$^X" t/900_data/910_scripts/talk-to-ourself.pl]);
# Taken from LWP
sub okay_tcp {
return 0 if not -f q[t/900_data/910_scripts/TCP-talk-to-ourself.pl];
system(qq["$^X" t/900_data/910_scripts/TCP-talk-to-ourself.pl]);
return $? ? 0 : 1;
}

sub okay_udp {
return 0 if not -f q[t/900_data/910_scripts/UDP-talk-to-ourself.pl];
system(qq["$^X" t/900_data/910_scripts/UDP-talk-to-ourself.pl]);
return $? ? 0 : 1;
}

# Find only .t files
sub find_cb {
return if -d $_ or -l $_;
return unless -T $_;
return unless $_ =~ m[.+\.t$];
return unshift @tests, $File::Find::name;
return unshift @tests, $File::Find::name; # suite runs in 'reverse'
}
# $Id$
5 changes: 4 additions & 1 deletion MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ lib/Net/BitTorrent/Session/Tracker.pm
lib/Net/BitTorrent/Session/Tracker/HTTP.pm
lib/Net/BitTorrent/Session/Tracker/UDP.pm
lib/Net/BitTorrent/Util.pm
lib/Net/BitTorrent/Version.pm
LICENSE
MANIFEST This list of files
META.yml
Expand All @@ -30,7 +31,9 @@ t/700_classes/Net/BitTorrent/Session/Tracker.t
t/700_classes/Net/BitTorrent/Session/Tracker/HTTP.t
t/700_classes/Net/BitTorrent/Session/Tracker/UDP.t
t/700_classes/Net/BitTorrent/Util.t
t/900_data/910_scripts/talk-to-ourself.pl
t/700_classes/Net/BitTorrent/Version.t
t/900_data/910_scripts/TCP-talk-to-ourself.pl
t/900_data/910_scripts/UDP-talk-to-ourself.pl
t/900_data/930_miniswarm/seed/1291672777_30adc6a421_o.jpg
t/900_data/930_miniswarm/seed/2183742557_5c9a91727d_m.jpg
t/900_data/930_miniswarm/seed/credit.txt
Expand Down
2 changes: 2 additions & 0 deletions MANIFEST.SKIP
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,5 @@ scripts/POE.pl
scripts/.*.bencode
scripts/.*.torrent

# Avoid profiler stuff
\.out$
122 changes: 19 additions & 103 deletions Notes.pod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ L<Net::BitTorrent|Net::BitTorrent> is a mess.
But it doesn't have to be! This document is a first draft attempt at
defining a roadmap for future C<Net::BitTorrent> development and a
behavioral reference for third-party client developers. There are bits in
here that may eventually make it into a recipe book for users too.
here that may be of some use to regular users too.

Note: C<Net::BitTorrent::Notes> and the ideas behind it are a work in
progress.
Expand All @@ -20,16 +20,19 @@ progress.

.---- N::B::S::T::UDP
/
.-------- N::B::S::Tracker
/ .-- N::B::S::File \
/ / `--- N::B::S::T::HTTP
.---- Net::BitTorrent::Session
.-------- N::B::S::Tracker
/ \
/ .-- N::B::S::File `--- N::B::S::T::HTTP
/ /
.---- Net::BitTorrent::Session
/
/ .--- Net::BitTorrent::DHT
/ / \
Net::BitTorrent `---- N::B::D::Node
\
`---- Net::BitTorrent::Peer


See Also: L<Class Pseudo-structures|/"Class Pseudo-structures">

=head1 Installation
Expand Down Expand Up @@ -99,8 +102,7 @@ and a list of the current 'working' pieces and their progress. Saving
the DHT ID and routing table would be a good idea too. Add to that some
sort of verification scheme to be sure you're loading information that
hasn't been tampered with or corrupted. Then, when you load the torrent,
set the C<skip_hashcheck> parameter to a C<true> value and reload the
torrent with your stored data.
reload the torrent with your stored data.

[TODO]

Expand Down Expand Up @@ -262,91 +264,7 @@ C<Net::BitTorrent> work. Or not work. It depends.

=head2 Peer ID Specification

This section describes and provides examples of the Peer ID format used
by the current release of the C<Net::BitTorrent> module.

=head3 Format

This non-standard format was developed to be URL-safe, unique to the
implementation, and "human parsable."

There are three distinct sections to the Peer IDs generated: the
L<header|/Header>, the L<mid-section|/Mid-section>, and the
L<signature|/Signature>. Consider this example:

NB004S-rogzGB1v--SVN

Here, C<NB004S> is the header, C<-rogzGB1v> is the mid-section, and
C<--SVN> is the trailing signature.

=head4 Header

Two uppercase characters ('C<NB>') followed by three digits representing
the SVN revision number with leading zeros, a single character
potentially indicating stability and how the release was obtained, and a
single hyphen (C<->).

If the client is a CPAN build, the sixth byte is the capital letter
'C<C>'. If the client is running a version checked out from public SVN
(considered unstable), the sixth byte is the capital letter 'S'. Any
other characters in the sixth byte are unsupported and may indicate a bad
client.

=head4 Mid-section

Following that are eight random characters in the following range:

ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~

That is, all uppercase and lowercase letters, decimal digits, as well as
the hyphen, period, underscore, and tilde (66 total). These are all
characters allowed in a URL without encoded (referred to as "Unreserved
Characters in [rfc://3986]) to reduce weight on the tracker during
announce. On a popular tracker, every bit (and byte) helps.

This section is inspired by the pseudo-base64 set used by SHADOW's
BitTornado client.

=head4 Signature

The final five characters may be random or static and should not be used
in identifying the version of the client software. Some early versions
even have my name in this spot. .:shrugs:.

=head3 CPAN Version Numbers

Stable CPAN releases will have the sixth byte set to 'C<C>' (capital
letter 'c').

Unstable releases (referred to as DEVELOPER releases on PAUSE) on CPAN
will have this bit set as if the user checked the source out from SVN,
that is, the sixth byte will be 'C<S>' (capital letter 's'). These will
be released on CPAN with version numbers matching C<m[\d\.\d+_\d]>. See
the PAUSE FAQ section entitled "Developer Releases"
(L<http://www.cpan.org/modules/04pause.html>).

Version numbers will be some value less than one with the revision number
in the three significant decimal places. Eventually, I would like to
make a v1.0 release of Net::BitTorrent on CPAN. The information in this
document and the means of generating the module's version number will
need to reflect that.

=head3 Examples

=over

=item C<NB393C-04.9EraQ--SVN>

This would be the stable CPAN release C<v0.393>. The C<--SVN> signature
should be ignored.

=item C<NB003X-9E-ayR6b-BTE<lt>3>

Improper Peer ID; the sixth bit is neither 'C' nor 'S'. Possibly fake.

=item C<NB065S--09Egae69sy8W>

Completely legal Peer ID generated by SVN/Dev r65.
Please see L<Net::BitTorrent::Version|Net::BitTorrent::Version>.

=back

Expand Down Expand Up @@ -384,8 +302,8 @@ Count the number of unrequested C<$free_blocks> in all working pieces.

Count how many C<$free_slots> we have open to us. To calculate this, we
iterate through all peers who aren't choking us adding the difference
between the total number of outgoing requests and the user-defined
C<maximum_requests_per_peer> value.
between the total number of outgoing requests and the peer-defined
maximum or our own internal 'safe' max of 20.

=item *

Expand Down Expand Up @@ -523,16 +441,14 @@ IPv6 right now.

=head2 Portability Hacks

Net::BitTorrent aims to be portable between the big three OS (Win32,
Linux [*buntu], MacOS X); When possible, this should be achieved without
a glut of code using easily obtained third-party modules. Core modules
are considered first followed by well tested CPAN modules. Modules that
prevent broad use (ie. fails to install on a majority of systems) will
not be considered.
Net::BitTorrent aims to be portable between the big three OS When
possible, this should be achieved without a glut of code using easily
obtained third-party modules. Core modules are considered first
followed by well tested CPAN modules. Modules that prevent broad use
(ie. fails to install on a majority of systems) will not be considered.

There will be times, though, that C<$^O>-based clutter (and, eventually,
OS-based subclassing) is needed. Here is a list of both stable and
experimental workarounds by OS:
There will be times, though, that C<$^O>-based clutter is needed. Here
is a list of both stable and experimental workarounds by OS:

=over 2

Expand Down
Loading

0 comments on commit d79b72b

Please sign in to comment.