IPv6 support
authorJamie Cameron <jcameron@webmin.com>
Tue, 2 Nov 2010 06:00:05 +0000 (23:00 -0700)
committerJamie Cameron <jcameron@webmin.com>
Tue, 2 Nov 2010 06:00:05 +0000 (23:00 -0700)
spam/save_db.cgi
spam/spam-lib.pl

index 70c5f98..e85644a 100755 (executable)
@@ -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'});
index e89f1ca..30791ba 100755 (executable)
@@ -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);
        }