'require fs';
'require rpc';
'require validation';
+'require ui';
var callNetworkInterfaceDump = rpc.declare({
object: 'network.interface',
callNetworkInterfaceDump(),
L.resolveDefault(fs.exec('/sbin/ip', [ '-4', 'neigh', 'show' ]), {}),
L.resolveDefault(fs.exec('/sbin/ip', [ '-4', 'route', 'show', 'table', 'all' ]), {}),
+ L.resolveDefault(fs.exec('/sbin/ip', [ '-4', 'rule', 'show' ]), {}),
L.resolveDefault(fs.exec('/sbin/ip', [ '-6', 'neigh', 'show' ]), {}),
- L.resolveDefault(fs.exec('/sbin/ip', [ '-6', 'route', 'show', 'table', 'all' ]), {})
+ L.resolveDefault(fs.exec('/sbin/ip', [ '-6', 'route', 'show', 'table', 'all' ]), {}),
+ L.resolveDefault(fs.exec('/sbin/ip', [ '-6', 'rule', 'show' ]), {})
]);
},
res = [];
for (var i = 0; i < lines.length; i++) {
- var m = lines[i].match(/^([0-9a-f:.]+) (.+) (\S+)$/),
+ var m = lines[i].match(/^([0-9a-f:.]+) (.+) (\S+) *$/),
addr = m ? m[1] : null,
flags = m ? m[2].trim().split(/\s+/) : [],
state = (m ? m[3] : null) || 'FAILED';
dest,
(v6 ? flags.from : flags.via) || '-',
String(flags.metric || 0),
- flags.table || 'main'
+ flags.table || 'main',
+ flags.proto,
+ ]);
+ }
+
+ return res;
+ },
+
+ parseRule: function(s) {
+ var lines = s.trim().split(/\n/),
+ res = [];
+
+ for (var i = 0; i < lines.length; i++) {
+ var m = lines[i].match(/^(\d+):\s+(.+)$/),
+ prio = m ? m[1] : null,
+ rule = m ? m[2] : null;
+
+ res.push([
+ prio,
+ rule
]);
}
var networks = data[0],
ip4neigh = data[1].stdout || '',
ip4route = data[2].stdout || '',
- ip6neigh = data[3].stdout || '',
- ip6route = data[4].stdout || '';
-
- var neigh4tbl = E('div', { 'class': 'table' }, [
- E('div', { 'class': 'tr table-titles' }, [
- E('div', { 'class': 'th' }, [ _('IPv4-Address') ]),
- E('div', { 'class': 'th' }, [ _('MAC-Address') ]),
- E('div', { 'class': 'th' }, [ _('Interface') ])
+ ip4rule = data[3].stdout || '',
+ ip6neigh = data[4].stdout || '',
+ ip6route = data[5].stdout || '',
+ ip6rule = data[6].stdout || '';
+
+ var neigh4tbl = E('table', { 'class': 'table' }, [
+ E('tr', { 'class': 'tr table-titles' }, [
+ E('th', { 'class': 'th' }, [ _('IP address') ]),
+ E('th', { 'class': 'th' }, [ _('MAC address') ]),
+ E('th', { 'class': 'th' }, [ _('Interface') ])
])
]);
- var route4tbl = E('div', { 'class': 'table' }, [
- E('div', { 'class': 'tr table-titles' }, [
- E('div', { 'class': 'th' }, [ _('Network') ]),
- E('div', { 'class': 'th' }, [ _('Target') ]),
- E('div', { 'class': 'th' }, [ _('IPv4-Gateway') ]),
- E('div', { 'class': 'th' }, [ _('Metric') ]),
- E('div', { 'class': 'th' }, [ _('Table') ])
+ var route4tbl = E('table', { 'class': 'table' }, [
+ E('tr', { 'class': 'tr table-titles' }, [
+ E('th', { 'class': 'th' }, [ _('Network') ]),
+ E('th', { 'class': 'th' }, [ _('Target') ]),
+ E('th', { 'class': 'th' }, [ _('Gateway') ]),
+ E('th', { 'class': 'th' }, [ _('Metric') ]),
+ E('th', { 'class': 'th' }, [ _('Table') ]),
+ E('th', { 'class': 'th' }, [ _('Protocol') ])
])
]);
- var neigh6tbl = E('div', { 'class': 'table' }, [
- E('div', { 'class': 'tr table-titles' }, [
- E('div', { 'class': 'th' }, [ _('IPv6-Address') ]),
- E('div', { 'class': 'th' }, [ _('MAC-Address') ]),
- E('div', { 'class': 'th' }, [ _('Interface') ])
+ var rule4tbl = E('table', { 'class': 'table' }, [
+ E('tr', { 'class': 'tr table-titles' }, [
+ E('th', { 'class': 'th' }, [ _('Priority') ]),
+ E('th', { 'class': 'th' }, [ _('Rule') ])
])
]);
- var route6tbl = E('div', { 'class': 'table' }, [
- E('div', { 'class': 'tr table-titles' }, [
- E('div', { 'class': 'th' }, [ _('Network') ]),
- E('div', { 'class': 'th' }, [ _('Target') ]),
- E('div', { 'class': 'th' }, [ _('Source') ]),
- E('div', { 'class': 'th' }, [ _('Metric') ]),
- E('div', { 'class': 'th' }, [ _('Table') ])
+ var neigh6tbl = E('table', { 'class': 'table' }, [
+ E('tr', { 'class': 'tr table-titles' }, [
+ E('th', { 'class': 'th' }, [ _('IP address') ]),
+ E('th', { 'class': 'th' }, [ _('MAC address') ]),
+ E('th', { 'class': 'th' }, [ _('Interface') ])
])
]);
- cbi_update_table(neigh4tbl, this.parseNeigh(ip4neigh, networks, false));
- cbi_update_table(route4tbl, this.parseRoute(ip4route, networks, false));
- cbi_update_table(neigh6tbl, this.parseNeigh(ip6neigh, networks, true));
- cbi_update_table(route6tbl, this.parseRoute(ip6route, networks, true));
-
- return E([], [
- E('h2', {}, [ _('Routes') ]),
- E('p', {}, [ _('The following rules are currently active on this system.') ]),
+ var route6tbl = E('table', { 'class': 'table' }, [
+ E('tr', { 'class': 'tr table-titles' }, [
+ E('th', { 'class': 'th' }, [ _('Network') ]),
+ E('th', { 'class': 'th' }, [ _('Target') ]),
+ E('th', { 'class': 'th' }, [ _('Source') ]),
+ E('th', { 'class': 'th' }, [ _('Metric') ]),
+ E('th', { 'class': 'th' }, [ _('Table') ]),
+ E('th', { 'class': 'th' }, [ _('Protocol') ])
+ ])
+ ]);
- E('h3', {}, [ _('ARP') ]),
- neigh4tbl,
+ var rule6tbl = E('table', { 'class': 'table' }, [
+ E('tr', { 'class': 'tr table-titles' }, [
+ E('th', { 'class': 'th' }, [ _('Priority') ]),
+ E('th', { 'class': 'th' }, [ _('Rule') ])
+ ])
+ ]);
- E('h3', {}, _('Active <abbr title="Internet Protocol Version 4">IPv4</abbr>-Routes')),
- route4tbl,
+ cbi_update_table(neigh4tbl, this.parseNeigh(ip4neigh, networks, false),
+ E('em', _('No entries available'))
+ );
+ cbi_update_table(route4tbl, this.parseRoute(ip4route, networks, false),
+ E('em', _('No entries available'))
+ );
+ cbi_update_table(rule4tbl, this.parseRule(ip4rule, networks, false),
+ E('em', _('No entries available'))
+ );
+ cbi_update_table(neigh6tbl, this.parseNeigh(ip6neigh, networks, true),
+ E('em', _('No entries available'))
+ );
+ cbi_update_table(route6tbl, this.parseRoute(ip6route, networks, true),
+ E('em', _('No entries available'))
+ );
+ cbi_update_table(rule6tbl, this.parseRule(ip6rule, networks, false),
+ E('em', _('No entries available'))
+ );
+
+ var view = E([], [
+ E('h2', {}, [ _('Routing') ]),
+ E('p', {}, [ _('The following rules are currently active on this system.') ]),
+ E('div', {}, [
+ E('div', { 'class': 'cbi-section', 'data-tab': 'ipv4routing', 'data-tab-title': _('IPv4 Routing') }, [
+ E('h3', {}, [ _('IPv4 Neighbours') ]),
+ neigh4tbl,
+
+ E('h3', {}, [ _('Active IPv4 Routes') ]),
+ route4tbl,
+
+ E('h3', {}, [ _('Active IPv4 Rules') ]),
+ rule4tbl
+ ]),
+ E('div', { 'class': 'cbi-section', 'data-tab': 'ipv6routing', 'data-tab-title': _('IPv6 Routing') }, [
+ E('h3', {}, [ _('IPv6 Neighbours') ]),
+ neigh6tbl,
+
+ E('h3', {}, [ _('Active IPv6 Routes') ]),
+ route6tbl,
+
+ E('h3', {}, [ _('Active IPv6 Rules') ]),
+ rule6tbl
+ ])
+ ])
+ ]);
- E('h3', {}, [ _('IPv6 Neighbours') ]),
- neigh6tbl,
+ ui.tabs.initTabGroup(view.lastElementChild.childNodes);
- E('h3', {}, _('Active <abbr title="Internet Protocol Version 6">IPv6</abbr>-Routes')),
- route6tbl
- ]);
+ return view;
},
handleSaveApply: null,
handleSave: null,
handleReset: null
});
-