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 (-9 / +42 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 268-276 Link Here
268
  my $pkt = $self->new_dns_packet($host, $type, $class);
282
  my $pkt = $self->new_dns_packet($host, $type, $class);
269
283
270
  my $data = $pkt->data;
284
  my $data = $pkt->data;
271
  my $dest = $self->{dest};
272
  $self->connect_sock() if !$self->{sock};
285
  $self->connect_sock() if !$self->{sock};
273
  if (!$self->{sock}->send ($pkt->data, 0, $self->{dest})) {
286
  if (!$self->{sock}->send ($pkt->data, 0)) {
274
    warn "dns: sendto() failed: $@";
287
    warn "dns: sendto() failed: $@";
275
    return;
288
    return;
276
  }
289
  }
Lines 426-431 Link Here
426
  $self->connect_sock();
439
  $self->connect_sock();
427
}
440
}
428
441
442
sub _ipv6_ns_warning {
443
  my ($self) = @_;
444
445
  # warn about the attempted use of an IPv6 nameserver without
446
  # IO::Socket::INET6 installed (bug 4412)
447
  my $firstns = $self->{res}->{nameservers}[0];
448
449
  use Mail::SpamAssassin::Constants qw(:ip);
450
  my $ip64 = IP_ADDRESS;
451
  my $ip4 = IPV4_ADDRESS;
452
453
  # was the nameserver in IPv6 format?
454
  if ($firstns =~ /^${ip64}$/o && $firstns !~ /^${ip4}$/o) {
455
    my $addr = inet_aton($firstns);
456
    if (!defined $addr) {
457
      die "IO::Socket::INET6 module is required to use IPv6 nameservers such as '$firstns': $@\n";
458
    }
459
  }
460
}
461
429
1;
462
1;
430
463
431
=back
464
=back

Return to bug 4412