Changeset 5374
- Timestamp:
- 10/08/09 02:22:21 (4 years ago)
- Files:
-
- 1 modified
-
luci/trunk/libs/core/luasrc/model/firewall.lua (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
luci/trunk/libs/core/luasrc/model/firewall.lua
r5367 r5374 38 38 end 39 39 40 function add_zone( n)41 if n then40 function add_zone(self, n) 41 if n and #n > 0 and n:match("^[a-zA-Z0-9_]+$") and not self:get_zone(n) then 42 42 local z = ub.uci:section("firewall", "zone", nil, { 43 43 name = n, … … 52 52 end 53 53 54 function get_zone( n)54 function get_zone(self, n) 55 55 local z 56 56 ub.uci:foreach("firewall", "zone", … … 64 64 end 65 65 66 function get_zones( )66 function get_zones(self) 67 67 local zones = { } 68 68 ub.uci:foreach("firewall", "zone", … … 75 75 end 76 76 77 function get_zones_by_network( net)77 function get_zones_by_network(self, net) 78 78 local zones = { } 79 79 ub.uci:foreach("firewall", "zone", … … 92 92 end 93 93 94 function del_zone( n)94 function del_zone(self, n) 95 95 local r = false 96 96 ub.uci:foreach("firewall", "zone", … … 124 124 end 125 125 126 function del_network(net) 126 function rename_zone(self, old, new) 127 local r = false 128 if new and #new > 0 and new:match("^[a-zA-Z0-9_]+$") and not self:get_zone(new) then 129 ub.uci:foreach("firewall", "zone", 130 function(s) 131 if n and s.name == old then 132 ub.uci:set("firewall", s['.name'], "name", new) 133 r = true 134 return false 135 end 136 end) 137 if r then 138 ub.uci:foreach("firewall", "rule", 139 function(s) 140 if s.src == old then 141 ub.uci:set("firewall", s['.name'], "src", new) 142 elseif s.dest == old then 143 ub.uci:set("firewall", s['.name'], "dest", new) 144 end 145 end) 146 ub.uci:foreach("firewall", "redirect", 147 function(s) 148 if s.src == old then 149 ub.uci:set("firewall", s['.name'], "src", new) 150 end 151 end) 152 ub.uci:foreach("firewall", "forwarding", 153 function(s) 154 if s.src == old then 155 ub.uci:set("firewall", s['.name'], "src", new) 156 end 157 end) 158 end 159 end 160 return r 161 end 162 163 function del_network(self, net) 127 164 local z 128 165 if net then 129 for _, z in ipairs( get_zones()) do166 for _, z in ipairs(self:get_zones()) do 130 167 z:del_network(net) 131 168 end
