1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-03-09 15:40:03 +00:00

Update luci-mod-network

This commit is contained in:
Ycarus (Yannick Chabanois) 2023-11-27 16:37:15 +01:00
parent 6920f7227f
commit 53a6411d5b
10 changed files with 1329 additions and 540 deletions

View file

@ -4,6 +4,7 @@
'require fs';
'require ui';
'require uci';
'require network';
return view.extend({
handleCommand: function(exec, args) {
@ -13,8 +14,7 @@ return view.extend({
buttons[i].setAttribute('disabled', 'true');
return fs.exec(exec, args).then(function(res) {
var out = document.querySelector('.command-output');
out.style.display = '';
var out = document.querySelector('textarea');
dom.content(out, [ res.stdout || '', res.stderr || '' ]);
}).catch(function(err) {
@ -36,7 +36,7 @@ return view.extend({
handleTraceroute: function(ev, cmd) {
var exec = cmd || 'traceroute',
addr = ev.currentTarget.parentNode.previousSibling.value,
args = (exec == 'traceroute') ? [ '-q', '1', '-w', '1', '-n', addr ] : [ '-q', '1', '-w', '2', '-n', addr ];
args = (exec == 'traceroute') ? [ '-4', '-q', '1', '-w', '1', '-n', '-m', String(L.env.rpctimeout || 20), addr ] : [ '-q', '1', '-w', '2', '-n', addr ];
return this.handleCommand(exec, args);
},
@ -47,12 +47,20 @@ return view.extend({
return this.handleCommand('nslookup', [ addr ]);
},
handleArpScan: function(ev, cmd) {
var addr = ev.currentTarget.parentNode.previousSibling.value;
return this.handleCommand('arp-scan', [ '-l', '-I', addr ]);
},
load: function() {
return Promise.all([
L.resolveDefault(fs.stat('/bin/ping6'), {}),
L.resolveDefault(fs.stat('/usr/bin/ping6'), {}),
L.resolveDefault(fs.stat('/bin/traceroute6'), {}),
L.resolveDefault(fs.stat('/usr/bin/traceroute6'), {}),
L.resolveDefault(fs.stat('/usr/bin/arp-scan'), {}),
network.getDevices(),
uci.load('luci')
]);
},
@ -60,15 +68,15 @@ return view.extend({
render: function(res) {
var has_ping6 = res[0].path || res[1].path,
has_traceroute6 = res[2].path || res[3].path,
has_arpscan = res[4].path,
devices = res[5],
dns_host = uci.get('luci', 'diag', 'dns') || 'openwrt.org',
ping_host = uci.get('luci', 'diag', 'ping') || 'openwrt.org',
route_host = uci.get('luci', 'diag', 'route') || 'openwrt.org';
return E([], [
E('h2', {}, [ _('Network Utilities') ]),
E('table', { 'class': 'table' }, [
var table = E('table', { 'class': 'table' }, [
E('tr', { 'class': 'tr' }, [
E('td', { 'class': 'td left' }, [
E('td', { 'class': 'td left', 'style': 'overflow:initial' }, [
E('input', {
'style': 'margin:5px 0',
'type': 'text',
@ -91,7 +99,7 @@ return view.extend({
])
]),
E('td', { 'class': 'td left' }, [
E('td', { 'class': 'td left', 'style': 'overflow:initial' }, [
E('input', {
'style': 'margin:5px 0',
'type': 'text',
@ -126,11 +134,45 @@ return view.extend({
'click': ui.createHandlerFn(this, 'handleNslookup')
}, [ _('Nslookup') ])
])
])
]),
has_arpscan ? E('td', { 'class': 'td left' }, [
E('select', {
'style': 'margin:5px 0'
}, devices.map(function(device) {
if (!device.isUp())
return E([]);
return E('option', { 'value': device.getName() }, [ device.getI18n() ]);
})),
E('span', { 'class': 'diag-action' }, [
E('button', {
'class': 'cbi-button cbi-button-action',
'click': ui.createHandlerFn(this, 'handleArpScan')
}, [ _('Arp-scan') ])
])
]) : E([]),
])
]),
E('pre', { 'class': 'command-output', 'style': 'display:none' })
]);
var view = E('div', { 'class': 'cbi-map'}, [
E('h2', {}, [ _('Diagnostics') ]),
E('div', { 'class': 'cbi-map-descr'}, _('Execution of various network commands to check the connection and name resolution to other systems.')),
table,
E('div', {'class': 'cbi-section'}, [
E('div', { 'id' : 'command-output'},
E('textarea', {
'id': 'widget.command-output',
'style': 'width: 100%; font-family:monospace; white-space:pre',
'readonly': true,
'wrap': 'off',
'rows': '20'
})
)
])
]);
return view;
},
handleSaveApply: null,