libs/core: fix firewall model
authorJo-Philipp Wich <jow@openwrt.org>
Sat, 10 Oct 2009 04:48:57 +0000 (04:48 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Sat, 10 Oct 2009 04:48:57 +0000 (04:48 +0000)
libs/core/luasrc/model/firewall.lua

index 6fc207cac484d95e37749ee6fd31f251d88325a9..a6158c20523125f8d0e77f63f6a5c14b241de9c2 100644 (file)
@@ -74,21 +74,21 @@ function get_zones(self)
        return zones
 end
 
-function get_zones_by_network(self, net)
-       local zones = { }
+function get_zone_by_network(self, net)
+       local z
        ub.uci:foreach("firewall", "zone",
                function(s)
-                       if s.name then
+                       if s.name and net then
                                local n
                                for _, n in ipairs(ub:list(s.network or s.name)) do
                                        if n == net then
-                                               zones[#zones+1] = zone(s['.name'])
-                                               return true
+                                               z = s['.name']
+                                               return false
                                        end
                                end
                        end
                end)
-       return zones
+       return z and zone(z)
 end
 
 function del_zone(self, n)