Permalink
Browse files

Put IPv6 stuff off until after v1.0.0

  • Loading branch information...
1 parent d5a1180 commit a5929fb27c90f9d670acc9fe41156d89c6cb4564 @sanko committed Dec 29, 2011
Showing with 38 additions and 12 deletions.
  1. +3 −0 TODO
  2. +4 −3 lib/Net/BitTorrent/Protocol/BEP07.pm
  3. +31 −9 t/0007_net_bittorrent_protocol_bep07.t
View
3 TODO
@@ -6,3 +6,6 @@ Already in dist but require tests and/or docs...
Ideas...
- compact( ... ) and uncompact( ... ) to wrap both BEP23 and BEP07 functions
+
+Bugs
+ - Everything IPv6 related is considered incomplete or incorrect
@@ -29,7 +29,7 @@ PEER: for my $peer (grep(defined && !$seen{$_}++, @_)) {
}
else {
next PEER unless $ip;
- if ($ip =~ /^(.*):(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/)
+ if ($ip =~ /^(.+):(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/)
{ # mixed hex, dot-quad
next PEER if $2 > 255 || $3 > 255 || $4 > 255 || $5 > 255;
$ip = sprintf("%s:%X%02X:%X%02X", $1, $2, $3, $4, $5)
@@ -38,8 +38,8 @@ PEER: for my $peer (grep(defined && !$seen{$_}++, @_)) {
my $c;
next PEER
if $ip =~ /[^:0-9a-fA-F]/ || # non-hex character
- (($c = $ip) =~ s/::/x/ && $c =~ /(?:x|:):/)
- || # double :: ::?
+ #(($c = $ip) =~ s/::/x/ && $c =~ /(?:x|:):/)
+ #|| # double :: ::?
$ip =~ /[0-9a-fA-F]{5,}/; # more than 4 digits
$c = $ip =~ tr/:/:/; # count the colons
next PEER if $c < 7 && $ip !~ /::/;
@@ -49,6 +49,7 @@ PEER: for my $peer (grep(defined && !$seen{$_}++, @_)) {
}
$ip =~ s/::/:::/ while $c++ < 7; # expand compressed fields
$ip .= 0 if $ip =~ /:$/;
+ next if $seen{$ip . '|'. $port}++;
$return .= pack('H36', join '', split /:/, $ip) . pack 'n', $port;
}
}
@@ -4,18 +4,40 @@ $|++;
# Does it return 1?
use_ok 'Net::BitTorrent::Protocol::BEP07', ':all';
+TODO: {
+ local $TODO = 'IPv6 is just plain broken';
-#
-is compact_ipv6(['2001:0db8:85a3:0000:0000:8a2e:0370:7334', 2223]),
- pack('H*', '20010db885a3000000008a2e03707334000008af'),
- 'compact_ipv6( ... )';
+ #
+ is compact_ipv6(['2001:0db8:85a3:0000:0000:8a2e:0370:7334', 2223]),
+ pack('H*', '20010db885a3000000008a2e03707334000008af'),
+ 'compact_ipv6( [...] )';
+ is compact_ipv6(['2001:0db8:85a3:::8a2e:0370:7334', 2223],
+ ['3ffe:1900:4545:3:200:f8ff:fe21:67cf', 911],
+ ['2001:0db8:85a3:::8a2e:0370:7334', 2223]
+ ),
+ pack("H*",
+ "20010db885a3000000008a2e03707334000008af3ffe190045453200f8fffe2167cf00000000038f"
+ ),
+ 'compact_ipv6( [...], [...], [...] )';
-#
-is_deeply uncompact_ipv6(
+ #
+ is_deeply uncompact_ipv6(
pack('H*', '20010db885a3000000008a2e03707334000008af')
- ),
- ['2001:DB8:85A3:0:0:8A2E:370:7334', 2223],
- 'uncompact_ipv6( ... )';
+ ),
+ ['2001:DB8:85A3:0:0:8A2E:370:7334', 2223],
+ 'uncompact_ipv6( ... )';
+ is_deeply [
+ uncompact_ipv6(
+ pack("H*",
+ "20010db885a3000000008a2e03707334000008af3ffe1900454500030200f8fffe2167cf0000038f"
+ )
+ )
+ ],
+ [['2001:DB8:85A3:0:0:8A2E:370:7334', 2223],
+ ['3FFE:1900:4545:3:200:F8FF:FE21:67CF', 911]
+ ],
+ 'uncompact_ipv6( ... )';
+}
# We're finished!
done_testing;

0 comments on commit a5929fb

Please sign in to comment.