mirror of
https://github.com/openwrt/luci.git
synced 2026-04-15 10:51:51 +00:00
luci-app-banip: update 1.8.1-3
* sync with base package Signed-off-by: Dirk Brenken <dev@brenken.org>
This commit is contained in:
@@ -7,7 +7,7 @@ LUCI_TITLE:=LuCI support for banIP
|
||||
LUCI_DEPENDS:=+luci-base +banip
|
||||
|
||||
PKG_VERSION:=1.8.1
|
||||
PKG_RELEASE:=2
|
||||
PKG_RELEASE:=3
|
||||
PKG_LICENSE:=Apache-2.0
|
||||
PKG_MAINTAINER:=Dirk Brenken <dev@brenken.org>
|
||||
|
||||
|
||||
@@ -233,7 +233,7 @@ return view.extend({
|
||||
o = s.option(form.Value, 'rule', _('Rule'));
|
||||
o.value('feed 1', _('<IP-Address>'));
|
||||
o.value('feed 1 ,', _('<IP-Address><CSV-Seperator>'));
|
||||
o.value('feed 13', _('<IP-Address> <Netmask>'));
|
||||
o.value('feed 13', _('<IP-Address><Space><Netmask>'));
|
||||
o.value('suricata 1', _('<Suricata Syntax>'));
|
||||
o.optional = true;
|
||||
o.rmempty = true;
|
||||
|
||||
@@ -17,25 +17,15 @@ function Logview(logtag, name) {
|
||||
return callLogRead(1000, false, true).then(res => {
|
||||
const logEl = document.getElementById('logfile');
|
||||
if (!logEl) return;
|
||||
|
||||
const filtered = (res?.log ?? [])
|
||||
.filter(entry => !logtag || entry.msg.includes(logtag))
|
||||
.map(entry => {
|
||||
const d = new Date(entry.time * 1000);
|
||||
const date = d.toLocaleDateString([], {
|
||||
year: 'numeric',
|
||||
month: '2-digit',
|
||||
day: '2-digit'
|
||||
});
|
||||
const time = d.toLocaleTimeString([], {
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
second: '2-digit',
|
||||
hour12: false
|
||||
});
|
||||
const d = new Date(entry.time);
|
||||
const pad = n => String(n).padStart(2, '0');
|
||||
const date = `${pad(d.getDate())}/${pad(d.getMonth() + 1)}/${d.getFullYear()}`;
|
||||
const time = `${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`;
|
||||
return `[${date}-${time}] ${entry.msg}`;
|
||||
});
|
||||
|
||||
logEl.value = filtered.length > 0
|
||||
? filtered.join('\n')
|
||||
: _('No %s related logs yet!').format(name);
|
||||
|
||||
@@ -45,14 +45,34 @@ function handleAction(report, ev) {
|
||||
'class': 'btn cbi-button-action',
|
||||
'click': ui.createHandlerFn(this, function (ev) {
|
||||
let ip = document.getElementById('search').value.trim().toLowerCase();
|
||||
|
||||
if (ip) {
|
||||
document.getElementById('search').value = ip;
|
||||
document.getElementById('result').textContent = 'The search is running, please wait...';
|
||||
return L.resolveDefault(fs.exec_direct('/etc/init.d/banip', ['search', ip])).then(function (res) {
|
||||
let result = document.getElementById('result');
|
||||
result.textContent = res.trim();
|
||||
document.getElementById('search').value = '';
|
||||
})
|
||||
document.getElementById('result').textContent = _('Search is running, please wait...');
|
||||
if (window._banipPoller) {
|
||||
clearInterval(window._banipPoller);
|
||||
window._banipPoller = null;
|
||||
}
|
||||
L.resolveDefault(fs.write('/var/run/banIP.search', ''), '').then(function () {
|
||||
L.resolveDefault(fs.exec_direct('/etc/init.d/banip', ['search', ip]), '').then(function () {
|
||||
let attempts = 0;
|
||||
window._banipPoller = setInterval(function () {
|
||||
attempts++;
|
||||
L.resolveDefault(fs.read('/var/run/banIP.search'), '').then(function (res) {
|
||||
if (res && res.trim()) {
|
||||
clearInterval(window._banipPoller);
|
||||
window._banipPoller = null;
|
||||
document.getElementById('result').textContent = res.trim();
|
||||
document.getElementById('search').value = '';
|
||||
} else if (attempts >= 40) {
|
||||
clearInterval(window._banipPoller);
|
||||
window._banipPoller = null;
|
||||
document.getElementById('result').textContent = _('Search timed out.');
|
||||
}
|
||||
});
|
||||
}, 3000);
|
||||
});
|
||||
});
|
||||
}
|
||||
document.getElementById('search').focus();
|
||||
})
|
||||
@@ -132,9 +152,9 @@ function handleAction(report, ev) {
|
||||
let set = document.getElementById('set').value;
|
||||
if (set) {
|
||||
document.getElementById('result').textContent = 'Collecting Set content, please wait...';
|
||||
return L.resolveDefault(fs.exec_direct('/etc/init.d/banip', ['content', set, isChecked])).then(function (res) {
|
||||
return L.resolveDefault(fs.exec_direct('/etc/init.d/banip', ['content', set, isChecked]), '').then(function (res) {
|
||||
let result = document.getElementById('result');
|
||||
result.textContent = res.trim();
|
||||
result.textContent = res ? res.trim() : _('Network error');
|
||||
document.getElementById('set').value = '';
|
||||
})
|
||||
}
|
||||
@@ -339,18 +359,26 @@ return view.extend({
|
||||
});
|
||||
btn.blur();
|
||||
btn.classList.add('spinning');
|
||||
L.resolveDefault(fs.exec_direct('/etc/init.d/banip', ['report', 'gen']))
|
||||
.then(function (res) {
|
||||
if (res !== null) {
|
||||
location.reload();
|
||||
} else {
|
||||
btn.classList.remove('spinning');
|
||||
document.querySelectorAll('.cbi-page-actions button').forEach(function (b) {
|
||||
b.disabled = false;
|
||||
});
|
||||
ui.addNotification(null, E('p', _('Failed to generate banIP report!')), 'error');
|
||||
}
|
||||
});
|
||||
L.resolveDefault(fs.write('/var/run/banIP.report', ''), '').then(function () {
|
||||
L.resolveDefault(fs.exec_direct('/etc/init.d/banip', ['report', 'gen']), '');
|
||||
let attempts = 0;
|
||||
let poller = setInterval(function () {
|
||||
attempts++;
|
||||
L.resolveDefault(fs.read('/var/run/banIP.report'), '').then(function (res) {
|
||||
if (res && res.trim()) {
|
||||
clearInterval(poller);
|
||||
location.reload();
|
||||
} else if (attempts >= 40) {
|
||||
clearInterval(poller);
|
||||
btn.classList.remove('spinning');
|
||||
document.querySelectorAll('.cbi-page-actions button').forEach(function (b) {
|
||||
b.disabled = false;
|
||||
});
|
||||
ui.addNotification(null, E('p', _('Failed to generate a banIP report!')), 'error');
|
||||
}
|
||||
});
|
||||
}, 3000);
|
||||
});
|
||||
}
|
||||
}, [_('Refresh')])
|
||||
])
|
||||
|
||||
@@ -2,31 +2,80 @@
|
||||
"luci-app-banip": {
|
||||
"description": "Grant access to LuCI app banIP",
|
||||
"write": {
|
||||
"uci": [ "banip" ],
|
||||
"uci": [
|
||||
"banip"
|
||||
],
|
||||
"file": {
|
||||
"/etc/banip/*": [ "read", "write" ],
|
||||
"/etc/banip/banip.allowlist": [ "write" ],
|
||||
"/etc/banip/banip.blocklist": [ "write" ],
|
||||
"/etc/banip/banip.custom.feeds": [ "read", "write" ]
|
||||
"/etc/banip/*": [
|
||||
"read"
|
||||
],
|
||||
"/etc/banip/banip.allowlist": [
|
||||
"read",
|
||||
"write"
|
||||
],
|
||||
"/etc/banip/banip.blocklist": [
|
||||
"read",
|
||||
"write"
|
||||
],
|
||||
"/etc/banip/banip.custom.feeds": [
|
||||
"read",
|
||||
"write"
|
||||
],
|
||||
"/var/run/banIP.search": [
|
||||
"read",
|
||||
"write"
|
||||
],
|
||||
"/var/run/banIP.report": [
|
||||
"read",
|
||||
"write"
|
||||
]
|
||||
}
|
||||
},
|
||||
"read": {
|
||||
"cgi-io": [ "exec" ],
|
||||
"cgi-io": [
|
||||
"exec"
|
||||
],
|
||||
"file": {
|
||||
"/var/run/banip.lock": [ "read" ],
|
||||
"/var/run/banip_runtime.json": [ "read" ],
|
||||
"/usr/sbin/nft -tj list sets": [ "exec" ],
|
||||
"/etc/init.d/banip stop": [ "exec" ],
|
||||
"/etc/init.d/banip reload": [ "exec" ],
|
||||
"/etc/init.d/banip restart": [ "exec" ],
|
||||
"/etc/init.d/banip report json": [ "exec" ],
|
||||
"/etc/init.d/banip report gen": [ "exec" ],
|
||||
"/etc/init.d/banip search [A-Za-z0-9:.]*": [ "exec" ],
|
||||
"/etc/init.d/banip content [A-Za-z0-9]* *": [ "exec" ],
|
||||
"/etc/init.d/banip status": [ "exec" ]
|
||||
"/var/run/banip.lock": [
|
||||
"read"
|
||||
],
|
||||
"/var/run/banip_runtime.json": [
|
||||
"read"
|
||||
],
|
||||
"/usr/sbin/nft -tj list sets": [
|
||||
"exec"
|
||||
],
|
||||
"/etc/init.d/banip stop": [
|
||||
"exec"
|
||||
],
|
||||
"/etc/init.d/banip reload": [
|
||||
"exec"
|
||||
],
|
||||
"/etc/init.d/banip restart": [
|
||||
"exec"
|
||||
],
|
||||
"/etc/init.d/banip report json": [
|
||||
"exec"
|
||||
],
|
||||
"/etc/init.d/banip report gen": [
|
||||
"exec"
|
||||
],
|
||||
"/etc/init.d/banip search *": [
|
||||
"exec"
|
||||
],
|
||||
"/etc/init.d/banip content *": [
|
||||
"exec"
|
||||
],
|
||||
"/etc/init.d/banip status": [
|
||||
"exec"
|
||||
]
|
||||
},
|
||||
"uci": [ "banip"],
|
||||
"log": [ "read" ]
|
||||
"uci": [
|
||||
"banip"
|
||||
],
|
||||
"log": [
|
||||
"read"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user