libs/core: fixes for luci.model.firewall, luci.model.network and luci.model.network.wireless
This commit is contained in:
parent
7bf9452985
commit
99d425aeed
3 changed files with 25 additions and 6 deletions
|
@ -234,7 +234,7 @@ function zone.add_forwarding_to(self, dest, with_mtu_fix)
|
||||||
local s = ub.uci:section("firewall", "forwarding", nil, {
|
local s = ub.uci:section("firewall", "forwarding", nil, {
|
||||||
src = self:name(),
|
src = self:name(),
|
||||||
dest = dest,
|
dest = dest,
|
||||||
mtu_fix = with_mtu_fix and true or false
|
mtu_fix = with_mtu_fix and "1" or "0"
|
||||||
})
|
})
|
||||||
return s and forwarding(s)
|
return s and forwarding(s)
|
||||||
end
|
end
|
||||||
|
@ -252,12 +252,22 @@ function zone.add_forwarding_from(self, src, with_mtu_fix)
|
||||||
local s = ub.uci:section("firewall", "forwarding", nil, {
|
local s = ub.uci:section("firewall", "forwarding", nil, {
|
||||||
src = src,
|
src = src,
|
||||||
dest = self:name(),
|
dest = self:name(),
|
||||||
mtu_fix = with_mtu_fix and true or false
|
mtu_fix = with_mtu_fix and "1" or "0"
|
||||||
})
|
})
|
||||||
return s and forwarding(s)
|
return s and forwarding(s)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function zone.del_forwardings_by(self, what)
|
||||||
|
local name = self:name()
|
||||||
|
ub.uci:foreach("firewall", "forwarding",
|
||||||
|
function(s)
|
||||||
|
if s.src and s.dest and s[what] == name then
|
||||||
|
ub.uci:delete("firewall", s['.name'])
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
function zone.add_redirect(self, options)
|
function zone.add_redirect(self, options)
|
||||||
options = options or { }
|
options = options or { }
|
||||||
options.src = self:name()
|
options.src = self:name()
|
||||||
|
|
|
@ -217,7 +217,16 @@ function rename_network(self, old, new)
|
||||||
end
|
end
|
||||||
|
|
||||||
function get_interface(self, i)
|
function get_interface(self, i)
|
||||||
return ifs[i] and interface(i)
|
if ifs[i] then
|
||||||
|
return interface(i)
|
||||||
|
else
|
||||||
|
local j
|
||||||
|
for j, _ in pairs(ifs) do
|
||||||
|
if ifs[j].sid == i then
|
||||||
|
return interface(j)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function get_interfaces(self)
|
function get_interfaces(self)
|
||||||
|
|
|
@ -44,11 +44,11 @@ function init(self, cursor)
|
||||||
|
|
||||||
local device = s.device or "wlan0"
|
local device = s.device or "wlan0"
|
||||||
local state = st:get_all("wireless", s['.name'])
|
local state = st:get_all("wireless", s['.name'])
|
||||||
local name = state.ifname or device .. ".network" .. count
|
local name = device .. ".network" .. count
|
||||||
|
|
||||||
ifs[state and state.ifname or name] = {
|
ifs[name] = {
|
||||||
idx = count,
|
idx = count,
|
||||||
name = state and state.ifname or name,
|
name = name,
|
||||||
rawname = state and state.ifname or name,
|
rawname = state and state.ifname or name,
|
||||||
flags = { },
|
flags = { },
|
||||||
ipaddrs = { },
|
ipaddrs = { },
|
||||||
|
|
Loading…
Reference in a new issue