mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-16 09:34:39 +00:00
remove legacy static routes, for https://github.com/opnsense/core/issues/1774
This commit is contained in:
parent
33d98ca951
commit
ba8e2fca38
@ -1,332 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
Copyright (C) 2014-2015 Deciso B.V.
|
||||
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
require_once("guiconfig.inc");
|
||||
require_once("interfaces.inc");
|
||||
require_once("filter.inc");
|
||||
require_once("system.inc");
|
||||
require_once("rrd.inc");
|
||||
|
||||
function delete_static_route($id)
|
||||
{
|
||||
global $config, $a_routes;
|
||||
|
||||
if (!isset($a_routes[$id])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$targets = array();
|
||||
if (is_alias($a_routes[$id]['network'])) {
|
||||
foreach (filter_expand_alias_array($a_routes[$id]['network']) as $tgt) {
|
||||
if (is_ipaddrv4($tgt)) {
|
||||
$tgt .= "/32";
|
||||
} elseif (is_ipaddrv6($tgt)) {
|
||||
$tgt .= "/128";
|
||||
}
|
||||
if (!is_subnet($tgt)) {
|
||||
continue;
|
||||
}
|
||||
$targets[] = $tgt;
|
||||
}
|
||||
} else {
|
||||
$targets[] = $a_routes[$id]['network'];
|
||||
}
|
||||
|
||||
foreach ($targets as $tgt) {
|
||||
$family = (is_subnetv6($tgt) ? "-inet6" : "-inet");
|
||||
mwexec("/sbin/route delete {$family} " . escapeshellarg($tgt));
|
||||
}
|
||||
|
||||
unset($targets);
|
||||
}
|
||||
|
||||
$a_routes = &config_read_array('staticroutes', 'route');
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$pconfig = $_POST;
|
||||
if (isset($_POST['id']) && isset($a_routes[$_POST['id']])) {
|
||||
$id = $_POST['id'];
|
||||
}
|
||||
if (!empty($_POST['act'])) {
|
||||
$act = $_POST['act'];
|
||||
} else {
|
||||
$act = null;
|
||||
}
|
||||
|
||||
if (!empty($pconfig['apply'])) {
|
||||
// todo: remove this ugly hook
|
||||
if (file_exists('/tmp/.system_routes.apply')) {
|
||||
$toapplylist = unserialize(file_get_contents('/tmp/.system_routes.apply'));
|
||||
foreach ($toapplylist as $toapply) {
|
||||
mwexec("{$toapply}");
|
||||
}
|
||||
@unlink('/tmp/.system_routes.apply');
|
||||
}
|
||||
|
||||
system_routing_configure();
|
||||
filter_configure();
|
||||
setup_gateways_monitor();
|
||||
clear_subsystem_dirty('staticroutes');
|
||||
} elseif (isset($id) && $act == 'del') {
|
||||
delete_static_route($id);
|
||||
unset($a_routes[$id]);
|
||||
write_config();
|
||||
} elseif ($act == 'del_x' && isset($pconfig['route'])) {
|
||||
/* delete selected routes */
|
||||
if (is_array($pconfig['route'])) {
|
||||
foreach ($_POST['route'] as $routei) {
|
||||
delete_static_route($routei);
|
||||
unset($a_routes[$routei]);
|
||||
}
|
||||
write_config();
|
||||
}
|
||||
} elseif (isset($id) && $act == "toggle") {
|
||||
if (isset($a_routes[$id]['disabled'])) {
|
||||
unset($a_routes[$id]['disabled']);
|
||||
} else {
|
||||
delete_static_route($id);
|
||||
$a_routes[$id]['disabled'] = true;
|
||||
}
|
||||
|
||||
write_config();
|
||||
mark_subsystem_dirty('staticroutes');
|
||||
} elseif ( $act == 'move' && isset($pconfig['route']) && count($pconfig['route']) > 0) {
|
||||
// move selected rules
|
||||
if (!isset($id)) {
|
||||
// if rule not set/found, move to end
|
||||
$id = count($a_routes);
|
||||
}
|
||||
$a_routes = legacy_move_config_list_items($a_routes, $id, $pconfig['route']);
|
||||
write_config();
|
||||
mark_subsystem_dirty('staticroutes');
|
||||
}
|
||||
header(url_safe('Location: /system_routes.php'));
|
||||
exit;
|
||||
}
|
||||
|
||||
$a_gateways = return_gateways_array(true, true, true);
|
||||
legacy_html_escape_form_data($a_routes);
|
||||
legacy_html_escape_form_data($a_gateways);
|
||||
|
||||
$main_buttons = array(
|
||||
array('label'=> gettext('Add route'), 'href'=>'system_routes_edit.php'),
|
||||
);
|
||||
|
||||
include("head.inc");
|
||||
|
||||
?>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
$( document ).ready(function() {
|
||||
// link remove route
|
||||
$(".act-del-route").click(function(event){
|
||||
var id = $(this).data('id');
|
||||
event.preventDefault();
|
||||
BootstrapDialog.show({
|
||||
type:BootstrapDialog.TYPE_DANGER,
|
||||
title: "<?= gettext("Route");?>",
|
||||
message: '<?=gettext("Do you really want to delete this route?");?>',
|
||||
buttons: [{
|
||||
label: "<?= gettext("No");?>",
|
||||
action: function(dialogRef) {
|
||||
dialogRef.close();
|
||||
}}, {
|
||||
label: "<?= gettext("Yes");?>",
|
||||
action: function(dialogRef) {
|
||||
$("#id").val(id);
|
||||
$("#act").val("del");
|
||||
$("#iform").submit();
|
||||
}
|
||||
}]
|
||||
});
|
||||
});
|
||||
|
||||
// link remove list of routes
|
||||
$("#del_x").click(function(event){
|
||||
event.preventDefault();
|
||||
BootstrapDialog.show({
|
||||
type:BootstrapDialog.TYPE_DANGER,
|
||||
title: "<?= gettext("Route");?>",
|
||||
message: '<?=gettext("Do you really want to delete the selected routes?");?>',
|
||||
buttons: [{
|
||||
label: "<?= gettext("No");?>",
|
||||
action: function(dialogRef) {
|
||||
dialogRef.close();
|
||||
}}, {
|
||||
label: "<?= gettext("Yes");?>",
|
||||
action: function(dialogRef) {
|
||||
$("#id").val(id);
|
||||
$("#act").val("del_x");
|
||||
$("#iform").submit();
|
||||
}
|
||||
}]
|
||||
});
|
||||
});
|
||||
|
||||
// link toggle buttons
|
||||
$(".act_toggle").click(function(event){
|
||||
event.preventDefault();
|
||||
var id = $(this).data("id");
|
||||
$("#id").val(id);
|
||||
$("#act").val("toggle");
|
||||
$("#iform").submit();
|
||||
});
|
||||
|
||||
// link move buttons
|
||||
$(".act_move").click(function(event){
|
||||
event.preventDefault();
|
||||
var id = $(this).data("id");
|
||||
$("#id").val(id);
|
||||
$("#act").val("move");
|
||||
$("#iform").submit();
|
||||
});
|
||||
|
||||
// watch scroll position and set to last known on page load
|
||||
watchScrollPosition();
|
||||
});
|
||||
</script>
|
||||
<body>
|
||||
<?php include("fbegin.inc"); ?>
|
||||
<section class="page-content-main">
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<?php
|
||||
if (is_subsystem_dirty('staticroutes')):?><p>
|
||||
<?php print_info_box_apply(sprintf(gettext("The static route configuration has been changed.%sYou must apply the changes in order for them to take effect."), "<br />"));?><br /></p>
|
||||
<?php
|
||||
endif; ?>
|
||||
<section class="col-xs-12">
|
||||
<div class="tab-content content-box col-xs-12">
|
||||
<form method="post" name="iform" id="iform">
|
||||
<input type="hidden" id="act" name="act" value="" />
|
||||
<input type="hidden" id="id" name="id" value="" />
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped">
|
||||
<tr>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td><?=gettext("Network");?></td>
|
||||
<td><?=gettext("Gateway");?></td>
|
||||
<td><?=gettext("Interface");?></td>
|
||||
<td><?=gettext("Description");?></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<?php
|
||||
$i = 0;
|
||||
foreach ($a_routes as $route) :?>
|
||||
<tr class="<?=isset($route['disabled']) ? "text-muted" : "";?>">
|
||||
<td>
|
||||
<input type="checkbox" name="route[]" value="<?=$i;?>"/>
|
||||
</td>
|
||||
<td>
|
||||
<a href="#" class="act_toggle" data-id="<?=$i;?>">
|
||||
<span class="glyphicon glyphicon-play <?=isset($route['disabled']) ? "text-muted" : "text-success" ;?>" data-toggle="tooltip"
|
||||
title="<?=(!isset($route['disabled'])) ? gettext("disable route") : gettext("enable route");?>" alt="icon">
|
||||
</span>
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
<?=strtolower($route['network']);?>
|
||||
</td>
|
||||
<td>
|
||||
<?=$a_gateways[$route['gateway']]['name'] . " - " . $a_gateways[$route['gateway']]['gateway'];?>
|
||||
</td>
|
||||
<td>
|
||||
<?=convert_friendly_interface_to_friendly_descr($a_gateways[$route['gateway']]['friendlyiface']);?>
|
||||
</td>
|
||||
<td>
|
||||
<?=$route['descr'];?>
|
||||
</td>
|
||||
<td>
|
||||
<a data-id="<?=$i;?>" data-toggle="tooltip" title="<?=gettext("move selected routes before this route");?>" class="act_move btn btn-default btn-xs">
|
||||
<span class="glyphicon glyphicon-arrow-left"></span>
|
||||
</a>
|
||||
<a class="btn btn-default btn-xs" href="system_routes_edit.php?id=<?=$i;?>"
|
||||
title="<?=gettext("edit route");?>" data-toggle="tooltip">
|
||||
<span class="glyphicon glyphicon-pencil" alt="edit" ></span>
|
||||
</a>
|
||||
<button type="button" class="btn btn-default btn-xs act-del-route"
|
||||
data-id="<?=$i?>" title="<?=gettext("delete route");?>" data-toggle="tooltip">
|
||||
<span class="fa fa-trash text-muted"></span>
|
||||
</button>
|
||||
<a class="btn btn-default btn-xs" href="system_routes_edit.php?dup=<?=$i;?>"
|
||||
title="<?=gettext("clone route");?>" data-toggle="tooltip">
|
||||
<span class="fa fa-clone text-muted" alt="duplicate"></span>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
$i++;
|
||||
endforeach; ?>
|
||||
<tr>
|
||||
<td colspan="6"></td>
|
||||
<td>
|
||||
<?php
|
||||
if ($i == 0) :?>
|
||||
<span class="glyphicon glyphicon-arrow-left text-muted"
|
||||
title="<?=gettext("move selected routes to end");?>" alt="move" />
|
||||
<?php
|
||||
else :?>
|
||||
<button type="submit" data-id="<?=$i;?>" data-toggle="tooltip" title="<?=gettext("move selected routes to end");?>" class="act_move btn btn-default btn-xs">
|
||||
<span class="glyphicon glyphicon-arrow-left"></span>
|
||||
</button>
|
||||
<?php
|
||||
endif;?>
|
||||
<?php
|
||||
if ($i == 0) :?>
|
||||
<span class="btn btn-default btn-xs">
|
||||
<span class="fa fa-trash text-muted"></span>
|
||||
</span>
|
||||
|
||||
<?php
|
||||
else :?>
|
||||
<button id="del_x" title="<?=gettext("delete selected routes");?>" class="btn btn-default btn-xs" data-toggle="tooltip"><span class="fa fa-trash text-muted"></span></button>
|
||||
<?php
|
||||
endif;?>
|
||||
<a href="system_routes_edit.php" class="btn btn-default btn-xs" title="<?=gettext("add route");?>" data-toggle="tooltip">
|
||||
<span class="glyphicon glyphicon-plus"></span>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="7">
|
||||
<?=gettext("Do not enter static routes for networks assigned on any interface of this firewall. Static routes are only used for networks reachable via a different router, and not reachable via your default gateway.");?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<?php include("foot.inc");
|
||||
@ -1,339 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
Copyright (C) 2014-2015 Deciso B.V.
|
||||
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
||||
Copyright (C) 2010 Scott Ullrich <sullrich@gmail.com>
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
require_once("guiconfig.inc");
|
||||
require_once("filter.inc");
|
||||
require_once("interfaces.inc");
|
||||
|
||||
$a_routes = &config_read_array('staticroutes', 'route');
|
||||
$a_gateways = return_gateways_array(true, true);
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||
if (isset($_GET['id']) && isset($a_routes[$_GET['id']])) {
|
||||
$id = $_GET['id'];
|
||||
$configId = $id;
|
||||
} elseif (isset($_GET['dup']) && isset($a_routes[$_GET['dup']])) {
|
||||
$configId = $_GET['dup'];
|
||||
}
|
||||
$pconfig = array();
|
||||
|
||||
if (isset($configId)) {
|
||||
list($pconfig['network'],$pconfig['network_subnet']) =
|
||||
explode('/', $a_routes[$configId]['network']);
|
||||
$pconfig['gateway'] = $a_routes[$configId]['gateway'];
|
||||
$pconfig['descr'] = $a_routes[$configId]['descr'];
|
||||
$pconfig['disabled'] = isset($a_routes[$configId]['disabled']);
|
||||
} else {
|
||||
$pconfig['network'] = null;
|
||||
$pconfig['network_subnet'] = null;
|
||||
$pconfig['gateway'] = null;
|
||||
$pconfig['disabled'] = false;
|
||||
}
|
||||
} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
if (isset($_POST['id']) && isset($a_routes[$_POST['id']])) {
|
||||
$id = $_POST['id'];
|
||||
}
|
||||
global $aliastable;
|
||||
|
||||
$input_errors = array();
|
||||
$pconfig = $_POST;
|
||||
|
||||
/* input validation */
|
||||
$reqdfields = explode(" ", "network network_subnet gateway");
|
||||
$reqdfieldsn = explode(
|
||||
",",
|
||||
gettext("Destination network") . "," .
|
||||
gettext("Destination network bit count") . "," .
|
||||
gettext("Gateway")
|
||||
);
|
||||
|
||||
do_input_validation($pconfig, $reqdfields, $reqdfieldsn, $input_errors);
|
||||
|
||||
if (($pconfig['network'] && !is_ipaddr($pconfig['network']) && !is_alias($pconfig['network']))) {
|
||||
$input_errors[] = gettext("A valid IPv4 or IPv6 destination network must be specified.");
|
||||
}
|
||||
if (($_POST['network_subnet'] && !is_numeric($pconfig['network_subnet']))) {
|
||||
$input_errors[] = gettext("A valid destination network bit count must be specified.");
|
||||
}
|
||||
if (($_POST['gateway']) && is_ipaddr($pconfig['network'])) {
|
||||
if (!isset($a_gateways[$pconfig['gateway']])) {
|
||||
$input_errors[] = gettext("A valid gateway must be specified.");
|
||||
}
|
||||
if (!validate_address_family($pconfig['network'], lookup_gateway_ip_by_name($pconfig['gateway']))) {
|
||||
$input_errors[] = gettext("The gateway '{$a_gateways[$pconfig['gateway']]['gateway']}' is a different Address Family as network '{$pconfig['network']}'.");
|
||||
}
|
||||
}
|
||||
|
||||
/* check for overlaps */
|
||||
$current_targets = get_staticroutes(true);
|
||||
$new_targets = array();
|
||||
if (is_ipaddrv6($pconfig['network'])) {
|
||||
$osn = gen_subnetv6($pconfig['network'], $pconfig['network_subnet']) . "/" . $pconfig['network_subnet'];
|
||||
$new_targets[] = $osn;
|
||||
}
|
||||
if (is_ipaddrv4($pconfig['network'])) {
|
||||
if ($pconfig['network_subnet'] > 32) {
|
||||
$input_errors[] = gettext("A IPv4 subnet can not be over 32 bits.");
|
||||
} else {
|
||||
$osn = gen_subnet($pconfig['network'], $pconfig['network_subnet']) . "/" . $pconfig['network_subnet'];
|
||||
$new_targets[] = $osn;
|
||||
}
|
||||
} elseif (is_alias($pconfig['network'])) {
|
||||
$osn = $pconfig['network'];
|
||||
foreach (preg_split('/\s+/', $aliastable[$osn]) as $tgt) {
|
||||
if (is_ipaddrv4($tgt)) {
|
||||
$tgt .= "/32";
|
||||
}
|
||||
if (is_ipaddrv6($tgt)) {
|
||||
$tgt .= "/128";
|
||||
}
|
||||
if (!is_subnet($tgt)) {
|
||||
continue;
|
||||
}
|
||||
if (!is_subnetv6($tgt)) {
|
||||
continue;
|
||||
}
|
||||
$new_targets[] = $tgt;
|
||||
}
|
||||
}
|
||||
if (!isset($id)) {
|
||||
$id = count($a_routes);
|
||||
}
|
||||
$oroute = $a_routes[$id];
|
||||
$old_targets = array();
|
||||
if (!empty($oroute)) {
|
||||
if (is_alias($oroute['network'])) {
|
||||
foreach (filter_expand_alias_array($oroute['network']) as $tgt) {
|
||||
if (is_ipaddrv4($tgt)) {
|
||||
$tgt .= "/32";
|
||||
} elseif (is_ipaddrv6($tgt)) {
|
||||
$tgt .= "/128";
|
||||
}
|
||||
if (!is_subnet($tgt)) {
|
||||
continue;
|
||||
}
|
||||
$old_targets[] = $tgt;
|
||||
}
|
||||
} else {
|
||||
$old_targets[] = $oroute['network'];
|
||||
}
|
||||
}
|
||||
|
||||
$overlaps = array_intersect($current_targets, $new_targets);
|
||||
$overlaps = array_diff($overlaps, $old_targets);
|
||||
if (count($overlaps)) {
|
||||
$input_errors[] = gettext("A route to these destination networks already exists") . ": " . implode(", ", $overlaps);
|
||||
}
|
||||
|
||||
if (is_array($config['interfaces'])) {
|
||||
foreach (legacy_config_get_interfaces(array("virtual" => false)) as $if) {
|
||||
if (is_ipaddrv4($pconfig['network'])
|
||||
&& isset($if['ipaddr']) && isset($if['subnet'])
|
||||
&& is_ipaddrv4($if['ipaddr']) && is_numeric($if['subnet'])
|
||||
&& ($_POST['network_subnet'] == $if['subnet'])
|
||||
&& (gen_subnet($pconfig['network'], $pconfig['network_subnet']) == gen_subnet($if['ipaddr'], $if['subnet']))) {
|
||||
$input_errors[] = sprintf(gettext("This network conflicts with address configured on interface %s."), $if['descr']);
|
||||
} elseif (is_ipaddrv6($pconfig['network'])
|
||||
&& isset($if['ipaddrv6']) && isset($if['subnetv6'])
|
||||
&& is_ipaddrv6($if['ipaddrv6']) && is_numeric($if['subnetv6'])
|
||||
&& ($_POST['network_subnet'] == $if['subnetv6'])
|
||||
&& (gen_subnetv6($pconfig['network'], $pconfig['network_subnet']) == gen_subnetv6($if['ipaddrv6'], $if['subnetv6']))) {
|
||||
$input_errors[] = sprintf(gettext("This network conflicts with address configured on interface %s."), $if['descr']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (count($input_errors) == 0){
|
||||
$route = array();
|
||||
$route['network'] = $osn;
|
||||
$route['gateway'] = $pconfig['gateway'];
|
||||
$route['descr'] = $pconfig['descr'];
|
||||
if (!empty($pconfig['disabled'])) {
|
||||
$route['disabled'] = true;
|
||||
} else {
|
||||
unset($route['disabled']);
|
||||
}
|
||||
|
||||
if (file_exists('/tmp/.system_routes.apply')) {
|
||||
$toapplylist = unserialize(file_get_contents('/tmp/.system_routes.apply'));
|
||||
} else {
|
||||
$toapplylist = array();
|
||||
}
|
||||
$a_routes[$id] = $route;
|
||||
|
||||
if (!empty($oroute)) {
|
||||
$delete_targets = array_diff($old_targets, $new_targets);
|
||||
if (count($delete_targets)) {
|
||||
foreach ($delete_targets as $dts) {
|
||||
if (is_ipaddrv6($dts)) {
|
||||
$family = '-inet6';
|
||||
}
|
||||
$toapplylist[] = "/sbin/route delete {$family} {$dts}";
|
||||
}
|
||||
}
|
||||
}
|
||||
file_put_contents('/tmp/.system_routes.apply', serialize($toapplylist));
|
||||
mark_subsystem_dirty('staticroutes');
|
||||
write_config();
|
||||
|
||||
header(url_safe('Location: /system_routes.php'));
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
legacy_html_escape_form_data($a_gateways);
|
||||
legacy_html_escape_form_data($pconfig);
|
||||
|
||||
include("head.inc");
|
||||
|
||||
?>
|
||||
|
||||
<body>
|
||||
<script type="text/javascript">
|
||||
$( document ).ready(function() {
|
||||
// hook in, ipv4/ipv6 selector events
|
||||
hook_ipv4v6('ipv4v6net', 'network-id');
|
||||
// collect aliases
|
||||
var all_aliases = [];
|
||||
$("#aliases > option").each(function(){
|
||||
all_aliases.push($(this).val())
|
||||
});
|
||||
$("#network").typeahead({ source: all_aliases});
|
||||
});
|
||||
</script>
|
||||
<?php include("fbegin.inc"); ?>
|
||||
<!-- push all available aliases in a hidden select box -->
|
||||
<select class="hidden" id="aliases">
|
||||
<?php
|
||||
if (!empty($config['aliases']['alias'])):
|
||||
foreach ($config['aliases']['alias'] as $alias):
|
||||
if ($alias['type'] == 'network' || $alias['type'] == 'host'):?>
|
||||
<option value="<?=$alias['name'];?>"></option>
|
||||
<?php
|
||||
endif;
|
||||
endforeach;
|
||||
endif;
|
||||
?>
|
||||
</select>
|
||||
<section class="page-content-main">
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<?php if (isset($input_errors) && count($input_errors) > 0) {
|
||||
print_input_errors($input_errors);
|
||||
} ?>
|
||||
<section class="col-xs-12">
|
||||
<div class="content-box">
|
||||
<form method="post" name="iform" id="iform">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped opnsense_standard_table_form">
|
||||
<tr>
|
||||
<td width="22%"></td>
|
||||
<td width="78%" align="right">
|
||||
<small><?=gettext("full help"); ?> </small>
|
||||
<i class="fa fa-toggle-off text-danger" style="cursor: pointer;" id="show_all_help_page" type="button"></i>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a id="help_for_network" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Destination network"); ?></td>
|
||||
<td>
|
||||
<input name="network" type="text" id="network" value="<?=$pconfig['network'];?>" />
|
||||
/
|
||||
<select name="network_subnet" data-network-id="network" class="ipv4v6net" id="network_netbits">
|
||||
<?php for ($i = 128; $i >= 0; $i--) :
|
||||
?>
|
||||
<option value="<?=$i;?>" <?= isset($pconfig['network_subnet']) && $i == $pconfig['network_subnet'] ? "selected=\"selected\"" : "";?>>
|
||||
<?=$i;?>
|
||||
</option>
|
||||
<?php
|
||||
endfor; ?>
|
||||
</select>
|
||||
<div class="hidden" for="help_for_network">
|
||||
<?=gettext("Destination network for this static route"); ?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a id="help_for_gateway" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Gateway"); ?></td>
|
||||
<td>
|
||||
<select name="gateway" id="gateway" class="selectpicker">
|
||||
<?php
|
||||
foreach ($a_gateways as $gateway):?>
|
||||
<option value="<?=$gateway['name'];?>" <?=$gateway['name'] == $pconfig['gateway'] ? "selected=\"selected\"" : "";?>>
|
||||
<?=$gateway['name'] . " - " . $gateway['gateway'];?>
|
||||
</option>
|
||||
<?php
|
||||
endforeach;?>
|
||||
</select>
|
||||
<div class="hidden" for="help_for_gateway">
|
||||
<?=gettext("Choose which gateway this route applies to or");?>
|
||||
<a href="/system_gateways_edit.php"><?=gettext("add a new one.");?></a>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a id="help_for_disabled" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Disabled");?></td>
|
||||
<td width="78%" class="vtable">
|
||||
<input name="disabled" type="checkbox" value="yes" <?= !empty($pconfig['disabled']) ? "checked=\"checked\"" : "";?>/>
|
||||
<div class="hidden" for="help_for_disabled">
|
||||
<strong><?=gettext("Disable this static route");?></strong><br/>
|
||||
<?=gettext("Set this option to disable this static route without removing it from the list.");?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a id="help_for_descr" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Description"); ?></td>
|
||||
<td>
|
||||
<input name="descr" type="text" value="<?=$pconfig['descr'];?>" />
|
||||
<div for="help_for_descr" class="hidden">
|
||||
<?=gettext("You may enter a description here for your reference (not parsed)."); ?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>
|
||||
<input id="save" name="Submit" type="submit" class="btn btn-primary" value="<?=gettext("Save");?>" />
|
||||
<input id="cancel" type="button" class="btn btn-default" value="<?=gettext("Cancel");?>" onclick="window.location.href='/system_routes.php'" />
|
||||
<?php
|
||||
if (isset($id) && $a_routes[$id]) :?>
|
||||
<input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" />
|
||||
<?php
|
||||
endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<?php include("foot.inc");
|
||||
Loading…
x
Reference in New Issue
Block a user