Hi,
On Tuesday, 15. May 2007 02:20, Graham Barr wrote:
> > My understanding is that IPv6 support is added to IO::Socket by a
> > separate module, IO::Socket::INET6, which in turn uses Socket6
> > which is
> > an add-on module to the standard Socket module.
>
> Yes, that is correct.
>
> > So where LDAP.pm now calls IO::Socket::INET, it would need to call
> > IO::Socket::INET6. The new INET6 Domain argument already defaults to
> > AF_UNSPEC, so I don't believe that needs to be specified; though, for
> > testing purposes, it might be nice if Net::LDAP externalised it.
> >
> > Any, or all, of the above might be total rubbish... :)
>
> I have not looked at INET6 and I do not have easy access to test
> INET6, but if someone wants to send a patch then I would gladly
> incorporate it.
I have tried to write a little patch to Net::LDAP that should
implement support for IPv6.
It tries to stay compatible as much as possible.
Only if the
inet6 => 1
option is passed to Net::LDAP->new() it takes the IPv6 variants
of the modules into account.
It works well with IPv4 (even when inet6 is set), but fails
with IPv6 in my ienvironment: the connection gets immediately
closed by the server.
This might be a problem of my environment or of the patch.
Currently I cannot tell, since this was my first tyoing with IPv6.
The more adventuresomes can try the attached patch.
Have fun, and please report success/problems/fixes ...
Peter
--
Peter Marschall
[EMAIL PROTECTED]
diff -rub lib/Net/LDAP.pm lib/Net/LDAP.pm
--- lib/Net/LDAP.pm
+++ lib/Net/LDAP.pm
@@ -135,11 +135,18 @@
sub connect_ldap {
my ($ldap, $host, $arg) = @_;
my $port = $arg->{port} || 389;
+ my $class = 'IO::Socket::INET';
# separate port from host overwriting given/default port
$host =~ s/^([^:]+|\[.*\]):(\d+)$/$1/ and $port = $2;
- $ldap->{net_ldap_socket} = IO::Socket::INET->new(
+ if ($arg->{inet6}) {
+ require Socket6;
+ require IO::Socket::INET6;
+ $class = 'IO::Socket::INET6';
+ }
+
+ $ldap->{net_ldap_socket} = $class->new(
PeerAddr => $host,
PeerPort => $port,
LocalAddr => $arg->{localaddr} || undef,
@@ -162,7 +169,9 @@
my ($ldap, $host, $arg) = @_;
my $port = $arg->{port} || 636;
+ require Socket6 if ($arg->{inet6});
require IO::Socket::SSL;
+ IO::Socket::SSL::import(qw/inet6/) if ($arg->{inet6});
# separate port from host overwriting given/default port
$host =~ s/^([^:]+|\[.*\]):(\d+)$/$1/ and $port = $2;