summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-app-banip
diff options
context:
space:
mode:
Diffstat (limited to 'applications/luci-app-banip')
-rw-r--r--applications/luci-app-banip/luasrc/controller/banip.lua14
-rw-r--r--applications/luci-app-banip/luasrc/model/cbi/banip/overview_tab.lua202
-rw-r--r--applications/luci-app-banip/luasrc/view/banip/banip_css.htm10
-rw-r--r--applications/luci-app-banip/luasrc/view/banip/runtime.htm10
-rw-r--r--applications/luci-app-banip/luasrc/view/banip/sourcelist.htm2
5 files changed, 120 insertions, 118 deletions
diff --git a/applications/luci-app-banip/luasrc/controller/banip.lua b/applications/luci-app-banip/luasrc/controller/banip.lua
index e201295d5f..42328d7ea4 100644
--- a/applications/luci-app-banip/luasrc/controller/banip.lua
+++ b/applications/luci-app-banip/luasrc/controller/banip.lua
@@ -1,4 +1,4 @@
--- Copyright 2018 Dirk Brenken (dev@brenken.org)
+-- Copyright 2018-2019 Dirk Brenken (dev@brenken.org)
-- This is free software, licensed under the Apache License, Version 2.0
module("luci.controller.banip", package.seeall)
@@ -30,8 +30,8 @@ function index()
end
function ban_action(name)
- if name == "do_refresh" then
- luci.sys.call("/etc/init.d/banip start >/dev/null 2>&1")
+ if name == "do_reload" then
+ luci.sys.call("/etc/init.d/banip reload >/dev/null 2>&1")
end
luci.http.prepare_content("text/plain")
luci.http.write("0")
@@ -51,13 +51,7 @@ function status_update()
end
function log_view()
- local content
-
- if nixio.fs.access("/var/log/messages") then
- content = util.trim(util.exec("grep -F 'banIP-' /var/log/messages"))
- else
- content = util.trim(util.exec("logread -e 'banIP-' 2>/dev/null"))
- end
+ local content = util.trim(util.exec("logread -e 'banIP-' 2>/dev/null")) or ""
if content == "" then
content = "No banIP related logs yet!"
diff --git a/applications/luci-app-banip/luasrc/model/cbi/banip/overview_tab.lua b/applications/luci-app-banip/luasrc/model/cbi/banip/overview_tab.lua
index 8b5bedc089..57294e5c46 100644
--- a/applications/luci-app-banip/luasrc/model/cbi/banip/overview_tab.lua
+++ b/applications/luci-app-banip/luasrc/model/cbi/banip/overview_tab.lua
@@ -1,17 +1,15 @@
--- Copyright 2018 Dirk Brenken (dev@brenken.org)
+-- Copyright 2018-2019 Dirk Brenken (dev@brenken.org)
-- This is free software, licensed under the Apache License, Version 2.0
-local fs = require("nixio.fs")
-local uci = require("luci.model.uci").cursor()
-local sys = require("luci.sys")
-local net = require "luci.model.network".init()
-local util = require("luci.util")
-local dump = util.ubus("network.interface", "dump", {})
-local devices = sys.net:devices()
+local fs = require("nixio.fs")
+local uci = require("luci.model.uci").cursor()
+local net = require "luci.model.network".init()
+local util = require("luci.util")
+local dump = util.ubus("network.interface", "dump", {})
m = Map("banip", translate("banIP"),
translate("Configuration of the banIP package to block ip adresses/subnets via IPSet. ")
- .. translatef("For further information "
+ ..translatef("For further information "
.. "<a href=\"%s\" target=\"_blank\">"
.. "check the online documentation</a>", "https://github.com/openwrt/packages/blob/master/net/banip/files/README.md"))
@@ -29,22 +27,16 @@ o2.rmempty = false
o3 = s:option(MultiValue, "ban_iface", translate("Interface Selection"),
translate("Disable the automatic WAN detection and select your preferred interface(s) manually."))
-for _, dev in ipairs(devices) do
- if dev ~= "lo" and dev ~= "br-lan" then
- local iface = net:get_interface(dev)
- if iface then
- iface = iface:get_networks() or {}
- for k, v in pairs(iface) do
- iface[k] = iface[k].sid
- if iface[k] ~= "lan" then
- o3:value(iface[k], iface[k].. " (" ..dev.. ")")
- end
- end
+if dump then
+ local i, v
+ for i, v in ipairs(dump.interface) do
+ if v.interface ~= "loopback" and v.interface ~= "lan" then
+ local device = v.l3_device or v.device or "-"
+ o3:value(v.interface, v.interface.. " (" ..device.. ")")
end
end
end
o3.widget = "checkbox"
-o3.default = ban_iface
o3.rmempty = false
o4 = s:option(ListValue, "ban_fetchutil", translate("Download Utility"),
@@ -107,96 +99,112 @@ e = m:section(NamedSection, "extra", "banip", translate("Extra Options"),
e1 = e:option(Flag, "ban_debug", translate("Verbose Debug Logging"),
translate("Enable verbose debug logging in case of any processing error."))
-e1.default = e1.disabled
e1.rmempty = false
e2 = e:option(Flag, "ban_nice", translate("Low Priority Service"),
translate("Set the nice level to 'low priority' and banIP background processing will take less resources from the system. ")
..translate("This change requires a manual service stop/re-start to take effect."))
-e2.default = e2.disabled
e2.disabled = "0"
e2.enabled = "10"
e2.rmempty = false
-e3 = e:option(Value, "ban_maxqueue", translate("Max. Download Queue"),
- translate("Size of the download queue to handle downloads &amp; IPset processing in parallel (default '8'). ")
- .. translate("For further performance improvements you can raise this value, e.g. '16' or '32' should be safe."))
-e3.default = 8
-e3.datatype = "range(1,32)"
+e3 = e:option(Flag, "ban_backup", translate("Enable Blocklist Backup"),
+ translate("Create compressed blocklist backups, they will be used in case of download errors or during startup in 'backup mode'."))
e3.rmempty = false
-e4 = e:option(Value, "ban_triggerdelay", translate("Trigger Delay"),
- translate("Additional trigger delay in seconds before banIP processing begins."))
-e4.default = 2
-e4.datatype = "range(1,60)"
-e4.optional = true
+e4 = e:option(Value, "ban_backupdir", translate("Backup Directory"),
+ translate("Target directory for banIP backups. Please use preferably a non-volatile disk, e.g. an external usb stick."))
+e4:depends("ban_backup", 1)
+e4.datatype = "directory"
+e4.default = "/mnt"
+e4.rmempty = true
-e5 = e:option(Value, "ban_fetchparm", translate("Download Options"),
- translate("Special options for the selected download utility, e.g. '--timeout=20 --no-check-certificate -O'."))
-e5.optional = true
-
-e10 = e:option(Value, "ban_wan_input_chain", translate("WAN Input Chain IPv4"))
-e10.default = "input_wan_rule"
-e10.datatype = "uciname"
-e10.optional = true
-
-e11 = e:option(Value, "ban_wan_forward_chain", translate("WAN Forward Chain IPv4"))
-e11.default = "forwarding_wan_rule"
-e11.datatype = "uciname"
-e11.optional = true
-
-e12 = e:option(Value, "ban_lan_input_chain", translate("LAN Input Chain IPv4"))
-e12.default = "input_lan_rule"
-e12.datatype = "uciname"
-e12.optional = true
-
-e13 = e:option(Value, "ban_lan_forward_chain", translate("LAN Forward Chain IPv4"))
-e13.default = "forwarding_lan_rule"
-e13.datatype = "uciname"
-e13.optional = true
-
-e14 = e:option(ListValue, "ban_target_src", translate("SRC Target IPv4"))
-e14:value("REJECT")
-e14:value("DROP")
-e14.default = "DROP"
-e14.optional = true
-
-e15 = e:option(ListValue, "ban_target_dst", translate("DST Target IPv4"))
-e15:value("REJECT")
-e15:value("DROP")
-e15.default = "REJECT"
-e15.optional = true
-
-e16 = e:option(Value, "ban_wan_input_chain_6", translate("WAN Input Chain IPv6"))
-e16.default = "input_wan_rule"
-e16.datatype = "uciname"
-e16.optional = true
-
-e17 = e:option(Value, "ban_wan_forward_chain_6", translate("WAN Forward Chain IPv6"))
-e17.default = "forwarding_wan_rule"
-e17.datatype = "uciname"
-e17.optional = true
-
-e18 = e:option(Value, "ban_lan_input_chain_6", translate("LAN Input Chain IPv6"))
-e18.default = "input_lan_rule"
-e18.datatype = "uciname"
-e18.optional = true
-
-e19 = e:option(Value, "ban_lan_forward_chain_6", translate("LAN Forward Chain IPv6"))
-e19.default = "forwarding_lan_rule"
-e19.datatype = "uciname"
-e19.optional = true
-
-e20 = e:option(ListValue, "ban_target_src_6", translate("SRC Target IPv6"))
-e20:value("REJECT")
-e20:value("DROP")
-e20.default = "DROP"
+e5 = e:option(Flag, "ban_backupboot", translate("Backup Mode"),
+ translate("Do not automatically update blocklists during startup, use their backups instead."))
+e5:depends("ban_backup", 1)
+e5.rmempty = true
+
+e6 = e:option(Value, "ban_maxqueue", translate("Max. Download Queue"),
+ translate("Size of the download queue to handle downloads &amp; IPset processing in parallel (default '4'). ")
+ .. translate("For further performance improvements you can raise this value, e.g. '8' or '16' should be safe."))
+e6.default = 4
+e6.datatype = "range(1,32)"
+e6.rmempty = false
+
+-- Optional Extra Options
+
+e20 = e:option(Value, "ban_triggerdelay", translate("Trigger Delay"),
+ translate("Additional trigger delay in seconds before banIP processing begins."))
+e20.default = 2
+e20.datatype = "range(1,60)"
e20.optional = true
-e21 = e:option(ListValue, "ban_target_dst_6", translate("DST Target IPv6"))
-e21:value("REJECT")
-e21:value("DROP")
-e21.default = "REJECT"
+e21 = e:option(Value, "ban_fetchparm", translate("Download Options"),
+ translate("Special options for the selected download utility, e.g. '--timeout=20 --no-check-certificate -O'."))
e21.optional = true
+e22 = e:option(Value, "ban_wan_input_chain", translate("WAN Input Chain IPv4"))
+e22.default = "input_wan_rule"
+e22.datatype = "uciname"
+e22.optional = true
+
+e23 = e:option(Value, "ban_wan_forward_chain", translate("WAN Forward Chain IPv4"))
+e23.default = "forwarding_wan_rule"
+e23.datatype = "uciname"
+e23.optional = true
+
+e24 = e:option(Value, "ban_lan_input_chain", translate("LAN Input Chain IPv4"))
+e24.default = "input_lan_rule"
+e24.datatype = "uciname"
+e24.optional = true
+
+e25 = e:option(Value, "ban_lan_forward_chain", translate("LAN Forward Chain IPv4"))
+e25.default = "forwarding_lan_rule"
+e25.datatype = "uciname"
+e25.optional = true
+
+e26 = e:option(ListValue, "ban_target_src", translate("SRC Target IPv4"))
+e26:value("REJECT")
+e26:value("DROP")
+e26.default = "DROP"
+e26.optional = true
+
+e27 = e:option(ListValue, "ban_target_dst", translate("DST Target IPv4"))
+e27:value("REJECT")
+e27:value("DROP")
+e27.default = "REJECT"
+e27.optional = true
+
+e28 = e:option(Value, "ban_wan_input_chain_6", translate("WAN Input Chain IPv6"))
+e28.default = "input_wan_rule"
+e28.datatype = "uciname"
+e28.optional = true
+
+e29 = e:option(Value, "ban_wan_forward_chain_6", translate("WAN Forward Chain IPv6"))
+e29.default = "forwarding_wan_rule"
+e29.datatype = "uciname"
+e29.optional = true
+
+e30 = e:option(Value, "ban_lan_input_chain_6", translate("LAN Input Chain IPv6"))
+e30.default = "input_lan_rule"
+e30.datatype = "uciname"
+e30.optional = true
+
+e31 = e:option(Value, "ban_lan_forward_chain_6", translate("LAN Forward Chain IPv6"))
+e31.default = "forwarding_lan_rule"
+e31.datatype = "uciname"
+e31.optional = true
+
+e32 = e:option(ListValue, "ban_target_src_6", translate("SRC Target IPv6"))
+e32:value("REJECT")
+e32:value("DROP")
+e32.default = "DROP"
+e32.optional = true
+
+e33 = e:option(ListValue, "ban_target_dst_6", translate("DST Target IPv6"))
+e33:value("REJECT")
+e33:value("DROP")
+e33.default = "REJECT"
+e33.optional = true
+
return m
diff --git a/applications/luci-app-banip/luasrc/view/banip/banip_css.htm b/applications/luci-app-banip/luasrc/view/banip/banip_css.htm
index b1b9707f04..2fd4109e90 100644
--- a/applications/luci-app-banip/luasrc/view/banip/banip_css.htm
+++ b/applications/luci-app-banip/luasrc/view/banip/banip_css.htm
@@ -1,8 +1,8 @@
<style type="text/css">
textarea
{
- width: 100%;
- height: 450px;
+ width: 100% !important;
+ height: 450px !important;
border: 1px solid #cccccc;
padding: 5px;
font-size: 12px;
@@ -16,8 +16,8 @@
select[readonly],
textarea[readonly]
{
- width: 100%;
- height: 450px;
+ width: 100% !important;
+ height: 450px !important;
border: 1px solid #cccccc;
padding: 5px;
font-size: 12px;
@@ -33,7 +33,7 @@
.cbi-section-table-row,
.tr[data-title]::before
{
- text-align: left;
+ text-align: left !important;
vertical-align: top;
margin-left: 0px;
padding-left: 2px;
diff --git a/applications/luci-app-banip/luasrc/view/banip/runtime.htm b/applications/luci-app-banip/luasrc/view/banip/runtime.htm
index 08ef90399d..410528130c 100644
--- a/applications/luci-app-banip/luasrc/view/banip/runtime.htm
+++ b/applications/luci-app-banip/luasrc/view/banip/runtime.htm
@@ -1,5 +1,5 @@
<%#
-Copyright 2018 Dirk Brenken (dev@brenken.org)
+Copyright 2018-2019 Dirk Brenken (dev@brenken.org)
This is free software, licensed under the Apache License, Version 2.0
-%>
@@ -13,8 +13,8 @@ This is free software, licensed under the Apache License, Version 2.0
var view = document.getElementById("value_1");
var input = json.data.status;
- btn1.value = "<%:Refresh%>";
- btn1.name = "do_refresh";
+ btn1.value = "<%:Reload%>";
+ btn1.name = "do_reload";
view.innerHTML = input || "-";
if (input != "running")
{
@@ -121,9 +121,9 @@ function btn_action(action)
</div>
<hr />
<div class="cbi-value" id="button_1">
- <label class="cbi-value-title" for="button_1"><%:Refresh IPSets%></label>
+ <label class="cbi-value-title" for="button_1"><%:Reload IPSets%></label>
<div class="cbi-value-field">
- <input class="cbi-button cbi-button-apply" id="btn1" type="button" name="do_refresh" value="<%:Refresh%>" onclick="btn_action(this)" />
+ <input class="cbi-button cbi-button-apply" id="btn1" type="button" name="do_reload" value="<%:Reload%>" onclick="btn_action(this)" />
<span id="btn1_running" class="btn_running"></span>
</div>
</div>
diff --git a/applications/luci-app-banip/luasrc/view/banip/sourcelist.htm b/applications/luci-app-banip/luasrc/view/banip/sourcelist.htm
index 743886f884..12240e5ae4 100644
--- a/applications/luci-app-banip/luasrc/view/banip/sourcelist.htm
+++ b/applications/luci-app-banip/luasrc/view/banip/sourcelist.htm
@@ -27,7 +27,7 @@ local anonclass = (not self.anonymous or self.sectiontitle) and "named" or "ano
for i, k in ipairs(self:cfgsections()) do
section = k
local sectionname = striptags((type(self.sectiontitle) == "function") and self:sectiontitle(section) or k)
- local sectiontitle = ifattr(sectionname and (not self.anonymous or self.sectiontitle), "data-title", sectionname)
+ local sectiontitle = ifattr(sectionname and (not self.anonymous or self.sectiontitle), "data-title", sectionname, true)
isempty = false
scope = { valueheader = "cbi/cell_valueheader", valuefooter = "cbi/cell_valuefooter" }
-%>