Skip Menu |

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

Report information
The Basics
Id: 127044
Status: rejected
Priority: 0/
Queue: Net-DNS

People
Owner: Nobody in particular
Requestors: TODDR [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 1.17
Fixed in: (no value)



Subject: No longer need USE_SOCKET_IP?
Hi, now IO::Socket::IP is a requires, couldn't this patch be applied?
Subject: dns.patch.txt
diff --git a/lib/Net/DNS/Resolver/Base.pm b/lib/Net/DNS/Resolver/Base.pm index 36e17514b..db93167ed 100644 --- a/lib/Net/DNS/Resolver/Base.pm +++ b/lib/Net/DNS/Resolver/Base.pm @@ -25,12 +25,6 @@ our $VERSION = (qw$LastChangedRevision: 1698 $)[1]; # Olaf Kolkman, RIPE NCC, December 2003. # [Revised March 2016, June 2018] - -use constant USE_SOCKET_IP => defined eval 'use IO::Socket::IP 0.32; 1;'; - -use constant IPv6 => USE_SOCKET_IP; - - # If SOCKSified Perl, use TCP instead of UDP and keep the socket open. use constant SOCKS => scalar eval 'require Config; $Config::Config{usesocks}'; @@ -47,6 +41,7 @@ use integer; use Carp; use IO::Select; use IO::Socket; +use IO::Socket::IP; use Net::DNS::RR; use Net::DNS::Packet; @@ -84,7 +79,7 @@ use constant PACKETSZ => 512; adflag => 0, # see RFC6840, 5.7 cdflag => 0, # see RFC6840, 5.9 udppacketsize => 0, # value bounded below by PACKETSZ - force_v4 => ( IPv6 ? 0 : 1 ), + force_v4 => 0, force_v6 => 0, # only relevant if IPv6 is supported prefer_v4 => 0, prefer_v6 => 0, @@ -284,10 +279,8 @@ sub nameservers { my $packet = $defres->search( $ns, 'A' ); my @iplist = _cname_addr( $packet, $names ); - if (IPv6) { - $packet = $defres->search( $ns, 'AAAA' ); - push @iplist, _cname_addr( $packet, $names ); - } + $packet = $defres->search( $ns, 'AAAA' ); + push @iplist, _cname_addr( $packet, $names ); my %unique = map( ( $_ => $_ ), @iplist ); @@ -862,7 +855,7 @@ sub _create_tcp_socket { $self->_diag('socket disconnected (trying to connect)'); } - my $ip6_addr = IPv6 && _ipv6($ip); + my $ip6_addr = _ipv6($ip); $socket = IO::Socket::IP->new( LocalAddr => $ip6_addr ? $self->{srcaddr6} : $self->{srcaddr4}, @@ -871,20 +864,7 @@ sub _create_tcp_socket { PeerPort => $self->{port}, Proto => 'tcp', Timeout => $self->{tcp_timeout}, - ) - if USE_SOCKET_IP; - - unless (USE_SOCKET_IP) { - $socket = IO::Socket::INET->new( - LocalAddr => $self->{srcaddr4}, - LocalPort => $self->{srcport} || undef, - PeerAddr => $ip, - PeerPort => $self->{port}, - Proto => 'tcp', - Timeout => $self->{tcp_timeout}, - ) - unless $ip6_addr; - } + ); $self->errorstring("no socket $sock_key $!") unless $socket; $self->{persistent}{$sock_key} = $self->{persistent_tcp} ? $socket : undef; @@ -896,8 +876,8 @@ sub _create_udp_socket { my $self = shift; my $ip = shift; - my $ip6_addr = IPv6 && _ipv6($ip); - my $sock_key = IPv6 && $ip6_addr ? 'UDP/IPv6' : 'UDP/IPv4'; + my $ip6_addr = _ipv6($ip); + my $sock_key = $ip6_addr ? 'UDP/IPv6' : 'UDP/IPv4'; my $socket; return $socket if $socket = $self->{persistent}{$sock_key}; @@ -906,18 +886,7 @@ sub _create_udp_socket { LocalPort => $self->{srcport}, Proto => 'udp', Type => SOCK_DGRAM - ) - if USE_SOCKET_IP; - - unless (USE_SOCKET_IP) { - $socket = IO::Socket::INET->new( - LocalAddr => $self->{srcaddr4}, - LocalPort => $self->{srcport} || undef, - Proto => 'udp', - Type => SOCK_DGRAM - ) - unless $ip6_addr; - } + ); $self->errorstring("no socket $sock_key $!") unless $socket; $self->{persistent}{$sock_key} = $self->{persistent_udp} ? $socket : undef; @@ -933,18 +902,13 @@ sub _create_udp_socket { socktype => SOCK_DGRAM ); - my $ip4 = USE_SOCKET_IP ? {family => AF_INET, @udp} : {}; - my $ip6 = USE_SOCKET_IP ? {family => AF_INET6, @udp} : {}; + my $ip4 = {family => AF_INET, @udp}; + my $ip6 = {family => AF_INET6, @udp}; sub _create_dst_sockaddr { ## create UDP destination sockaddr structure my ( $self, $ip, $port ) = @_; - unless (USE_SOCKET_IP) { - return sockaddr_in( $port, inet_aton($ip) ) unless _ipv6($ip); - } - - ( grep ref, Socket::getaddrinfo( $ip, $port, _ipv6($ip) ? $ip6 : $ip4 ), {} )[0]->{addr} - if USE_SOCKET_IP; # NB: errors raised in socket->send + return ( grep ref, Socket::getaddrinfo( $ip, $port, _ipv6($ip) ? $ip6 : $ip4 ), {} )[0]->{addr}; # NB: errors raised in socket->send } }
On Wed Sep 05 21:03:59 2018, TODDR wrote: Show quoted text
> Hi, now IO::Socket::IP is a requires, couldn't this patch be applied? >
No! It is naive to imagine that just adding IO::Socket::IP to the distro metadata will somehow make that wish come true. It is not reasonable to rely upon the existence of socket code beyond that provided in the perl core distribution: 5.26.0 (May 2017) IO::Socket::IP 0.38 5.24.4 (Sep 2017) IO::Socket::IP 0.37 non-blocking socket issue 5.22.4 (Jul 2017) IO::Socket::IP 0.37 5.24.0 (May 2016) IO::Socket::IP 0.37 5.22.0 (Jul 2015) IO::Socket::IP 0.37 5.20.3 (Sep 2015) IO::Socket::IP 0.29 critical TCP timeout issue 5.20.0 (May 2014) IO::Socket::IP 0.29 5.18.4 (Oct 2014) IO::Socket::IP not in perl core None of these is yet 5 years old, and still shipping bugs as recently as 1 year ago. Enterprise users and major Linux/Unix vendors expect far longer support commitment than that. Your proposed patch inflicts a critical bug on perl 5.20.x users and breaks earlier versions entirely by removing the ability to fall back on IO::Socket::INET. The existing socket code is portable across all perl versions (5.6.2+). It is also well tested. The version of IO::Socket::IP is only relevant when using IPv6.
ok then isn't it a bug that IO::Socket::IP is in the requires section of the META.yaml file? cpan installers won't install Net::DNS until that requirement is met first.
On Thu Sep 06 13:59:15 2018, TODDR wrote: Show quoted text
> ok then isn't it a bug that IO::Socket::IP is in the requires section > of the META.yaml file? cpan installers won't install Net::DNS until > that requirement is met first.
cpan and similar tools will attempt to satisfy the dependencies in META.(yaml|json), which is generally a sound strategy; BUT, the traditional, perl Makefile.PL make make test make install installation route also needs to work. MakeMaker lists any unsatisfied dependencies, but the user can choose to ignore the advice, accepting some loss of functionality. In the case of IO::Socket::IP, this restricts the resolver to use IPv4 only.
I acknowledge you're right on this. I disagree that in reality people ignore this advice. I most cases, people go out of their way to either meet the advice or give up. A CPAN client will make this a hard rule. I'd encourage you to take the module out of the requires slot if you don't require it. Either way, feel free to close this ticket as rejected. Todd
One thing to know, you've almost guaranteed that this will never be smoker on a perl version that can't have all of the require modules.
On Fri Sep 07 13:40:20 2018, TODDR wrote: Show quoted text
> I acknowledge you're right on this. > > I disagree that in reality people ignore this advice. I most cases, > people go out of their way to either meet the advice or give up. A > CPAN client will make this a hard rule.
Existing design supports that. Show quoted text
> I'd encourage you to take the module out of the requires slot if you > don't require it.
The requirement is to use it if available AND a version which works sufficiently well. If that test is not met, Net::DNS will still work with reduced functionality. The proposal that you offered comes nowhere close to meeting that requirement, so kindly do not pontificate about how I should change the design or the metadata which supports it.