249acdf90d1ca70694406a6ab9e0d9392e5d88c6
[project/luci2/ui.git] / luci2 / htdocs / luci2 / view / status.routes.js
1 L.ui.view.extend({
2 title: L.tr('Routes'),
3 description: L.tr('The following rules are currently active on this system.'),
4 execute: function() {
5 return $.when(
6 L.network.getARPTable().then(function(arp) {
7 var arpTable = new L.ui.table({
8 caption: L.tr('ARP'),
9 columns: [{
10 caption: L.tr('IPv4-Address'),
11 key: 'ipaddr'
12 }, {
13 caption: L.tr('MAC-Address'),
14 key: 'macaddr'
15 }, {
16 caption: L.tr('Interface'),
17 key: 'device'
18 }]
19 });
20
21 arpTable.rows(arp);
22 arpTable.insertInto('#arp_table');
23 }),
24 L.network.getRoutes().then(function(routes) {
25 var routeTable = new L.ui.table({
26 caption: L.tr('Active IPv4-Routes'),
27 columns: [{
28 caption: L.tr('Target'),
29 key: 'target'
30 }, {
31 caption: L.tr('Gateway'),
32 key: 'nexthop'
33 }, {
34 caption: L.tr('Metric'),
35 key: 'metric'
36 }, {
37 caption: L.tr('Interface'),
38 key: 'device'
39 }]
40 });
41
42 routeTable.rows(routes);
43 routeTable.insertInto('#route_table');
44 }),
45 L.network.getIPv6Routes().then(function(routes) {
46 var route6Table = new L.ui.table({
47 caption: L.tr('Active IPv6-Routes'),
48 columns: [{
49 caption: L.tr('Target'),
50 key: 'target'
51 }, {
52 caption: L.tr('Gateway'),
53 key: 'nexthop'
54 }, {
55 caption: L.tr('Source'),
56 key: 'source'
57 }, {
58 caption: L.tr('Metric'),
59 key: 'metric'
60 }, {
61 caption: L.tr('Interface'),
62 key: 'device'
63 }]
64 });
65
66 for (var i = 0; i < routes.length; i++)
67 {
68 var prefix = routes[i].target.substr(0, 5).toLowerCase();
69 if (prefix == 'fe80:' || prefix == 'fe90:' || prefix == 'fea0:' || prefix == 'feb0:' || prefix == 'ff00:')
70 continue;
71
72 route6Table.row(routes[i]);
73 }
74
75 route6Table.insertInto('#route6_table');
76 })
77 )
78 }
79 });