diff options
Diffstat (limited to 'modules')
12 files changed, 379 insertions, 396 deletions
diff --git a/modules/luci-base/root/usr/share/rpcd/acl.d/luci-base.json b/modules/luci-base/root/usr/share/rpcd/acl.d/luci-base.json index 298b5ed336..ba0c213c9e 100644 --- a/modules/luci-base/root/usr/share/rpcd/acl.d/luci-base.json +++ b/modules/luci-base/root/usr/share/rpcd/acl.d/luci-base.json @@ -39,16 +39,20 @@ "/proc/sys/net/netfilter/nf_conntrack_*": [ "read" ], "/proc/mounts": [ "read" ], "/usr/lib/lua/luci/version.lua": [ "read" ], + "/bin/dmesg -r": [ "exec" ], "/bin/ping *": [ "exec" ], "/bin/ping6 *": [ "exec" ], "/bin/traceroute *": [ "exec" ], "/bin/traceroute6 *": [ "exec" ], + "/sbin/logread -e ^": [ "exec" ], "/usr/bin/ping *": [ "exec" ], "/usr/bin/ping6 *": [ "exec" ], "/usr/bin/traceroute *": [ "exec" ], "/usr/bin/traceroute6 *": [ "exec" ], "/usr/bin/nslookup *": [ "exec" ], - "/usr/libexec/luci-peeraddr": [ "exec" ] + "/usr/libexec/luci-peeraddr": [ "exec" ], + "/usr/sbin/iptables --line-numbers -w -nvxL -t *": [ "exec" ], + "/usr/sbin/ip6tables --line-numbers -w -nvxL -t *": [ "exec" ] }, "ubus": { "file": [ "list", "read", "stat" ], @@ -68,6 +72,7 @@ "file": { "/etc/crontabs/root": [ "write" ], "/etc/dropbear/authorized_keys": [ "write" ], + "/etc/init.d/firewall restart": [ "exec" ], "/etc/luci-uploads/*": [ "write" ], "/etc/rc.local": [ "write" ], "/etc/sysupgrade.conf": [ "write" ], @@ -83,7 +88,9 @@ "/bin/umount": [ "exec" ], "/tmp/backup.tar.gz": [ "write" ], "/tmp/firmware.bin": [ "write" ], - "/tmp/upload.ipk": [ "write" ] + "/tmp/upload.ipk": [ "write" ], + "/usr/sbin/iptables -Z": [ "exec" ], + "/usr/sbin/ip6tables -Z": [ "exec" ] }, "ubus": { "file": [ "write", "remove", "exec" ], diff --git a/modules/luci-mod-admin-mini/luasrc/model/cbi/mini/dhcp.lua b/modules/luci-mod-admin-mini/luasrc/model/cbi/mini/dhcp.lua index bcc26cd442..8841d1ff82 100644 --- a/modules/luci-mod-admin-mini/luasrc/model/cbi/mini/dhcp.lua +++ b/modules/luci-mod-admin-mini/luasrc/model/cbi/mini/dhcp.lua @@ -71,7 +71,7 @@ if leases then end ip = v:option(DummyValue, 3, translate("<abbr title=\"Internet Protocol Version 4\">IPv4</abbr>-Address")) mac = v:option(DummyValue, 2, translate("<abbr title=\"Media Access Control\">MAC</abbr>-Address")) - ltime = v:option(DummyValue, 1, translate("Leasetime remaining")) + ltime = v:option(DummyValue, 1, translate("Lease time remaining")) function ltime.cfgvalue(self, ...) local value = DummyValue.cfgvalue(self, ...) return wa.date_format(os.difftime(tonumber(value), os.time())) diff --git a/modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js b/modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js index 716d67b2aa..c4db638b11 100644 --- a/modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js +++ b/modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js @@ -52,7 +52,7 @@ CBILease6Status = form.DummyValue.extend({ E('div', { 'class': 'th' }, _('Host')), E('div', { 'class': 'th' }, _('IPv6-Address')), E('div', { 'class': 'th' }, _('DUID')), - E('div', { 'class': 'th' }, _('Leasetime remaining')) + E('div', { 'class': 'th' }, _('Lease time remaining')) ]), E('div', { 'class': 'tr placeholder' }, [ E('div', { 'class': 'td' }, E('em', _('Collecting data...'))) diff --git a/modules/luci-mod-status/htdocs/luci-static/resources/view/status/dmesg.js b/modules/luci-mod-status/htdocs/luci-static/resources/view/status/dmesg.js new file mode 100644 index 0000000000..3b9428eaf1 --- /dev/null +++ b/modules/luci-mod-status/htdocs/luci-static/resources/view/status/dmesg.js @@ -0,0 +1,35 @@ +'use strict'; +'require fs'; +'require ui'; + +return L.view.extend({ + load: function() { + return fs.exec_direct('/bin/dmesg', [ '-r' ]).catch(function(err) { + ui.addNotification(null, E('p', {}, _('Unable to load log data: ' + err.message))); + return ''; + }); + }, + + render: function(logdata) { + var loglines = logdata.trim().split(/\n/).map(function(line) { + return line.replace(/^<\d+>/, ''); + }); + + return E([], [ + E('h2', {}, [ _('Kernel Log') ]), + E('div', { 'id': 'content_syslog' }, [ + E('textarea', { + 'id': 'syslog', + 'style': 'font-size:12px', + 'readonly': 'readonly', + 'wrap': 'off', + 'rows': loglines.length + 1 + }, [ loglines.join('\n') ]) + ]) + ]); + }, + + handleSaveApply: null, + handleSave: null, + handleReset: null +}); diff --git a/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/40_dhcp.js b/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/40_dhcp.js index 83c0c151eb..b1068f0e36 100644 --- a/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/40_dhcp.js +++ b/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/40_dhcp.js @@ -28,7 +28,7 @@ return L.Class.extend({ E('div', { 'class': 'th' }, _('Hostname')), E('div', { 'class': 'th' }, _('IPv4-Address')), E('div', { 'class': 'th' }, _('MAC-Address')), - E('div', { 'class': 'th' }, _('Leasetime remaining')) + E('div', { 'class': 'th' }, _('Lease time remaining')) ]) ]); @@ -55,7 +55,7 @@ return L.Class.extend({ E('div', { 'class': 'th' }, _('Host')), E('div', { 'class': 'th' }, _('IPv6-Address')), E('div', { 'class': 'th' }, _('DUID')), - E('div', { 'class': 'th' }, _('Leasetime remaining')) + E('div', { 'class': 'th' }, _('Lease time remaining')) ]) ]); diff --git a/modules/luci-mod-status/htdocs/luci-static/resources/view/status/iptables.js b/modules/luci-mod-status/htdocs/luci-static/resources/view/status/iptables.js index eaeba578fe..04abcba9d0 100644 --- a/modules/luci-mod-status/htdocs/luci-static/resources/view/status/iptables.js +++ b/modules/luci-mod-status/htdocs/luci-static/resources/view/status/iptables.js @@ -1,232 +1,196 @@ -var table_names = [ 'Filter', 'NAT', 'Mangle', 'Raw' ], - current_mode = document.querySelector('.cbi-tab[data-mode="6"]') ? 6 : 4; - -function create_table_section(table) -{ - var idiv = document.getElementById('iptables'), - tdiv = idiv.querySelector('[data-table="%s"]'.format(table)), - title = '%s: %s'.format(_('Table'), table); - - if (!tdiv) { - tdiv = E('div', { 'data-table': table }, [ - E('h3', {}, title), - E('div') - ]); +'use strict'; +'require fs'; +'require ui'; + +var table_names = [ 'Filter', 'NAT', 'Mangle', 'Raw' ]; + +return L.view.extend({ + load: function() { + return L.resolveDefault(fs.stat('/usr/sbin/ip6tables')); + }, + + createTableSection: function(is_ipv6, table) { + var idiv = document.querySelector('div[data-tab="%s"]'.format(is_ipv6 ? 'ip6tables' : 'iptables')), + tdiv = idiv.querySelector('[data-table="%s-%s"]'.format(is_ipv6 ? 'ipv6' : 'ipv4', table)), + title = '%s: %s'.format(_('Table'), table); + + if (!tdiv) { + tdiv = E('div', { 'data-table': '%s-%s'.format(is_ipv6 ? 'ipv6' : 'ipv4', table) }, [ + E('h3', {}, title), + E('div') + ]); - if (idiv.firstElementChild.nodeName.toLowerCase() === 'p') - idiv.removeChild(idiv.firstElementChild); + if (idiv.firstElementChild.nodeName.toLowerCase() === 'p') + idiv.removeChild(idiv.firstElementChild); - var added = false, thisIdx = table_names.indexOf(table); + var added = false, thisIdx = table_names.indexOf(table); - idiv.querySelectorAll('[data-table]').forEach(function(child) { - var childIdx = table_names.indexOf(child.getAttribute('data-table')); + idiv.querySelectorAll('[data-table]').forEach(function(child) { + var childIdx = table_names.indexOf(child.getAttribute('data-table').split(/-/)[1]); - if (added === false && childIdx > thisIdx) { - idiv.insertBefore(tdiv, child); - added = true; - } - }); - - if (added === false) - idiv.appendChild(tdiv); - } - - return tdiv.lastElementChild; -} - -function create_chain_section(table, chain, policy, packets, bytes, references) -{ - var tdiv = create_table_section(table), - cdiv = tdiv.querySelector('[data-chain="%s"]'.format(chain)), - title; - - if (policy) - title = '%s <em>%s</em> <span>(%s: <em>%s</em>, %d %s, %.2mB %s)</span>' - .format(_('Chain'), chain, _('Policy'), policy, packets, _('Packets'), bytes, _('Traffic')); - else - title = '%s <em>%s</em> <span class="references">(%d %s)</span>' - .format(_('Chain'), chain, references, _('References')); - - if (!cdiv) { - cdiv = E('div', { 'data-chain': chain }, [ - E('h4', { 'id': 'rule_%s_%s'.format(table.toLowerCase(), chain) }, title), - E('div', { 'class': 'table' }, [ - E('div', { 'class': 'tr table-titles' }, [ - E('div', { 'class': 'th center' }, _('Pkts.')), - E('div', { 'class': 'th center' }, _('Traffic')), - E('div', { 'class': 'th' }, _('Target')), - E('div', { 'class': 'th' }, _('Prot.')), - E('div', { 'class': 'th' }, _('In')), - E('div', { 'class': 'th' }, _('Out')), - E('div', { 'class': 'th' }, _('Source')), - E('div', { 'class': 'th' }, _('Destination')), - E('div', { 'class': 'th' }, _('Options')), - E('div', { 'class': 'th' }, _('Comment')) - ]) - ]) - ]); + if (added === false && childIdx > thisIdx) { + idiv.insertBefore(tdiv, child); + added = true; + } + }); - tdiv.appendChild(cdiv); - } - else { - cdiv.firstElementChild.innerHTML = title; - } - - return cdiv.lastElementChild; -} - -function update_chain_section(chaintable, rows) -{ - if (!chaintable) - return; - - cbi_update_table(chaintable, rows, _('No rules in this chain.')); - - if (rows.length === 0 && - document.querySelector('form > [data-hide-empty="true"]')) - chaintable.parentNode.style.display = 'none'; - else - chaintable.parentNode.style.display = ''; - - chaintable.parentNode.setAttribute('data-empty', rows.length === 0); -} - -function hide_empty(btn) -{ - var hide = (btn.getAttribute('data-hide-empty') === 'false'); - - btn.setAttribute('data-hide-empty', hide); - btn.value = hide ? _('Show empty chains') : _('Hide empty chains'); - btn.blur(); - - document.querySelectorAll('[data-chain][data-empty="true"]') - .forEach(function(chaintable) { - chaintable.style.display = hide ? 'none' : ''; - }); -} - -function jump_target(ev) -{ - var link = ev.target, - table = findParent(link, '[data-table]').getAttribute('data-table'), - chain = link.textContent, - num = +link.getAttribute('data-num'), - elem = document.getElementById('rule_%s_%s'.format(table.toLowerCase(), chain)); - - if (elem) { - (document.documentElement || document.body.parentNode || document.body).scrollTop = elem.offsetTop - 40; - elem.classList.remove('flash'); - void elem.offsetWidth; - elem.classList.add('flash'); - - if (num) { - var rule = elem.nextElementSibling.childNodes[num]; - if (rule) { - rule.classList.remove('flash'); - void rule.offsetWidth; - rule.classList.add('flash'); - } + if (added === false) + idiv.appendChild(tdiv); } - } -} - -function parse_output(table, s) -{ - var current_chain = null; - var current_rules = []; - var seen_chains = {}; - var chain_refs = {}; - var re = /([^\n]*)\n/g; - var m, m2; - - while ((m = re.exec(s)) != null) { - if (m[1].match(/^Chain (.+) \(policy (\w+) (\d+) packets, (\d+) bytes\)$/)) { - var chain = RegExp.$1, - policy = RegExp.$2, - packets = +RegExp.$3, - bytes = +RegExp.$4; - - update_chain_section(current_chain, current_rules); - - seen_chains[chain] = true; - current_chain = create_chain_section(table, chain, policy, packets, bytes); - current_rules = []; - } - else if (m[1].match(/^Chain (.+) \((\d+) references\)$/)) { - var chain = RegExp.$1, - references = +RegExp.$2; - update_chain_section(current_chain, current_rules); + return tdiv.lastElementChild; + }, + + createChainSection: function(is_ipv6, table, chain, policy, packets, bytes, references) { + var tdiv = this.createTableSection(is_ipv6, table), + cdiv = tdiv.querySelector('[data-chain="%s"]'.format(chain)), + title; + + if (policy) + title = '%s <em>%s</em> <span>(%s: <em>%s</em>, %d %s, %.2mB %s)</span>' + .format(_('Chain'), chain, _('Policy'), policy, packets, _('Packets'), bytes, _('Traffic')); + else + title = '%s <em>%s</em> <span class="references">(%d %s)</span>' + .format(_('Chain'), chain, references, _('References')); + + if (!cdiv) { + cdiv = E('div', { 'data-chain': chain }, [ + E('h4', { 'id': 'rule_%s-%s_%s'.format(is_ipv6 ? 'ipv6' : 'ipv4', table.toLowerCase(), chain) }, title), + E('div', { 'class': 'table' }, [ + E('div', { 'class': 'tr table-titles' }, [ + E('div', { 'class': 'th center' }, _('Pkts.')), + E('div', { 'class': 'th center' }, _('Traffic')), + E('div', { 'class': 'th' }, _('Target')), + E('div', { 'class': 'th' }, _('Prot.')), + E('div', { 'class': 'th' }, _('In')), + E('div', { 'class': 'th' }, _('Out')), + E('div', { 'class': 'th' }, _('Source')), + E('div', { 'class': 'th' }, _('Destination')), + E('div', { 'class': 'th' }, _('Options')), + E('div', { 'class': 'th' }, _('Comment')) + ]) + ]) + ]); - seen_chains[chain] = true; - current_chain = create_chain_section(table, chain, null, null, null, references); - current_rules = []; + tdiv.appendChild(cdiv); } - else if (m[1].match(/^num /)) { - continue; + else { + cdiv.firstElementChild.innerHTML = title; } - else if ((m2 = m[1].match(/^(\d+) +(\d+) +(\d+) +(.*?) +(\S+) +(\S*) +(\S+) +(\S+) +([a-f0-9:.]+(?:\/[a-f0-9:.]+)?) +([a-f0-9:.]+(?:\/[a-f0-9:.]+)?) +(.+)$/)) !== null) { - var num = +m2[1], - pkts = +m2[2], - bytes = +m2[3], - target = m2[4], - proto = m2[5], - indev = m2[7], - outdev = m2[8], - srcnet = m2[9], - dstnet = m2[10], - options = m2[11] || '-', - comment = '-'; - - options = options.trim().replace(/(?:^| )\/\* (.+) \*\//, - function(m1, m2) { - comment = m2.replace(/^!fw3(: |$)/, '').trim() || '-'; - return ''; - }) || '-'; - - current_rules.push([ - '%.2m'.format(pkts).nobr(), - '%.2mB'.format(bytes).nobr(), - target ? '<span class="target">%s</span>'.format(target) : '-', - proto, - (indev !== '*') ? '<span class="ifacebadge">%s</span>'.format(indev) : '*', - (outdev !== '*') ? '<span class="ifacebadge">%s</span>'.format(outdev) : '*', - srcnet, - dstnet, - options, - [ comment ] - ]); - if (target) { - chain_refs[target] = chain_refs[target] || []; - chain_refs[target].push([ current_chain, num ]); + return cdiv.lastElementChild; + }, + + updateChainSection: function(chaintable, rows) { + if (!chaintable) + return; + + cbi_update_table(chaintable, rows, _('No rules in this chain.')); + + if (rows.length === 0 && + document.querySelector('[data-hide-empty="true"]')) + chaintable.parentNode.style.display = 'none'; + else + chaintable.parentNode.style.display = ''; + + chaintable.parentNode.setAttribute('data-empty', rows.length === 0); + }, + + parseIptablesDump: function(is_ipv6, table, s) { + var current_chain = null; + var current_rules = []; + var seen_chains = {}; + var chain_refs = {}; + var re = /([^\n]*)\n/g; + var m, m2; + + while ((m = re.exec(s)) != null) { + if (m[1].match(/^Chain (.+) \(policy (\w+) (\d+) packets, (\d+) bytes\)$/)) { + var chain = RegExp.$1, + policy = RegExp.$2, + packets = +RegExp.$3, + bytes = +RegExp.$4; + + this.updateChainSection(current_chain, current_rules); + + seen_chains[chain] = true; + current_chain = this.createChainSection(is_ipv6, table, chain, policy, packets, bytes); + current_rules = []; + } + else if (m[1].match(/^Chain (.+) \((\d+) references\)$/)) { + var chain = RegExp.$1, + references = +RegExp.$2; + + this.updateChainSection(current_chain, current_rules); + + seen_chains[chain] = true; + current_chain = this.createChainSection(is_ipv6, table, chain, null, null, null, references); + current_rules = []; + } + else if (m[1].match(/^num /)) { + continue; + } + else if ((m2 = m[1].match(/^(\d+) +(\d+) +(\d+) +(.*?) +(\S+) +(\S*) +(\S+) +(\S+) +([a-f0-9:.]+(?:\/[a-f0-9:.]+)?) +([a-f0-9:.]+(?:\/[a-f0-9:.]+)?) +(.+)$/)) !== null) { + var num = +m2[1], + pkts = +m2[2], + bytes = +m2[3], + target = m2[4], + proto = m2[5], + indev = m2[7], + outdev = m2[8], + srcnet = m2[9], + dstnet = m2[10], + options = m2[11] || '-', + comment = '-'; + + options = options.trim().replace(/(?:^| )\/\* (.+) \*\//, + function(m1, m2) { + comment = m2.replace(/^!fw3(: |$)/, '').trim() || '-'; + return ''; + }) || '-'; + + current_rules.push([ + '%.2m'.format(pkts).nobr(), + '%.2mB'.format(bytes).nobr(), + target ? '<span class="target">%s</span>'.format(target) : '-', + proto, + (indev !== '*') ? '<span class="ifacebadge">%s</span>'.format(indev) : '*', + (outdev !== '*') ? '<span class="ifacebadge">%s</span>'.format(outdev) : '*', + srcnet, + dstnet, + options, + [ comment ] + ]); + + if (target) { + chain_refs[target] = chain_refs[target] || []; + chain_refs[target].push([ current_chain, num ]); + } } } - } - update_chain_section(current_chain, current_rules); + this.updateChainSection(current_chain, current_rules); - document.querySelectorAll('[data-table="%s"] [data-chain]'.format(table)) - .forEach(function(cdiv) { + document.querySelectorAll('[data-table="%s-%s"] [data-chain]'.format(is_ipv6 ? 'ipv6' : 'ipv4', table)).forEach(L.bind(function(cdiv) { if (!seen_chains[cdiv.getAttribute('data-chain')]) { cdiv.parentNode.removeChild(cdiv); return; } - cdiv.querySelectorAll('.target').forEach(function(tspan) { + cdiv.querySelectorAll('.target').forEach(L.bind(function(tspan) { if (seen_chains[tspan.textContent]) { tspan.classList.add('jump'); - tspan.addEventListener('click', jump_target); + tspan.addEventListener('click', this.handleJumpTarget); } - }); + }, this)); - cdiv.querySelectorAll('.references').forEach(function(rspan) { + cdiv.querySelectorAll('.references').forEach(L.bind(function(rspan) { var refs = chain_refs[cdiv.getAttribute('data-chain')]; if (refs && refs.length) { rspan.classList.add('cbi-tooltip-container'); rspan.appendChild(E('small', { 'class': 'cbi-tooltip ifacebadge', 'style': 'top:1em; left:auto' }, [ E('ul') ])); - refs.forEach(function(ref) { + refs.forEach(L.bind(function(ref) { var chain = ref[0].parentNode.getAttribute('data-chain'), num = ref[1]; @@ -235,19 +199,136 @@ function parse_output(table, s) E('span', { 'class': 'jump', 'data-num': num, - 'onclick': 'jump_target(event)' + 'click': this.handleJumpTarget }, chain), ', %s #%d'.format(_('Rule'), num) ])); - }); + }, this)); + } + }, this)); + }, this)); + }, + + pollFirewallLists: function(has_ip6tables) { + var cmds = [ '/usr/sbin/iptables' ]; + + if (has_ip6tables) + cmds.push('/usr/sbin/ip6tables'); + + L.Poll.add(L.bind(function() { + var tasks = []; + + for (var i = 0; i < cmds.length; i++) { + for (var j = 0; j < table_names.length; j++) { + tasks.push(L.resolveDefault( + fs.exec_direct(cmds[i], [ '--line-numbers', '-w', '-nvxL', '-t', table_names[j].toLowerCase() ]) + .then(this.parseIptablesDump.bind(this, i > 0, table_names[j])))); + } + } + + return Promise.all(tasks); + }, this)); + }, + + handleJumpTarget: function(ev) { + var link = ev.target, + table = findParent(link, '[data-table]').getAttribute('data-table'), + chain = link.textContent, + num = +link.getAttribute('data-num'), + elem = document.getElementById('rule_%s_%s'.format(table.toLowerCase(), chain)); + + if (elem) { + (document.documentElement || document.body.parentNode || document.body).scrollTop = elem.offsetTop - 40; + elem.classList.remove('flash'); + void elem.offsetWidth; + elem.classList.add('flash'); + + if (num) { + var rule = elem.nextElementSibling.childNodes[num]; + if (rule) { + rule.classList.remove('flash'); + void rule.offsetWidth; + rule.classList.add('flash'); } + } + } + }, + + handleHideEmpty: function(ev) { + var btn = ev.currentTarget, + hide = (btn.getAttribute('data-hide-empty') === 'false'); + + btn.setAttribute('data-hide-empty', hide); + btn.firstChild.data = hide ? _('Show empty chains') : _('Hide empty chains'); + btn.blur(); + + document.querySelectorAll('[data-chain][data-empty="true"]') + .forEach(function(chaintable) { + chaintable.style.display = hide ? 'none' : ''; }); - }); -} - -table_names.forEach(function(table) { - L.poll(5, L.url('admin/status/iptables_dump', current_mode, table.toLowerCase()), null, - function (xhr) { - parse_output(table, xhr.responseText); - }); + }, + + handleCounterReset: function(has_ip6tables, ev) { + return Promise.all([ + fs.exec('/usr/sbin/iptables', [ '-Z' ]) + .catch(function(err) { ui.addNotification(null, E('p', {}, _('Unable to reset iptables counters: %s').format(err.message))) }), + has_ip6tables ? fs.exec('/usr/sbin/ip6tables', [ '-Z' ]) + .catch(function(err) { ui.addNotification(null, E('p', {}, _('Unable to reset ip6tables counters: %s').format(err.message))) }) : null + ]); + }, + + handleRestart: function(ev) { + return fs.exec_direct('/etc/init.d/firewall', [ 'restart' ]) + .catch(function(err) { ui.addNotification(null, E('p', {}, _('Unable to restart firewall: %s').format(err.message))) }); + }, + + render: function(has_ip6tables) { + var view = E([], [ + E('style', { 'type': 'text/css' }, [ + '.cbi-tooltip-container, span.jump { border-bottom:1px dotted #00f;cursor:pointer }', + 'ul { list-style:none }', + '.references { position:relative }', + '.references .cbi-tooltip { left:0!important;top:1.5em!important }', + 'h4>span { font-size:90% }' + ]), + + E('h2', {}, [ _('Firewall Status') ]), + E('div', { 'class': 'right', 'style': 'margin-bottom:-1.5em' }, [ + E('button', { + 'class': 'cbi-button', + 'data-hide-empty': false, + 'click': ui.createHandlerFn(this, 'handleHideEmpty') + }, [ _('Hide empty chains') ]), + ' ', + E('button', { + 'class': 'cbi-button', + 'click': ui.createHandlerFn(this, 'handleCounterReset', has_ip6tables) + }, [ _('Reset Counters') ]), + ' ', + E('button', { + 'class': 'cbi-button', + 'click': ui.createHandlerFn(this, 'handleRestart') + }, [ _('Restart Firewall') ]) + ]), + E('div', {}, [ + E('div', { 'data-tab': 'iptables', 'data-tab-title': has_ip6tables ? _('IPv4 Firewall') : null }, [ + E('p', {}, E('em', { 'class': 'spinning' }, [ _('Collecting data...') ])) + ]), + has_ip6tables ? E('div', { 'data-tab': 'ip6tables', 'data-tab-title': _('IPv6 Firewall') }, [ + E('p', {}, E('em', { 'class': 'spinning' }, [ _('Collecting data...') ])) + ]) : E([]) + ]) + ]); + + if (has_ip6tables) + ui.tabs.initTabGroup(view.lastElementChild.childNodes); + + this.pollFirewallLists(has_ip6tables); + + return view; + }, + + handleSaveApply: null, + handleSave: null, + handleReset: null }); diff --git a/modules/luci-mod-status/htdocs/luci-static/resources/view/status/syslog.js b/modules/luci-mod-status/htdocs/luci-static/resources/view/status/syslog.js new file mode 100644 index 0000000000..69694bcfb3 --- /dev/null +++ b/modules/luci-mod-status/htdocs/luci-static/resources/view/status/syslog.js @@ -0,0 +1,33 @@ +'use strict'; +'require fs'; +'require ui'; + +return L.view.extend({ + load: function() { + return fs.exec_direct('/sbin/logread', [ '-e', '^' ]).catch(function(err) { + ui.addNotification(null, E('p', {}, _('Unable to load log data: ' + err.message))); + return ''; + }); + }, + + render: function(logdata) { + var loglines = logdata.trim().split(/\n/); + + return E([], [ + E('h2', {}, [ _('System Log') ]), + E('div', { 'id': 'content_syslog' }, [ + E('textarea', { + 'id': 'syslog', + 'style': 'font-size:12px', + 'readonly': 'readonly', + 'wrap': 'off', + 'rows': loglines.length + 1 + }, [ loglines.join('\n') ]) + ]) + ]); + }, + + handleSaveApply: null, + handleSave: null, + handleReset: null +}); diff --git a/modules/luci-mod-status/luasrc/controller/admin/status.lua b/modules/luci-mod-status/luasrc/controller/admin/status.lua deleted file mode 100644 index 2684bdf715..0000000000 --- a/modules/luci-mod-status/luasrc/controller/admin/status.lua +++ /dev/null @@ -1,50 +0,0 @@ --- Copyright 2008 Steven Barth <steven@midlink.org> --- Copyright 2011 Jo-Philipp Wich <jow@openwrt.org> --- Licensed to the public under the Apache License 2.0. - -module("luci.controller.admin.status", package.seeall) - -function action_syslog() - local syslog = luci.sys.syslog() - luci.template.render("admin_status/syslog", {syslog=syslog}) -end - -function action_dmesg() - local dmesg = luci.sys.dmesg() - luci.template.render("admin_status/dmesg", {dmesg=dmesg}) -end - -function dump_iptables(family, table) - local prefix = (family == "6") and "ip6" or "ip" - local ok, lines = pcall(io.lines, "/proc/net/%s_tables_names" % prefix) - if ok and lines then - local s - for s in lines do - if s == table then - luci.http.prepare_content("text/plain") - luci.sys.process.exec({ - "/usr/sbin/%stables" % prefix, "-w", "-t", table, - "--line-numbers", "-nxvL" - }, luci.http.write) - return - end - end - end - - luci.http.status(404, "No such table") - luci.http.prepare_content("text/plain") -end - -function action_iptables() - if luci.http.formvalue("zero") then - if luci.http.formvalue("family") == "6" then - luci.util.exec("/usr/sbin/ip6tables -Z") - else - luci.util.exec("/usr/sbin/iptables -Z") - end - elseif luci.http.formvalue("restart") then - luci.util.exec("/etc/init.d/firewall restart") - end - - luci.http.redirect(luci.dispatcher.build_url("admin/status/iptables")) -end diff --git a/modules/luci-mod-status/luasrc/view/admin_status/dmesg.htm b/modules/luci-mod-status/luasrc/view/admin_status/dmesg.htm deleted file mode 100644 index 1a8770ef88..0000000000 --- a/modules/luci-mod-status/luasrc/view/admin_status/dmesg.htm +++ /dev/null @@ -1,12 +0,0 @@ -<%# - Copyright 2008 Steven Barth <steven@midlink.org> - Copyright 2008 Jo-Philipp Wich <jow@openwrt.org> - Licensed to the public under the Apache License 2.0. --%> - -<%+header%> -<h2 name="content"><%:Kernel Log%></h2> -<div id="content_syslog"> -<textarea style="font-size: 12px;" readonly="readonly" wrap="off" rows="<%=dmesg:cmatch("\n")+2%>" id="syslog"><%=dmesg:pcdata()%></textarea> -</div> -<%+footer%> diff --git a/modules/luci-mod-status/luasrc/view/admin_status/iptables.htm b/modules/luci-mod-status/luasrc/view/admin_status/iptables.htm deleted file mode 100644 index 89f229f3ba..0000000000 --- a/modules/luci-mod-status/luasrc/view/admin_status/iptables.htm +++ /dev/null @@ -1,73 +0,0 @@ -<%# - Copyright 2008-2009 Steven Barth <steven@midlink.org> - Copyright 2008-2018 Jo-Philipp Wich <jo@mein.io> - Licensed to the public under the Apache License 2.0. --%> - -<%- - local fs = require "nixio.fs" - local has_ip6tables = fs.access("/usr/sbin/ip6tables") - local mode = 4 - - if has_ip6tables then - mode = luci.dispatcher.context.requestpath - mode = tonumber(mode[#mode] ~= "iptables" and mode[#mode]) or 4 - end --%> - -<%+header%> - -<style type="text/css"> - span.jump, .cbi-tooltip-container { - border-bottom: 1px dotted blue; - cursor: pointer; - } - - ul { - list-style: none; - } - - .references { - position: relative; - } - - .references .cbi-tooltip { - left: 0 !important; - top: 1.5em !important; - } - - h4 > span { - font-size: 90%; - } -</style> - -<h2 name="content"><%:Firewall Status%></h2> - -<% if has_ip6tables then %> -<ul class="cbi-tabmenu"> - <li data-mode="4" class="cbi-tab<%= mode ~= 4 and "-disabled" %>"> - <a href="<%=url("admin/status/iptables/4")%>"><%:IPv4 Firewall%></a> - </li> - <li data-mode="6" class="cbi-tab<%= mode ~= 6 and "-disabled" %>"> - <a href="<%=url("admin/status/iptables/6")%>"><%:IPv6 Firewall%></a> - </li> -</ul> -<% end %> - -<div style="position: relative"> - <form method="post" action="<%=url("admin/status/iptables_action")%>" style="position: absolute; right: 0"> - <input type="hidden" name="token" value="<%=token%>" /> - <input type="hidden" name="family" value="<%=mode%>" /> - <input type="button" class="cbi-button" data-hide-empty="false" value="<%:Hide empty chains%>" onclick="hide_empty(this)" /> - <input type="submit" class="cbi-button" name="zero" value="<%:Reset Counters%>" /> - <input type="submit" class="cbi-button" name="restart" value="<%:Restart Firewall%>" /> - </form> -</div> - -<div id="iptables"> - <p><em class="spinning"><%:Collecting data...%></em></p> -</div> - -<script type="text/javascript" src="<%=resource%>/view/status/iptables.js"></script> - -<%+footer%> diff --git a/modules/luci-mod-status/luasrc/view/admin_status/syslog.htm b/modules/luci-mod-status/luasrc/view/admin_status/syslog.htm deleted file mode 100644 index fb734a76d9..0000000000 --- a/modules/luci-mod-status/luasrc/view/admin_status/syslog.htm +++ /dev/null @@ -1,12 +0,0 @@ -<%# - Copyright 2008 Steven Barth <steven@midlink.org> - Copyright 2008 Jo-Philipp Wich <jow@openwrt.org> - Licensed to the public under the Apache License 2.0. --%> - -<%+header%> -<h2 name="content"><%:System Log%></h2> -<div id="content_syslog"> -<textarea style="font-size: 12px;" readonly="readonly" wrap="off" rows="<%=syslog:cmatch("\n")+2%>" id="syslog"><%=syslog:pcdata()%></textarea> -</div> -<%+footer%> diff --git a/modules/luci-mod-status/root/usr/share/luci/menu.d/luci-mod-status.json b/modules/luci-mod-status/root/usr/share/luci/menu.d/luci-mod-status.json index 03f7dce3b9..5b53b12d39 100644 --- a/modules/luci-mod-status/root/usr/share/luci/menu.d/luci-mod-status.json +++ b/modules/luci-mod-status/root/usr/share/luci/menu.d/luci-mod-status.json @@ -8,28 +8,12 @@ } }, - "admin/status/iptables/*": { + "admin/status/iptables": { "title": "Firewall", "order": 2, "action": { - "type": "template", - "path": "admin_status/iptables" - } - }, - - "admin/status/iptables_dump/*": { - "action": { - "type": "call", - "module": "luci.controller.admin.status", - "function": "dump_iptables" - } - }, - - "admin/status/iptables_action/*": { - "action": { - "type": "call", - "module": "luci.controller.admin.status", - "function": "action_iptables" + "type": "view", + "path": "status/iptables" } }, @@ -46,9 +30,8 @@ "title": "System Log", "order": 4, "action": { - "type": "call", - "module": "luci.controller.admin.status", - "function": "action_syslog" + "type": "view", + "path": "status/syslog" } }, @@ -56,9 +39,8 @@ "title": "Kernel Log", "order": 5, "action": { - "type": "call", - "module": "luci.controller.admin.status", - "function": "action_dmesg" + "type": "view", + "path": "status/dmesg" } }, @@ -117,13 +99,5 @@ "type": "view", "path": "status/connections" } - }, - - "admin/status/nameinfo/*": { - "action": { - "type": "call", - "module": "luci.controller.admin.status", - "function": "action_nameinfo" - } } } |