| 94 | | local zones = wa.network_get_zones(arg[1]) |
| 95 | | if zones then |
| 96 | | if #zones == 0 then |
| 97 | | m:chain("firewall") |
| 98 | | |
| 99 | | fwzone = s:taboption("general", Value, "_fwzone", |
| 100 | | translate("network_interface_fwzone"), |
| 101 | | translate("network_interface_fwzone_desc")) |
| 102 | | fwzone.rmempty = true |
| 103 | | fwzone:value("", "- " .. translate("none") .. " -") |
| 104 | | fwzone:value(arg[1]) |
| 105 | | m.uci:load("firewall") |
| 106 | | m.uci:foreach("firewall", "zone", |
| 107 | | function (section) |
| 108 | | fwzone:value(section.name) |
| 109 | | end |
| 110 | | ) |
| 111 | | |
| 112 | | function fwzone.write(self, section, value) |
| 113 | | local zone = wa.firewall_find_zone(value) |
| 114 | | local stat |
| 115 | | |
| 116 | | if not zone then |
| 117 | | stat = m.uci:section("firewall", "zone", nil, { |
| 118 | | name = value, |
| 119 | | network = section |
| 120 | | }) |
| 121 | | else |
| 122 | | local net = m.uci:get("firewall", zone, "network") |
| 123 | | net = (net or value) .. " " .. section |
| 124 | | stat = m.uci:set("firewall", zone, "network", net) |
| 125 | | end |
| 126 | | |
| 127 | | if stat then |
| 128 | | self.render = function() end |
| 129 | | end |
| | 97 | |
| | 98 | fwzone = s:taboption("general", Value, "_fwzone", |
| | 99 | translate("network_interface_fwzone"), |
| | 100 | translate("network_interface_fwzone_desc")) |
| | 101 | |
| | 102 | fwzone.template = "cbi/firewall_zonelist" |
| | 103 | fwzone.rmempty = false |
| | 104 | |
| | 105 | function fwzone.cfgvalue(self, section) |
| | 106 | self.iface = section |
| | 107 | local z = fw.get_zones_by_network(section)[1] |
| | 108 | return z and z:name() |
| | 109 | end |
| | 110 | |
| | 111 | function fwzone.write(self, section, value) |
| | 112 | |
| | 113 | fw.del_network(section) |
| | 114 | |
| | 115 | local zone = fw.get_zone(value) |
| | 116 | |
| | 117 | if not zone then |
| | 118 | value = m:formvalue(self:cbid(section) .. ".newzone") |
| | 119 | if value and #value > 0 and value:match("^[a-zA-Z0-9_]+$") then |
| | 120 | zone = fw.add_zone(value) |