IPv6 support

This commit is contained in:
Jamie Cameron
2010-11-01 23:00:05 -07:00
parent 29232c583c
commit 9554d1ff82
2 changed files with 8 additions and 3 deletions

View File

@@ -17,7 +17,7 @@ if ($in{'mode'} == 0) {
}
elsif ($in{'mode'} == 1) {
# Database of some type
gethostbyname($in{'dbhost'}) || &error($text{'db_edbhost'});
&to_ipaddress($in{'dbhost'}) || &error($text{'db_edbhost'});
$in{'dbdb'} =~ /^[a-z0-9\.\-\_]+$/ || &error($text{'db_edbdb'});
$in{'dbport_def'} || $in{'dbport'} =~ /^\d+$/ ||
&error($text{'db_edbport'});
@@ -26,7 +26,8 @@ elsif ($in{'mode'} == 1) {
}
elsif ($in{'mode'} == 3) {
# LDAP
gethostbyname($in{'ldaphost'}) || &error($text{'db_eldaphost'});
&to_ipaddress($in{'ldaphost'}) || &to_ip6address($in{'ldaphost'}) ||
&error($text{'db_eldaphost'});
$in{'ldapport_def'} || $in{'ldapport'} =~ /^\d+$/ ||
&error($text{'db_eldapport'});
$in{'ldapdn'} =~ /^\S+$/ || &error($text{'db_eldapdn'});

View File

@@ -905,7 +905,11 @@ if ($@) {
return &text('connect_eldapmod', "<tt>Net::LDAP</tt>");
}
local $port = $config{'port'} || 389;
local $ldap = Net::LDAP->new($config{'server'}, port => $port);
local $inet6 = !&to_ipaddress($config{'server'}) &&
&to_ip6address($config{'server'});
local $ldap = Net::LDAP->new($config{'server'},
port => $port,
inet6 => $inet6);
if (!$ldap) {
return &text('connect_eldap', "<tt>$config{'server'}</tt>", $port);
}