Skip Menu |
 

This queue is for tickets about the Net-Server CPAN distribution.

Report information
The Basics
Id: 33289
Status: resolved
Priority: 0/
Queue: Net-Server

People
Owner: Nobody in particular
Requestors: lapo [...] lapo.it
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 0.97
Fixed in: (no value)



Subject: Add support for IPv6
Download (untitled) / with headers
text/plain 679b
Original problem: I'd like to have a munin node listen on tcp6. Munin uses Net::Server. So I tried using "proto tcp6" in the configuration, but that doesn't exists. So I hacked it into existence, refer to patch in http://munin.projects.linpro.no/ticket/358 So far, so well... but then I kinda stuck around line 746 of Net::Server: it uses Socket:: to get the address, so even if TCP6 and Net::CIDR do support IPv6, it breaks... But changing it to use Socket6 it's a bit out of my stretch (this time around I guess adding a "6" here and there won't suffice, as unpack_sockaddr_in6 only supports IPv6 and not IPv4 and maybe there's a whole different and more generic way to do it).
RT-Send-CC: perl [...] seamons.com
Download (untitled) / with headers
text/plain 1.1k
On Fri Feb 15 15:38:57 2008, lapo wrote: Show quoted text
> Original problem: I'd like to have a munin node listen on tcp6. Munin > uses Net::Server. > So I tried using "proto tcp6" in the configuration, but that doesn't
exists. Show quoted text
> So I hacked it into existence, refer to patch in > http://munin.projects.linpro.no/ticket/358 > So far, so well... but then I kinda stuck around line 746 of > Net::Server: it uses Socket:: to get the address, so even if TCP6 and > Net::CIDR do support IPv6, it breaks... > But changing it to use Socket6 it's a bit out of my stretch (this time > around I guess adding a "6" here and there won't suffice, as > unpack_sockaddr_in6 only supports IPv6 and not IPv4 and maybe there's a > whole different and more generic way to do it).
Having the same issue, I found the following : There is a kind of patch (for 0.97) available at the following location : http://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg643557.html based on an older patch : http://dev.fiqz.com/svn/fiqz/patches/perl-Net-Server-0.86-ipv6.patch It could be nice if the author of Net::Server have a look and could incorporate the patch. Thanks a lot,
Download (untitled) / with headers
text/plain 635b
On Fri Feb 15 15:38:57 2008, lapo wrote: Show quoted text
> But changing it to use Socket6 it's a bit out of my stretch (this time > around I guess adding a "6" here and there won't suffice, as > unpack_sockaddr_in6 only supports IPv6 and not IPv4 and maybe there's a > whole different and more generic way to do it).
You should be able to make this JustWork by using http://search.cpan.org/~pevans/IO-Socket-IP-0.05/lib/IO/Socket/IP.pm Simply find the lines where it creates an IO::Socket::INET socket then make it use ::IP instead. There upon it ought ideally to JustWork. If it doesn't, let me know and I'll see what I can do. -- Paul Evans
Download (untitled) / with headers
text/plain 806b
On Fri Oct 01 17:00:58 2010, PEVANS wrote: Show quoted text
> On Fri Feb 15 15:38:57 2008, lapo wrote:
> > But changing it to use Socket6 it's a bit out of my stretch (this time > > around I guess adding a "6" here and there won't suffice, as > > unpack_sockaddr_in6 only supports IPv6 and not IPv4 and maybe there's a > > whole different and more generic way to do it).
> > You should be able to make this JustWork by using > > http://search.cpan.org/~pevans/IO-Socket-IP-0.05/lib/IO/Socket/IP.pm > > Simply find the lines where it creates an IO::Socket::INET socket then > make it use ::IP instead. There upon it ought ideally to JustWork. > > If it doesn't, let me know and I'll see what I can do.
Will you be updating Net::Server to use IO-Socket-IP so that people can skip manually hacking it for IPv6 support?
Download (untitled) / with headers
text/plain 328b
On Mon Jul 18 16:10:39 2011, MISHIKAL wrote: Show quoted text
> Will you be updating Net::Server to use IO-Socket-IP so that people can > skip manually hacking it for IPv6 support?
I would also note that there is an alternative patch by the author of Amavisd available at: http://lists.amavis.org/pipermail/amavis-users/2011-June/000462.html
Subject: Add support for IPv6 - patch attached
Download (untitled) / with headers
text/plain 219b
This patch is from Debian and is based on IO::Socket::INET6 which seems to be in more widespread use than IO::Socket::IP. The Debian folks seems to have tested quite a bit and it worked flawlessly when used by munin.
Subject: Net::Server.patch
Download Net::Server.patch
text/x-diff 7.6k
This patch file has been copied off the Debian. Their Net::Server package can be found at http://packages.qa.debian.org/libn/libnet-server-perl.html diff -ur lib.orig/Net/Server/Proto/SSLEAY.pm lib/Net/Server/Proto/SSLEAY.pm --- lib.orig/Net/Server/Proto/SSLEAY.pm 2010-07-09 18:44:48.000000000 +0200 +++ lib/Net/Server/Proto/SSLEAY.pm 2011-04-06 16:32:19.835579843 +0200 @@ -23,7 +23,7 @@ use strict; use vars qw($VERSION $AUTOLOAD @ISA); -use IO::Socket::INET; +use IO::Socket::INET6; use Fcntl (); use Errno (); use Socket (); @@ -38,7 +38,7 @@ } $VERSION = $Net::Server::VERSION; # done until separated -@ISA = qw(IO::Socket::INET); +@ISA = qw(IO::Socket::INET6); sub object { my $type = shift; @@ -48,9 +48,12 @@ my $prop = $server->{'server'}; my $host; - if ($port =~ m/^([\w\.\-\*\/]+):(\w+)$/) { # allow for things like "domain.com:80" + if ($port =~ m/^([\w\.\-\*\/]+):(\w+)$/) { # allow for things like "domain.com:80" (IPv4) ($host, $port) = ($1, $2); } + elsif( $port =~ m/^\[([\:\w\.\-\*\/]+)\]:(\w+)$/ ){ # allow for things like "[::1]:80" (IPv6) + ($host,$port) = ($1,$2); + } elsif ($port =~ /^(\w+)$/) { # allow for things like "80" ($host, $port) = ($default_host, $1); } diff -ur lib.orig/Net/Server/Proto/SSL.pm lib/Net/Server/Proto/SSL.pm --- lib.orig/Net/Server/Proto/SSL.pm 2010-05-05 05:13:03.000000000 +0200 +++ lib/Net/Server/Proto/SSL.pm 2011-04-05 14:39:39.788076698 +0200 @@ -39,10 +39,14 @@ my $prop = $server->{server}; my $host; - ### allow for things like "domain.com:80" + ### allow for things like "domain.com:80" (IPv4) if( $port =~ m/^([\w\.\-\*\/]+):(\w+)$/ ){ ($host,$port) = ($1,$2); + ### allow for things like "[::1]:80" (IPv6) + }elsif( $port =~ m/^\[([\:\w\.\-\*\/]+)\]:(\w+)$/ ){ + ($host,$port) = ($1,$2); + ### allow for things like "80" }elsif( $port =~ /^(\w+)$/ ){ ($host,$port) = ($default_host,$1); diff -ur lib.orig/Net/Server/Proto/TCP.pm lib/Net/Server/Proto/TCP.pm --- lib.orig/Net/Server/Proto/TCP.pm 2010-05-05 06:41:08.000000000 +0200 +++ lib/Net/Server/Proto/TCP.pm 2011-04-05 14:29:26.123577536 +0200 @@ -23,10 +23,10 @@ use strict; use vars qw($VERSION $AUTOLOAD @ISA); -use IO::Socket (); +use IO::Socket::INET6 (); $VERSION = $Net::Server::VERSION; # done until separated -@ISA = qw(IO::Socket::INET); +@ISA = qw(IO::Socket::INET6); sub object { my $type = shift; @@ -35,10 +35,14 @@ my ($default_host,$port,$server) = @_; my $host; - ### allow for things like "domain.com:80" + ### allow for things like "domain.com:80" (IPv4) if( $port =~ m/^([\w\.\-\*\/]+):(\w+)$/ ){ ($host,$port) = ($1,$2); + ### allow for things like "[::1]:80" (IPv6) + }elsif( $port =~ m/^\[([\:\w\.\-\*\/]+)\]:(\w+)$/ ){ + ($host,$port) = ($1,$2); + ### allow for things like "80" }elsif( $port =~ /^(\w+)$/ ){ ($host,$port) = ($default_host,$1); diff -ur lib.orig/Net/Server.pm lib/Net/Server.pm --- lib.orig/Net/Server.pm 2010-07-09 16:55:31.000000000 +0200 +++ lib/Net/Server.pm 2011-04-06 16:33:57.739576765 +0200 @@ -25,7 +25,8 @@ use strict; use vars qw($VERSION); -use Socket qw(inet_aton inet_ntoa AF_INET AF_UNIX SOCK_DGRAM SOCK_STREAM); +use Socket qw(unpack_sockaddr_in sockaddr_family AF_INET AF_INET6 AF_UNIX SOCK_DGRAM SOCK_STREAM); +use Socket6 qw(inet_ntop inet_pton unpack_sockaddr_in6); use IO::Socket (); use IO::Select (); use POSIX (); @@ -356,7 +357,7 @@ push @{ $prop->{host} }, (($prop->{host}->[-1]) x (@{ $prop->{port} } - @{ $prop->{host}})); # augment hosts with as many as port foreach my $host (@{ $prop->{host} }) { $host = '*' if ! defined $host || ! length $host;; - $host = ($host =~ /^([\w\.\-\*\/]+)$/) ? $1 : $self->fatal("Unsecure host \"$host\""); + $host = ($host =~ /^([\[\]\:\w\.\-\*\/]+)$/) ? $1 : $self->fatal("Unsecure host \"$host\""); } $prop->{proto} = [] if ! defined $prop->{proto}; @@ -757,12 +758,14 @@ ### read information about this connection my $sockname = getsockname( $sock ); if( $sockname ){ + $prop->{sockfamily} = sockaddr_family( $sockname ); ($prop->{sockport}, $prop->{sockaddr}) - = Socket::unpack_sockaddr_in( $sockname ); - $prop->{sockaddr} = inet_ntoa( $prop->{sockaddr} ); + = ($prop->{sockfamily} == AF_INET6) ? unpack_sockaddr_in6( $sockname ) : unpack_sockaddr_in( $sockname ); + $prop->{sockaddr} = inet_ntop( $prop->{sockfamily}, $prop->{sockaddr} ); }else{ ### does this only happen from command line? + $prop->{sockfamily} = AF_INET; $prop->{sockaddr} = $ENV{'REMOTE_HOST'} || '0.0.0.0'; $prop->{sockhost} = 'inet.test'; $prop->{sockport} = 0; @@ -773,17 +776,17 @@ if( $prop->{udp_true} ){ $proto_type = 'UDP'; ($prop->{peerport} ,$prop->{peeraddr}) - = Socket::sockaddr_in( $prop->{udp_peer} ); + = ($prop->{sockfamily} == AF_INET6) ? unpack_sockaddr_in6( $prop->{udp_peer} ) : unpack_sockaddr_in( $prop->{udp_peer} ); }elsif( $prop->{peername} = getpeername( $sock ) ){ ($prop->{peerport}, $prop->{peeraddr}) - = Socket::unpack_sockaddr_in( $prop->{peername} ); + = ($prop->{sockfamily} == AF_INET6) ? unpack_sockaddr_in6( $prop->{peername} ) : unpack_sockaddr_in( $prop->{peername} ); } if( $prop->{peername} || $prop->{udp_true} ){ - $prop->{peeraddr} = inet_ntoa( $prop->{peeraddr} ); + $prop->{peeraddr} = inet_ntop( $prop->{sockfamily}, $prop->{peeraddr} ); if( defined $prop->{reverse_lookups} ){ - $prop->{peerhost} = gethostbyaddr( inet_aton($prop->{peeraddr}), AF_INET ); + $prop->{peerhost} = gethostbyaddr( inet_pton($prop->{sockfamily}, $prop->{peeraddr}), $prop->{sockfamily} ); } $prop->{peerhost} = '' unless defined $prop->{peerhost}; @@ -803,7 +806,6 @@ ### user customizable hook sub post_accept_hook {} - ### perform basic allow/deny service sub allow_deny { my $self = shift; @@ -1145,7 +1147,7 @@ or $self->fatal("Can't dup socket [$!]"); ### hold on to the socket copy until exec - $prop->{_HUP}->[$i] = IO::Socket::INET->new; + $prop->{_HUP}->[$i] = IO::Socket::INET6->new(); $prop->{_HUP}->[$i]->fdopen($fd, 'w') or $self->fatal("Can't open to file descriptor [$!]"); diff -ur lib.orig/Net/Server.pm lib/Net/Server.pm --- lib.orig/Net/Server.pm 2011-04-07 11:44:54.973953140 +0200 +++ lib/Net/Server.pm 2011-04-07 14:11:28.637453856 +0200 @@ -824,25 +824,29 @@ && $#{ $prop->{cidr_allow} } == -1 && $#{ $prop->{cidr_deny} } == -1; + ### work around Net::CIDR::cidrlookup() croaking, + ### if first parameter is an IPv4 address in IPv6 notation. + my $peeraddr = ($prop->{peeraddr} =~ /^\s*::ffff:([0-9.]+\s*)$/) ? $1 : $prop->{peeraddr}; + ### if the addr or host matches a deny, reject it immediately foreach ( @{ $prop->{deny} } ){ return 0 if $prop->{peerhost} =~ /^$_$/ && defined($prop->{reverse_lookups}); - return 0 if $prop->{peeraddr} =~ /^$_$/; + return 0 if $peeraddr =~ /^$_$/; } if ($#{ $prop->{cidr_deny} } != -1) { require Net::CIDR; - return 0 if Net::CIDR::cidrlookup($prop->{peeraddr}, @{ $prop->{cidr_deny} }); + return 0 if Net::CIDR::cidrlookup($peeraddr, @{ $prop->{cidr_deny} }); } ### if the addr or host isn't blocked yet, allow it if it is allowed foreach ( @{ $prop->{allow} } ){ return 1 if $prop->{peerhost} =~ /^$_$/ && defined($prop->{reverse_lookups}); - return 1 if $prop->{peeraddr} =~ /^$_$/; + return 1 if $peeraddr =~ /^$_$/; } if ($#{ $prop->{cidr_allow} } != -1) { require Net::CIDR; - return 1 if Net::CIDR::cidrlookup($prop->{peeraddr}, @{ $prop->{cidr_allow} }); + return 1 if Net::CIDR::cidrlookup($peeraddr, @{ $prop->{cidr_allow} }); } return 0;
Download (untitled) / with headers
text/plain 463b
On Fri Jul 22 09:07:16 2011, JANL wrote: Show quoted text
> This patch is from Debian and is based on IO::Socket::INET6 which seems > to be in more widespread use than IO::Socket::IP. The Debian folks seems > to have tested quite a bit and it worked flawlessly when used by munin.
I've attached a finalized version from what was discussed on the Amavis list. It is a bit more comprehensive than the Debian version, and will work consistently across multiple versions of perl.
Subject: Net-Server-0.99-IPv6.patch.gz
Download Net-Server-0.99-IPv6.patch.gz
application/x-gzip 10.3k

Message body not shown because it is not plain text.

Download (untitled) / with headers
text/plain 189b
For note, I am working to incorporate this. There were a lot of previous formatting and functional changes so I'm having to manually digest the patch. I am most of the way through though.
Download (untitled) / with headers
text/plain 131b
Excellent. When do you think you can make a release? This is the most wanted feature in net::server ever _I_ think ;-) Nicolai
Download (untitled) / with headers
text/plain 390b
The code is updated as of the just released version 2.000. There is now complete support for IPv6, IPv4, and IPv*. I apologize for the incredibly long wait time. Hopefully this won't happen again. Paul On Fri Aug 12 07:47:24 2011, JANL wrote: Show quoted text
> Excellent. When do you think you can make a release? This is the most > wanted feature in net::server ever _I_ think ;-) > > Nicolai


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.