summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-app-firewall/luasrc
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2018-06-08 08:19:20 +0200
committerJo-Philipp Wich <jo@mein.io>2018-06-08 08:19:20 +0200
commit74be6f39748a4f441e54e6bdfc768306a3c8b91f (patch)
treee4e8cf5f647814bed013fcdb675dc5f2c2b55699 /applications/luci-app-firewall/luasrc
parent9d4849072901b2a4bcf3a99492ade1e1cb54930d (diff)
treewide: switch firewall zone, network and iface lists to dropdown code
Also switch the weekday and monthday lists in the firewall rule details to cbi dropdowns, vastly uncluttering the form. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'applications/luci-app-firewall/luasrc')
-rw-r--r--applications/luci-app-firewall/luasrc/model/cbi/firewall/forward-details.lua1
-rw-r--r--applications/luci-app-firewall/luasrc/model/cbi/firewall/rule-details.lua26
-rw-r--r--applications/luci-app-firewall/luasrc/model/cbi/firewall/zone-details.lua9
3 files changed, 25 insertions, 11 deletions
diff --git a/applications/luci-app-firewall/luasrc/model/cbi/firewall/forward-details.lua b/applications/luci-app-firewall/luasrc/model/cbi/firewall/forward-details.lua
index 17a49483d..39895c6f0 100644
--- a/applications/luci-app-firewall/luasrc/model/cbi/firewall/forward-details.lua
+++ b/applications/luci-app-firewall/luasrc/model/cbi/firewall/forward-details.lua
@@ -55,6 +55,7 @@ o = s:option(Value, "src", translate("Source zone"))
o.nocreate = true
o.default = "wan"
o.template = "cbi/firewall_zonelist"
+o.rmempty = false
o = s:option(DynamicList, "src_mac",
diff --git a/applications/luci-app-firewall/luasrc/model/cbi/firewall/rule-details.lua b/applications/luci-app-firewall/luasrc/model/cbi/firewall/rule-details.lua
index 1c838888f..fffa64dad 100644
--- a/applications/luci-app-firewall/luasrc/model/cbi/firewall/rule-details.lua
+++ b/applications/luci-app-firewall/luasrc/model/cbi/firewall/rule-details.lua
@@ -255,7 +255,7 @@ else
o = s:option(Value, "src", translate("Source zone"))
o.nocreate = true
o.allowany = true
- o.default = "wan"
+ o.allowlocal = "src"
o.template = "cbi/firewall_zonelist"
@@ -282,11 +282,21 @@ else
o.placeholder = translate("any")
- o = s:option(Value, "dest", translate("Destination zone"))
+ o = s:option(Value, "dest_local", translate("Output zone"))
+ o.nocreate = true
+ o.allowany = true
+ o.rmempty = false
+ o.template = "cbi/firewall_zonelist"
+ o.alias = "dest"
+ o:depends("src", "")
+
+ o = s:option(Value, "dest_remote", translate("Destination zone"))
o.nocreate = true
o.allowany = true
o.allowlocal = true
o.template = "cbi/firewall_zonelist"
+ o.alias = "dest"
+ o:depends({["src"] = "", ["!reverse"] = true})
o = s:option(Value, "dest_ip", translate("Destination address"))
@@ -316,9 +326,9 @@ else
translate("Passes additional arguments to iptables. Use with care!"))
end
-o = s:option(MultiValue, "weekdays", translate("Week Days"))
-o.oneline = true
-o.widget = "checkbox"
+o = s:option(DropDown, "weekdays", translate("Week Days"))
+o.multiple = true
+o.display = 5
o:value("Sun", translate("Sunday"))
o:value("Mon", translate("Monday"))
o:value("Tue", translate("Tuesday"))
@@ -327,9 +337,9 @@ o:value("Thu", translate("Thursday"))
o:value("Fri", translate("Friday"))
o:value("Sat", translate("Saturday"))
-o = s:option(MultiValue, "monthdays", translate("Month Days"))
-o.oneline = true
-o.widget = "checkbox"
+o = s:option(DropDown, "monthdays", translate("Month Days"))
+o.multiple = true
+o.display = 15
for i = 1,31 do
o:value(translate(i))
end
diff --git a/applications/luci-app-firewall/luasrc/model/cbi/firewall/zone-details.lua b/applications/luci-app-firewall/luasrc/model/cbi/firewall/zone-details.lua
index a42c1499f..e168c3c60 100644
--- a/applications/luci-app-firewall/luasrc/model/cbi/firewall/zone-details.lua
+++ b/applications/luci-app-firewall/luasrc/model/cbi/firewall/zone-details.lua
@@ -101,9 +101,12 @@ end
function net.write(self, section, value)
zone:clear_networks()
- local n
- for n in ut.imatch(value) do
- zone:add_network(n)
+ local net
+ for net in ut.imatch(value) do
+ local n = nw:get_network(net) or nw:add_network(net, { proto = "none" })
+ if n then
+ zone:add_network(n:name())
+ end
end
end