mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-13 16:14:40 +00:00
interfaces: add fargw knob, last bits of UX; closes #2458
This commit is contained in:
parent
79b632565b
commit
0408e32f87
@ -1394,7 +1394,6 @@ include("head.inc");
|
||||
// new gateway action
|
||||
//
|
||||
$("#gwsave").click(function(){
|
||||
$("#addgateway").toggleClass("hidden visible");
|
||||
var iface = $('#if').val();
|
||||
var name = $('#name').val();
|
||||
var descr = $('#gatewaydescr').val();
|
||||
@ -1403,9 +1402,13 @@ include("head.inc");
|
||||
if ($("#defaultgw").prop('checked')) {
|
||||
defaultgw = "&defaultgw=on";
|
||||
}
|
||||
var fargw = "";
|
||||
if ($("#fargw").prop('checked')) {
|
||||
fargw = "&fargw=on";
|
||||
}
|
||||
jQuery.ajax( "system_gateways_edit.php", {
|
||||
type: 'post',
|
||||
data: 'isAjax=true&ipprotocol=inet' + defaultgw + '&interface=' + escape(iface) + '&name=' + escape(name) + '&descr=' + escape(descr) + '&gateway=' + escape(gatewayip),
|
||||
data: 'isAjax=true&ipprotocol=inet' + defaultgw + fargw + '&interface=' + escape(iface) + '&name=' + escape(name) + '&descr=' + escape(descr) + '&gateway=' + escape(gatewayip),
|
||||
error: function(request, textStatus, errorThrown){
|
||||
if (textStatus === "error" && request.getResponseHeader("Content-Type").indexOf("text/plain") === 0) {
|
||||
alert(request.responseText);
|
||||
@ -1414,6 +1417,7 @@ include("head.inc");
|
||||
}
|
||||
},
|
||||
success: function(response) {
|
||||
$("#addgateway").toggleClass("hidden visible");
|
||||
var selected = "selected=selected";
|
||||
if (!$("#multiwangw").prop('checked')) {
|
||||
selected = "";
|
||||
@ -1431,7 +1435,6 @@ include("head.inc");
|
||||
// new gateway v6 action
|
||||
//
|
||||
$("#gwsavev6").click(function(){
|
||||
$("#addgatewayv6").toggleClass("hidden visible");
|
||||
var iface = $('#if').val();
|
||||
var name = $('#namev6').val();
|
||||
var descr = $('#gatewaydescrv6').val();
|
||||
@ -1451,6 +1454,7 @@ include("head.inc");
|
||||
}
|
||||
},
|
||||
success: function(response) {
|
||||
$("#addgatewayv6").toggleClass("hidden visible");
|
||||
var selected = "selected=selected";
|
||||
if (!$("#multiwangwv6").prop('checked')) {
|
||||
selected = "";
|
||||
@ -1882,6 +1886,10 @@ include("head.inc");
|
||||
<td><?= gettext('Default gateway') ?></td>
|
||||
<td><input type="checkbox" id="defaultgw" name="defaultgw" <?= strtolower($if) == 'wan' ? 'checked="checked"' : '' ?> /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?= gettext('Far gateway') ?></td>
|
||||
<td><input type="checkbox" id="fargw" name="fargw" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?= gettext('Multi-WAN gateway') ?></td>
|
||||
<td><input type="checkbox" id="multiwangw" name="multiwangw" /></td>
|
||||
@ -2398,7 +2406,7 @@ include("head.inc");
|
||||
<td colspan="2"><b><?=gettext("Add new gateway"); ?></b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?= gettext("Default gateway"); ?></td>
|
||||
<td><?= gettext('Default gateway') ?></td>
|
||||
<td><input type="checkbox" id="defaultgwv6" name="defaultgwv6" <?= strtolower($if) == 'wan' ? 'checked="checked"' : '' ?> /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
@ -2406,7 +2414,7 @@ include("head.inc");
|
||||
<td><input type="checkbox" id="multiwangwv6" name="multiwangwv6" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?=gettext("Gateway Name"); ?></td>
|
||||
<td><?= gettext('Gateway Name') ?></td>
|
||||
<td><input id="namev6" type="text" name="namev6" value="<?= html_safe((empty($pconfig['descr']) ? strtoupper($if) : $pconfig['descr']) . '_GWv6') ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
@ -70,12 +70,11 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
|
||||
/* skip system gateways which have been automatically added */
|
||||
if (!empty($pconfig['gateway']) && !is_ipaddr($pconfig['gateway']) &&
|
||||
$pconfig['attribute'] !== "system" && $pconfig['gateway'] != "dynamic"
|
||||
) {
|
||||
$pconfig['attribute'] !== "system" && $pconfig['gateway'] != "dynamic") {
|
||||
$input_errors[] = gettext("A valid gateway IP address must be specified.");
|
||||
}
|
||||
|
||||
if (!empty($pconfig['gateway']) && (is_ipaddr($pconfig['gateway'])) && !isset($_REQUEST['isAjax'])) {
|
||||
if (!empty($pconfig['gateway']) && is_ipaddr($pconfig['gateway'])) {
|
||||
if (is_ipaddrv4($pconfig['gateway'])) {
|
||||
$parent_ip = get_interface_ip($pconfig['interface']);
|
||||
$parent_sn = get_interface_subnet($pconfig['interface']);
|
||||
@ -83,7 +82,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$input_errors[] = gettext("Cannot add IPv4 Gateway Address because no IPv4 address could be found on the interface.");
|
||||
} else {
|
||||
$subnets = array(gen_subnet($parent_ip, $parent_sn) . "/" . $parent_sn);
|
||||
$vips = link_interface_to_vips($_POST['interface']);
|
||||
$vips = link_interface_to_vips($pconfig['interface']);
|
||||
if (is_array($vips)) {
|
||||
foreach ($vips as $vip) {
|
||||
if (!is_ipaddrv4($vip['subnet'])) {
|
||||
@ -163,7 +162,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
}
|
||||
}
|
||||
/* only allow correct IPv4 and IPv6 monitor addresses */
|
||||
if ( !empty($_POST['monitor']) && is_ipaddr($pconfig['monitor']) && $pconfig['monitor'] != "dynamic") {
|
||||
if (!empty($pconfig['monitor']) && is_ipaddr($pconfig['monitor']) && $pconfig['monitor'] != "dynamic") {
|
||||
if (is_ipaddrv6($pconfig['monitor']) && ($pconfig['ipprotocol'] == "inet")) {
|
||||
$input_errors[] = sprintf(gettext('The IPv6 monitor address "%s" can not be used on an IPv4 gateway.'), $pconfig['monitor']);
|
||||
}
|
||||
@ -214,13 +213,13 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
if (!empty($pconfig['latencyhigh'])) {
|
||||
if (!is_numeric($pconfig['latencyhigh'])) {
|
||||
$input_errors[] = gettext("The high latency threshold needs to be a numeric value.");
|
||||
} elseif ($_POST['latencyhigh'] < 1) {
|
||||
} elseif ($pconfig['latencyhigh'] < 1) {
|
||||
$input_errors[] = gettext("The high latency threshold needs to be positive.");
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($pconfig['losslow'])) {
|
||||
if (!is_numeric($_POST['losslow'])) {
|
||||
if (!is_numeric($pconfig['losslow'])) {
|
||||
$input_errors[] = gettext("The low Packet Loss threshold needs to be a numeric value.");
|
||||
} elseif ($pconfig['losslow'] < 1) {
|
||||
$input_errors[] = gettext("The low Packet Loss threshold needs to be positive.");
|
||||
@ -250,7 +249,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$input_errors[] = sprintf(gettext('The low latency threshold needs to be less than the default high latency threshold (%d)'), $apinger_default['latencyhigh']);
|
||||
}
|
||||
} elseif (!empty($pconfig['latencyhigh'])) {
|
||||
if (is_numeric($_POST['latencyhigh']) && $_POST['latencyhigh'] < $apinger_default['latencylow']) {
|
||||
if (is_numeric($pconfig['latencyhigh']) && $pconfig['latencyhigh'] < $apinger_default['latencylow']) {
|
||||
$input_errors[] = sprintf(gettext('The high latency threshold needs to be higher than the default low latency threshold (%d)'), $apinger_default['latencylow']);
|
||||
}
|
||||
}
|
||||
@ -308,7 +307,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
}
|
||||
|
||||
if (!empty($pconfig['avg_loss_samples'])) {
|
||||
if (!is_numeric($_POST['avg_loss_samples'])) {
|
||||
if (!is_numeric($pconfig['avg_loss_samples'])) {
|
||||
$input_errors[] = gettext("The average packet loss probes qty needs to be a numeric value.");
|
||||
} elseif ($pconfig['avg_loss_samples'] < 1) {
|
||||
$input_errors[] = gettext("The average packet loss probes qty needs to be positive.");
|
||||
@ -404,13 +403,13 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_POST['disabled'])) {
|
||||
if (isset($pconfig['disabled'])) {
|
||||
$gateway['disabled'] = true;
|
||||
} elseif (isset($gateway['disabled'])) {
|
||||
unset($gateway['disabled']);
|
||||
}
|
||||
|
||||
if (isset($_POST['fargw'])) {
|
||||
if (isset($pconfig['fargw'])) {
|
||||
$gateway['fargw'] = true;
|
||||
} elseif (isset($gateway['fargw'])) {
|
||||
unset($gateway['fargw']);
|
||||
@ -427,7 +426,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
|
||||
write_config();
|
||||
|
||||
if (!empty($_REQUEST['isAjax'])) {
|
||||
if (!empty($pconfig['isAjax'])) {
|
||||
echo $pconfig['name'];
|
||||
exit;
|
||||
} elseif (!empty($reloadif)) {
|
||||
@ -437,7 +436,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
header(url_safe('Location: /system_gateways.php'));
|
||||
exit;
|
||||
} else {
|
||||
if (!empty($_REQUEST['isAjax'])) {
|
||||
if (!empty($pconfig['isAjax'])) {
|
||||
header("HTTP/1.0 500 Internal Server Error");
|
||||
header("Content-type: text/plain");
|
||||
echo implode("\n\n", $input_errors);
|
||||
@ -445,7 +444,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
}
|
||||
|
||||
if (!empty($pconfig['interface'])) {
|
||||
$pconfig['friendlyiface'] = $_POST['interface'];
|
||||
$pconfig['friendlyiface'] = $pconfig['interface'];
|
||||
}
|
||||
}
|
||||
} elseif ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user