diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2009-10-08 00:36:22 +0000 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2009-10-08 00:36:22 +0000 |
commit | 4854a46c680066a7914a521552d84c9df90c7d6c (patch) | |
tree | 5eabda04dfaf5ba342fa5c653c6d113a59e73c32 /modules | |
parent | 2e6995ea4d663c4daac362e6d2e1c686b947dc7f (diff) |
modules/admin-full: use firewall picker in interface config pages
Diffstat (limited to 'modules')
-rw-r--r-- | modules/admin-full/luasrc/model/cbi/admin_network/ifaces.lua | 74 |
1 files changed, 32 insertions, 42 deletions
diff --git a/modules/admin-full/luasrc/model/cbi/admin_network/ifaces.lua b/modules/admin-full/luasrc/model/cbi/admin_network/ifaces.lua index 6bee998b6..37fab9f2b 100644 --- a/modules/admin-full/luasrc/model/cbi/admin_network/ifaces.lua +++ b/modules/admin-full/luasrc/model/cbi/admin_network/ifaces.lua @@ -13,8 +13,8 @@ You may obtain a copy of the License at $Id$ ]]-- -local wa = require "luci.tools.webadmin" local fs = require "nixio.fs" +local fw = require "luci.model.firewall" arg[1] = arg[1] or "" @@ -26,6 +26,9 @@ local has_pppoa = fs.glob("/usr/lib/pppd/*/pppoatm.so")() local has_ipv6 = fs.access("/proc/net/ipv6_route") m = Map("network", translate("interfaces"), translate("a_n_ifaces1")) +m:chain("firewall") + +fw.init(m.uci) s = m:section(NamedSection, arg[1], "interface") s.addremove = true @@ -91,49 +94,36 @@ for i,d in ipairs(luci.sys.net.devices()) do end end -local zones = wa.network_get_zones(arg[1]) -if zones then - if #zones == 0 then - m:chain("firewall") - - fwzone = s:taboption("general", Value, "_fwzone", - translate("network_interface_fwzone"), - translate("network_interface_fwzone_desc")) - fwzone.rmempty = true - fwzone:value("", "- " .. translate("none") .. " -") - fwzone:value(arg[1]) - m.uci:load("firewall") - m.uci:foreach("firewall", "zone", - function (section) - fwzone:value(section.name) - end - ) - - function fwzone.write(self, section, value) - local zone = wa.firewall_find_zone(value) - local stat - - if not zone then - stat = m.uci:section("firewall", "zone", nil, { - name = value, - network = section - }) - else - local net = m.uci:get("firewall", zone, "network") - net = (net or value) .. " " .. section - stat = m.uci:set("firewall", zone, "network", net) - end - - if stat then - self.render = function() end - end + +fwzone = s:taboption("general", Value, "_fwzone", + translate("network_interface_fwzone"), + translate("network_interface_fwzone_desc")) + +fwzone.template = "cbi/firewall_zonelist" +fwzone.rmempty = false + +function fwzone.cfgvalue(self, section) + self.iface = section + local z = fw.get_zones_by_network(section)[1] + return z and z:name() +end + +function fwzone.write(self, section, value) + + fw.del_network(section) + + local zone = fw.get_zone(value) + + if not zone then + value = m:formvalue(self:cbid(section) .. ".newzone") + if value and #value > 0 and value:match("^[a-zA-Z0-9_]+$") then + zone = fw.add_zone(value) end - else - fwzone = s:taboption("general", DummyValue, "_fwzone", translate("zone")) - fwzone.value = table.concat(zones, ", ") end - fwzone.titleref = luci.dispatcher.build_url("admin", "network", "firewall", "zones") - m.uci:unload("firewall") + + if zone then + zone:add_network(section) + end end ipaddr = s:taboption("general", Value, "ipaddr", translate("ipaddress")) |