diff options
author | Ermal <eri@pfsense.org> | 2010-09-01 15:51:38 +0000 |
---|---|---|
committer | Ermal <eri@pfsense.org> | 2010-09-01 15:51:38 +0000 |
commit | e847108459441367a88a6e8185165f2e33690d67 (patch) | |
tree | f6fef1f6cd75052641248cef39dbfa069203147a /usr | |
parent | 8e0c376055498bf0a43ff2114062cd8ef8992a09 (diff) | |
download | pfsense-e847108459441367a88a6e8185165f2e33690d67.zip pfsense-e847108459441367a88a6e8185165f2e33690d67.tar.gz |
Ticket #866 #632. Save old settings or actions to be taken for reconfiguring a route/vip on a tmp file and make use that information when apply settings buttons is clicked. This makes the gui behave as expected.
Diffstat (limited to 'usr')
-rwxr-xr-x | usr/local/www/firewall_virtual_ip.php | 17 | ||||
-rwxr-xr-x | usr/local/www/firewall_virtual_ip_edit.php | 38 | ||||
-rwxr-xr-x | usr/local/www/system_routes.php | 9 | ||||
-rwxr-xr-x | usr/local/www/system_routes_edit.php | 22 |
4 files changed, 49 insertions, 37 deletions
diff --git a/usr/local/www/firewall_virtual_ip.php b/usr/local/www/firewall_virtual_ip.php index ec15fdf..ba67914 100755 --- a/usr/local/www/firewall_virtual_ip.php +++ b/usr/local/www/firewall_virtual_ip.php @@ -63,9 +63,11 @@ if ($_POST) { if ($_POST['apply']) { $toapplylist = array(); - if (file_exists("{$g['tmp_path']}/firewall_virtual_ip.apply")) - $toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/firewall_virtual_ip.apply")); - foreach ($toapplylist as $vid) { + if (file_exists("{$g['tmp_path']}/.firewall_virtual_ip.apply")) + $toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.firewall_virtual_ip.apply")); + foreach ($toapplylist as $vid => $ovip) { + if (!empty($ovip)) + interface_vip_bring_down($ovip); if ($a_vip[$vid]) { switch ($a_vip[$vid]['mode']) { case "ipalias": @@ -85,7 +87,7 @@ if ($_POST) { } } } - @unlink("{$g['tmp_path']}/firewall_virtual_ip.apply"); + @unlink("{$g['tmp_path']}/.firewall_virtual_ip.apply"); $retval = 0; $retval |= filter_configure(); $savemsg = get_std_save_message($retval); @@ -108,7 +110,7 @@ if ($_GET['act'] == "del") { } } - if ($a_vip[$_GET['id']]['mode'] == "proxyarp") { + if ($a_vip[$_GET['id']]['mode'] == "ipalias") { $vipiface = $a_vip[$_GET['id']]['interface']; foreach ($a_vip as $vip) { if ($vip['interface'] == $vipiface && $vip['mode'] == "carp") @@ -117,11 +119,13 @@ if ($_GET['act'] == "del") { } } + if (!$input_errors) { // Special case since every proxyarp vip is handled by the same daemon. if ($a_vip[$_GET['id']]['mode'] == "proxyarp") { + $viface = $a_vip[$_GET['id']]['interface']; unset($a_vip[$_GET['id']]); - interface_proxyarp_configure(); + interface_proxyarp_configure($viface); } else { interface_vip_bring_down($a_vip[$_GET['id']]); unset($a_vip[$_GET['id']]); @@ -129,7 +133,6 @@ if ($_GET['act'] == "del") { if (count($config['virtualip']['vip']) == 0) unset($config['virtualip']['vip']); write_config(); - mark_subsystem_dirty('vip'); header("Location: firewall_virtual_ip.php"); exit; } diff --git a/usr/local/www/firewall_virtual_ip_edit.php b/usr/local/www/firewall_virtual_ip_edit.php index 214d127..60baccd 100755 --- a/usr/local/www/firewall_virtual_ip_edit.php +++ b/usr/local/www/firewall_virtual_ip_edit.php @@ -149,11 +149,7 @@ if ($_POST) { if (!ip_in_subnet($_POST['subnet'], gen_subnet($parent_ip, $parent_sn) . "/" . $parent_sn) && !ip_in_interface_alias_subnet($_POST['interface'], $_POST['subnet'])) { $cannot_find = $_POST['subnet'] . "/" . $_POST['subnet_bits'] ; $input_errors[] = sprintf(gettext("Sorry, we could not locate an interface with a matching subnet for %s. Please add an IP alias in this subnet on this interface."),$cannot_find); - } else if ($parent_sn != $_POST['subnet_bits']) - $input_errors[] = gettext("Subnet bits needs to be the same as the parent interface."); - - if (isset($id) && ($a_vip[$id]) && $a_vip[$id]['vhid'] != $_POST['vhid']) - interface_vip_bring_down($a_vip[$id]); + } } if (isset($id) && ($a_vip[$id])) { @@ -163,18 +159,12 @@ if ($_POST) { $vipiface = $a_vip[$id]['interface']; foreach ($a_vip as $vip) { if ($vip['interface'] == $vipiface && $vip['mode'] == "carp") { - if (ip_in_subnet($vip['subnet'], gen_subnet($a_vip[$id]['subnet'], $a_vip[$id]['subnet_bits']) . "/" . $a_vip[$id]['subnet_bits'])) { + if (ip_in_subnet($vip['subnet'], gen_subnet($a_vip[$id]['subnet'], $a_vip[$id]['subnet_bits']) . "/" . $a_vip[$id]['subnet_bits'])) $input_errors[] = gettext("This entry cannot be modified because it is still referenced by CARP") . " {$vip['descr']}."; - $bringdown = false; - } } } } - if (bringdown == false) - interface_vip_bring_down($a_vip[$id]); } - if ($a_vip[$id]['interface'] != $_POST['interface']) - interface_vip_bring_down($a_vip[$id]); } if (!$input_errors) { @@ -220,27 +210,27 @@ if ($_POST) { unset($vipent['alias-subnet']); } - if (isset($id) && $a_vip[$id]) { + if (!isset($id)) + $id = count($a_vip); + if (file_exists("{$g['tmp_path']}/.firewall_virtual_ip.apply")) + $toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.firewall_virtual_ip.apply")); + else + $toapplylist = array(); + + $toapplylist[$id] = $a_vip[$id]; + if (!empty($a_vip[$id])) { /* modify all virtual IP rules with this address */ for ($i = 0; isset($config['nat']['rule'][$i]); $i++) { if ($config['nat']['rule'][$i]['destination']['address'] == $a_vip[$id]['subnet']) $config['nat']['rule'][$i]['destination']['address'] = $vipent['subnet']; } - $a_vip[$id] = $vipent; - } else - $a_vip[] = $vipent; + } + $a_vip[$id] = $vipent; mark_subsystem_dirty('vip'); write_config(); - if (!isset($id)) - $id = count($a_vip) - 1; - if (file_exists("{$g['tmp_path']}/firewall_virtual_ip.apply")) - $toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/firewall_virtual_ip.apply")); - else - $toapplylist = array(); - $toapplylist[] = $id; - file_put_contents("{$g['tmp_path']}/firewall_virtual_ip.apply", serialize($toapplylist)); + file_put_contents("{$g['tmp_path']}/.firewall_virtual_ip.apply", serialize($toapplylist)); header("Location: firewall_virtual_ip.php"); exit; } diff --git a/usr/local/www/system_routes.php b/usr/local/www/system_routes.php index 454e613..84f5de0 100755 --- a/usr/local/www/system_routes.php +++ b/usr/local/www/system_routes.php @@ -59,6 +59,14 @@ if ($_POST) { $retval = 0; + if (file_exists("{$g['tmp_path']}/.system_routes.apply")) { + $toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.system_routes.apply")); + foreach ($toapplylist as $toapply) + mwexec("{$toapply}"); + + @unlink("{$g['tmp_path']}/.system_routes.apply"); + } + $retval = system_routing_configure(); $retval |= filter_configure(); /* reconfigure our gateway monitor */ @@ -92,7 +100,6 @@ if ($_GET['act'] == "del") { mwexec("/sbin/route delete " . escapeshellarg($a_routes[$_GET['id']]['network'])); unset($a_routes[$_GET['id']]); write_config($changedesc); - mark_subsystem_dirty('staticroutes'); header("Location: system_routes.php"); exit; } diff --git a/usr/local/www/system_routes_edit.php b/usr/local/www/system_routes_edit.php index af50af2..9895d0e 100755 --- a/usr/local/www/system_routes_edit.php +++ b/usr/local/www/system_routes_edit.php @@ -1,5 +1,4 @@ <?php -/* $Id$ */ /* system_routes_edit.php part of m0n0wall (http://m0n0.ch/wall) @@ -122,10 +121,23 @@ if ($_POST) { $route['gateway'] = $_POST['gateway']; $route['descr'] = $_POST['descr']; - if (isset($id) && $a_routes[$id]) - $a_routes[$id] = $route; - else - $a_routes[] = $route; + if (!isset($id)) + $id = count($a_routes); + if (file_exists("{$g['tmp_path']}/.system_routes.apply")) + $toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.system_routes.apply")); + else + $toapplylist = array(); + $oroute = $a_routes[$id]; + + $a_routes[$id] = $route; + + if (!empty($oroute)) { + $osn = explode('/', $oroute['network']); + $sn = explode('/', $route['network']); + if ($oroute['network'] <> $route['network']) + $toapplylist[] = "/sbin/route delete {$oroute['network']}"; + } + file_put_contents("{$g['tmp_path']}/.system_routes.apply", serialize($toapplylist)); staticroutes_sort(); mark_subsystem_dirty('staticroutes'); |