View | Details | Raw Unified | Return to bug 4412
Collapse All | Expand All

(-)INSTALL (+7 lines)
Lines 278-283 Link Here
278
    to install this module.
278
    to install this module.
279
279
280
280
281
  - IO::Socket::INET6 (from CPAN)
282
283
    This is required if the first nameserver listed in your IP
284
    configuration or /etc/resolv.conf file is available only via an IPv6
285
    address.
286
287
281
  - IO::Socket::SSL (from CPAN)
288
  - IO::Socket::SSL (from CPAN)
282
289
283
    If you wish to use SSL encryption to communicate between spamc and
290
    If you wish to use SSL encryption to communicate between spamc and
(-)lib/Mail/SpamAssassin/Util/DependencyInfo.pm (+7 lines)
Lines 109-114 Link Here
109
  to install this module.',
109
  to install this module.',
110
},
110
},
111
{
111
{
112
  module => 'IO::Socket::INET6',
113
  version => '0.00',
114
  desc => 'This is required if the first nameserver listed in your IP
115
  configuration or /etc/resolv.conf file is available only via
116
  an IPv6 address.',
117
},
118
{
112
  module => 'IO::Socket::SSL',
119
  module => 'IO::Socket::SSL',
113
  version => '0.00',
120
  version => '0.00',
114
  desc => 'If you wish to use SSL encryption to communicate between spamc and
121
  desc => 'If you wish to use SSL encryption to communicate between spamc and
(-)lib/Mail/SpamAssassin/DnsResolver.pm (-7 / +41 lines)
Lines 43-48 Link Here
43
43
44
use IO::Socket::INET;
44
use IO::Socket::INET;
45
45
46
use constant HAS_SOCKET_INET6 => eval { require IO::Socket::INET6 };
47
46
our @ISA = qw();
48
our @ISA = qw();
47
49
48
###########################################################################
50
###########################################################################
Lines 149-164 Link Here
149
  my $port_offset = int(rand(64511));  # 65535 - 1024
151
  my $port_offset = int(rand(64511));  # 65535 - 1024
150
  for (my $i = 0; (!$sock && ($i<64511)); $i++) {
152
  for (my $i = 0; (!$sock && ($i<64511)); $i++) {
151
    my $lport = 1024 + (($port_offset + $i) % 64511);
153
    my $lport = 1024 + (($port_offset + $i) % 64511);
152
    $sock = IO::Socket::INET->new (
154
153
                                   Proto => 'udp',
155
    my %args = (
154
                                   LocalPort => $lport,
156
        PeerAddr => $self->{res}->{nameservers}[0],
155
                                   Type => SOCK_DGRAM,
157
        PeerPort => $self->{res}->{port},
156
                                   );
158
        Proto => 'udp',
159
        LocalPort => $lport,
160
        Type => SOCK_DGRAM
161
    );
162
163
    if (HAS_SOCKET_INET6) {
164
      $sock = IO::Socket::INET6->new(%args);
165
    } else {
166
      $sock = IO::Socket::INET->new(%args);
167
168
      # did we fail due to the attempted use of an IPv6 nameserver?
169
      if (!$sock) {
170
        $self->_ipv6_ns_warning();
171
      }
172
    }
157
  }
173
  }
158
174
159
  $self->{sock} = $sock;
175
  $self->{sock} = $sock;
160
  $self->{dest} = sockaddr_in($self->{res}->{port},
161
            inet_aton($self->{res}->{nameservers}[0]));
162
176
163
  $self->{sock_as_vec} = $self->fhs_to_vec($self->{sock});
177
  $self->{sock_as_vec} = $self->fhs_to_vec($self->{sock});
164
}
178
}
Lines 426-431 Link Here
426
  $self->connect_sock();
440
  $self->connect_sock();
427
}
441
}
428
442
443
sub _ipv6_ns_warning {
444
  my ($self) = @_;
445
446
  # warn about the attempted use of an IPv6 nameserver without
447
  # IO::Socket::INET6 installed (bug 4412)
448
  my $firstns = $self->{res}->{nameservers}[0];
449
450
  use Mail::SpamAssassin::Constants qw(:ip);
451
  my $ip64 = IP_ADDRESS;
452
  my $ip4 = IPV4_ADDRESS;
453
454
  # was the nameserver in IPv6 format?
455
  if ($firstns =~ /^${ip64}$/o && $firstns !~ /^${ip4}$/o) {
456
    my $addr = inet_aton($firstns);
457
    if (!defined $addr) {
458
      die "IO::Socket::INET6 module is required to use IPv6 nameservers such as '$firstns': $@\n";
459
    }
460
  }
461
}
462
429
1;
463
1;
430
464
431
=back
465
=back

Return to bug 4412