libs/core: some firewall model enhancements
This commit is contained in:
parent
aab6378bc3
commit
75ccb1c5a8
1 changed files with 23 additions and 6 deletions
|
@ -64,14 +64,31 @@ function commit(self, ...)
|
||||||
uci_r:load(...)
|
uci_r:load(...)
|
||||||
end
|
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)
|
function add_zone(self, n)
|
||||||
if _valid_id(n) and not self:get_zone(n) then
|
if _valid_id(n) and not self:get_zone(n) then
|
||||||
|
local d = defaults()
|
||||||
local z = uci_r:section("firewall", "zone", nil, {
|
local z = uci_r:section("firewall", "zone", nil, {
|
||||||
name = n,
|
name = n,
|
||||||
network = " ",
|
network = " ",
|
||||||
input = defaults:input() or "DROP",
|
input = d:input() or "DROP",
|
||||||
forward = defaults:forward() or "DROP",
|
forward = d:forward() or "DROP",
|
||||||
output = defaults:output() or "DROP"
|
output = d:output() or "DROP"
|
||||||
})
|
})
|
||||||
|
|
||||||
return z and zone(z)
|
return z and zone(z)
|
||||||
|
@ -315,15 +332,15 @@ function zone.network(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
function zone.input(self)
|
function zone.input(self)
|
||||||
return self:get("input") or "DROP"
|
return self:get("input") or defaults():input() or "DROP"
|
||||||
end
|
end
|
||||||
|
|
||||||
function zone.forward(self)
|
function zone.forward(self)
|
||||||
return self:get("forward") or "DROP"
|
return self:get("forward") or defaults():forward() or "DROP"
|
||||||
end
|
end
|
||||||
|
|
||||||
function zone.output(self)
|
function zone.output(self)
|
||||||
return self:get("output") or "DROP"
|
return self:get("output") or defaults():output() or "DROP"
|
||||||
end
|
end
|
||||||
|
|
||||||
function zone.add_network(self, net)
|
function zone.add_network(self, net)
|
||||||
|
|
Loading…
Reference in a new issue