From 9554d1ff82c7f509b8a31e8739141504699be1c2 Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Mon, 1 Nov 2010 23:00:05 -0700 Subject: [PATCH] IPv6 support --- spam/save_db.cgi | 5 +++-- spam/spam-lib.pl | 6 +++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/spam/save_db.cgi b/spam/save_db.cgi index 70c5f9864..e85644a70 100755 --- a/spam/save_db.cgi +++ b/spam/save_db.cgi @@ -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'}); diff --git a/spam/spam-lib.pl b/spam/spam-lib.pl index e89f1ca3d..30791ba54 100755 --- a/spam/spam-lib.pl +++ b/spam/spam-lib.pl @@ -905,7 +905,11 @@ if ($@) { return &text('connect_eldapmod', "Net::LDAP"); } 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', "$config{'server'}", $port); }