Subject: | IPv6 support |
When HTTP::Daemon supports IPv6 <https://rt.cpan.org/Public/Bug/Display.html?id=91699>, RPC-XML-0.80 t/40_server.t test will fail like this:
not ok 19 - RPC::XML::Server::url method (set)
# Failed test 'RPC::XML::Server::url method (set)'
# at t/40_server.t line 187.
# 'http://[::1]:42761/'
# doesn't match '(?^:http://(127[.]0[.]0[.]1|localhost|localhost[.]localdomain|localhost4|localhost4[.]localdomain4|localhost[.]localdomain|localhost6|localhost6[.]localdomain6):42761)'
and
Not an ARRAY reference at t/40_server.t line 332.
# Looks like your test exited with 255 just after 43.
The first failure can be easily fixed (I have a patch), but the second is one is more troublesome. It crashes on:
$res = $res->value->value;
→ is($res->[2], inet_ntoa(inet_aton('localhost')),
because localhost resolves to ::1 IPv6 address and inet_ntoa supports IPv4 only. This could be also corrected, by the issue with $res whose values come from code:
$res = $srv->add_method({ name => 'perl.test.suite.peeraddr',
signature => [ 'array' ],
code =>
sub {
my $server = shift;
my $ipaddr = inet_aton($server->{peerhost});
my $peeraddr = RPC_BASE64 $server->{peeraddr};
my $packet = pack_sockaddr_in($server->{peerport},
$ipaddr);
$packet = RPC_BASE64 $packet;
[ $peeraddr, $packet,
$server->{peerhost}, $server->{peerport} ];
} });
and especially $server->{peeraddr} is documented in RPC::XML as:
peeraddr
This is the address part of a packed SOCKADDR_IN structure, as
returned by "pack_sockaddr_in" in Socket, which contains the address
That means the documentation explicitly allows only IPv4 addresses.
How could this be fixed? It's good to know that "an address part of a packaged structure" itself is useless because one needs to know address family to interpret it correctly.
One could add new $server->{family} element to carry address family.
Or one could change the $server->{peeraddr} meaning to deliver complete packed structure including IP address, port, and address family (output of pack_sockaddr_in or pack_sockaddr_in6).
I have not yet studied Net::Server how it deals with it.