IPv6 friendly functions

This commit is contained in:
Jamie Cameron
2010-11-07 00:15:46 -07:00
parent 4c450423a9
commit 7ce74a5e6c
4 changed files with 7 additions and 6 deletions

View File

@@ -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\.]+)$/ &&

View File

@@ -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'};
}

View File

@@ -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'});

View File

@@ -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