IPv6 friendly functions
authorJamie Cameron <jcameron@webmin.com>
Sun, 7 Nov 2010 07:15:46 +0000 (00:15 -0700)
committerJamie Cameron <jcameron@webmin.com>
Sun, 7 Nov 2010 07:15:46 +0000 (00:15 -0700)
frox/save_acl.cgi
frox/save_cache.cgi
frox/save_iptables.cgi
frox/save_net.cgi

index 23be58b..d6207c9 100755 (executable)
@@ -69,14 +69,14 @@ return $_[0] =~ /^\d+$/ ? undef : $text{'acl_erate'};
 
 sub check_ntp
 {
-return $_[0] =~ /^(\S+):(\d+)$/ && gethostbyname($1) ? undef
+return $_[0] =~ /^(\S+):(\d+)$/ && &to_ipaddress("$1") ? undef
                                                     : $text{'acl_entp'};
 }
 
 
 sub valid_srcdest
 {
-return gethostbyname($_[0]) ||
+return &to_ipaddress($_[0]) ||
           ($_[0] =~ /^([0-9\.]+)\/(\d+)$/ &&
            &check_ipaddress($1) && $2 > 0 && $2 <= 32) ||
           ($_[0] =~ /^([0-9\.]+)\/([0-9\.]+)$/ &&
index e106f68..de869d6 100755 (executable)
@@ -40,7 +40,7 @@ return $_[0] =~ /^\d+$/ ? undef : $text{'cache_esize'};
 
 sub check_proxy
 {
-return $_[0] =~ /^(\S+):(\d+)$/ && gethostbyname($1) ?
+return $_[0] =~ /^(\S+):(\d+)$/ && &to_ipaddress($1) ?
        undef : $text{'cache_eproxy'};
 }
 
index 8f18e7d..f0af837 100755 (executable)
@@ -10,7 +10,7 @@ $port = &find_value("Port", $conf);
 
 # Validate inputs
 if ($in{'enabled'} == 1) {
-       gethostbyname($in{'net'}) ||
+       &to_ipaddress($in{'net'}) ||
            ($in{'net'} =~ /^([0-9\.]+)\/(\d+)$/ &&
             &check_ipaddress($1) && $2 > 0 && $2 <= 32) ||
                &error($text{'iptables_enet'});
index a342260..13f30ea 100755 (executable)
@@ -24,7 +24,7 @@ $conf = &get_config();
 
 sub check_listen
 {
-return gethostbyname($_[0]) ? undef : $text{'net_ehost'};
+return &to_ipaddress($_[0]) ? undef : $text{'net_ehost'};
 }
 
 sub check_port
@@ -39,7 +39,8 @@ return $_[0] =~ /^[a-z]+(\d*)(:\d+)?$/ ? undef : $text{'net_eiface'};
 
 sub check_proxy
 {
-return $_[0] =~ /^(\S+):(\d+)$/ && gethostbyname($1) ? undef : $text{'net_eproxy'};
+return $_[0] =~ /^(\S+):(\d+)$/ && &to_ipaddress($1) ?
+       undef : $text{'net_eproxy'};
 }
 
 sub check_ip