diff options
author | jim-p <jim@pingle.org> | 2010-03-07 16:37:02 -0500 |
---|---|---|
committer | jim-p <jim@pingle.org> | 2010-03-07 16:37:02 -0500 |
commit | ecd1f2d946abe16193e0ea62dbbdd6c87aa9b985 (patch) | |
tree | e94638d481a7a7932080a3d7053cf8351125b681 /usr/local | |
parent | abfd0c9bcdf4b31d64983ea557de018afbcd720d (diff) | |
download | pfsense-ecd1f2d946abe16193e0ea62dbbdd6c87aa9b985.zip pfsense-ecd1f2d946abe16193e0ea62dbbdd6c87aa9b985.tar.gz |
Adding support for using IP ranges aliases. If you input an IP Range such as 192.168.0.1-192.168.0.254, it will instead turn that into a number of CIDR networks which will completely fill the range.
Diffstat (limited to 'usr/local')
-rwxr-xr-x | usr/local/www/firewall_aliases_edit.php | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/usr/local/www/firewall_aliases_edit.php b/usr/local/www/firewall_aliases_edit.php index d974bb43..acf898c 100755 --- a/usr/local/www/firewall_aliases_edit.php +++ b/usr/local/www/firewall_aliases_edit.php @@ -221,20 +221,25 @@ if ($_POST) { $wrongaliases = ""; for($x=0; $x<4999; $x++) { if($_POST["address{$x}"] <> "") { + $count = 0; if ($isfirst > 0) $address .= " "; - $address .= $_POST["address{$x}"]; - if(($_POST['type'] == "network" || is_ipaddr($_POST["address{$x}"])) && $_POST["address_subnet{$x}"] <> "") - $address .= "/" . $_POST["address_subnet{$x}"]; - - if($_POST["detail{$x}"] <> "") { - $final_address_details .= $_POST["detail{$x}"]; - } else { - $final_address_details .= "Entry added" . " "; - $final_address_details .= date('r'); - } - $final_address_details .= "||"; - $isfirst++; + if (is_iprange($_POST["address{$x}"])) { + list($startip, $endip) = explode('-', $_POST["address{$x}"]); + $rangesubnets = ip_range_to_subnet_array($startip, $endip); + $count = count($rangesubnets); + $address .= implode($rangesubnets, ' '); + } else { + $address .= $_POST["address{$x}"]; + if(($_POST['type'] == "network" || is_ipaddr($_POST["address{$x}"])) && $_POST["address_subnet{$x}"] <> "") + $address .= "/" . $_POST["address_subnet{$x}"]; + } + if($_POST["detail{$x}"] <> "") { + $final_address_details .= str_repeat($_POST["detail{$x}"] . "||", $count); + } else { + $final_address_details .= str_repeat("Entry added " . date('r') . "||", $count); + } + $isfirst += $count; if (is_alias($_POST["address{$x}"])) { if (!alias_same_type($_POST["address{$x}"], $_POST['type'])) @@ -243,7 +248,9 @@ if ($_POST) { if (!is_port($_POST["address{$x}"])) $input_errors[] = $_POST["address{$x}"] . " is not a valid port or alias."; } else if ($_POST['type'] == "host" || $_POST['type'] == "network") { - if (!is_ipaddr($_POST["address{$x}"]) && !is_hostname($_POST["address{$x}"])) + if (!is_ipaddr($_POST["address{$x}"]) + && !is_hostname($_POST["address{$x}"]) + && !is_iprange($_POST["address{$x}"])) $input_errors[] = $_POST["address{$x}"] . " is not a valid {$_POST['type']} alias."; } } |