summaryrefslogtreecommitdiffhomepage
path: root/libs/core
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2010-11-01 19:39:02 +0000
committerJo-Philipp Wich <jow@openwrt.org>2010-11-01 19:39:02 +0000
commit75ccb1c5a89f23f6f6c99f9bcc77272e86dc2097 (patch)
tree4f9855e58adf4610496fcc70f5efa7bb0f3a9c9c /libs/core
parentaab6378bc31be9b50c34135d4d3bbca00fcd732d (diff)
libs/core: some firewall model enhancements
Diffstat (limited to 'libs/core')
-rw-r--r--libs/core/luasrc/model/firewall.lua29
1 files changed, 23 insertions, 6 deletions
diff --git a/libs/core/luasrc/model/firewall.lua b/libs/core/luasrc/model/firewall.lua
index 160995c26..c4904eba8 100644
--- a/libs/core/luasrc/model/firewall.lua
+++ b/libs/core/luasrc/model/firewall.lua
@@ -64,14 +64,31 @@ function commit(self, ...)
uci_r:load(...)
end
+function get_defaults()
+ return defaults()
+end
+
+function new_zone(self)
+ local name = "newzone"
+ local count = 1
+
+ while self:get_zone(name) do
+ count = count + 1
+ name = "newzone%d" % count
+ end
+
+ return self:add_zone(name)
+end
+
function add_zone(self, n)
if _valid_id(n) and not self:get_zone(n) then
+ local d = defaults()
local z = uci_r:section("firewall", "zone", nil, {
name = n,
network = " ",
- input = defaults:input() or "DROP",
- forward = defaults:forward() or "DROP",
- output = defaults:output() or "DROP"
+ input = d:input() or "DROP",
+ forward = d:forward() or "DROP",
+ output = d:output() or "DROP"
})
return z and zone(z)
@@ -315,15 +332,15 @@ function zone.network(self)
end
function zone.input(self)
- return self:get("input") or "DROP"
+ return self:get("input") or defaults():input() or "DROP"
end
function zone.forward(self)
- return self:get("forward") or "DROP"
+ return self:get("forward") or defaults():forward() or "DROP"
end
function zone.output(self)
- return self:get("output") or "DROP"
+ return self:get("output") or defaults():output() or "DROP"
end
function zone.add_network(self, net)