Commit 18364725 authored by Ad Schellevis's avatar Ad Schellevis

(mvc) move system routes to mvc including dependencies

parent 05e75ec6
......@@ -101,4 +101,31 @@ class InterfaceController extends ApiControllerBase
return $ndptable;
}
/**
* retrieve system routing table
* @return mixed
*/
public function getRoutesAction()
{
$backend = new Backend();
if (empty($this->request->get('resolve', null))) {
$response = $backend->configdpRun("interface routes list -n json");
} else {
$response = $backend->configdpRun("interface routes list json");
}
$routingtable = json_decode($response, true);
if (is_array($routingtable)) {
$intfmap = $this->getInterfaceNames();
foreach ($routingtable as &$routingentry) {
if (array_key_exists($routingentry['netif'], $intfmap)) {
$ndpentry['intf_description'] = $intfmap[$routingentry['netif']];
} else {
$ndpentry['intf_description'] = "";
}
}
}
return $routingtable;
}
}
......@@ -53,4 +53,13 @@ class InterfaceController extends IndexController
$this->view->title = "System NDP table";
$this->view->pick('OPNsense/Diagnostics/ndp');
}
/**
* system Routing table
*/
public function routesAction()
{
$this->view->title = "System Routing table";
$this->view->pick('OPNsense/Diagnostics/routes');
}
}
......@@ -32,11 +32,10 @@
<CARPStatus order="100" VisibleName="CARP Status" url="/carp_status.php"/>
</HighAvailability>
<Routes order="40" cssClass="fa fa-map-signs fa-fw">
<All url="/system_routes.php">
<All order="10" url="/system_routes.php">
<Edit url="/system_routes_edit.php*" visibility="hidden"/>
</All>
<Status url="/diag_routes.php"/>
<Log VisibleName="Log File" url="/diag_logs_routing.php"/>
<Log order="100" VisibleName="Log File" url="/diag_logs_routing.php"/>
</Routes>
<Gateways order="30" cssClass="fa fa-location-arrow fa-fw">
<All url="/system_gateways.php">
......
......@@ -197,13 +197,6 @@
"diag_resetstate.php*"
]
},
"page-diagnostics-routingtables": {
"name": "WebCfg - Diagnostics: Routing tables page",
"descr": "Allow access to the 'Diagnostics: Routing tables' page.",
"match": [
"diag_routes.php*"
]
},
"page-diagnostics-showstates": {
"name": "WebCfg - Diagnostics: Show States page",
"descr": "Allow access to the 'Diagnostics: Show States' page.",
......
......@@ -16,6 +16,14 @@
<pattern>api/diagnostics/interface/getNdp*</pattern>
</patterns>
</page-diagnostics-ndptable>
<page-diagnostics-routingtables>
<name>WebCfg - Diagnostics: Routing tables page</name>
<description>Allow access to the 'Diagnostics: Routing tables' page.</description>
<patterns>
<pattern>ui/diagnostics/interface/routes/*</pattern>
<pattern>api/diagnostics/interface/getRoutes*</pattern>
</patterns>
</page-diagnostics-routingtables>
<page-diagnostics-system-activity>
<name>WebCfg - Diagnostics: System Activity</name>
<description>Allows access to the 'Diagnostics: System Activity' page</description>
......
......@@ -4,6 +4,9 @@
<Diagnostics>
<Activity order="10" VisibleName="Activity Monitor" url="/ui/diagnostics/activity/"/>
</Diagnostics>
<Routes>
<Status order="20" url="/ui/diagnostics/interface/routes/"/>
</Routes>
</System>
<Interfaces>
<Diagnostics>
......
{#
OPNsense® is Copyright © 2014 – 2016 by Deciso B.V.
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.
#}
<script type="text/javascript">
$( document ).ready(function() {
var gridopt = {
ajax: false,
selection: false,
multiSelect: false
};
$("#grid-routes").bootgrid('destroy');
$("#grid-routes").bootgrid(gridopt);
// update routes
$("#update").click(function() {
$('#processing-dialog').modal('show');
if ($("#resolve").prop("checked")) {
resolve = "yes";
} else {
resolve = "";
}
ajaxGet(url = "/api/diagnostics/interface/getRoutes",
sendData = {resolve:resolve}, callback = function (data, status) {
if (status == "success") {
$("#grid-routes").bootgrid('destroy');
var html = [];
$.each(data, function (key, value) {
var fields = ["proto", "destination", "gateway", "flags", "use", "mtu", "netif","intf_description", "expire"];
tr_str = '<tr>';
for (var i = 0; i < fields.length; i++) {
if (value[fields[i]] != null) {
tr_str += '<td>' + value[fields[i]] + '</td>';
} else {
tr_str += '<td></td>';
}
}
tr_str += '</tr>';
html.push(tr_str);
});
$("#grid-routes > tbody").html(html.join(''));
$("#grid-routes").bootgrid(gridopt);
$('#processing-dialog').modal('hide');
}
}
);
});
// initial load
$("#update").click();
});
</script>
<div class="content-box">
<div class="content-box-main">
<div class="table-responsive">
<div class="col-sm-12">
<div class="table-responsive">
<table id="grid-routes" class="table table-condensed table-hover table-striped table-responsive">
<thead>
<tr>
<th data-column-id="proto" data-type="string" >{{ lang._('Proto') }}</th>
<th data-column-id="destination" data-type="string" data-identifier="true">{{ lang._('Destination') }}</th>
<th data-column-id="gateway" data-type="string">{{ lang._('Gateway') }}</th>
<th data-column-id="flags" data-type="string" data-css-class="hidden-xs hidden-sm" data-header-css-class="hidden-xs hidden-sm">{{ lang._('Flags') }}</th>
<th data-column-id="use" data-type="string" data-css-class="hidden-xs hidden-sm" data-header-css-class="hidden-xs hidden-sm">{{ lang._('Use') }}</th>
<th data-column-id="mtu" data-type="string" data-css-class="hidden-xs hidden-sm" data-header-css-class="hidden-xs hidden-sm">{{ lang._('MTU') }}</th>
<th data-column-id="netif" data-type="string" data-css-class="hidden-xs hidden-sm" data-header-css-class="hidden-xs hidden-sm">{{ lang._('Netif') }}</th>
<th data-column-id="intf_description" data-type="string" data-css-class="hidden-xs hidden-sm" data-header-css-class="hidden-xs hidden-sm">{{ lang._('Netif (name)') }}</th>
<th data-column-id="expire" data-type="string" data-css-class="hidden-xs hidden-sm" data-header-css-class="hidden-xs hidden-sm">{{ lang._('Expire') }}</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
<div class="col-sm-12">
<div class="row">
<table class="table">
<tr>
<td>
<input type="checkbox" class="formfld" id="resolve" name="resolve" value="yes">
</td>
<td>
<strong><?=gettext("Name resolution");?></strong>
<p class="text-muted">
<small>
{{ lang._("Enable this to attempt to resolve names when displaying the tables.") }}<br/>
{{ lang._('Note:') }} {{ lang._("By enabling name resolution, the query should take a bit longer.") }}
</small>
</p>
</td>
<td>
<div class="pull-right">
<button id="update" type="button" class="btn btn-default">
<span>{{ lang._('Refresh') }}</span>
<span class="fa fa-refresh"></span>
</button>
</div>
</td>
</tr>
</table>
</div>
<hr/>
</div>
</div>
</div>
</div>
{{ partial("layout_partials/base_dialog_processing") }}
<!-- Static Modal "Processing request", prevent user input while busy -->
<div class="modal modal-static fade" id="processing-dialog" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body">
<div class="text-center">
<i class="fa fa-spinner fa-pulse fa-5x"></i>
<h4>{{ lang._('Processing request...') }} </h4>
</div>
</div>
</div>
</div>
</div>
......@@ -58,3 +58,9 @@ command:/usr/local/opnsense/scripts/interfaces/list_ndp.py
parameters: %s
type:script_output
message:request ndp table
[routes.list]
command:/usr/local/opnsense/scripts/routes/show_routes.py
parameters:%s %s
type:script_output
message:show system routing table
......@@ -3,9 +3,3 @@ command:/usr/local/opnsense/scripts/systemhealth/activity.py
parameters:%s
type:script_output
message:show system activity
[routes.list]
command:/usr/local/opnsense/scripts/routes/show_routes.py
parameters:%s %s
type:script_output
message:show system routing table
<?php
/*
Copyright (C) 2014-2016 Deciso B.V.
Copyright (C) 2006 Fernando Lamos
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.
*/
include('guiconfig.inc');
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (empty($_POST['resolve'])) {
$resolve = '-n';
} else {
$resolve = '';
}
echo configd_run("system routes list {$resolve} json");
exit;
}
include('head.inc');
?>
<body>
<?php include("fbegin.inc"); ?>
<link rel="stylesheet" type="text/css" href="/ui/css/jquery.bootgrid.css"/>
<script type="text/javascript" src="/ui/js/jquery.bootgrid.js"></script>
<script type="text/javascript">
$( document ).ready(function() {
var gridopt = {
ajax: false,
selection: false,
multiSelect: false
};
$("#grid-routes").bootgrid('destroy');
$("#grid-routes").bootgrid(gridopt);
// update routes
$("#update").click(function() {
$("#loading").show();
if ($("#resolve").prop("checked")) {
resolve = "yes";
} else {
resolve = "";
}
$.post(window.location, {resolve: resolve}, function(data) {
$("#grid-routes").bootgrid('destroy');
var html = [];
$.each(data, function (key, value) {
var fields = ["proto", "destination", "gateway", "flags", "use", "mtu", "netif", "expire"];
tr_str = '<tr>';
for (var i = 0; i < fields.length; i++) {
if (value[fields[i]] != null) {
tr_str += '<td>' + value[fields[i]] + '</td>';
} else {
tr_str += '<td></td>';
}
}
tr_str += '</tr>';
html.push(tr_str);
});
$("#grid-routes > tbody").html(html.join(''));
$("#grid-routes").bootgrid(gridopt);
$("#loading").hide();
}, "json");
});
// initial load
$("#update").click();
});
</script>
<section class="page-content-main">
<div class="container-fluid">
<div class="row">
<section class="col-xs-12">
<div class="tab-content content-box col-xs-12">
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th><?=gettext("Name resolution");?></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td>
<input type="checkbox" class="formfld" id="resolve" name="resolve" value="yes">
</td>
<td>
<p class="text-muted">
<em>
<small>
<?=gettext("Enable this to attempt to resolve names when displaying the tables.");?><br/>
<?= gettext('Note:') ?> <?=gettext("By enabling name resolution, the query should take a bit longer. You can stop it at any time by clicking the Stop button in your browser.");?>
</small>
</em>
</p>
</td>
<td>
<input type="button" id="update" class="btn btn-primary" value="<?=gettext("Update"); ?>" />
</td>
</tr>
</tbody>
</table>
</div>
<div class="table-responsive">
<table id="grid-routes" class="table table-condensed table-hover table-striped table-responsive">
<thead>
<tr>
<th data-column-id="proto" data-type="string" ><?=gettext("Proto");?></th>
<th data-column-id="destination" data-type="string" data-identifier="true"><?=gettext("Destination");?></th>
<th data-column-id="gateway" data-type="string"><?=gettext("Gateway");?></th>
<th data-column-id="flags" data-type="string" data-css-class="hidden-xs hidden-sm" data-header-css-class="hidden-xs hidden-sm"><?=gettext("Flags");?></th>
<th data-column-id="use" data-type="string" data-css-class="hidden-xs hidden-sm" data-header-css-class="hidden-xs hidden-sm"><?=gettext("Use");?></th>
<th data-column-id="mtu" data-type="string" data-css-class="hidden-xs hidden-sm" data-header-css-class="hidden-xs hidden-sm"><?=gettext("MTU");?></th>
<th data-column-id="netif" data-type="string" data-css-class="hidden-xs hidden-sm" data-header-css-class="hidden-xs hidden-sm"><?=gettext("Netif");?></th>
<th data-column-id="expire" data-type="string" data-css-class="hidden-xs hidden-sm" data-header-css-class="hidden-xs hidden-sm"><?=gettext("Expire");?></th>
</tr>
</thead>
<tbody>
</tbody>
<tfoot>
<tr>
<td colspan="6" id="loading"><?=gettext("loading....");?></td>
</tr>
</tfoot>
</table>
</div>
</div>
</section>
</div>
</div>
</section>
<?php
include('foot.inc');?>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment